Source Code Cross Referenced for PropertyTable.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » gui » property » 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.property 
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.property;
019:
020:        import java.awt.Color;
021:        import java.awt.event.ActionEvent;
022:        import java.awt.event.ActionListener;
023:
024:        import javax.swing.DefaultCellEditor;
025:        import javax.swing.JCheckBox;
026:        import javax.swing.JComboBox;
027:        import javax.swing.JLabel;
028:        import javax.swing.JTable;
029:        import javax.swing.JTextField;
030:        import javax.swing.table.TableCellRenderer;
031:
032:        import de.finix.contelligent.client.base.ComponentProperty;
033:        import de.finix.contelligent.client.base.TypeProperty;
034:        import de.finix.contelligent.client.util.SortableTable;
035:        import de.finix.contelligent.client.util.TableModelSorter;
036:        import de.finix.contelligent.client.util.dnd.JTextFieldDND;
037:
038:        public class PropertyTable extends SortableTable {
039:
040:            private final static int MIN_ROW_HEIGHT = 22;
041:
042:            public PropertyTable(PropertyTableModel ptm) {
043:                super (new TableModelSorter(ptm));
044:                propertyTableModel = ptm;
045:                propertyTable = this ;
046:
047:                setDefaultRenderer(ComponentProperty.class,
048:                        new PropertyRenderer());
049:                setDefaultEditor(ComponentProperty.class, new PropertyEditor(
050:                        this ));
051:
052:                setRowHeight(MIN_ROW_HEIGHT);
053:            }
054:
055:            PropertyTableModel propertyTableModel;
056:
057:            public void stopEditing() {
058:                if (cellEditor != null)
059:                    cellEditor.stopCellEditing();
060:            }
061:
062:            class PropertyEditor extends DefaultCellEditor {
063:                private ComponentProperty property;
064:
065:                private PropertyTable propertyTable;
066:
067:                private java.awt.Component cellEditor;
068:
069:                public PropertyEditor(PropertyTable vt) {
070:                    super (new JCheckBox()); // Bad Swing design
071:                    propertyTable = vt;
072:                }
073:
074:                public Object getCellEditorValue() {
075:                    return property;
076:                }
077:
078:                public java.awt.Component getTableCellEditorComponent(
079:                        JTable table, Object object, boolean isSelected,
080:                        final int row, final int column) {
081:                    // Property to edit
082:                    property = (ComponentProperty) object;
083:
084:                    TypeProperty typeProperty = property.getTypeProperty();
085:
086:                    if (typeProperty.isEnumerable()) {
087:                        String[] items = typeProperty.getEnumeration();
088:                        cellEditor = new JComboBox(items);
089:                        // preselect the current value
090:                        ((JComboBox) cellEditor).setSelectedItem(property
091:                                .getValue());
092:                        if (typeProperty.isFreeTextAllowed()) {
093:                            ((JComboBox) cellEditor).setEditable(true);
094:                        } else {
095:                            ((JComboBox) cellEditor).setEditable(false);
096:                        }
097:                        ((JComboBox) cellEditor)
098:                                .addActionListener(new ActionListener() {
099:                                    public void actionPerformed(ActionEvent e) {
100:                                        JComboBox cb = (JComboBox) e
101:                                                .getSource();
102:                                        property.setValue((String) cb
103:                                                .getSelectedItem());
104:                                        fireEditingStopped();
105:                                    }
106:                                });
107:                        if (property.isFinal()
108:                                || typeProperty.getMode().equals(
109:                                        TypeProperty.READ_ONLY)
110:                                || typeProperty.getMode().equals(
111:                                        TypeProperty.READ_ONLY_NOT_PERSISTENT)) {
112:                            ((JComboBox) cellEditor).setEditable(false);
113:                        }
114:                    } else {
115:                        if (typeProperty.getPropertyType().equals(
116:                                TypeProperty.PATH)) {
117:                            cellEditor = new JTextFieldDND(property.getValue());
118:                            ((JTextFieldDND) cellEditor).setDragEnabled(true);
119:                        } else {
120:                            cellEditor = new JTextField(property.getValue());
121:                        }
122:                        if (property.isFinal()
123:                                || typeProperty.getMode().equals(
124:                                        TypeProperty.READ_ONLY)
125:                                || typeProperty.getMode().equals(
126:                                        TypeProperty.READ_ONLY_NOT_PERSISTENT)) {
127:                            ((JTextField) cellEditor).setEditable(false);
128:                        } else {
129:                            ((JTextField) cellEditor)
130:                                    .addActionListener(new ActionListener() {
131:                                        public void actionPerformed(
132:                                                ActionEvent e) {
133:                                            property
134:                                                    .setValue(((JTextField) cellEditor)
135:                                                            .getText());
136:                                            fireEditingStopped();
137:                                        }
138:                                    });
139:                        }
140:                    }
141:                    return cellEditor;
142:                }
143:
144:                /*
145:                 * (non-Javadoc)
146:                 * 
147:                 * @see javax.swing.CellEditor#stopCellEditing()
148:                 */
149:                public boolean stopCellEditing() {
150:                    if (cellEditor != null
151:                            && (cellEditor instanceof  JTextField)) {
152:                        property.setValue(((JTextField) cellEditor).getText());
153:                        // fireEditingStopped();
154:                    }
155:                    return super .stopCellEditing();
156:                }
157:
158:            }
159:
160:            class PropertyRenderer implements  TableCellRenderer {
161:                public java.awt.Component getTableCellRendererComponent(
162:                        JTable table, Object object, boolean isSelected,
163:                        boolean hasFocus, int row, int column) {
164:                    JLabel cellRenderer = new JLabel();
165:                    cellRenderer.setOpaque(true);
166:                    ComponentProperty property = (ComponentProperty) object;
167:                    if (column == 0) {
168:                        cellRenderer.setText(property.getName());
169:                    } else {
170:                        cellRenderer.setText(property.getValue());
171:                    }
172:                    if (property.getValue() != null
173:                            && property.getValue().equals(
174:                                    property.getInitialValue())) {
175:                        cellRenderer.setForeground(Color.gray);
176:                    } else {
177:                        cellRenderer.setForeground(Color.black);
178:                    }
179:                    if (isSelected) {
180:                        cellRenderer.setBackground(propertyTable
181:                                .getSelectionBackground());
182:                        cellRenderer.setForeground(propertyTable
183:                                .getSelectionForeground());
184:                    } else {
185:                        if (property.isFinal()) {
186:                            cellRenderer.setBackground(Color.yellow);
187:                        } else {
188:                            cellRenderer.setBackground(propertyTable
189:                                    .getBackground());
190:                        }
191:                    }
192:                    cellRenderer.setFont(propertyTable.getFont());
193:                    return cellRenderer;
194:                }
195:            }
196:
197:            JTable propertyTable;
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.