Source Code Cross Referenced for DirectoryTreeModel.java in  » UML » jrefactory » org » acm » seguin » pmd » 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 » UML » jrefactory » org.acm.seguin.pmd.swingui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.pmd.swingui;
002:
003:        import javax.swing.event.TreeExpansionEvent;
004:        import javax.swing.event.TreeWillExpandListener;
005:        import javax.swing.tree.DefaultTreeModel;
006:        import javax.swing.tree.TreePath;
007:        import java.io.File;
008:        import java.io.FileFilter;
009:        import java.util.Enumeration;
010:
011:        /**
012:         *
013:         * @author Donald A. Leckie
014:         * @since August 17, 2002
015:         * @version $Revision: 1.2 $, $Date: 2003/09/21 20:51:41 $
016:         */
017:        class DirectoryTreeModel extends DefaultTreeModel implements 
018:                TreeWillExpandListener {
019:
020:            private DirectoryTree m_directoryTree;
021:
022:            /**
023:             *****************************************************************************
024:             */
025:            protected DirectoryTreeModel(String rootName) {
026:                super (DirectoryTreeNode.createRootNode(rootName));
027:            }
028:
029:            /**
030:             ********************************************************************************
031:             *
032:             */
033:            protected void setupFiles(File[] rootFiles) {
034:                DirectoryTreeNode rootNode;
035:                FilesFilter filesFilter;
036:
037:                rootNode = (DirectoryTreeNode) getRoot();
038:                filesFilter = new FilesFilter();
039:
040:                if (rootFiles != null) {
041:                    for (int n1 = 0; n1 < rootFiles.length; n1++) {
042:                        File rootFile;
043:                        DirectoryTreeNode fileNode;
044:
045:                        rootFile = rootFiles[n1];
046:                        fileNode = new DirectoryTreeNode(rootFile);
047:
048:                        rootNode.add(fileNode);
049:
050:                        if (rootFile.exists()) {
051:                            File[] files = rootFile.listFiles(filesFilter);
052:
053:                            if (files != null) {
054:                                for (int n2 = 0; n2 < files.length; n2++) {
055:                                    fileNode.add(new DirectoryTreeNode(
056:                                            files[n2]));
057:                                }
058:                            }
059:                        }
060:                    }
061:                }
062:            }
063:
064:            /**
065:             ********************************************************************************
066:             *
067:             * @param directory
068:             */
069:            protected void setDirectoryTree(DirectoryTree directoryTree) {
070:                m_directoryTree = directoryTree;
071:
072:                m_directoryTree.addTreeWillExpandListener(this );
073:            }
074:
075:            /**
076:             ******************************************************************************
077:             *
078:             * Called before a directory tree node in the tree will be expanded.  The tree node
079:             * to be expanded will contain a directory.  The tree node will contain children
080:             * consisting of subdirectories and/or files.  The subdirectory tree nodes will have
081:             * child tree nodes added so that they may be expanded.
082:             *
083:             * @param event
084:             *
085:             * @throws ExpandVetoException
086:             */
087:            public void treeWillExpand(TreeExpansionEvent event) {
088:                TreePath treePath;
089:                DirectoryTreeNode treeNode;
090:                Enumeration children;
091:
092:                treePath = event.getPath();
093:                treeNode = (DirectoryTreeNode) treePath.getLastPathComponent();
094:                children = treeNode.children();
095:
096:                while (children.hasMoreElements()) {
097:                    DirectoryTreeNode childTreeNode = (DirectoryTreeNode) children
098:                            .nextElement();
099:                    File directory = (File) childTreeNode.getUserObject();
100:                    if (directory.exists()) {
101:                        File[] files = directory.listFiles(new FilesFilter());
102:
103:                        childTreeNode.removeAllChildren();
104:
105:                        if (files != null) {
106:                            for (int n = 0; n < files.length; n++) {
107:                                childTreeNode.add(new DirectoryTreeNode(
108:                                        files[n]));
109:                            }
110:                        }
111:                    }
112:                }
113:            }
114:
115:            /**
116:             ******************************************************************************
117:             *
118:             * Called before a directory tree node in the tree will be collapsed.  The tree node
119:             * to be collapsed will contain a directory.  The tree node will contain children
120:             * consisting of subdirectories and/or files.  The subdirectory tree nodes will have
121:             * their child tree nodes removed since they will no longer be visible.
122:             *
123:             * @param event
124:             *
125:             * @throws ExpandVetoException
126:             */
127:            public void treeWillCollapse(TreeExpansionEvent event) {
128:                TreePath treePath;
129:                DirectoryTreeNode treeNode;
130:                Enumeration children;
131:
132:                treePath = event.getPath();
133:                treeNode = (DirectoryTreeNode) treePath.getLastPathComponent();
134:                children = treeNode.children();
135:
136:                while (children.hasMoreElements()) {
137:                    DirectoryTreeNode childTreeNode = (DirectoryTreeNode) children
138:                            .nextElement();
139:
140:                    childTreeNode.removeAllChildren();
141:                }
142:            }
143:
144:            /**
145:             *******************************************************************************
146:             *******************************************************************************
147:             *******************************************************************************
148:             */
149:            private class FilesFilter implements  FileFilter {
150:
151:                /**
152:                 ****************************************************************************
153:                 *
154:                 * @param file
155:                 *
156:                 * @return
157:                 */
158:                public boolean accept(File file) {
159:                    return file.isDirectory() && (file.isHidden() == false);
160:                }
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.