Source Code Cross Referenced for AbstractTreeModel.java in  » Scripting » oscript-2.10.4 » ti » 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 » Scripting » oscript 2.10.4 » ti.swing.treetable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*=============================================================================
002:         *     Copyright Texas Instruments 2002. All Rights Reserved.
003:         * 
004:         *  This program is free software; you can redistribute it and/or modify
005:         *  it under the terms of the GNU General Public License as published by
006:         *  the Free Software Foundation; either version 2 of the License, or
007:         *  (at your option) any later version.
008:         * 
009:         *  This program is distributed in the hope that it will be useful,
010:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         *  GNU General Public License for more details.
013:         * 
014:         *  You should have received a copy of the GNU General Public License
015:         *  along with this program; if not, write to the Free Software
016:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package ti.swing.treetable;
020:
021:        import javax.swing.tree.*;
022:        import javax.swing.event.*;
023:
024:        /**
025:         * Default implmentations for methods in the TreeTableModel interface. 
026:         */
027:        public abstract class AbstractTreeModel implements  TreeModel {
028:            protected Object root;
029:            protected EventListenerList listenerList = new EventListenerList();
030:
031:            /**
032:             * Class Constructor.
033:             */
034:            public AbstractTreeModel(Object root) {
035:                this .root = root;
036:            }
037:
038:            /**
039:             * Get the root of the tree.
040:             */
041:            public Object getRoot() {
042:                return root;
043:            }
044:
045:            /**
046:             * Is the particular node a leaf node?
047:             */
048:            public boolean isLeaf(Object node) {
049:                return getChildCount(node) == 0;
050:            }
051:
052:            /**
053:             */
054:            public void valueForPathChanged(TreePath path, Object newValue) {
055:            }
056:
057:            // This is not called in the JTree's default mode: use a naive implementation. 
058:            public int getIndexOfChild(Object parent, Object child) {
059:                for (int i = 0; i < getChildCount(parent); i++)
060:                    if (getChild(parent, i).equals(child))
061:                        return i;
062:                return -1;
063:            }
064:
065:            public void addTreeModelListener(TreeModelListener l) {
066:                listenerList.add(TreeModelListener.class, l);
067:            }
068:
069:            public void removeTreeModelListener(TreeModelListener l) {
070:                listenerList.remove(TreeModelListener.class, l);
071:            }
072:
073:            /*
074:             * Notify all listeners that have registered interest for
075:             * notification on this event type.  The event instance 
076:             * is lazily created using the parameters passed into 
077:             * the fire method.
078:             * @see EventListenerList
079:             */
080:            public void fireTreeNodesChanged(Object source, Object[] path,
081:                    int[] childIndices, Object[] children) {
082:                // Guaranteed to return a non-null array
083:                Object[] listeners = listenerList.getListenerList();
084:                TreeModelEvent e = null;
085:                // Process the listeners last to first, notifying
086:                // those that are interested in this event
087:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
088:                    if (listeners[i] == TreeModelListener.class) {
089:                        // Lazily create the event:
090:                        if (e == null)
091:                            e = new TreeModelEvent(source, path, childIndices,
092:                                    children);
093:                        ((TreeModelListener) listeners[i + 1])
094:                                .treeNodesChanged(e);
095:                    }
096:                }
097:            }
098:
099:            /*
100:             * Notify all listeners that have registered interest for
101:             * notification on this event type.  The event instance 
102:             * is lazily created using the parameters passed into 
103:             * the fire method.
104:             * @see EventListenerList
105:             */
106:            public void fireTreeNodesInserted(Object source, Object[] path,
107:                    int[] childIndices, Object[] children) {
108:                // Guaranteed to return a non-null array
109:                Object[] listeners = listenerList.getListenerList();
110:                TreeModelEvent e = null;
111:                // Process the listeners last to first, notifying
112:                // those that are interested in this event
113:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
114:                    if (listeners[i] == TreeModelListener.class) {
115:                        // Lazily create the event:
116:                        if (e == null)
117:                            e = new TreeModelEvent(source, path, childIndices,
118:                                    children);
119:                        ((TreeModelListener) listeners[i + 1])
120:                                .treeNodesInserted(e);
121:                    }
122:                }
123:            }
124:
125:            /*
126:             * Notify all listeners that have registered interest for
127:             * notification on this event type.  The event instance 
128:             * is lazily created using the parameters passed into 
129:             * the fire method.
130:             * @see EventListenerList
131:             */
132:            public void fireTreeNodesRemoved(Object source, Object[] path,
133:                    int[] childIndices, Object[] children) {
134:                // Guaranteed to return a non-null array
135:                Object[] listeners = listenerList.getListenerList();
136:                TreeModelEvent e = null;
137:                // Process the listeners last to first, notifying
138:                // those that are interested in this event
139:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
140:                    if (listeners[i] == TreeModelListener.class) {
141:                        // Lazily create the event:
142:                        if (e == null)
143:                            e = new TreeModelEvent(source, path, childIndices,
144:                                    children);
145:                        ((TreeModelListener) listeners[i + 1])
146:                                .treeNodesRemoved(e);
147:                    }
148:                }
149:            }
150:
151:            /*
152:             * Notify all listeners that have registered interest for
153:             * notification on this event type.  The event instance 
154:             * is lazily created using the parameters passed into 
155:             * the fire method.
156:             * @see EventListenerList
157:             */
158:            public void fireTreeStructureChanged(Object source, Object[] path,
159:                    int[] childIndices, Object[] children) {
160:                // Guaranteed to return a non-null array
161:                Object[] listeners = listenerList.getListenerList();
162:                TreeModelEvent e = null;
163:                // Process the listeners last to first, notifying
164:                // those that are interested in this event
165:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
166:                    if (listeners[i] == TreeModelListener.class) {
167:                        // Lazily create the event:
168:                        if (e == null)
169:                            e = new TreeModelEvent(source, path, childIndices,
170:                                    children);
171:                        ((TreeModelListener) listeners[i + 1])
172:                                .treeStructureChanged(e);
173:                    }
174:                }
175:            }
176:        }
177:
178:        /*
179:         *   Local Variables:
180:         *   tab-width: 2
181:         *   indent-tabs-mode: nil
182:         *   mode: java
183:         *   c-indentation-style: java
184:         *   c-basic-offset: 2
185:         *   eval: (c-set-offset 'substatement-open '0)
186:         *   eval: (c-set-offset 'case-label '+)
187:         *   eval: (c-set-offset 'inclass '+)
188:         *   eval: (c-set-offset 'inline-open '0)
189:         *   End:
190:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.