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