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


001:        package net.sourceforge.squirrel_sql.plugins.editextras;
002:
003:        /*
004:         * Copyright (C) 2003 Gerd Wagner
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         */
020:        import javax.swing.Action;
021:        import javax.swing.JMenu;
022:        import javax.swing.JMenuItem;
023:
024:        import net.sourceforge.squirrel_sql.client.IApplication;
025:        import net.sourceforge.squirrel_sql.client.action.ActionCollection;
026:        import net.sourceforge.squirrel_sql.client.gui.session.BaseSessionInternalFrame;
027:        import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
028:        import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
029:        import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
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.session.ISQLPanelAPI;
035:        import net.sourceforge.squirrel_sql.client.session.ISession;
036:        import net.sourceforge.squirrel_sql.client.session.event.ISQLPanelListener;
037:        import net.sourceforge.squirrel_sql.client.session.event.SQLPanelAdapter;
038:        import net.sourceforge.squirrel_sql.client.session.event.SQLPanelEvent;
039:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
040:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
041:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
042:
043:        /**
044:         * The plugin class.
045:         *
046:         * @author  Gerd Wagner
047:         */
048:        public class EditExtrasPlugin extends DefaultSessionPlugin {
049:            /** Logger for this class. */
050:            private final static ILogger s_log = LoggerController
051:                    .createLogger(EditExtrasPlugin.class);
052:
053:            private interface IMenuResourceKeys {
054:                String MENU = "editextras";
055:            }
056:
057:            /** Name of file to store user prefs in. */
058:            static final String USER_PREFS_FILE_NAME = "prefs.xml";
059:
060:            /** Resources for this plugin. */
061:            private Resources _resources;
062:
063:            /** Listener to the SQL panel. */
064:            private ISQLPanelListener _lis = new SQLPanelListener();
065:
066:            /**
067:             * Return the internal name of this plugin.
068:             *
069:             * @return  the internal name of this plugin.
070:             */
071:            public String getInternalName() {
072:                return "editextras";
073:            }
074:
075:            /**
076:             * Return the descriptive name of this plugin.
077:             *
078:             * @return  the descriptive name of this plugin.
079:             */
080:            public String getDescriptiveName() {
081:                return "SQL Entry Area Enhancements";
082:            }
083:
084:            /**
085:             * Returns the current version of this plugin.
086:             *
087:             * @return  the current version of this plugin.
088:             */
089:            public String getVersion() {
090:                return "1.0.1";
091:            }
092:
093:            /**
094:             * Returns the authors name.
095:             *
096:             * @return  the authors name.
097:             */
098:            public String getAuthor() {
099:                return "Gerd Wagner";
100:            }
101:
102:            /**
103:             * Returns the name of the change log for the plugin. This should
104:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
105:             * directory.
106:             *
107:             * @return	the changelog file name or <TT>null</TT> if plugin doesn't have
108:             * 			a change log.
109:             */
110:            public String getChangeLogFileName() {
111:                return "changes.txt";
112:            }
113:
114:            /**
115:             * Returns the name of the Help file for the plugin. This should
116:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
117:             * directory.
118:             *
119:             * @return	the Help file name or <TT>null</TT> if plugin doesn't have
120:             * 			a help file.
121:             */
122:            public String getHelpFileName() {
123:                return "readme.html";
124:            }
125:
126:            /**
127:             * Returns the name of the Licence file for the plugin. This should
128:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
129:             * directory.
130:             *
131:             * @return	the Licence file name or <TT>null</TT> if plugin doesn't have
132:             * 			a licence file.
133:             */
134:            public String getLicenceFileName() {
135:                return "licence.txt";
136:            }
137:
138:            /**
139:             * Called on application startup after application started.
140:             */
141:            public void initialize() throws PluginException {
142:                super .initialize();
143:
144:                final IApplication app = getApplication();
145:
146:                // Load resources.
147:                _resources = new Resources(this );
148:
149:                createMenu();
150:            }
151:
152:            public boolean allowsSessionStartedInBackground() {
153:                return true;
154:            }
155:
156:            /**
157:             * Session has been started.
158:             * 
159:             * @param	session		Session that has started.
160:             */
161:            public PluginSessionCallback sessionStarted(ISession session) {
162:                ISQLPanelAPI sqlPanelAPI = FrameWorkAcessor.getSQLPanelAPI(
163:                        session, this );
164:                initEditExtras(sqlPanelAPI);
165:
166:                PluginSessionCallback ret = new PluginSessionCallback() {
167:                    public void sqlInternalFrameOpened(
168:                            final SQLInternalFrame sqlInternalFrame,
169:                            final ISession sess) {
170:                        initEditExtras(sqlInternalFrame.getSQLPanelAPI());
171:                    }
172:
173:                    public void objectTreeInternalFrameOpened(
174:                            ObjectTreeInternalFrame objectTreeInternalFrame,
175:                            ISession sess) {
176:                    }
177:                };
178:
179:                return ret;
180:            }
181:
182:            private void initEditExtras(final ISQLPanelAPI sqlPanelAPI) {
183:                GUIUtils.processOnSwingEventThread(new Runnable() {
184:                    public void run() {
185:                        sqlPanelAPI.addSQLPanelListener(_lis);
186:                        createSQLEntryAreaPopMenuItems(sqlPanelAPI);
187:
188:                        ActionCollection actions = getApplication()
189:                                .getActionCollection();
190:                        sqlPanelAPI.addToToolsPopUp("quote", actions
191:                                .get(InQuotesAction.class));
192:                        sqlPanelAPI.addToToolsPopUp("unquote", actions
193:                                .get(RemoveQuotesAction.class));
194:                        sqlPanelAPI.addToToolsPopUp("quotesb", actions
195:                                .get(ConvertToStringBufferAction.class));
196:                        sqlPanelAPI.addToToolsPopUp("format", actions
197:                                .get(FormatSQLAction.class));
198:                        sqlPanelAPI.addToToolsPopUp("date", actions
199:                                .get(EscapeDateAction.class));
200:                        sqlPanelAPI.addToToolsPopUp("sqlcut", actions
201:                                .get(CutSqlAction.class));
202:                        sqlPanelAPI.addToToolsPopUp("sqlcopy", actions
203:                                .get(CopySqlAction.class));
204:                    }
205:                });
206:            }
207:
208:            /**
209:             * Called when a session shutdown.
210:             *
211:             * @param	session	The session that is ending.
212:             */
213:            public void sessionEnding(ISession session) {
214:                BaseSessionInternalFrame[] frames = session.getApplication()
215:                        .getWindowManager().getAllFramesOfSession(
216:                                session.getIdentifier());
217:
218:                for (int i = 0; i < frames.length; i++) {
219:                    if (frames[i] instanceof  SQLInternalFrame) {
220:                        ((SQLInternalFrame) frames[i]).getSQLPanelAPI()
221:                                .removeSQLPanelListener(_lis);
222:                    }
223:
224:                    if (frames[i] instanceof  SessionInternalFrame) {
225:                        ((SessionInternalFrame) frames[i]).getSQLPanelAPI()
226:                                .removeSQLPanelListener(_lis);
227:                    }
228:                }
229:
230:                super .sessionEnding(session);
231:            }
232:
233:            /**
234:             * Retrieve plugins resources.
235:             * 
236:             * @return	Plugins resources.
237:             */
238:            public PluginResources getResources() {
239:                return _resources;
240:            }
241:
242:            private void createMenu() {
243:                IApplication app = getApplication();
244:                ActionCollection coll = app.getActionCollection();
245:
246:                JMenu menu = _resources.createMenu(IMenuResourceKeys.MENU);
247:                app.addToMenu(IApplication.IMenuIDs.SESSION_MENU, menu);
248:
249:                Action act = new InQuotesAction(app, this );
250:                coll.add(act);
251:                _resources.addToMenu(act, menu);
252:
253:                act = new RemoveQuotesAction(app, this );
254:                coll.add(act);
255:                _resources.addToMenu(act, menu);
256:
257:                act = new RemoveNewLinesAction(app, this );
258:                coll.add(act);
259:                _resources.addToMenu(act, menu);
260:
261:                act = new ConvertToStringBufferAction(app, this );
262:                coll.add(act);
263:                _resources.addToMenu(act, menu);
264:
265:                act = new FormatSQLAction(app, this );
266:                coll.add(act);
267:                _resources.addToMenu(act, menu);
268:
269:                act = new EscapeDateAction(getApplication(), _resources);
270:                coll.add(act);
271:                _resources.addToMenu(act, menu);
272:
273:                act = new CutSqlAction(getApplication(), _resources);
274:                coll.add(act);
275:                _resources.addToMenu(act, menu);
276:
277:                act = new CopySqlAction(getApplication(), _resources);
278:                coll.add(act);
279:                _resources.addToMenu(act, menu);
280:
281:            }
282:
283:            private void createSQLEntryAreaPopMenuItems(ISQLPanelAPI api) {
284:                JMenuItem mnu;
285:
286:                ActionCollection actions = getApplication()
287:                        .getActionCollection();
288:                api.addToSQLEntryAreaMenu(actions.get(InQuotesAction.class));
289:                api
290:                        .addToSQLEntryAreaMenu(actions
291:                                .get(RemoveQuotesAction.class));
292:                api.addToSQLEntryAreaMenu(actions
293:                        .get(ConvertToStringBufferAction.class));
294:
295:                // To make the shortcut visible in the popup
296:                mnu = api.addToSQLEntryAreaMenu(actions
297:                        .get(FormatSQLAction.class));
298:                _resources.configureMenuItem(
299:                        actions.get(FormatSQLAction.class), mnu);
300:
301:                mnu = api.addToSQLEntryAreaMenu(actions
302:                        .get(RemoveNewLinesAction.class));
303:                _resources.configureMenuItem(actions
304:                        .get(RemoveNewLinesAction.class), mnu);
305:
306:                api.addToSQLEntryAreaMenu(actions.get(EscapeDateAction.class));
307:
308:                mnu = api
309:                        .addToSQLEntryAreaMenu(actions.get(CutSqlAction.class));
310:                _resources.configureMenuItem(actions.get(CutSqlAction.class),
311:                        mnu);
312:
313:                mnu = api.addToSQLEntryAreaMenu(actions
314:                        .get(CopySqlAction.class));
315:                _resources.configureMenuItem(actions.get(CopySqlAction.class),
316:                        mnu);
317:
318:            }
319:
320:            private class SQLPanelListener extends SQLPanelAdapter {
321:                public void sqlEntryAreaReplaced(SQLPanelEvent evt) {
322:                    createSQLEntryAreaPopMenuItems(evt.getSQLPanel());
323:                }
324:            }
325:
326:            public Object getExternalService() {
327:                return new EditExtrasExternalServiceImpl();
328:            }
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.