Source Code Cross Referenced for ExportConfigPlugin.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » exportconfig » 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 » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.exportconfig 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.exportconfig;
002:
003:        /*
004:         * Copyright (C) 2003 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.io.File;
022:        import java.io.FileNotFoundException;
023:        import java.io.IOException;
024:        import java.util.Iterator;
025:
026:        import javax.swing.JMenu;
027:
028:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
029:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
030:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
031:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
032:        import net.sourceforge.squirrel_sql.fw.xml.XMLBeanReader;
033:        import net.sourceforge.squirrel_sql.fw.xml.XMLBeanWriter;
034:
035:        import net.sourceforge.squirrel_sql.client.IApplication;
036:        import net.sourceforge.squirrel_sql.client.action.ActionCollection;
037:        import net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin;
038:        import net.sourceforge.squirrel_sql.client.plugin.PluginException;
039:        import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
040:
041:        import net.sourceforge.squirrel_sql.plugins.exportconfig.action.ExportAliasesAction;
042:        import net.sourceforge.squirrel_sql.plugins.exportconfig.action.ExportConfigurationAction;
043:        import net.sourceforge.squirrel_sql.plugins.exportconfig.action.ExportDriversAction;
044:        import net.sourceforge.squirrel_sql.plugins.exportconfig.action.ExportSettingsAction;
045:
046:        /**
047:         * Plugin controlling class.
048:         *
049:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
050:         */
051:        public class ExportConfigPlugin extends DefaultPlugin {
052:            private static final StringManager s_stringMgr = StringManagerFactory
053:                    .getStringManager(ExportConfigPlugin.class);
054:
055:            /** Logger for this class. */
056:            private final static ILogger s_log = LoggerController
057:                    .createLogger(ExportConfigPlugin.class);
058:
059:            /** Name of preferences file. */
060:            private static final String USER_PREFS_FILE_NAME = "prefs.xml";
061:
062:            /** Folder to store user settings in. */
063:            private File _userSettingsFolder;
064:
065:            /** Plugin resources. */
066:            private PluginResources _resources;
067:
068:            /** Export menu. */
069:            private JMenu _exportMenu;
070:
071:            /** Plugin preferences. */
072:            private ExportConfigPreferences _prefs;
073:
074:            /**
075:             * Return the internal name of this plugin.
076:             *
077:             * @return	the internal name of this plugin.
078:             */
079:            public String getInternalName() {
080:                return "exportconfig";
081:            }
082:
083:            /**
084:             * Return the descriptive name of this plugin.
085:             *
086:             * @return	the descriptive name of this plugin.
087:             */
088:            public String getDescriptiveName() {
089:                return "Export Configuration Plugin";
090:            }
091:
092:            /**
093:             * Returns the current version of this plugin.
094:             *
095:             * @return	the current version of this plugin.
096:             */
097:            public String getVersion() {
098:                return "0.10";
099:            }
100:
101:            /**
102:             * Returns the authors name.
103:             *
104:             * @return	the authors name.
105:             */
106:            public String getAuthor() {
107:                return "Colin Bell";
108:            }
109:
110:            /**
111:             * Returns a comma separated list of other contributors.
112:             *
113:             * @return      Contributors names.
114:             */
115:            public String getContributors() {
116:                return "Rob Manning";
117:            }
118:
119:            /**
120:             * Load this plugin.
121:             *
122:             * @param	app	 Application API.
123:             */
124:            public synchronized void load(IApplication app)
125:                    throws PluginException {
126:                super .load(app);
127:
128:                // Folder to store user settings.
129:                try {
130:                    _userSettingsFolder = getPluginUserSettingsFolder();
131:                } catch (IOException ex) {
132:                    throw new PluginException(ex);
133:                }
134:
135:                _resources = new ExportConfigResources(getClass().getName(),
136:                        this );
137:            }
138:
139:            /**
140:             * Retrieve the name of the change log.
141:             *
142:             * @return	The name of the change log.
143:             */
144:            public String getChangeLogFileName() {
145:                return "changes.txt";
146:            }
147:
148:            /**
149:             * Retrieve the name of the help file.
150:             *
151:             * @return	The nane of the help file.
152:             */
153:            public String getHelpFileName() {
154:                return "readme.html";
155:            }
156:
157:            /**
158:             * Retrieve the name of the licence file.
159:             *
160:             * @return	The nane of the licence file.
161:             */
162:            public String getLicenceFileName() {
163:                return "licence.txt";
164:            }
165:
166:            /**
167:             * Initialize this plugin.
168:             */
169:            public synchronized void initialize() throws PluginException {
170:                super .initialize();
171:
172:                final IApplication app = getApplication();
173:                final ActionCollection coll = app.getActionCollection();
174:
175:                coll.add(new ExportAliasesAction(app, _resources, this ));
176:                coll.add(new ExportConfigurationAction(app, _resources, this ));
177:                coll.add(new ExportDriversAction(app, _resources, this ));
178:                coll.add(new ExportSettingsAction(app, _resources, this ));
179:
180:                // Load plugin preferences.
181:                loadPrefs();
182:
183:                _exportMenu = createExportMenu();
184:                app.addToMenu(IApplication.IMenuIDs.PLUGINS_MENU, _exportMenu);
185:            }
186:
187:            /**
188:             * Application is shutting down so save preferences.
189:             */
190:            public void unload() {
191:                savePrefs();
192:                super .unload();
193:            }
194:
195:            /**
196:             * Retrieve the plugin preferences.
197:             *
198:             * @erturn	The plugin preferences.
199:             */
200:            public ExportConfigPreferences getPreferences() {
201:                return _prefs;
202:            }
203:
204:            /**
205:             * Load from preferences file.
206:             */
207:            private void loadPrefs() {
208:                try {
209:                    XMLBeanReader doc = new XMLBeanReader();
210:                    doc
211:                            .load(new File(_userSettingsFolder,
212:                                    USER_PREFS_FILE_NAME), getClass()
213:                                    .getClassLoader());
214:                    final Iterator<?> it = doc.iterator();
215:                    if (it.hasNext()) {
216:                        _prefs = (ExportConfigPreferences) it.next();
217:                    }
218:                } catch (FileNotFoundException ignore) {
219:                    // i18n[exportconfig.fileWillBeCreated={0} not found - will be created]
220:                    s_log.info(s_stringMgr.getString(
221:                            "exportconfig.fileWillBeCreated",
222:                            USER_PREFS_FILE_NAME));
223:                } catch (Exception ex) {
224:                    // i18n[exportconfig.errorCreatingFile=Error occured reading from preferences file: {0}]
225:                    s_log.error(s_stringMgr.getString(
226:                            "exportconfig.errorCreatingFile",
227:                            USER_PREFS_FILE_NAME), ex);
228:                }
229:                if (_prefs == null) {
230:                    _prefs = new ExportConfigPreferences();
231:                }
232:            }
233:
234:            /**
235:             * Save preferences to disk.
236:             */
237:            private void savePrefs() {
238:                try {
239:                    XMLBeanWriter wtr = new XMLBeanWriter(_prefs);
240:                    wtr
241:                            .save(new File(_userSettingsFolder,
242:                                    USER_PREFS_FILE_NAME));
243:                } catch (Exception ex) {
244:                    // i18n[exportconfig.errorWritingPrefs=Error occured writing to preferences file: {0}]
245:                    s_log.error(s_stringMgr.getString(
246:                            "exportconfig.errorWritingPrefs",
247:                            USER_PREFS_FILE_NAME), ex);
248:                }
249:            }
250:
251:            /**
252:             * Create menu containing actions relevant for the object tree.
253:             *
254:             * @return	The menu object.
255:             */
256:            private JMenu createExportMenu() {
257:                final IApplication app = getApplication();
258:                final ActionCollection coll = app.getActionCollection();
259:
260:                final JMenu exportMenu = _resources
261:                        .createMenu(ExportConfigResources.IMenuResourceKeys.EXPORT);
262:                _resources.addToMenu(coll.get(ExportConfigurationAction.class),
263:                        exportMenu);
264:                _resources.addToMenu(coll.get(ExportAliasesAction.class),
265:                        exportMenu);
266:                _resources.addToMenu(coll.get(ExportDriversAction.class),
267:                        exportMenu);
268:                _resources.addToMenu(coll.get(ExportSettingsAction.class),
269:                        exportMenu);
270:
271:                app.addToMenu(IApplication.IMenuIDs.SESSION_MENU, exportMenu);
272:
273:                return exportMenu;
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.