Source Code Cross Referenced for TreeTableModelAdapter.java in  » Project-Management » memoranda » net » sf » memoranda » ui » treetable » 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 » Project Management » memoranda » net.sf.memoranda.ui.treetable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.memoranda.ui.treetable;
002:
003:        /*
004:         * @(#)TreeTableModelAdapter.java	1.2 98/10/27
005:         *
006:         * Copyright 1997, 1998 by Sun Microsystems, Inc.,
007:         * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
008:         * All rights reserved.
009:         *
010:         * This software is the confidential and proprietary information
011:         * of Sun Microsystems, Inc. ("Confidential Information").  You
012:         * shall not disclose such Confidential Information and shall use
013:         * it only in accordance with the terms of the license agreement
014:         * you entered into with Sun.
015:         */
016:
017:        import javax.swing.JTree;
018:        import javax.swing.SwingUtilities;
019:        import javax.swing.table.AbstractTableModel;
020:        import javax.swing.tree.TreePath;
021:        import javax.swing.event.TreeExpansionEvent;
022:        import javax.swing.event.TreeExpansionListener;
023:        import javax.swing.event.TreeModelEvent;
024:        import javax.swing.event.TreeModelListener;
025:
026:        /**
027:         * This is a wrapper class takes a TreeTableModel and implements 
028:         * the table model interface. The implementation is trivial, with 
029:         * all of the event dispatching support provided by the superclass: 
030:         * the AbstractTableModel. 
031:         *
032:         * @version 1.2 10/27/98
033:         *
034:         * @author Philip Milne
035:         * @author Scott Violet
036:         */
037:        public class TreeTableModelAdapter extends AbstractTableModel {
038:            JTree tree;
039:            TreeTableModel treeTableModel;
040:
041:            public TreeTableModelAdapter(TreeTableModel treeTableModel,
042:                    JTree tree) {
043:                this .tree = tree;
044:                this .treeTableModel = treeTableModel;
045:
046:                tree.addTreeExpansionListener(new TreeExpansionListener() {
047:                    // Don't use fireTableRowsInserted() here; the selection model
048:                    // would get updated twice. 
049:                    public void treeExpanded(TreeExpansionEvent event) {
050:                        fireTableDataChanged();
051:                    }
052:
053:                    public void treeCollapsed(TreeExpansionEvent event) {
054:                        fireTableDataChanged();
055:                    }
056:                });
057:
058:                // Install a TreeModelListener that can update the table when
059:                // tree changes. We use delayedFireTableDataChanged as we can
060:                // not be guaranteed the tree will have finished processing
061:                // the event before us.
062:                treeTableModel.addTreeModelListener(new TreeModelListener() {
063:                    public void treeNodesChanged(TreeModelEvent e) {
064:                        delayedFireTableDataChanged();
065:                    }
066:
067:                    public void treeNodesInserted(TreeModelEvent e) {
068:                        delayedFireTableDataChanged();
069:                    }
070:
071:                    public void treeNodesRemoved(TreeModelEvent e) {
072:                        delayedFireTableDataChanged();
073:                    }
074:
075:                    public void treeStructureChanged(TreeModelEvent e) {
076:                        delayedFireTableDataChanged();
077:                    }
078:                });
079:            }
080:
081:            // Wrappers, implementing TableModel interface. 
082:
083:            public int getColumnCount() {
084:                return treeTableModel.getColumnCount();
085:            }
086:
087:            public String getColumnName(int column) {
088:                return treeTableModel.getColumnName(column);
089:            }
090:
091:            public Class getColumnClass(int column) {
092:                return treeTableModel.getColumnClass(column);
093:            }
094:
095:            public int getRowCount() {
096:                return tree.getRowCount();
097:            }
098:
099:            protected Object nodeForRow(int row) {
100:                TreePath treePath = tree.getPathForRow(row);
101:                return treePath.getLastPathComponent();
102:            }
103:
104:            public Object getValueAt(int row, int column) {
105:                return treeTableModel.getValueAt(nodeForRow(row), column);
106:            }
107:
108:            public boolean isCellEditable(int row, int column) {
109:                return treeTableModel.isCellEditable(nodeForRow(row), column);
110:            }
111:
112:            public void setValueAt(Object value, int row, int column) {
113:                treeTableModel.setValueAt(value, nodeForRow(row), column);
114:            }
115:
116:            /**
117:             * Invokes fireTableDataChanged after all the pending events have been
118:             * processed. SwingUtilities.invokeLater is used to handle this.
119:             */
120:            protected void delayedFireTableDataChanged() {
121:                SwingUtilities.invokeLater(new Runnable() {
122:                    public void run() {
123:                        fireTableDataChanged();
124:                    }
125:                });
126:            }
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.