Source Code Cross Referenced for AbstractTreeTableModel.java in  » XML-UI » xui32 » com » xoetrope » swing » 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 » XML UI » xui32 » com.xoetrope.swing.treetable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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