Source Code Cross Referenced for MetadataTableModel.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » gui » metadata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » contelligent » de.finix.contelligent.client.gui.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.client.gui.metadata;
019:
020:        import java.util.HashSet;
021:        import java.util.LinkedList;
022:        import java.util.List;
023:        import java.util.Set;
024:
025:        import javax.swing.table.AbstractTableModel;
026:
027:        import de.finix.contelligent.client.base.ContelligentComponent;
028:        import de.finix.contelligent.client.i18n.Resources;
029:        import de.finix.contelligent.client.util.SortableTableModel;
030:
031:        public class MetadataTableModel extends AbstractTableModel implements 
032:                SortableTableModel {
033:
034:            private boolean editable = false;
035:
036:            private ContelligentComponent component;
037:
038:            private List keys;
039:
040:            private List values;
041:
042:            private List originalKeys;
043:
044:            private List originalValues;
045:
046:            private String[] columnNames = { Resources.getLocalString("key"),
047:                    Resources.getLocalString("value") };
048:
049:            public MetadataTableModel(ContelligentComponent component,
050:                    String visibleGroup) {
051:                this .component = component;
052:                updateData();
053:            }
054:
055:            List getKeys() {
056:                return keys;
057:            }
058:
059:            List getValues() {
060:                return values;
061:            }
062:
063:            int addRow() {
064:                keys.add("");
065:                values.add("");
066:                return keys.size();
067:            }
068:
069:            void deleteRow(int row) {
070:                keys.remove(row);
071:                values.remove(row);
072:            }
073:
074:            public boolean isColumnSortable(int column) {
075:                return false;
076:            }
077:
078:            public String getComparable(Object o, int column) {
079:                return (String) o;
080:            }
081:
082:            public synchronized void updateData() {
083:                keys = component.getMetadataKeys();
084:                values = component.getMetadataValues();
085:                originalKeys = component.getMetadataKeys();
086:                originalValues = component.getMetadataValues();
087:            }
088:
089:            private Set findAlterations(List aKeys, List aValues, List bKeys,
090:                    List bValues) {
091:                Set results = new HashSet();
092:                for (int i = 0; i < aKeys.size(); i++) {
093:                    String aKey = (String) aKeys.get(i);
094:                    String aValue = (String) aValues.get(i);
095:                    boolean found = false;
096:                    for (int j = 0; j < bKeys.size(); j++) {
097:                        String bKey = (String) bKeys.get(j);
098:                        if (aKey.equals(bKey)) {
099:                            String bValue = (String) bValues.get(j);
100:                            if (aValue.equals(bValue)) {
101:                                found = true;
102:                            }
103:                        }
104:                    }
105:                    if (!found) {
106:                        results.add(aKey);
107:                    }
108:                }
109:                return results;
110:            }
111:
112:            public synchronized Set getAlteredKeys() {
113:                Set results = new HashSet();
114:                // forward check
115:                results.addAll(findAlterations(originalKeys, originalValues,
116:                        keys, values));
117:                // reverse check
118:                results.addAll(findAlterations(keys, values, originalKeys,
119:                        originalValues));
120:                return results;
121:            }
122:
123:            public synchronized List getValuesForKey(String key) {
124:                List results = new LinkedList();
125:                for (int i = 0; i < keys.size(); i++) {
126:                    if (key.equals((String) keys.get(i))) {
127:                        results.add((String) values.get(i));
128:                    }
129:                }
130:                return results;
131:            }
132:
133:            public int getColumnCount() {
134:                return columnNames.length;
135:            }
136:
137:            public int getRowCount() {
138:                return keys.size();
139:            }
140:
141:            public String getColumnName(int col) {
142:                return columnNames[col];
143:            }
144:
145:            public Object getValueAt(int row, int col) {
146:                if (col == 0) {
147:                    return keys.get(row);
148:                } else {
149:                    return values.get(row);
150:                }
151:            }
152:
153:            public Class getColumnClass(int c) {
154:                return String.class;
155:            }
156:
157:            public boolean isCellEditable(int row, int col) {
158:                return editable;
159:            }
160:
161:            public void setValueAt(Object value, int row, int col) {
162:                component.setModified(true);
163:                if (col == 0) {
164:                    keys.set(row, value);
165:                } else {
166:                    values.set(row, value);
167:                }
168:                fireTableCellUpdated(row, 0);
169:                fireTableCellUpdated(row, 1);
170:            }
171:
172:            public void setEditable(boolean editable) {
173:                this .editable = editable;
174:            }
175:
176:            public void removeEmptyRows() {
177:                int oldSize = keys.size();
178:                for (int i = 0; i < keys.size(); i++) {
179:                    String key = (String) keys.get(i);
180:                    String value = (String) values.get(i);
181:                    if ((key == null) || (value == null)) {
182:                        deleteRow(i);
183:                        i--;
184:                    } else if ((key.length() == 0) || (value.length() == 0)) {
185:                        deleteRow(i);
186:                        i--;
187:                    }
188:                }
189:                if (oldSize != keys.size()) {
190:                    fireTableStructureChanged();
191:                }
192:            }
193:
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.