Source Code Cross Referenced for DependTreeModel.java in  » Development » jdepend-2.9 » jdepend » swingui » 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 » Development » jdepend 2.9 » jdepend.swingui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jdepend.swingui;
002:
003:        import java.util.*;
004:        import javax.swing.tree.*;
005:        import javax.swing.event.*;
006:
007:        /**
008:         * The <code>DependTreeModel</code> class defines the data model being
009:         * observed by a <code>DependTree</code> instance.
010:         * 
011:         * @author <b>Mike Clark</b>
012:         * @author Clarkware Consulting, Inc.
013:         */
014:
015:        public class DependTreeModel implements  TreeModel {
016:
017:            private PackageNode root;
018:
019:            private Vector listeners;
020:
021:            /**
022:             * Constructs a <code>DependTreeModel</code> with the specified root
023:             * package node.
024:             * 
025:             * @param root Root package node.
026:             */
027:            public DependTreeModel(PackageNode root) {
028:                this .root = root;
029:                listeners = new Vector();
030:            }
031:
032:            /**
033:             * Returns the root of the tree.
034:             * 
035:             * @return The root of the tree, or <code>null</code> if the tree has no
036:             *         nodes.
037:             */
038:            public Object getRoot() {
039:                return root;
040:            }
041:
042:            /**
043:             * Returns the child of the specified parent at the specified index in the
044:             * parent's child collection.
045:             * <p>
046:             * The specified parent must be a node previously obtained from this data
047:             * source.
048:             * 
049:             * @param parent A node in the tree, obtained from this data source.
050:             * @param index Index of child in the parent's child collection.
051:             * @return Child.
052:             */
053:            public Object getChild(Object parent, int index) {
054:
055:                Object answer = null;
056:                ArrayList children;
057:
058:                if (parent instanceof  PackageNode) {
059:                    children = ((PackageNode) parent).getChildren();
060:
061:                    if (children != null) {
062:                        if (index < children.size()) {
063:                            answer = children.get(index);
064:                        }
065:                    }
066:                }
067:
068:                return answer;
069:            }
070:
071:            /**
072:             * Returns the number of children for the specified parent.
073:             * <p>
074:             * The specified parent must be a node previously obtained from this data
075:             * source.
076:             * 
077:             * @param parent A node in the tree, obtained from this data source.
078:             * @return The number of children of the specified parent, or 0 if the
079:             *         parent is a leaf node or if it has no children.
080:             */
081:            public int getChildCount(Object parent) {
082:
083:                int answer = 0;
084:                ArrayList children;
085:
086:                if (parent instanceof  PackageNode) {
087:                    children = ((PackageNode) parent).getChildren();
088:
089:                    if (children != null) {
090:                        answer = children.size();
091:                    }
092:                }
093:
094:                return answer;
095:            }
096:
097:            /**
098:             * Determines whether the specified tree node is a leaf node.
099:             * 
100:             * @param o A node in the tree, obtained from this data source.
101:             * @return <code>true</code> if the node is a leaf; <code>false</code>
102:             *         otherwise.
103:             */
104:            public boolean isLeaf(Object o) {
105:
106:                boolean answer = true;
107:
108:                if (o instanceof  PackageNode) {
109:                    PackageNode node = (PackageNode) o;
110:                    return node.isLeaf();
111:                }
112:
113:                return answer;
114:            }
115:
116:            /**
117:             * Callback method triggered when the value for the item specified by
118:             * <i>path </i> has changed to <i>newValue </i>.
119:             * 
120:             * @param path Path to the node that has changed.
121:             * @param newValue The new value of the node.
122:             */
123:            public void valueForPathChanged(TreePath path, Object newValue) {
124:                // do nothing
125:            }
126:
127:            /**
128:             * Returns the index of the specified child within the specified parent.
129:             * 
130:             * @param parent Parent node.
131:             * @param child Child node.
132:             * @return Index of child within parent.
133:             */
134:            public int getIndexOfChild(Object parent, Object child) {
135:                int answer = -1;
136:                ArrayList children = null;
137:
138:                if (parent instanceof  PackageNode) {
139:                    children = ((PackageNode) parent).getChildren();
140:
141:                    if (children != null) {
142:                        answer = children.indexOf(child);
143:                    }
144:                }
145:
146:                return answer;
147:            }
148:
149:            /**
150:             * Adds a listener for the <code>TreeModelEvent</code> posted after the
151:             * tree changes.
152:             * 
153:             * @param l The listener to add.
154:             */
155:            public void addTreeModelListener(TreeModelListener l) {
156:
157:                if ((l != null) && !listeners.contains(l)) {
158:                    listeners.addElement(l);
159:                }
160:            }
161:
162:            /**
163:             * Removes a listener for <code>TreeModelEvent</code>s.
164:             * 
165:             * @param l The listener to remove.
166:             */
167:            public void removeTreeModelListener(TreeModelListener l) {
168:                listeners.removeElement(l);
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.