Source Code Cross Referenced for PermissionsTreeNode.java in  » Content-Management-System » harmonise » org » openharmonise » him » serverconfig » permissions » tree » 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.serverconfig.permissions.tree 
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.serverconfig.permissions.tree;
020:
021:        import java.util.Iterator;
022:        import java.util.List;
023:
024:        import javax.swing.Icon;
025:        import javax.swing.tree.DefaultMutableTreeNode;
026:
027:        import org.openharmonise.vfs.gui.*;
028:        import org.openharmonise.vfs.metadata.*;
029:        import org.openharmonise.vfs.metadata.range.*;
030:        import org.openharmonise.vfs.metadata.value.*;
031:
032:        /**
033:         * Tree node for the permissions tree.
034:         * 
035:         * @author Matthew Large
036:         * @version $Revision: 1.1 $
037:         *
038:         */
039:        public class PermissionsTreeNode extends DefaultMutableTreeNode {
040:
041:            /**
042:             * Property Instance for this object on the selected Role.
043:             */
044:            private PropertyInstance m_propInst;
045:
046:            /**
047:             * Full path to the object/permission.
048:             */
049:            private String m_sHREF = null;
050:
051:            /**
052:             * Name for this object/permission.
053:             */
054:            private String m_sDisplayName = "";
055:
056:            /**
057:             * Icon for this object/permission.
058:             */
059:            private Icon m_iDisplayIcon = null;
060:
061:            /**
062:             * Expanded icon for this object/permission.
063:             */
064:            private Icon m_iDisplayIconExpanded = null;
065:
066:            /**
067:             * True if this is a leaf node.
068:             */
069:            private boolean m_bIsLeaf = false;
070:
071:            /**
072:             * True if the children of this node are populated.
073:             */
074:            private boolean m_bChildrenPopulated = false;
075:
076:            /**
077:             * True if this node is selected.
078:             */
079:            private boolean m_bSelected = false;
080:
081:            /**
082:             * Cell for this node.
083:             */
084:            private PermissionsTreeCell m_cell = null;
085:
086:            /**
087:             * True if this node is enabled.
088:             */
089:            private boolean m_bEnabled = true;
090:
091:            /**
092:             * Constructs a new permissions tree node.
093:             * 
094:             * @param propInst property Instance for this object on the selected Role.
095:             * @param value permission value object.
096:             * @param bEnabled true if this node is enabled.
097:             */
098:            public PermissionsTreeNode(PropertyInstance propInst, Value value,
099:                    boolean bEnabled) {
100:                super (value.getHREF());
101:                this .m_propInst = propInst;
102:                this .m_sHREF = value.getHREF();
103:                this .m_bEnabled = bEnabled;
104:
105:                this .m_sDisplayName = value.getDisplayName();
106:                this .m_iDisplayIcon = IconManager.getInstance().getIcon(
107:                        "16-value.gif");
108:                this .m_iDisplayIconExpanded = IconManager.getInstance()
109:                        .getIcon("16-value.gif");
110:                this .m_bIsLeaf = true;
111:
112:                this .populateChildren();
113:            }
114:
115:            /**
116:             * Constructs a new permissions tree node.
117:             * 
118:             * @param propInst property Instance for this object on the selected Role.
119:             * @param valuegroup object valuegroup object.
120:             * @param bEnabled true if this node is enabled.
121:             */
122:            public PermissionsTreeNode(PropertyInstance propInst,
123:                    ValueGroup valuegroup, boolean bEnabled) {
124:                super (valuegroup.getHREF());
125:                this .m_propInst = propInst;
126:                this .m_sHREF = valuegroup.getHREF();
127:                this .m_bEnabled = bEnabled;
128:
129:                this .m_sDisplayName = propInst.getDefinition().getDisplayName();
130:                this .m_iDisplayIcon = IconManager.getInstance().getIcon(
131:                        "16-value-container.gif");
132:                this .m_iDisplayIconExpanded = IconManager.getInstance()
133:                        .getIcon("16-value-container.gif");
134:                this .m_bIsLeaf = false;
135:
136:                this .populateChildren();
137:            }
138:
139:            /**
140:             * Sets whether this node is selected.
141:             * 
142:             * @param bSelected true to select this node.
143:             */
144:            public void setSelected(boolean bSelected) {
145:                ValueValue val = (ValueValue) this .m_propInst
146:                        .getNewValueInstance();
147:                val.setValue(this .getValue().getHREF());
148:                if (bSelected && this .m_bIsLeaf && this .getValue() != null) {
149:                    this .m_propInst.addValue(val);
150:                } else if (!bSelected && this .m_bIsLeaf
151:                        && this .getValue() != null) {
152:                    this .m_propInst.removeValue(val);
153:                } else if (bSelected && this .getValueGroup() != null) {
154:                    this .addAllValues(this .m_propInst, this .getValueGroup());
155:                } else if (!bSelected && this .getValueGroup() != null) {
156:                    this .removeAllValues(this .m_propInst, this .getValueGroup());
157:                }
158:            }
159:
160:            /**
161:             * Checks if this node is enabled.
162:             * 
163:             * @return true if this node is enabled.
164:             */
165:            public boolean getEnabled() {
166:                return this .m_bEnabled;
167:            }
168:
169:            /**
170:             * Checks if this node is selected.
171:             * 
172:             * @return true if this node is selected.
173:             */
174:            public boolean isSelected() {
175:                if (this .m_bIsLeaf) {
176:                    List vals = this .m_propInst.getValues();
177:                    Iterator itor = vals.iterator();
178:                    while (itor.hasNext()) {
179:                        ValueValue value = (ValueValue) itor.next();
180:                        if (value.getValue().equalsIgnoreCase(
181:                                this .getValue().getHREF())) {
182:                            return true;
183:                        }
184:                    }
185:                    return false;
186:                } else {
187:                    return this .checkAllValues(this .m_propInst, this 
188:                            .getValueGroup());
189:                }
190:            }
191:
192:            /**
193:             * Adds all the values from a valuegroup to the children of this node.
194:             * 
195:             * @param propInst property Instance for this object on the selected Role.
196:             * @param valGrp valuegroup to get children from.
197:             */
198:            private void addAllValues(PropertyInstance propInst,
199:                    ValueGroup valGrp) {
200:                List subGrps = valGrp.getSubGroups();
201:                Iterator itor = subGrps.iterator();
202:                while (itor.hasNext()) {
203:                    ValueGroup subGrp = (ValueGroup) itor.next();
204:                    this .addAllValues(propInst, subGrp);
205:                }
206:
207:                List children = valGrp.getChildren();
208:                itor = children.iterator();
209:                while (itor.hasNext()) {
210:                    Value val = (Value) itor.next();
211:                    ValueValue valInst = (ValueValue) propInst
212:                            .getNewValueInstance();
213:                    valInst.setValue(val.getHREF());
214:                    propInst.addValue(valInst);
215:                }
216:            }
217:
218:            /**
219:             * Removes all the values from a valuegroup from the children of this node.
220:             * 
221:             * @param propInst property Instance for this object on the selected Role.
222:             * @param valGrp valuegroup to get children to remove from.
223:             */
224:            private void removeAllValues(PropertyInstance propInst,
225:                    ValueGroup valGrp) {
226:                List subGrps = valGrp.getSubGroups();
227:                Iterator itor = subGrps.iterator();
228:                while (itor.hasNext()) {
229:                    ValueGroup subGrp = (ValueGroup) itor.next();
230:                    this .removeAllValues(propInst, subGrp);
231:                }
232:
233:                List children = valGrp.getChildren();
234:                itor = children.iterator();
235:                while (itor.hasNext()) {
236:                    Value val = (Value) itor.next();
237:                    ValueValue valInst = (ValueValue) propInst
238:                            .getNewValueInstance();
239:                    valInst.setValue(val.getHREF());
240:                    propInst.removeValue(valInst);
241:                }
242:            }
243:
244:            /**
245:             * Checks all the values from a valuegroup as children of this node.
246:             * 
247:             * @param propInst property Instance for this object on the selected Role.
248:             * @param valGrp valuegroup to get children to check from.
249:             * @return true if all values where successfully checked.
250:             */
251:            private boolean checkAllValues(PropertyInstance propInst,
252:                    ValueGroup valGrp) {
253:                boolean bChecked = true;
254:
255:                List subGrps = valGrp.getSubGroups();
256:                Iterator itor = subGrps.iterator();
257:                while (itor.hasNext()) {
258:                    ValueGroup subGrp = (ValueGroup) itor.next();
259:                    if (!this .checkAllValues(propInst, subGrp)) {
260:                        bChecked = false;
261:                    }
262:                }
263:
264:                if (bChecked) {
265:                    List children = valGrp.getChildren();
266:                    itor = children.iterator();
267:                    while (itor.hasNext()) {
268:                        Value val = (Value) itor.next();
269:
270:                        boolean bFound = false;
271:                        List vals = this .m_propInst.getValues();
272:                        Iterator itor2 = vals.iterator();
273:                        while (itor2.hasNext()) {
274:                            ValueValue value = (ValueValue) itor2.next();
275:                            if (value.getValue()
276:                                    .equalsIgnoreCase(val.getHREF())) {
277:                                bFound = true;
278:                            }
279:                        }
280:                        if (!bFound) {
281:                            bChecked = false;
282:                        }
283:                    }
284:                }
285:
286:                return bChecked;
287:            }
288:
289:            /**
290:             * Gets the icon for this node.
291:             * 
292:             * @param bExpanded true to get the expanded version icon.
293:             * @return icon for this node.
294:             */
295:            public Icon getDisplayIcon(boolean bExpanded) {
296:                return this .m_iDisplayIcon;
297:            }
298:
299:            /**
300:             * Gets the valuegroup this node represents.
301:             * 
302:             * @return valuegroup this node represents.
303:             */
304:            public ValueGroup getValueGroup() {
305:                return ValueCache.getInstance().getValueGroup(this .m_sHREF);
306:            }
307:
308:            /**
309:             * Gets the value this node represents.
310:             * 
311:             * @return value this node represents.
312:             */
313:            public Value getValue() {
314:                return ValueCache.getInstance().getValue(this .m_sHREF);
315:            }
316:
317:            /**
318:             * Gets the property instance for this object on the selected Role.
319:             * 
320:             * @return property instance for this object on the selected Role.
321:             */
322:            public PropertyInstance getPropertyInstance() {
323:                return this .m_propInst;
324:            }
325:
326:            /**
327:             * Gets the name for this node.
328:             * 
329:             * @return name for this node.
330:             */
331:            public String getDisplayName() {
332:                return this .m_sDisplayName;
333:            }
334:
335:            /**
336:             * Checks if this is a leaf node.
337:             * 
338:             * @return true if this is a leaf node.
339:             */
340:            public boolean isLeaf() {
341:                return this .m_bIsLeaf;
342:            }
343:
344:            /**
345:             * Populates the children of this node.
346:             *
347:             */
348:            protected void populateChildren() {
349:                if (!this .isLeaf()) {
350:                    if (this .m_sDisplayName.equalsIgnoreCase("Asset")) {
351:                        this .m_iDisplayIcon = IconManager.getInstance()
352:                                .getIcon("16-image.gif");
353:                    } else if (this .m_sDisplayName.equalsIgnoreCase("Document")) {
354:                        this .m_iDisplayIcon = IconManager.getInstance()
355:                                .getIcon("16-document.gif");
356:                    } else if (this .m_sDisplayName.equalsIgnoreCase("Property")) {
357:                        this .m_iDisplayIcon = IconManager.getInstance()
358:                                .getIcon("16-property.gif");
359:                    } else if (this .m_sDisplayName
360:                            .equalsIgnoreCase("Property Group")) {
361:                        this .m_iDisplayIcon = IconManager.getInstance()
362:                                .getIcon("16-property-container.gif");
363:                    } else if (this .m_sDisplayName.equalsIgnoreCase("Section")) {
364:                        this .m_iDisplayIcon = IconManager.getInstance()
365:                                .getIcon("16-section.gif");
366:                    } else if (this .m_sDisplayName.equalsIgnoreCase("User")) {
367:                        this .m_iDisplayIcon = IconManager.getInstance()
368:                                .getIcon("16-user.gif");
369:                    } else if (this .m_sDisplayName
370:                            .equalsIgnoreCase("User Group")) {
371:                        this .m_iDisplayIcon = IconManager.getInstance()
372:                                .getIcon("16-user-container.gif");
373:                    } else if (this .m_sDisplayName.equalsIgnoreCase("Value")) {
374:                        this .m_iDisplayIcon = IconManager.getInstance()
375:                                .getIcon("16-value.gif");
376:                    } else if (this .m_sDisplayName
377:                            .equalsIgnoreCase("Value Group")) {
378:                        this .m_iDisplayIcon = IconManager.getInstance()
379:                                .getIcon("16-value-container.gif");
380:                    } else if (this .m_sDisplayName
381:                            .equalsIgnoreCase("XML Resource")) {
382:                        this .m_iDisplayIcon = IconManager.getInstance()
383:                                .getIcon("16-page-definition.gif");
384:                    } else if (this .m_sDisplayName
385:                            .equalsIgnoreCase("XML Resource Group")) {
386:                        this .m_iDisplayIcon = IconManager.getInstance()
387:                                .getIcon("16-page-definition-folder.gif");
388:                    } else if (this .m_sDisplayName
389:                            .equalsIgnoreCase("XSL Resource")) {
390:                        this .m_iDisplayIcon = IconManager.getInstance()
391:                                .getIcon("16-xslt.gif");
392:                    } else if (this .m_sDisplayName
393:                            .equalsIgnoreCase("XSL Resource Group")) {
394:                        this .m_iDisplayIcon = IconManager.getInstance()
395:                                .getIcon("16-xslt-folder.gif");
396:                    } else if (this .m_sDisplayName
397:                            .equalsIgnoreCase("WebPage Group")) {
398:                        this .m_iDisplayIcon = IconManager.getInstance()
399:                                .getIcon("16-page-definition-folder.gif");
400:                    } else if (this .m_sDisplayName.equalsIgnoreCase("WebPage")) {
401:                        this .m_iDisplayIcon = IconManager.getInstance()
402:                                .getIcon("16-page-definition.gif");
403:                    } else if (this .m_sDisplayName.equalsIgnoreCase("Template")) {
404:                        this .m_iDisplayIcon = IconManager.getInstance()
405:                                .getIcon("16-object-template.gif");
406:                    } else if (this .m_sDisplayName
407:                            .equalsIgnoreCase("Template Group")) {
408:                        this .m_iDisplayIcon = IconManager.getInstance()
409:                                .getIcon("16-object-template-folder.gif");
410:                    } else if (this .m_sDisplayName.equalsIgnoreCase("Workflow")) {
411:                        this .m_iDisplayIcon = IconManager.getInstance()
412:                                .getIcon("16-command-change-status.gif");
413:                    } else if (this .m_sDisplayName
414:                            .equalsIgnoreCase("Workflow Group")) {
415:                        this .m_iDisplayIcon = IconManager.getInstance()
416:                                .getIcon("16-folder.gif");
417:                    } else if (this .m_sDisplayName
418:                            .equalsIgnoreCase("Workflow Stage")) {
419:                        this .m_iDisplayIcon = IconManager.getInstance()
420:                                .getIcon("16-workflow-container.gif");
421:                    } else if (this .m_sDisplayName
422:                            .equalsIgnoreCase("Workflow Stage Group")) {
423:                        this .m_iDisplayIcon = IconManager.getInstance()
424:                                .getIcon("16-folder.gif");
425:                    }
426:                } else {
427:                    if (this .getDisplayName().equalsIgnoreCase("Archive")) {
428:                        this .m_iDisplayIcon = IconManager.getInstance()
429:                                .getIcon("16-archive-container.gif");
430:                    } else if (this .getDisplayName()
431:                            .equalsIgnoreCase("Publish")) {
432:                        this .m_iDisplayIcon = IconManager.getInstance()
433:                                .getIcon("16-command-publish.gif");
434:                    } else if (this .getDisplayName().equalsIgnoreCase("Lock")) {
435:                        this .m_iDisplayIcon = IconManager.getInstance()
436:                                .getIcon("16-command-lock.gif");
437:                    } else if (this .getDisplayName().equalsIgnoreCase("Unlock")) {
438:                        this .m_iDisplayIcon = IconManager.getInstance()
439:                                .getIcon("16-command-unlock.gif");
440:                    } else if (this .getDisplayName().equalsIgnoreCase(
441:                            "Move/Copy")) {
442:                        this .m_iDisplayIcon = IconManager.getInstance()
443:                                .getIcon("16-command-move.gif");
444:                    } else if (this .getDisplayName().equalsIgnoreCase(
445:                            "Retrieve")) {
446:                        this .m_iDisplayIcon = IconManager.getInstance()
447:                                .getIcon("16-command-retrieve.gif");
448:                    } else if (this .getDisplayName().equalsIgnoreCase(
449:                            "Submit to Server")) {
450:                        this .m_iDisplayIcon = IconManager.getInstance()
451:                                .getIcon("16-command-sync-all.gif");
452:                    } else if (this .getDisplayName().equalsIgnoreCase("View")) {
453:                        this .m_iDisplayIcon = IconManager.getInstance()
454:                                .getIcon("16-command-preview.gif");
455:                    }
456:                }
457:
458:                if (!this .m_bIsLeaf && !m_bChildrenPopulated) {
459:                    Iterator itor = ValueCache.getInstance().getValueGroup(
460:                            this .m_sHREF).getSubGroups().iterator();
461:                    int nCount = 0;
462:                    while (itor.hasNext()) {
463:                        this .add(new PermissionsTreeNode(this .m_propInst,
464:                                (ValueGroup) itor.next(), this .m_bEnabled));
465:                        nCount++;
466:                    }
467:                    itor = ValueCache.getInstance().getValueGroup(this .m_sHREF)
468:                            .getChildren().iterator();
469:                    while (itor.hasNext()) {
470:                        this .add(new PermissionsTreeNode(this .m_propInst,
471:                                (Value) itor.next(), this .m_bEnabled));
472:                        nCount++;
473:                    }
474:                    m_bChildrenPopulated = true;
475:                }
476:            }
477:
478:            /**
479:             * Gets the full path to the object/permission this node represents.
480:             * 
481:             * @return full path to the object/permission this node represents.
482:             */
483:            public String getHREF() {
484:                return this .m_sHREF;
485:            }
486:
487:            /**
488:             * @param userObject
489:             */
490:            private PermissionsTreeNode(Object userObject) {
491:                super (userObject);
492:            }
493:
494:            /**
495:             * @param userObject
496:             * @param allowsChildren
497:             */
498:            private PermissionsTreeNode(Object userObject,
499:                    boolean allowsChildren) {
500:                super (userObject, allowsChildren);
501:            }
502:
503:            /**
504:             * Sets whether this node is enabled.
505:             * 
506:             * @param bEnable true to enable this node.
507:             */
508:            public void setEnabled(boolean bEnable) {
509:                this.m_bEnabled = bEnable;
510:            }
511:
512:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.