Source Code Cross Referenced for TreeNode.java in  » Content-Management-System » harmonise » org » openharmonise » him » swing » resourcetree » 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 » Content Management System » harmonise » org.openharmonise.him.swing.resourcetree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.him.swing.resourcetree;
020:
021:        import java.util.*;
022:        import java.util.Iterator;
023:
024:        import javax.swing.Icon;
025:        import javax.swing.JTree;
026:        import javax.swing.tree.DefaultMutableTreeNode;
027:        import javax.swing.tree.DefaultTreeModel;
028:        import javax.swing.tree.TreePath;
029:
030:        import org.openharmonise.vfs.*;
031:        import org.openharmonise.vfs.event.*;
032:
033:        /**
034:         * A node in a resource tree.
035:         * 
036:         * @author Matthew Large
037:         * @version $Revision: 1.1 $
038:         *
039:         */
040:        public class TreeNode extends DefaultMutableTreeNode implements 
041:                VirtualFileListener {
042:
043:            /**
044:             * Full path to resource.
045:             */
046:            private String m_sFullPath = null;
047:
048:            /**
049:             * Virtual file system for resource.
050:             */
051:            private AbstractVirtualFileSystem m_vfs = null;
052:
053:            /**
054:             * Display name of resource.
055:             */
056:            private String m_sDisplayName = "";
057:
058:            /**
059:             * Icon of resource.
060:             */
061:            private Icon m_iDisplayIcon = null;
062:
063:            /**
064:             * Expanded icon for collection resources.
065:             */
066:            private Icon m_iDisplayIconExpanded = null;
067:
068:            /**
069:             * true if this is a leaf node.
070:             */
071:            private boolean m_bIsLeaf = false;
072:
073:            /**
074:             * true if child nodes have been populated.
075:             */
076:            private boolean m_bChildrenPopulated = false;
077:
078:            private AbstractResourceFilter m_resourceFilter = null;
079:
080:            /**
081:             * Tree
082:             */
083:            private JTree m_tree = null;
084:
085:            /**
086:             * Constructs a new tree node.
087:             * 
088:             * @param vfs Virtual file system for resource
089:             * @param sFullPath Full path for resource
090:             * @param tree Tree
091:             */
092:            public TreeNode(AbstractVirtualFileSystem vfs, String sFullPath,
093:                    JTree tree, AbstractResourceFilter resourceFilter) {
094:                super (sFullPath);
095:                m_sFullPath = sFullPath;
096:                m_vfs = vfs;
097:                this .m_tree = tree;
098:                VirtualFileSystemView vfsView = vfs.getVirtualFileSystemView();
099:                VirtualFile vfFile = vfs.getVirtualFile(sFullPath)
100:                        .getResource();
101:
102:                vfFile.addVirtualFileListener(this );
103:
104:                this .m_sDisplayName = vfsView.getDisplayName(vfFile);
105:                this .m_iDisplayIcon = vfsView.getIcon(vfFile);
106:                this .m_iDisplayIconExpanded = vfsView.getIcon(vfFile, true);
107:                this .m_bIsLeaf = !vfFile.isDirectory();
108:
109:                this .m_resourceFilter = resourceFilter;
110:            }
111:
112:            /**
113:             * Returns the icon for the resource.
114:             * 
115:             * @param bExpanded true if the expanded icon is to be returned for collection resoruces
116:             * @return Icon
117:             */
118:            public Icon getDisplayIcon(boolean bExpanded) {
119:                if (bExpanded) {
120:                    return this .m_iDisplayIconExpanded;
121:                } else {
122:                    return this .m_iDisplayIcon;
123:                }
124:            }
125:
126:            /**
127:             * Returns the display name for the resource.
128:             * 
129:             * @return Display name
130:             */
131:            public String getDisplayName() {
132:                return this .m_sDisplayName;
133:            }
134:
135:            /* (non-Javadoc)
136:             * @see javax.swing.tree.TreeNode#isLeaf()
137:             */
138:            public boolean isLeaf() {
139:                return this .m_bIsLeaf;
140:            }
141:
142:            /**
143:             * Checks if leaf node children will be displayed.
144:             * 
145:             * @return true if leaf node children will be displayed
146:             */
147:            public boolean isShowChildren() {
148:                return !this .m_resourceFilter.isShowCollectionsOnly();
149:            }
150:
151:            /**
152:             * Checks if only published children will be displayed.
153:             * 
154:             * @return true if only published children will be displayed
155:             */
156:            public boolean isShowApprovedOnly() {
157:                return this .m_resourceFilter.isShowLiveResourcesOnly();
158:            }
159:
160:            /**
161:             * Populates this nodes child nodes.
162:             * 
163:             * @param bShowLeafNodes true if leaf node children are to be displayed
164:             * @param bShowApprovedOnly true if only published children are to be displayed
165:             */
166:            protected void populateChildren() {
167:                if (!this .m_bIsLeaf && !m_bChildrenPopulated) {
168:                    Iterator itor = this .m_vfs.getVirtualFile(this .m_sFullPath)
169:                            .getResource().getChildren().iterator();
170:                    int nCount = 0;
171:                    while (itor.hasNext()) {
172:                        String sPath = (String) itor.next();
173:                        VirtualFile vfChild = this .m_vfs.getVirtualFile(sPath)
174:                                .getResource();
175:                        if (sPath != null
176:                                && (vfChild.isDirectory() || !this .m_resourceFilter
177:                                        .isShowCollectionsOnly())
178:                                && (!this .m_resourceFilter
179:                                        .isShowLiveResourcesOnly() || vfChild
180:                                        .getState() == VirtualFile.STATE_LIVE)
181:                                && this .m_resourceFilter.checkResource(vfChild)) {
182:                            this .add(new TreeNode(this .m_vfs, sPath,
183:                                    this .m_tree, this .m_resourceFilter));
184:                            nCount++;
185:                        }
186:                    }
187:                    m_bChildrenPopulated = true;
188:                }
189:            }
190:
191:            public boolean isChildrenPopulated() {
192:                return this .m_bChildrenPopulated;
193:            }
194:
195:            /**
196:             * Refreshes the children of this node.
197:             *
198:             */
199:            private void refreshChildren() {
200:                TreePath treePath = this .m_tree.getSelectionPath();
201:                if (treePath != null) {
202:                    Object treeComp = treePath.getLastPathComponent();
203:                }
204:                this .m_bChildrenPopulated = false;
205:                this .removeAllChildren();
206:                this .populateChildren();
207:                DefaultTreeModel model = (DefaultTreeModel) this .m_tree
208:                        .getModel();
209:                model.reload(this );
210:                VirtualFile vfFile = this .m_vfs
211:                        .getVirtualFile(this .m_sFullPath).getResource();
212:                vfFile.addVirtualFileListener(this );
213:                this .m_tree.revalidate();
214:                if (treePath != null) {
215:                    this .m_tree.expandPath(treePath);
216:                }
217:            }
218:
219:            /**
220:             * Returns the full path of the resouce.
221:             * 
222:             * @return Full path
223:             */
224:            public String getFilePath() {
225:                return this .m_sFullPath;
226:            }
227:
228:            /**
229:             * Returns the virtual file system for the resource.
230:             * 
231:             * @return Virtual file system
232:             */
233:            public AbstractVirtualFileSystem getVFS() {
234:                return this .m_vfs;
235:            }
236:
237:            /**
238:             * @param userObject
239:             */
240:            private TreeNode(Object userObject) {
241:                super (userObject);
242:            }
243:
244:            /**
245:             * @param userObject
246:             * @param allowsChildren
247:             */
248:            private TreeNode(Object userObject, boolean allowsChildren) {
249:                super (userObject, allowsChildren);
250:            }
251:
252:            /* (non-Javadoc)
253:             * @see com.simulacramedia.vfs.event.VirtualFileListener#virtualFileChanged(com.simulacramedia.vfs.event.VirtualFileEvent)
254:             */
255:            public void virtualFileChanged(VirtualFileEvent vfe) {
256:                if (vfe.getEventType() == VirtualFileEvent.FILE_MEMBERS_CHANGED) {
257:                    this .refreshChildren();
258:                }
259:            }
260:
261:            /* (non-Javadoc)
262:             * @see javax.swing.tree.TreeNode#children()
263:             */
264:            public Enumeration children() {
265:                populateChildren();
266:                return super.children();
267:            }
268:
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.