Source Code Cross Referenced for AddressbookTreeNode.java in  » Mail-Clients » columba-1.4 » org » columba » addressbook » folder » 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 » Mail Clients » columba 1.4 » org.columba.addressbook.folder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // The contents of this file are subject to the Mozilla Public License Version
002:        // 1.1
003:        //(the "License"); you may not use this file except in compliance with the
004:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005:        //
006:        //Software distributed under the License is distributed on an "AS IS" basis,
007:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008:        //for the specific language governing rights and
009:        //limitations under the License.
010:        //
011:        //The Original Code is "The Columba Project"
012:        //
013:        //The Initial Developers of the Original Code are Frederik Dietz and Timo
014:        // Stich.
015:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016:        //
017:        //All Rights Reserved.
018:        package org.columba.addressbook.folder;
019:
020:        import java.lang.reflect.Method;
021:        import java.util.Hashtable;
022:
023:        import javax.swing.ImageIcon;
024:        import javax.swing.tree.DefaultMutableTreeNode;
025:
026:        import org.columba.addressbook.config.FolderItem;
027:        import org.columba.api.command.IWorkerStatusController;
028:        import org.columba.api.plugin.IExtensionInterface;
029:        import org.columba.core.base.Lock;
030:        import org.columba.core.resourceloader.IconKeys;
031:        import org.columba.core.resourceloader.ImageLoader;
032:        import org.columba.core.xml.XmlElement;
033:
034:        public abstract class AddressbookTreeNode extends
035:                DefaultMutableTreeNode implements  IFolder, IExtensionInterface {
036:            protected final static ImageIcon expandedIcon = ImageLoader
037:                    .getSmallIcon(IconKeys.FOLDER_OPEN);
038:
039:            private static int nextFolderUid = 0;
040:
041:            protected ImageIcon collapsedIcon = ImageLoader
042:                    .getSmallIcon(IconKeys.FOLDER);
043:
044:            protected FolderItem node;
045:
046:            protected Lock myLock;
047:
048:            private final Class[] FOLDER_ITEM_ARG = new Class[] { FolderItem.class };
049:
050:            public AddressbookTreeNode(String name) {
051:                super (name);
052:
053:            }
054:
055:            public AddressbookTreeNode(FolderItem item) {
056:                super ();
057:
058:                setNode(item);
059:
060:            }
061:
062:            public static Object generateNextFolderUid() {
063:                return new Integer(++nextFolderUid);
064:            }
065:
066:            /**
067:             * @param nextUid
068:             *            The nextUid to set.
069:             */
070:            public static void setNextFolderUid(int uid) {
071:                nextFolderUid = uid;
072:            }
073:
074:            /**
075:             * @return Returns the nextUid.
076:             */
077:            public static int getNextFolderUid() {
078:                return nextFolderUid;
079:            }
080:
081:            /*
082:             * public AddressbookTreeNode(String name) { super(name); this.name = name; }
083:             */
084:            public FolderItem getFolderItem() {
085:                return node;
086:            }
087:
088:            public ImageIcon getIcon() {
089:                return collapsedIcon;
090:            }
091:
092:            public final static FolderItem getDefaultItem(String className,
093:                    XmlElement props) {
094:                XmlElement defaultElement = new XmlElement("folder");
095:                defaultElement.addAttribute("class", className);
096:                defaultElement.addAttribute("uid", Integer
097:                        .toString(nextFolderUid++));
098:
099:                if (props != null) {
100:                    defaultElement.addElement(props);
101:                }
102:
103:                // FAILURE!!!
104:
105:                /*
106:                 * XmlElement filter = new XmlElement("filter");
107:                 * defaultElement.addElement(filter);
108:                 */
109:                return new FolderItem(defaultElement);
110:            }
111:
112:            /*
113:             * public TreePath getSelectionTreePath() { //TreeNodeList list = new
114:             * TreeNodeList( getTreePath() ); TreeNode[] treeNodes = getPathToRoot(this,
115:             * 0); TreePath path = new TreePath(treeNodes[0]);
116:             * 
117:             * for (int i = 1; i < treeNodes.length; i++) { Folder folder = (Folder)
118:             * treeNodes[i]; path.pathByAddingChild(folder); }
119:             * 
120:             * return path; }
121:             */
122:
123:            public static XmlElement getDefaultProperties() {
124:                return null;
125:            }
126:
127:            public ImageIcon getExpandedIcon() {
128:                return expandedIcon;
129:            }
130:
131:            /*
132:             * public void setName(String s) { name = s; } public String getName() {
133:             * return name; }
134:             */
135:            public String getId() {
136:                return node.get("uid");
137:            }
138:
139:            public boolean tryToGetLock() {
140:                return myLock.tryToGetLock(null);
141:            }
142:
143:            public void releaseLock() {
144:                myLock.release(null);
145:            }
146:
147:            /**
148:             * Returns the node.
149:             * 
150:             * @return FolderItem
151:             */
152:            public XmlElement getNode() {
153:                return node.getRoot();
154:            }
155:
156:            /**
157:             * Sets the node.
158:             * 
159:             * @param node
160:             *            The node to set
161:             */
162:            public void setNode(FolderItem node) {
163:                this .node = node;
164:            }
165:
166:            // public abstract Class getDefaultChild();
167:            public Class getDefaultChild() {
168:                return null;
169:            }
170:
171:            final public Hashtable getAttributes() {
172:                return node.getElement("property").getAttributes();
173:            }
174:
175:            public abstract void createChildren(IWorkerStatusController worker);
176:
177:            public void addFolder(String name, Class childClass)
178:                    throws Exception {
179:                Method m_getDefaultProperties = childClass.getMethod(
180:                        "getDefaultProperties", null);
181:
182:                XmlElement props = (XmlElement) m_getDefaultProperties.invoke(
183:                        null, null);
184:                FolderItem childNode = getDefaultItem(childClass.getName(),
185:                        props);
186:
187:                childNode.setString("property", "name", name);
188:
189:                // Put properties that should be copied from parent here
190:                AbstractFolder subFolder = (AbstractFolder) childClass
191:                        .getConstructor(FOLDER_ITEM_ARG).newInstance(
192:                                new Object[] { childNode });
193:                addWithXml(subFolder);
194:            }
195:
196:            public void addFolder(String name) throws Exception {
197:                addFolder(name, getDefaultChild());
198:            }
199:
200:            public void addWithXml(AddressbookTreeNode folder) {
201:                add(folder);
202:                this .getNode().addElement(folder.getNode());
203:            }
204:
205:            /**
206:             * @see javax.swing.tree.MutableTreeNode#removeFromParent()
207:             */
208:            public void removeFromParent() {
209:
210:                // remove xml config
211:                getNode().removeFromParent();
212:
213:                // remove node
214:                super .removeFromParent();
215:            }
216:
217:            public String getName() {
218:                String name = null;
219:
220:                FolderItem item = getFolderItem();
221:                name = item.getString("property", "name");
222:
223:                return name;
224:            }
225:
226:            /**
227:             * @see org.columba.modules.mail.folder.FolderTreeNode#setName(String)
228:             */
229:            public void setName(String newName) {
230:                FolderItem item = getFolderItem();
231:                item.setString("property", "name", newName);
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.