Source Code Cross Referenced for HoSwingEnhJTable.java in  » J2EE » WiSerFramework » de » ug2t » channel » ho » client » swing » 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 » J2EE » WiSerFramework » de.ug2t.channel.ho.client.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // @@
002:        // @@
003:        /*
004:         * Wi.Ser Framework
005:         *
006:         * LGPL Version: 1.8.1, 20-September-2007  
007:         * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library located in LGPL.txt in the 
021:         * license directory; if not, write to the 
022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023:         * Boston, MA  02111-1307, USA.
024:         * 
025:         * If this agreement does not cover your requirements, please contact us
026:         * via email to get detailed information about the commercial license 
027:         * or our service offerings!
028:         *
029:         */
030:        // @@
031:        package de.ug2t.channel.ho.client.swing;
032:
033:        import java.awt.*;
034:        import java.lang.reflect.*;
035:        import java.util.*;
036:
037:        import javax.swing.*;
038:        import javax.swing.event.*;
039:        import javax.swing.table.*;
040:
041:        import de.ug2t.channel.ho.client.swing.enhanced.*;
042:
043:        final class MyTableCellEditor implements  TableCellEditor {
044:            private HoSwingComponent pem_obj = null;
045:            private JTable pem_table = null;
046:
047:            public MyTableCellEditor(JTable xTable) {
048:                this .pem_table = xTable;
049:            }
050:
051:            public Component getTableCellEditorComponent(JTable table,
052:                    Object value, boolean isSelected, int row, int column) {
053:                this .pem_obj = (HoSwingComponent) value;
054:                if (this .pem_table.getRowSelectionAllowed())
055:                    return (table.getCellRenderer(row, column)
056:                            .getTableCellRendererComponent(table, value, true,
057:                                    true, row, column));
058:                else
059:                    return (this .pem_obj.pcmf_getRealSwingObj());
060:            };
061:
062:            // Add a listener to the list that's notified when the editor starts, stops,
063:            // or cancels editing.
064:            public void addCellEditorListener(CellEditorListener l) {
065:                return;
066:            };
067:
068:            // Tell the editor to cancel editing and not accept any partially edited
069:            // value.
070:            public void cancelCellEditing() {
071:                this .pem_table.removeEditor();
072:                return;
073:            };
074:
075:            // Returns the value contained in the editor
076:            public Object getCellEditorValue() {
077:                return (this .pem_obj.pcmf_getValue());
078:            };
079:
080:            // Ask the editor if it can start editing using anEvent.
081:            public boolean isCellEditable(EventObject anEvent) {
082:                return (true);
083:            };
084:
085:            // Remove a listener from the list that's notified
086:            public void removeCellEditorListener(CellEditorListener l) {
087:                return;
088:            };
089:
090:            // The return value of shouldSelectCell() is a boolean indicating whether the
091:            // editing cell should be selected or not.
092:            public boolean shouldSelectCell(EventObject anEvent) {
093:                return (true);
094:            };
095:
096:            public boolean stopCellEditing() {
097:                this .pem_table.removeEditor();
098:                return (true);
099:            };
100:        };
101:
102:        public final class HoSwingEnhJTable extends SpansJTable {
103:            private HoSwingFlexTableCellRenderer pem_myTableCellRenderer = new HoSwingFlexTableCellRenderer();
104:            private ArrayList pem_painters = new ArrayList();
105:
106:            final class JTableHeaderX extends JTableHeader {
107:                public JTableHeaderX() {
108:                    super ();
109:                }
110:
111:                public JTableHeaderX(TableColumnModel arg0) {
112:                    super (arg0);
113:                }
114:
115:                public void paint(Graphics g) {
116:                    super .paint(g);
117:                    HoSwingEnhJTable.this .pemf_clearPainters();
118:                }
119:
120:                public Dimension getPreferredSize() {
121:
122:                    TableColumnModel columnModel = this .getColumnModel();
123:                    int height = 0;
124:                    for (int column = 0; column < columnModel.getColumnCount(); column++) {
125:                        TableColumn aColumn = columnModel.getColumn(column);
126:                        Component comp = this .getTable().getCellRenderer(0, 0)
127:                                .getTableCellRendererComponent(this .getTable(),
128:                                        aColumn.getHeaderValue(), true, true,
129:                                        -1, column);
130:                        int rendererHeight = comp.getPreferredSize().height;
131:                        height = Math.max(height, rendererHeight);
132:                    }
133:                    // TODO Auto-generated method stub
134:                    return new Dimension(super .getPreferredSize().width, height);
135:                }
136:            }
137:
138:            private void pemf_clearPainters() {
139:                Iterator l_it = this .pem_painters.iterator();
140:                while (l_it.hasNext()) {
141:                    Component l_comp = (Component) l_it.next();
142:                    Container l_p = l_comp.getParent();
143:                    if (l_p != null)
144:                        l_p.remove(l_comp);
145:                }
146:                this .pem_painters.clear();
147:            }
148:
149:            protected JTableHeader createDefaultTableHeader() {
150:                return new JTableHeaderX(columnModel);
151:            };
152:
153:            public void pcmf_clearColorBuffer() {
154:                pem_myTableCellRenderer.pcmf_resetAllColors();
155:                pem_myTableCellRenderer = new HoSwingFlexTableCellRenderer();
156:            }
157:
158:            public void setRowHeight(int row, int rowHeight) {
159:                try {
160:                    Class jTableClass = this .getClass().getSuperclass()
161:                            .getSuperclass();
162:
163:                    Method getRowModelMethod = jTableClass.getDeclaredMethod(
164:                            "getRowModel", null);
165:
166:                    getRowModelMethod.setAccessible(true);
167:
168:                    SizeSequence rowModel = (SizeSequence) getRowModelMethod
169:                            .invoke(this , null);
170:
171:                    if (rowHeight < 0) {
172:                        throw new IllegalArgumentException(
173:                                "New row height less than 0");
174:                    }
175:
176:                    rowModel.setSize(row, rowHeight);
177:                    resizeAndRepaint();
178:                } catch (Exception ex) {
179:                    super .setRowHeight(row, rowHeight);
180:                }
181:            }
182:
183:            public HoSwingEnhJTable() {
184:                super ();
185:            };
186:
187:            public HoSwingEnhJTable(TableModel tm) {
188:                super (tm);
189:            };
190:
191:            public HoSwingEnhJTable(TableModel tm, TableColumnModel cm) {
192:                super (tm, cm);
193:            };
194:
195:            public HoSwingEnhJTable(TableModel tm, TableColumnModel cm,
196:                    ListSelectionModel sm) {
197:                super (tm, cm, sm);
198:            };
199:
200:            public HoSwingEnhJTable(int rows, int cols) {
201:                super (rows, cols);
202:            };
203:
204:            public HoSwingEnhJTable(final Vector rowData,
205:                    final Vector columnNames) {
206:                super (rowData, columnNames);
207:            };
208:
209:            public HoSwingEnhJTable(final Object[][] rowData,
210:                    final Object[] colNames) {
211:                super (rowData, colNames);
212:            };
213:
214:            public TableCellEditor getCellEditor(int row, int col) {
215:                Object l_obj = this .getValueAt(row, col);
216:                if (l_obj instanceof  HoSwingComponent) {
217:                    TableCellEditor l_edit = new MyTableCellEditor(this );
218:                    return (l_edit);
219:                }
220:                ;
221:                return (null);
222:                // return super.getCellEditor(row,col);
223:            };
224:
225:            public TableCellRenderer getCellRenderer(int arg0, int arg1) {
226:                return (pem_myTableCellRenderer);
227:            };
228:
229:            public void paint(Graphics g) {
230:                if (this .getAutoResizeMode() == JTable.AUTO_RESIZE_ALL_COLUMNS) {
231:                    int l = this .getColumnCount();
232:                    int l_width = 0;
233:                    for (int i = 0; i < l; i++)
234:                        l_width += this .getColumnModel().getColumn(i)
235:                                .getMinWidth();
236:
237:                    if (l_width > this .getWidth() && this .getWidth() > 0)
238:                        this .setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
239:                }
240:
241:                super .paint(g);
242:                this .pemf_clearPainters();
243:            }
244:
245:            public void pcmf_addPainter(Component xPainter) {
246:                this .pem_painters.add(xPainter);
247:
248:                return;
249:            }
250:
251:            protected void finalize() throws Throwable {
252:                this.pemf_clearPainters();
253:                super.finalize();
254:            }
255:        };
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.