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


001:        package net.sourceforge.squirrel_sql.plugins.postgres;
002:
003:        /*
004:         * Copyright (C) 2007 Rob Manning
005:         * manningr@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:
022:        import net.sourceforge.squirrel_sql.client.IApplication;
023:        import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
024:        import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
025:        import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
026:        import net.sourceforge.squirrel_sql.client.plugin.PluginException;
027:        import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
028:        import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
029:        import net.sourceforge.squirrel_sql.client.session.ISession;
030:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableIndexExtractor;
031:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor;
032:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.TableWithChildNodesExpander;
033:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.DatabaseObjectInfoTab;
034:        import net.sourceforge.squirrel_sql.fw.dialects.DialectFactory;
035:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
036:        import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
037:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
038:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
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.postgres.exp.PostgresTableIndexExtractorImpl;
042:        import net.sourceforge.squirrel_sql.plugins.postgres.exp.PostgresTableTriggerExtractorImpl;
043:        import net.sourceforge.squirrel_sql.plugins.postgres.exp.SchemaExpander;
044:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.IndexDetailsTab;
045:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.IndexSourceTab;
046:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.LockTab;
047:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.ProcedureSourceTab;
048:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.SequenceDetailsTab;
049:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.TriggerDetailsTab;
050:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.TriggerSourceTab;
051:        import net.sourceforge.squirrel_sql.plugins.postgres.tab.ViewSourceTab;
052:
053:        /**
054:         * The main controller class for the Postgres plugin.
055:         * 
056:         * @author manningr
057:         */
058:        public class PostgresPlugin extends DefaultSessionPlugin {
059:
060:            private static final StringManager s_stringMgr = StringManagerFactory
061:                    .getStringManager(PostgresPlugin.class);
062:
063:            /** Logger for this class. */
064:            @SuppressWarnings("unused")
065:            private final static ILogger s_log = LoggerController
066:                    .createLogger(PostgresPlugin.class);
067:
068:            /** API for the Obejct Tree. */
069:            private IObjectTreeAPI _treeAPI;
070:
071:            static interface i18n {
072:                //i18n[PostgresPlugin.showIndexSource=Show index source]
073:                String SHOW_INDEX_SOURCE = s_stringMgr
074:                        .getString("PostgresPlugin.showIndexSource");
075:
076:                //i18n[PostgresPlugin.showViewSource=Show view source]
077:                String SHOW_VIEW_SOURCE = s_stringMgr
078:                        .getString("PostgresPlugin.showViewSource");
079:
080:                //i18n[PostgresPlugin.showProcedureSource=Show procedure source]
081:                String SHOW_PROCEDURE_SOURCE = s_stringMgr
082:                        .getString("PostgresPlugin.showProcedureSource");
083:            }
084:
085:            /**
086:             * Return the internal name of this plugin.
087:             *
088:             * @return  the internal name of this plugin.
089:             */
090:            public String getInternalName() {
091:                return "postgres";
092:            }
093:
094:            /**
095:             * Return the descriptive name of this plugin.
096:             *
097:             * @return  the descriptive name of this plugin.
098:             */
099:            public String getDescriptiveName() {
100:                return "Postgres Plugin";
101:            }
102:
103:            /**
104:             * Returns the current version of this plugin.
105:             *
106:             * @return  the current version of this plugin.
107:             */
108:            public String getVersion() {
109:                return "0.11";
110:            }
111:
112:            /**
113:             * Returns the authors name.
114:             *
115:             * @return  the authors name.
116:             */
117:            public String getAuthor() {
118:                return "Rob Manning";
119:            }
120:
121:            /**
122:             * Returns a comma separated list of other contributors.
123:             *
124:             * @return  Contributors names.
125:             */
126:            public String getContributors() {
127:                return "";
128:            }
129:
130:            /**
131:             * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getChangeLogFileName()
132:             */
133:            public String getChangeLogFileName() {
134:                return "changes.txt";
135:            }
136:
137:            /**
138:             * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getHelpFileName()
139:             */
140:            public String getHelpFileName() {
141:                return "readme.html";
142:            }
143:
144:            /**
145:             * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getLicenceFileName()
146:             */
147:            public String getLicenceFileName() {
148:                return "licence.txt";
149:            }
150:
151:            /**
152:             * Load this plugin.
153:             *
154:             * @param	app	 Application API.
155:             */
156:            public synchronized void load(IApplication app)
157:                    throws PluginException {
158:                super .load(app);
159:            }
160:
161:            /**
162:             * Initialize this plugin.
163:             */
164:            public synchronized void initialize() throws PluginException {
165:                super .initialize();
166:            }
167:
168:            /**
169:             * Application is shutting down so save preferences.
170:             */
171:            public void unload() {
172:                super .unload();
173:            }
174:
175:            public boolean allowsSessionStartedInBackground() {
176:                return true;
177:            }
178:
179:            /**
180:             * Session has been started. Update the tree api in using the event thread
181:             *
182:             * @param   session     Session that has started.
183:             *
184:             * @return  <TT>true</TT> if session is Oracle in which case this plugin
185:             *                          is interested in it.
186:             */
187:            public PluginSessionCallback sessionStarted(final ISession session) {
188:                if (!isPluginSession(session)) {
189:                    return null;
190:                }
191:                GUIUtils.processOnSwingEventThread(new Runnable() {
192:                    public void run() {
193:                        updateTreeApi(session);
194:                    }
195:                });
196:
197:                return new PluginSessionCallback() {
198:                    public void sqlInternalFrameOpened(
199:                            SQLInternalFrame sqlInternalFrame, ISession sess) {
200:                        // Supports Session main window only
201:                    }
202:
203:                    public void objectTreeInternalFrameOpened(
204:                            ObjectTreeInternalFrame objectTreeInternalFrame,
205:                            ISession sess) {
206:                        // Supports Session main window only
207:                    }
208:                };
209:            }
210:
211:            @Override
212:            protected boolean isPluginSession(ISession session) {
213:                return DialectFactory.isPostgreSQL(session.getMetaData());
214:            }
215:
216:            private void updateTreeApi(ISession session) {
217:
218:                _treeAPI = session.getSessionInternalFrame().getObjectTreeAPI();
219:                _treeAPI.addExpander(DatabaseObjectType.SCHEMA,
220:                        new SchemaExpander());
221:                String stmtSep = session.getQueryTokenizer()
222:                        .getSQLStatementSeparator();
223:
224:                // Expanders - trigger and index expanders are added inside the table
225:                // expander        
226:                TableWithChildNodesExpander tableExpander = new TableWithChildNodesExpander();
227:
228:                //tableExpander.setTableIndexExtractor(extractor);
229:                ITableIndexExtractor indexExtractor = new PostgresTableIndexExtractorImpl();
230:                ITableTriggerExtractor triggerExtractor = new PostgresTableTriggerExtractorImpl();
231:
232:                tableExpander.setTableTriggerExtractor(triggerExtractor);
233:                tableExpander.setTableIndexExtractor(indexExtractor);
234:
235:                _treeAPI.addExpander(DatabaseObjectType.TABLE, tableExpander);
236:
237:                // Procedure tab
238:                _treeAPI.addDetailTab(DatabaseObjectType.PROCEDURE,
239:                        new ProcedureSourceTab(i18n.SHOW_PROCEDURE_SOURCE));
240:
241:                // View Tab
242:                _treeAPI.addDetailTab(DatabaseObjectType.VIEW,
243:                        new ViewSourceTab(i18n.SHOW_VIEW_SOURCE, stmtSep));
244:
245:                // Index tab
246:                _treeAPI.addDetailTab(DatabaseObjectType.INDEX,
247:                        new DatabaseObjectInfoTab());
248:                _treeAPI.addDetailTab(DatabaseObjectType.INDEX,
249:                        new IndexDetailsTab());
250:                _treeAPI.addDetailTab(DatabaseObjectType.INDEX,
251:                        new IndexSourceTab(i18n.SHOW_INDEX_SOURCE, stmtSep));
252:
253:                // Trigger tabs
254:                _treeAPI.addDetailTab(IObjectTypes.TRIGGER_PARENT,
255:                        new DatabaseObjectInfoTab());
256:                _treeAPI.addDetailTab(DatabaseObjectType.TRIGGER,
257:                        new DatabaseObjectInfoTab());
258:                _treeAPI.addDetailTab(DatabaseObjectType.TRIGGER,
259:                        new TriggerDetailsTab());
260:                _treeAPI.addDetailTab(DatabaseObjectType.TRIGGER,
261:                        new TriggerSourceTab("The source of the trigger"));
262:
263:                // Sequence tabs
264:                _treeAPI.addDetailTab(DatabaseObjectType.SEQUENCE,
265:                        new DatabaseObjectInfoTab());
266:                _treeAPI.addDetailTab(DatabaseObjectType.SEQUENCE,
267:                        new SequenceDetailsTab());
268:
269:                _treeAPI
270:                        .addDetailTab(DatabaseObjectType.SESSION, new LockTab());
271:
272:            }
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.