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


001:        package net.sourceforge.squirrel_sql.plugins.sqlparam;
002:
003:        /*
004:         * Copyright (C) 2007 Thorsten Mürell
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 java.util.HashMap;
021:        import java.util.Hashtable;
022:        import java.util.Map;
023:
024:        import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
025:        import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
026:        import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
027:        import net.sourceforge.squirrel_sql.client.plugin.PluginException;
028:        import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
029:        import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
030:        import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
031:        import net.sourceforge.squirrel_sql.client.session.ISession;
032:        import net.sourceforge.squirrel_sql.client.session.event.ISQLExecutionListener;
033:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
034:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
035:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
036:
037:        /**
038:         * The plugin class.
039:         *
040:         * @author Thorsten Mürell
041:         */
042:        public class SQLParamPlugin extends DefaultSessionPlugin {
043:            private final static ILogger log = LoggerController
044:                    .createLogger(SQLParamPlugin.class);
045:
046:            private Resources resources;
047:            //	private static final String PREFS_FILE_NAME = "sqlparamprefs.xml";
048:            Map<String, String> cache;
049:
050:            /** 
051:             * Remember which sqlpanelapis we've registered listeners with so that we 
052:             * can unregister them when it's time to unload.
053:             */
054:            HashMap<ISQLPanelAPI, ISQLExecutionListener> panelListenerMap = new HashMap<ISQLPanelAPI, ISQLExecutionListener>();
055:
056:            /**
057:             * Return the internal name of this plugin.
058:             *
059:             * @return  the internal name of this plugin.
060:             */
061:            public String getInternalName() {
062:                return "sqlparam";
063:            }
064:
065:            /**
066:             * Return the descriptive name of this plugin.
067:             *
068:             * @return  the descriptive name of this plugin.
069:             */
070:            public String getDescriptiveName() {
071:                return "SQL Parametrisation";
072:            }
073:
074:            /**
075:             * Returns the current version of this plugin.
076:             *
077:             * @return  the current version of this plugin.
078:             */
079:            public String getVersion() {
080:                return "1.0";
081:            }
082:
083:            /**
084:             * Returns a comma separated list of other contributors.
085:             *
086:             * @return      Contributors names.
087:             */
088:            @Override
089:            public String getContributors() {
090:                return "";
091:            }
092:
093:            /**
094:             * Returns the authors name.
095:             *
096:             * @return  the authors name.
097:             */
098:            public String getAuthor() {
099:                return "Thorsten Mürell";
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:            @Override
111:            public String getChangeLogFileName() {
112:                return null;
113:            }
114:
115:            /**
116:             * Returns the name of the Help file for the plugin. This should
117:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
118:             * directory.
119:             *
120:             * @return	the Help file name or <TT>null</TT> if plugin doesn't have
121:             * 			a help file.
122:             */
123:            @Override
124:            public String getHelpFileName() {
125:                return "readme.html";
126:            }
127:
128:            /**
129:             * Returns the name of the Licence file for the plugin. This should
130:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
131:             * directory.
132:             *
133:             * @return	the Licence file name or <TT>null</TT> if plugin doesn't have
134:             * 			a licence file.
135:             */
136:            @Override
137:            public String getLicenceFileName() {
138:                return "licence.txt";
139:            }
140:
141:            /**
142:             * Called on application startup after application started.
143:             */
144:            @Override
145:            public void initialize() throws PluginException {
146:                resources = new Resources(this );
147:            }
148:
149:            /**
150:             * Called on plugin unloading.
151:             */
152:            @Override
153:            public void unload() {
154:                for (ISQLPanelAPI api : panelListenerMap.keySet()) {
155:                    api.removeSQLExecutionListener(panelListenerMap.get(api));
156:                }
157:            }
158:
159:            /**
160:             * 
161:             */
162:            @Override
163:            public boolean allowsSessionStartedInBackground() {
164:                return true;
165:            }
166:
167:            /**
168:             * Called on session creating by callback.
169:             * 
170:             * @param session The session
171:             */
172:            @Override
173:            public void sessionCreated(ISession session) {
174:                cache = new Hashtable<String, String>();
175:            }
176:
177:            /**
178:             * Returns the value cache.
179:             * 
180:             * @return A map caching parameters to old values
181:             */
182:            public Map<String, String> getCache() {
183:                return cache;
184:            }
185:
186:            /**
187:             * Session has been started.
188:             * 
189:             * @param	session		Session that has started.
190:             * @return The callback to start on session events.
191:             */
192:            public PluginSessionCallback sessionStarted(final ISession session) {
193:                log.info("Initializing plugin");
194:                ISQLPanelAPI sqlPaneAPI = session.getSessionSheet()
195:                        .getSQLPaneAPI();
196:
197:                initSQLParam(sqlPaneAPI, session);
198:
199:                PluginSessionCallback ret = new PluginSessionCallback() {
200:                    public void sqlInternalFrameOpened(
201:                            final SQLInternalFrame sqlInternalFrame,
202:                            final ISession sess) {
203:                        initSQLParam(sqlInternalFrame.getSQLPanelAPI(), sess);
204:                    }
205:
206:                    public void objectTreeInternalFrameOpened(
207:                            ObjectTreeInternalFrame objectTreeInternalFrame,
208:                            ISession sess) {
209:                        // Nothing to do if object tree is opened.
210:                    }
211:
212:                };
213:
214:                return ret;
215:            }
216:
217:            /**
218:             * This method is called on session closing an needs to free resources.
219:             * 
220:             * @param session the session to be closed
221:             */
222:            @Override
223:            public void sessionEnding(ISession session) {
224:                ISQLPanelAPI sqlPaneAPI = session.getSessionSheet()
225:                        .getSQLPaneAPI();
226:                ISQLExecutionListener listener = panelListenerMap
227:                        .remove(sqlPaneAPI);
228:                sqlPaneAPI.removeSQLExecutionListener(listener);
229:            }
230:
231:            private void initSQLParam(final ISQLPanelAPI sqlPaneAPI,
232:                    final ISession session) {
233:                final SQLParamPlugin plugin = this ;
234:
235:                GUIUtils.processOnSwingEventThread(new Runnable() {
236:                    public void run() {
237:                        log.info("Adding SQL execution listener.");
238:                        ISQLExecutionListener listener = new SQLParamExecutionListener(
239:                                plugin, session);
240:                        sqlPaneAPI.addSQLExecutionListener(listener);
241:                        panelListenerMap.put(sqlPaneAPI, listener);
242:                    }
243:
244:                });
245:            }
246:
247:            /**
248:             * Retrieve plugins resources.
249:             * 
250:             * @return	Plugins resources.
251:             */
252:            public PluginResources getResources() {
253:                return resources;
254:            }
255:
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.