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


001:        package net.sourceforge.squirrel_sql.plugins.sqlscript;
002:
003:        /*
004:         * Copyright (C) 2001 Johan Compagner
005:         * jcompagner@j-com.nl
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or any later version.
011:         *
012:         * This program 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
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; 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.IOException;
023:
024:        import javax.swing.JMenu;
025:
026:        import net.sourceforge.squirrel_sql.client.IApplication;
027:        import net.sourceforge.squirrel_sql.client.action.ActionCollection;
028:        import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
029:        import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
030:        import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
031:        import net.sourceforge.squirrel_sql.client.plugin.PluginException;
032:        import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
033:        import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
034:        import net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel;
035:        import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
036:        import net.sourceforge.squirrel_sql.client.session.ISession;
037:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
038:        import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
039:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
040:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
041:        import net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferencesManager;
042:        import net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferencesTab;
043:        import net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.CreateDataScriptAction;
044:        import net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.CreateDataScriptOfCurrentSQLAction;
045:        import net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.CreateSelectScriptAction;
046:        import net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.CreateTableOfCurrentSQLAction;
047:        import net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.CreateTableScriptAction;
048:        import net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.CreateTemplateDataScriptAction;
049:        import net.sourceforge.squirrel_sql.plugins.sqlscript.table_script.DropTableScriptAction;
050:
051:        /**
052:         * The SQL Script plugin class.
053:         */
054:        public class SQLScriptPlugin extends DefaultSessionPlugin {
055:            private interface IMenuResourceKeys {
056:                String SCRIPTS = "scripts";
057:            }
058:
059:            /** Logger for this class. */
060:            private static ILogger s_log = LoggerController
061:                    .createLogger(SQLScriptPlugin.class);
062:
063:            /** The app folder for this plugin. */
064:            private File _pluginAppFolder;
065:
066:            /** Folder to store user settings in. */
067:            private File _userSettingsFolder;
068:
069:            private PluginResources _resources;
070:
071:            /**
072:             * Return the internal name of this plugin.
073:             *
074:             * @return  the internal name of this plugin.
075:             */
076:            public String getInternalName() {
077:                return "sqlscript";
078:            }
079:
080:            /**
081:             * Return the descriptive name of this plugin.
082:             *
083:             * @return  the descriptive name of this plugin.
084:             */
085:            public String getDescriptiveName() {
086:                return "SQL Scripts Plugin";
087:            }
088:
089:            /**
090:             * Returns the current version of this plugin.
091:             *
092:             * @return  the current version of this plugin.
093:             */
094:            public String getVersion() {
095:                return "1.2";
096:            }
097:
098:            /**
099:             * Returns the authors name.
100:             *
101:             * @return  the authors name.
102:             */
103:            public String getAuthor() {
104:                return "Johan Compagner";
105:            }
106:
107:            /**
108:             * Returns the name of the change log for the plugin. This should
109:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
110:             * directory.
111:             *
112:             * @return	the changelog file name or <TT>null</TT> if plugin doesn't have
113:             * 			a change log.
114:             */
115:            public String getChangeLogFileName() {
116:                return "changes.txt";
117:            }
118:
119:            /**
120:             * Returns the name of the Help file for the plugin. This should
121:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
122:             * directory.
123:             *
124:             * @return	the Help file name or <TT>null</TT> if plugin doesn't have
125:             * 			a help file.
126:             */
127:            public String getHelpFileName() {
128:                return "readme.html";
129:            }
130:
131:            /**
132:             * Returns the name of the Licence file for the plugin. This should
133:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
134:             * directory.
135:             *
136:             * @return	the Licence file name or <TT>null</TT> if plugin doesn't have
137:             * 			a licence file.
138:             */
139:            public String getLicenceFileName() {
140:                return "licence.txt";
141:            }
142:
143:            /**
144:             * @return	Comma separated list of contributors.
145:             */
146:            public String getContributors() {
147:                return "Gerd Wagner, John Murga, Rob Manning";
148:            }
149:
150:            /**
151:             * Create preferences panel for the Global Preferences dialog.
152:             *
153:             * @return  Preferences panel.
154:             */
155:            public IGlobalPreferencesPanel[] getGlobalPreferencePanels() {
156:                SQLScriptPreferencesTab tab = new SQLScriptPreferencesTab();
157:                return new IGlobalPreferencesPanel[] { tab };
158:            }
159:
160:            /**
161:             * Initialize this plugin.
162:             */
163:            public synchronized void initialize() throws PluginException {
164:                super .initialize();
165:                IApplication app = getApplication();
166:
167:                //PluginManager pmgr = app.getPluginManager();
168:
169:                // Folder within plugins folder that belongs to this
170:                // plugin.
171:                try {
172:                    _pluginAppFolder = getPluginAppSettingsFolder();
173:                } catch (IOException ex) {
174:                    throw new PluginException(ex);
175:                }
176:
177:                // Folder to store user settings.
178:                try {
179:                    _userSettingsFolder = getPluginUserSettingsFolder();
180:                } catch (IOException ex) {
181:                    throw new PluginException(ex);
182:                }
183:
184:                _resources = new SQLPluginResources(
185:                        "net.sourceforge.squirrel_sql.plugins.sqlscript.sqlscript",
186:                        this );
187:
188:                ActionCollection coll = app.getActionCollection();
189:                coll.add(new CreateTableScriptAction(app, _resources, this ));
190:                coll.add(new CreateSelectScriptAction(app, _resources, this ));
191:                coll.add(new DropTableScriptAction(app, _resources, this ));
192:                coll.add(new CreateDataScriptAction(app, _resources, this ));
193:                coll.add(new CreateTemplateDataScriptAction(app, _resources,
194:                        this ));
195:                coll.add(new CreateDataScriptOfCurrentSQLAction(app,
196:                        _resources, this ));
197:                coll.add(new CreateTableOfCurrentSQLAction(app, _resources,
198:                        this ));
199:                createMenu();
200:
201:                SQLScriptPreferencesManager.initialize(this );
202:            }
203:
204:            /**
205:             * Application is shutting down so save data.
206:             */
207:            public void unload() {
208:                super .unload();
209:                SQLScriptPreferencesManager.unload();
210:            }
211:
212:            public boolean allowsSessionStartedInBackground() {
213:                return true;
214:            }
215:
216:            /**
217:             * Called when a session started. Add commands to popup menu
218:             * in object tree.
219:             *
220:             * @param   session	 The session that is starting.
221:             *
222:             * @return  <TT>true</TT> to indicate that this plugin is
223:             *		  applicable to passed session.
224:             */
225:            public PluginSessionCallback sessionStarted(final ISession session) {
226:                GUIUtils.processOnSwingEventThread(new Runnable() {
227:                    public void run() {
228:                        addActionsToPopup(session);
229:                    }
230:                });
231:
232:                PluginSessionCallback ret = new PluginSessionCallback() {
233:                    public void sqlInternalFrameOpened(
234:                            SQLInternalFrame sqlInternalFrame, ISession sess) {
235:                        ActionCollection coll = sess.getApplication()
236:                                .getActionCollection();
237:                        sqlInternalFrame.addSeparatorToToolbar();
238:                        sqlInternalFrame.addToToolbar(coll
239:                                .get(CreateTableOfCurrentSQLAction.class));
240:
241:                        sqlInternalFrame.addToToolsPopUp("sql2table", coll
242:                                .get(CreateTableOfCurrentSQLAction.class));
243:                        sqlInternalFrame.addToToolsPopUp("sql2ins", coll
244:                                .get(CreateDataScriptOfCurrentSQLAction.class));
245:                    }
246:
247:                    public void objectTreeInternalFrameOpened(
248:                            ObjectTreeInternalFrame objectTreeInternalFrame,
249:                            ISession sess) {
250:                        ActionCollection coll = sess.getApplication()
251:                                .getActionCollection();
252:                        objectTreeInternalFrame.getObjectTreeAPI().addToPopup(
253:                                DatabaseObjectType.TABLE,
254:                                coll.get(CreateTableScriptAction.class));
255:                        objectTreeInternalFrame.getObjectTreeAPI().addToPopup(
256:                                DatabaseObjectType.TABLE,
257:                                coll.get(CreateSelectScriptAction.class));
258:                        objectTreeInternalFrame.getObjectTreeAPI().addToPopup(
259:                                DatabaseObjectType.TABLE,
260:                                coll.get(DropTableScriptAction.class));
261:                        objectTreeInternalFrame.getObjectTreeAPI().addToPopup(
262:                                DatabaseObjectType.TABLE,
263:                                coll.get(CreateDataScriptAction.class));
264:                        objectTreeInternalFrame.getObjectTreeAPI().addToPopup(
265:                                DatabaseObjectType.TABLE,
266:                                coll.get(CreateTemplateDataScriptAction.class));
267:                    }
268:                };
269:
270:                return ret;
271:            }
272:
273:            private void addActionsToPopup(ISession session) {
274:                ActionCollection coll = getApplication().getActionCollection();
275:
276:                //IObjectTreeAPI api = session.getObjectTreeAPI(this);
277:                IObjectTreeAPI api = FrameWorkAcessor.getObjectTreeAPI(session,
278:                        this );
279:
280:                JMenu menu = _resources.createMenu(IMenuResourceKeys.SCRIPTS);
281:
282:                api.addToPopup(DatabaseObjectType.TABLE, getTableMenu(true));
283:                api.addToPopup(DatabaseObjectType.VIEW, getTableMenu(false));
284:
285:                session.addSeparatorToToolbar();
286:                session.addToToolbar(coll
287:                        .get(CreateTableOfCurrentSQLAction.class));
288:
289:                session.getSessionInternalFrame().addToToolsPopUp("sql2table",
290:                        coll.get(CreateTableOfCurrentSQLAction.class));
291:                session.getSessionInternalFrame().addToToolsPopUp("sql2ins",
292:                        coll.get(CreateDataScriptOfCurrentSQLAction.class));
293:            }
294:
295:            private void createMenu() {
296:                IApplication app = getApplication();
297:                app.addToMenu(IApplication.IMenuIDs.SESSION_MENU,
298:                        getSessionMenu());
299:            }
300:
301:            private JMenu getSessionMenu() {
302:                IApplication app = getApplication();
303:                ActionCollection coll = app.getActionCollection();
304:
305:                JMenu menu = _resources.createMenu(IMenuResourceKeys.SCRIPTS);
306:                _resources.addToMenu(coll.get(CreateDataScriptAction.class),
307:                        menu);
308:                _resources.addToMenu(coll
309:                        .get(CreateTemplateDataScriptAction.class), menu);
310:                _resources.addToMenu(coll.get(CreateTableScriptAction.class),
311:                        menu);
312:                _resources.addToMenu(coll.get(CreateSelectScriptAction.class),
313:                        menu);
314:                _resources.addToMenu(coll.get(DropTableScriptAction.class),
315:                        menu);
316:                _resources.addToMenu(coll
317:                        .get(CreateDataScriptOfCurrentSQLAction.class), menu);
318:                _resources.addToMenu(coll
319:                        .get(CreateTableOfCurrentSQLAction.class), menu);
320:                return menu;
321:            }
322:
323:            private JMenu getTableMenu(boolean includeDrop) {
324:                IApplication app = getApplication();
325:                ActionCollection coll = app.getActionCollection();
326:
327:                JMenu menu = _resources.createMenu(IMenuResourceKeys.SCRIPTS);
328:                _resources.addToMenu(coll.get(CreateDataScriptAction.class),
329:                        menu);
330:                _resources.addToMenu(coll
331:                        .get(CreateTemplateDataScriptAction.class), menu);
332:                _resources.addToMenu(coll.get(CreateTableScriptAction.class),
333:                        menu);
334:                _resources.addToMenu(coll.get(CreateSelectScriptAction.class),
335:                        menu);
336:                if (includeDrop) {
337:                    _resources.addToMenu(coll.get(DropTableScriptAction.class),
338:                            menu);
339:                }
340:                return menu;
341:            }
342:
343:            public Object getExternalService() {
344:                return new SQLScriptExternalService(this);
345:            }
346:
347:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.