Source Code Cross Referenced for TreeTableModelAdapter.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfpshare » beans » table » 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 » ERP CRM Financial » Personal Finance Manager » br.com.gfpshare.beans.table 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved. Redistribution and use in source and binary
003:         * forms, with or without modification, are permitted provided that the following conditions are met: -
004:         * Redistributions of source code must retain the above copyright notice, this list of conditions and the
005:         * following disclaimer. - Redistribution in binary form must reproduce the above copyright notice, this list
006:         * of conditions and the following disclaimer in the documentation and/or other materials provided with the
007:         * distribution. Neither the name of Sun Microsystems, Inc. or the names of contributors may be used to
008:         * endorse or promote products derived from this software without specific prior written permission. This
009:         * software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS,
010:         * REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
011:         * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
012:         * OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS
013:         * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
014:         * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
015:         * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
016:         * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You acknowledge that this software is not
017:         * designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear
018:         * facility.
019:         */
020:
021:        package br.com.gfpshare.beans.table;
022:
023:        import javax.swing.JTree;
024:        import javax.swing.SwingUtilities;
025:        import javax.swing.event.TreeExpansionEvent;
026:        import javax.swing.event.TreeExpansionListener;
027:        import javax.swing.event.TreeModelEvent;
028:        import javax.swing.event.TreeModelListener;
029:        import javax.swing.table.AbstractTableModel;
030:        import javax.swing.tree.TreePath;
031:
032:        /**
033:         * This is a wrapper class takes a TreeTableModel and implements the table model interface. The implementation
034:         * is trivial, with all of the event dispatching support provided by the superclass: the AbstractTableModel.
035:         * 
036:         * @version 1.2 10/27/98
037:         * @author Philip Milne
038:         * @author Scott Violet
039:         */
040:        public class TreeTableModelAdapter extends AbstractTableModel {
041:            JTree tree;
042:
043:            TreeTableModel treeTableModel;
044:
045:            /**
046:             * Contrutor
047:             * @param treeTableModel Model
048:             * @param tree JTree
049:             */
050:            public TreeTableModelAdapter(TreeTableModel treeTableModel,
051:                    JTree tree) {
052:                this .tree = tree;
053:                this .treeTableModel = treeTableModel;
054:
055:                tree.addTreeExpansionListener(new TreeExpansionListener() {
056:                    // Don't use fireTableRowsInserted() here; the selection model
057:                    // would get updated twice.
058:                    public void treeExpanded(TreeExpansionEvent event) {
059:                        fireTableDataChanged();
060:                    }
061:
062:                    public void treeCollapsed(TreeExpansionEvent event) {
063:                        fireTableDataChanged();
064:                    }
065:                });
066:
067:                // Installs a TreeModelListener that can update the table when
068:                // the tree changes. We use delayedFireTableDataChanged as we can
069:                // not be guaranteed the tree will have finished processing
070:                // the event before us.
071:                treeTableModel.addTreeModelListener(new TreeModelListener() {
072:                    public void treeNodesChanged(TreeModelEvent e) {
073:                        delayedFireTableDataChanged();
074:                    }
075:
076:                    public void treeNodesInserted(TreeModelEvent e) {
077:                        delayedFireTableDataChanged();
078:                    }
079:
080:                    public void treeNodesRemoved(TreeModelEvent e) {
081:                        delayedFireTableDataChanged();
082:                    }
083:
084:                    public void treeStructureChanged(TreeModelEvent e) {
085:                        delayedFireTableDataChanged();
086:                    }
087:                });
088:            }
089:
090:            // Wrappers, implementing TableModel interface.
091:
092:            /**
093:             * @see javax.swing.table.TableModel#getColumnCount()
094:             */
095:            public int getColumnCount() {
096:                return treeTableModel.getColumnCount();
097:            }
098:
099:            /**
100:             * @see javax.swing.table.AbstractTableModel#getColumnName(int)
101:             */
102:            @Override
103:            public String getColumnName(int column) {
104:                return treeTableModel.getColumnName(column);
105:            }
106:
107:            /**
108:             * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
109:             */
110:            @Override
111:            public Class getColumnClass(int column) {
112:                return treeTableModel.getColumnClass(column);
113:            }
114:
115:            /**
116:             * @see javax.swing.table.TableModel#getRowCount()
117:             */
118:            public int getRowCount() {
119:                return tree.getRowCount();
120:            }
121:
122:            protected Object nodeForRow(int row) {
123:                TreePath treePath = tree.getPathForRow(row);
124:                return treePath.getLastPathComponent();
125:            }
126:
127:            /**
128:             * @see javax.swing.table.TableModel#getValueAt(int, int)
129:             */
130:            public Object getValueAt(int row, int column) {
131:                return treeTableModel.getValueAt(nodeForRow(row), column);
132:            }
133:
134:            /**
135:             * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int)
136:             */
137:            @Override
138:            public boolean isCellEditable(int row, int column) {
139:                return treeTableModel.isCellEditable(nodeForRow(row), column);
140:            }
141:
142:            /**
143:             * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, int, int)
144:             */
145:            @Override
146:            public void setValueAt(Object value, int row, int column) {
147:                treeTableModel.setValueAt(value, nodeForRow(row), column);
148:            }
149:
150:            /**
151:             * Invokes fireTableDataChanged after all the pending events have been processed.
152:             * SwingUtilities.invokeLater is used to handle this.
153:             */
154:            protected void delayedFireTableDataChanged() {
155:                SwingUtilities.invokeLater(new Runnable() {
156:                    public void run() {
157:                        fireTableDataChanged();
158:                    }
159:                });
160:            }
161:
162:            DBTreeTableModel getDBTreeTableModel() {
163:                return (DBTreeTableModel) treeTableModel;
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.