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


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the 
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003. 
014:        //
015:        //All Rights Reserved.
016:        package org.columba.mail.folderoptions;
017:
018:        import org.columba.api.plugin.IExtensionInterface;
019:        import org.columba.core.xml.XmlElement;
020:        import org.columba.mail.config.FolderItem;
021:        import org.columba.mail.folder.IMailbox;
022:        import org.columba.mail.gui.frame.MailFrameMediator;
023:
024:        /**
025:         * AbstractMessageFolder options plugin abstract class.
026:         * <p>
027:         * Plugins implementing this abstract class can load/save their configuration
028:         * data. They don't need to take care if this data is applied globally or on a
029:         * per-folder basis.
030:         * <p>
031:         * The most interest methods which you need to implement are:
032:         * <ul>
033:         * <li>createDefaultElement(boolean)</li>
034:         * <li>loadOptionsFromXml(AbstractMessageFolder)</li>
035:         * <li>saveOptionsToXml(AbstractMessageFolder)</li>
036:         * </ul>
037:         * <p>
038:         * Note, that every {@link MailFrameMediator} keeps its own
039:         * {@link FolderOptionsController}, which makes sure that all plugins are
040:         * singletons.
041:         * 
042:         * @author fdietz
043:         */
044:        public abstract class AbstractFolderOptionsPlugin implements 
045:                IExtensionInterface {
046:            /**
047:             * mail frame mediator
048:             */
049:            private MailFrameMediator mediator;
050:
051:            /**
052:             * name of configuration node
053:             */
054:            private String name;
055:
056:            /**
057:             * Constructor
058:             * 
059:             * TODO (@author fdietz):  pluginID is never used locally
060:             * @param name
061:             *            name of plugin
062:             * @param pluginId
063:             *            id of plugin used by plugin handler
064:             * @param mediator
065:             *            mail frame mediator
066:             */
067:            public AbstractFolderOptionsPlugin(String name, String pluginId,
068:                    MailFrameMediator mediator) {
069:                this .name = name;
070:                this .mediator = mediator;
071:            }
072:
073:            /**
074:             * Save configuration of this plugin.
075:             * <p>
076:             * 
077:             * Following a simple example of a toolbar configuration:<br>
078:             * 
079:             * <pre>
080:             * 
081:             *  
082:             *   &lt;toolbar enabled=&quot;true&quot; show_icon=&quot;true&quot; show_text=&quot;false&quot;&gt;
083:             *    &lt;button name=&quot;Cut&quot;/&gt;
084:             *    &lt;button name=&quot;Copy&quot;/&gt;
085:             *    &lt;button name=&quot;Paste&quot;/&gt;
086:             *    &lt;button name=&quot;Delete&quot;/&gt;
087:             *   &lt;/toolbar&gt;
088:             *   
089:             *  
090:             * </pre>
091:             * 
092:             * @param folder
093:             *            selected folder
094:             */
095:            public abstract void saveOptionsToXml(IMailbox folder);
096:
097:            /**
098:             * Load options of this plugin.
099:             * 
100:             * @param folder
101:             *            selected folder
102:             */
103:            public abstract void loadOptionsFromXml(IMailbox folder);
104:
105:            /**
106:             * Get frame mediator
107:             * 
108:             * @return frame mediator
109:             */
110:            public MailFrameMediator getMediator() {
111:                return mediator;
112:            }
113:
114:            /**
115:             * Get configuration node.
116:             * <p>
117:             * Determine if this should be applied globally or on a per-folder basis.
118:             * <p>
119:             * This way, plugins don't have to know, if they work on global or local
120:             * options.
121:             * <p>
122:             * Example for the sorting plugin configuration node. This is how it can be
123:             * found in options.xml and tree.xml:<br>
124:             * 
125:             * <pre>
126:             * 
127:             *  
128:             *    &lt;sorting column=&quot;Date&quot; order=&quot;true&quot; /&gt;
129:             *   
130:             *  
131:             * </pre>
132:             * 
133:             * @param folder
134:             *            currently selected folder
135:             * @return xml node
136:             */
137:            public XmlElement getConfigNode(IMailbox folder) {
138:                // global option
139:                if (folder == null) {
140:                    XmlElement result = FolderItem.getGlobalOptions()
141:                            .getElement(getName());
142:                    if (result == null) {
143:                        return createDefaultElement(true);
144:                    } else {
145:                        return result;
146:                    }
147:                }
148:
149:                // use folder specific options
150:                XmlElement parent = folder.getConfiguration()
151:                        .getFolderOptions();
152:
153:                XmlElement child = parent.getElement(getName());
154:
155:                // create element if not available
156:                if (child == null) {
157:                    child = createDefaultElement(false);
158:                    parent.addElement(child);
159:                }
160:
161:                // check if this folder is overwriting global options
162:                if (child.getAttribute("overwrite").equals("true")) {
163:                    // use folder-based options
164:                    return child;
165:                } else {
166:                    // use global options
167:                    parent = FolderItem.getGlobalOptions();
168:                    child = parent.getElement(getName());
169:
170:                    if (child == null) {
171:                        child = createDefaultElement(true);
172:                        parent.addElement(child);
173:                    }
174:
175:                    return child;
176:                }
177:            }
178:
179:            /**
180:             * Create default node.
181:             * <p>
182:             * Overwrite this method to add plugin-specific information to the parent
183:             * node.
184:             * <p>
185:             * 
186:             * @param global
187:             *            true, if this is a global options. False, otherwise
188:             * 
189:             * @return xml node
190:             */
191:            public XmlElement createDefaultElement(boolean global) {
192:                XmlElement parent = new XmlElement(getName());
193:
194:                // only local options have overwrite attribute
195:                if (!global) {
196:                    parent.addAttribute("overwrite", "false");
197:                }
198:
199:                return parent;
200:            }
201:
202:            /**
203:             * Get name of configuration node
204:             * 
205:             * @return config name
206:             */
207:            public String getName() {
208:                return name;
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.