Source Code Cross Referenced for AbstractTreeTableModel.java in  » XML-UI » SwingML » org » swingml » treetablebrowser » ext » 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 » XML UI » SwingML » org.swingml.treetablebrowser.ext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.swingml.treetablebrowser.ext;
002:
003:        import java.awt.*;
004:        import javax.swing.event.*;
005:        import javax.swing.tree.*;
006:
007:        import org.swingml.*;
008:
009:        public abstract class AbstractTreeTableModel extends SwingMLModel
010:                implements  TreeTableBrowserModelInterface {
011:            protected EventListenerList listenerList = new EventListenerList();
012:            protected Object root;
013:
014:            public AbstractTreeTableModel(Object aRoot, Container aContainer) {
015:                super ();
016:                this .root = aRoot;
017:            }
018:
019:            public void addTreeModelListener(TreeModelListener l) {
020:                listenerList.add(TreeModelListener.class, l);
021:            }
022:
023:            /*
024:             * Notify all listeners that have registered interest for
025:             * notification on this event type.  The event instance 
026:             * is lazily created using the parameters passed into 
027:             * the fire method.
028:             * @see EventListenerList
029:             */
030:            protected void fireTreeNodesChanged(Object source, Object[] path,
031:                    int[] childIndices, Object[] children) {
032:                // Guaranteed to return a non-null array
033:                Object[] listeners = listenerList.getListenerList();
034:                TreeModelEvent e = null;
035:                // Process the listeners last to first, notifying
036:                // those that are interested in this event
037:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
038:                    if (listeners[i] == TreeModelListener.class) {
039:                        // Lazily create the event:
040:                        if (e == null)
041:                            e = new TreeModelEvent(source, path, childIndices,
042:                                    children);
043:                        ((TreeModelListener) listeners[i + 1])
044:                                .treeNodesChanged(e);
045:                    }
046:                }
047:            }
048:
049:            /*
050:             * Notify all listeners that have registered interest for
051:             * notification on this event type.  The event instance 
052:             * is lazily created using the parameters passed into 
053:             * the fire method.
054:             * @see EventListenerList
055:             */
056:            protected void fireTreeNodesInserted(Object source, Object[] path,
057:                    int[] childIndices, Object[] children) {
058:                // Guaranteed to return a non-null array
059:                Object[] listeners = listenerList.getListenerList();
060:                TreeModelEvent e = null;
061:                // Process the listeners last to first, notifying
062:                // those that are interested in this event
063:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
064:                    if (listeners[i] == TreeModelListener.class) {
065:                        // Lazily create the event:
066:                        if (e == null)
067:                            e = new TreeModelEvent(source, path, childIndices,
068:                                    children);
069:                        ((TreeModelListener) listeners[i + 1])
070:                                .treeNodesInserted(e);
071:                    }
072:                }
073:            }
074:
075:            /*
076:             * Notify all listeners that have registered interest for
077:             * notification on this event type.  The event instance 
078:             * is lazily created using the parameters passed into 
079:             * the fire method.
080:             * @see EventListenerList
081:             */
082:            protected void fireTreeNodesRemoved(Object source, Object[] path,
083:                    int[] childIndices, Object[] children) {
084:                // Guaranteed to return a non-null array
085:                Object[] listeners = listenerList.getListenerList();
086:                TreeModelEvent e = null;
087:                // Process the listeners last to first, notifying
088:                // those that are interested in this event
089:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
090:                    if (listeners[i] == TreeModelListener.class) {
091:                        // Lazily create the event:
092:                        if (e == null)
093:                            e = new TreeModelEvent(source, path, childIndices,
094:                                    children);
095:                        ((TreeModelListener) listeners[i + 1])
096:                                .treeNodesRemoved(e);
097:                    }
098:                }
099:            }
100:
101:            /*
102:             * Notify all listeners that have registered interest for
103:             * notification on this event type.  The event instance 
104:             * is lazily created using the parameters passed into 
105:             * the fire method.
106:             * @see EventListenerList
107:             */
108:            protected void fireTreeStructureChanged(Object source,
109:                    Object[] path, int[] childIndices, Object[] children) {
110:                // Guaranteed to return a non-null array
111:                Object[] listeners = listenerList.getListenerList();
112:                TreeModelEvent e = null;
113:                // Process the listeners last to first, notifying
114:                // those that are interested in this event
115:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
116:                    if (listeners[i] == TreeModelListener.class) {
117:                        // Lazily create the event:
118:                        if (e == null)
119:                            e = new TreeModelEvent(source, path, childIndices,
120:                                    children);
121:                        ((TreeModelListener) listeners[i + 1])
122:                                .treeStructureChanged(e);
123:                    }
124:                }
125:            }
126:
127:            //
128:            // Default impelmentations for methods in the TreeTableModel interface. 
129:            //
130:            public Class getColumnClass(int column) {
131:                return Object.class;
132:            }
133:
134:            // This is not called in the JTree's default mode: use a naive implementation. 
135:            public int getIndexOfChild(Object parent, Object child) {
136:                for (int i = 0; i < getChildCount(parent); i++) {
137:                    if (getChild(parent, i).equals(child)) {
138:                        return i;
139:                    }
140:                }
141:                return -1;
142:            }
143:
144:            //
145:            // Default implmentations for methods in the TreeModel interface. 
146:            //
147:            public Object getRoot() {
148:                return root;
149:            }
150:
151:            /** By default, make the column with the Tree in it the only editable one. 
152:             *  Making this column editable causes the JTable to forward mouse 
153:             *  and keyboard events in the Tree column to the underlying JTree. 
154:             */
155:            public boolean isCellEditable(Object node, int column) {
156:                // return getColumnClass(column) ==
157:                // TreeTableBrowserModelInterface.class;
158:                boolean result = true;
159:                if (node instanceof  TreeTableBrowserNodeModel) {
160:                    TreeTableBrowserNodeModel nm = (TreeTableBrowserNodeModel) node;
161:                    TreeTableBrowserDataModel dm = (TreeTableBrowserDataModel) nm
162:                            .getTreeTableDatas().get(column);
163:                    result = dm.isEditable();
164:                } else if (node instanceof  TreeTableBrowserTreeModel) {
165:                    if (column != 0) {
166:                        TreeTableBrowserTreeModel nm = (TreeTableBrowserTreeModel) node;
167:                        TreeTableBrowserDataModel dm = (TreeTableBrowserDataModel) nm
168:                                .getTreeTableDatas().get(column);
169:                        result = dm.isEditable();
170:                    }
171:                } else if (node instanceof  TreeTableBrowserDataModel) {
172:                    // I don't think an argument NODE will ever be this...., but just in
173:                    // case
174:                    TreeTableBrowserDataModel dm = (TreeTableBrowserDataModel) node;
175:                    result = dm.isEditable();
176:                }
177:                return result;
178:                // return node instanceof TreeTableBrowserNodeModel;
179:            }
180:
181:            public boolean isLeaf(Object node) {
182:                return getChildCount(node) == 0;
183:            }
184:
185:            public void removeTreeModelListener(TreeModelListener l) {
186:                listenerList.remove(TreeModelListener.class, l);
187:            }
188:
189:            public void setRoot(Object aRoot) {
190:                this .root = aRoot;
191:            }
192:
193:            public void setValueAt(Object aValue, Object node, int column) {
194:            }
195:
196:            public void valueForPathChanged(TreePath path, Object newValue) {
197:            }
198:            // Left to be implemented in the subclass:
199:            /* 
200:             *   public Object getChild(Object parent, int index)
201:             *   public int getChildCount(Object parent) 
202:             *   public int getColumnCount() 
203:             *   public String getColumnName(Object node, int column)  
204:             *   public Object getValueAt(Object node, int column) 
205:             */
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.