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


001:        package net.sourceforge.squirrel_sql.plugins.dbdiff;
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 javax.swing.JMenu;
023:        import javax.swing.JMenuItem;
024:        import javax.swing.SwingUtilities;
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.plugin.DefaultSessionPlugin;
029:        import net.sourceforge.squirrel_sql.client.plugin.IPlugin;
030:        import net.sourceforge.squirrel_sql.client.plugin.PluginException;
031:        import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
032:        import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
033:        import net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel;
034:        import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
035:        import net.sourceforge.squirrel_sql.client.session.ISession;
036:        import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
037:        import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
038:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
039:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
040:        import net.sourceforge.squirrel_sql.plugins.dbdiff.actions.CompareAction;
041:        import net.sourceforge.squirrel_sql.plugins.dbdiff.actions.SelectAction;
042:
043:        /**
044:         * The class that sets up the various resources required by SQuirreL to 
045:         * implement a plugin.  This plugin implements the ability to diff tables and 
046:         * various other table-related objects from one database to another.
047:         */
048:        public class DBDiffPlugin extends DefaultSessionPlugin implements 
049:                SessionInfoProvider {
050:
051:            /** Logger for this class. */
052:            private final static ILogger s_log = LoggerController
053:                    .createLogger(DBDiffPlugin.class);
054:
055:            private PluginResources _resources;
056:
057:            private ISession diffSourceSession = null;
058:
059:            private ISession diffDestSession = null;
060:
061:            private IDatabaseObjectInfo[] selectedDatabaseObjects = null;
062:
063:            private IDatabaseObjectInfo[] selectedDestDatabaseObjects = null;
064:
065:            /* (non-Javadoc)
066:             * @see net.sourceforge.squirrel_sql.client.plugin.ISessionPlugin#sessionStarted(net.sourceforge.squirrel_sql.client.session.ISession)
067:             */
068:            public PluginSessionCallback sessionStarted(final ISession session) {
069:                addMenuItemsToContextMenu(session);
070:                return new DBDiffPluginSessionCallback(this );
071:            }
072:
073:            public void sessionEnding(final ISession session) {
074:                /*
075:                if (session.equals(copySourceSession)) {
076:                    copySourceSession = null;
077:                    // Can't paste from a session that is no longer around.
078:                    setPasteMenuEnabled(false);
079:                }
080:                 */
081:                // Be sure to forget the dialect that was being "remembered" for 
082:                // this session.  A reference to the session might possibly be 
083:                // maintained in ColTypeMapper that would keep it from being 
084:                // garbage collected.
085:                //DialectFactory.removeSession(session);        
086:            }
087:
088:            /* (non-Javadoc)
089:             * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getInternalName()
090:             */
091:            public String getInternalName() {
092:                return "dbdiff";
093:            }
094:
095:            /* (non-Javadoc)
096:             * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getDescriptiveName()
097:             */
098:            public String getDescriptiveName() {
099:                return "DBDiff Plugin";
100:            }
101:
102:            /* (non-Javadoc)
103:             * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getAuthor()
104:             */
105:            public String getAuthor() {
106:                return "Rob Manning";
107:            }
108:
109:            /* (non-Javadoc)
110:             * @see net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin#getContributors()
111:             */
112:            public String getContributors() {
113:                return "";
114:            }
115:
116:            /* (non-Javadoc)
117:             * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getVersion()
118:             */
119:            public String getVersion() {
120:                return "0.01";
121:            }
122:
123:            /**
124:             * Returns the name of the Help file for the plugin. This should
125:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
126:             * directory.
127:             *
128:             * @return  the Help file name or <TT>null</TT> if plugin doesn't have
129:             * a help file.
130:             */
131:            public String getHelpFileName() {
132:                return "readme.html";
133:            }
134:
135:            /**
136:             * Returns the name of the change log for the plugin. This should
137:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
138:             * directory.
139:             *
140:             * @return  the changelog file name or <TT>null</TT> if plugin doesn't have
141:             *          a change log.
142:             */
143:            public String getChangeLogFileName() {
144:                return "changes.txt";
145:            }
146:
147:            public void initialize() throws PluginException {
148:                super .initialize();
149:
150:                if (s_log.isDebugEnabled()) {
151:                    s_log.debug("Initializing DB Diff Plugin");
152:                }
153:
154:                _resources = new DBDiffPluginResources(
155:                        "net.sourceforge.squirrel_sql.plugins.dbdiff.dbdiff",
156:                        this );
157:                //PreferencesManager.initialize(this);
158:
159:                IApplication app = getApplication();
160:                ActionCollection coll = app.getActionCollection();
161:                coll.add(new SelectAction(app, _resources, this ));
162:                coll.add(new CompareAction(app, _resources, this ));
163:
164:            }
165:
166:            public void unload() {
167:                super .unload();
168:                /*
169:                diffSourceSession = null;
170:                setPasteMenuEnabled(false);
171:                PreferencesManager.unload();
172:                 */
173:            }
174:
175:            /**
176:             * @param selectedDatabaseObjects The selectedDatabaseObjects to set.
177:             */
178:            public void setSelectedDatabaseObjects(
179:                    IDatabaseObjectInfo[] dbObjArr) {
180:                if (dbObjArr != null) {
181:                    selectedDatabaseObjects = dbObjArr;
182:                    for (int i = 0; i < dbObjArr.length; i++) {
183:                        if (s_log.isDebugEnabled()) {
184:                            s_log
185:                                    .debug("setSelectedDatabaseObjects: IDatabaseObjectInfo["
186:                                            + i + "]=" + dbObjArr[i]);
187:                        }
188:                    }
189:                }
190:            }
191:
192:            /**
193:             * Create panel for the Global Properties dialog.
194:             * 
195:             * @return  properties panel.
196:             */
197:            public IGlobalPreferencesPanel[] getGlobalPreferencePanels() {
198:                /*
199:                DBCopyGlobalPreferencesTab tab = new DBCopyGlobalPreferencesTab();
200:                return new IGlobalPreferencesPanel[] { tab };
201:                 */
202:                return new IGlobalPreferencesPanel[0];
203:            }
204:
205:            /**
206:             * @param coll
207:             * @param api
208:             */
209:            protected void addMenuItemsToContextMenu(ISession session) {
210:                final IObjectTreeAPI api = session
211:                        .getObjectTreeAPIOfActiveSessionWindow();
212:                final ActionCollection coll = getApplication()
213:                        .getActionCollection();
214:
215:                if (SwingUtilities.isEventDispatchThread()) {
216:                    addToPopup(api, coll);
217:                } else {
218:                    SwingUtilities.invokeLater(new Runnable() {
219:                        public void run() {
220:                            addToPopup(api, coll);
221:                        }
222:                    });
223:                }
224:            }
225:
226:            private class DBDiffPluginResources extends PluginResources {
227:                DBDiffPluginResources(String rsrcBundleBaseName, IPlugin plugin) {
228:                    super (rsrcBundleBaseName, plugin);
229:                }
230:            }
231:
232:            private void addToPopup(IObjectTreeAPI api, ActionCollection coll) {
233:
234:                // Uses menu.dbdiff.* in dbdiff.properties
235:                JMenu dbdiffMenu = _resources.createMenu("dbdiff");
236:
237:                JMenuItem selectItem = new JMenuItem(coll
238:                        .get(SelectAction.class));
239:                JMenuItem compareItem = new JMenuItem(coll
240:                        .get(CompareAction.class));
241:                dbdiffMenu.add(selectItem);
242:                dbdiffMenu.add(compareItem);
243:
244:                api.addToPopup(DatabaseObjectType.CATALOG, dbdiffMenu);
245:                api.addToPopup(DatabaseObjectType.SCHEMA, dbdiffMenu);
246:                api.addToPopup(DatabaseObjectType.TABLE_TYPE_DBO, dbdiffMenu);
247:                api.addToPopup(DatabaseObjectType.TABLE, dbdiffMenu);
248:
249:            }
250:
251:            /*
252:            private class DBCopyPluginResources extends PluginResources {
253:            DBCopyPluginResources(String rsrcBundleBaseName, IPlugin plugin) {
254:                super(rsrcBundleBaseName, plugin);
255:            }
256:            }
257:             */
258:            public void setCompareMenuEnabled(boolean enabled) {
259:                final ActionCollection coll = getApplication()
260:                        .getActionCollection();
261:                CompareAction compareAction = (CompareAction) coll
262:                        .get(CompareAction.class);
263:                compareAction.setEnabled(enabled);
264:            }
265:
266:            // Interface SessionInfoProvider implementation
267:
268:            /* (non-Javadoc)
269:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getCopySourceSession()
270:             */
271:            public ISession getDiffSourceSession() {
272:                return diffSourceSession;
273:            }
274:
275:            /* (non-Javadoc)
276:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#setCopySourceSession(net.sourceforge.squirrel_sql.client.session.ISession)
277:             */
278:            public void setDiffSourceSession(ISession session) {
279:                if (session != null) {
280:                    diffSourceSession = session;
281:                }
282:            }
283:
284:            /* (non-Javadoc)
285:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getSelectedDatabaseObjects()
286:             */
287:            public IDatabaseObjectInfo[] getSourceSelectedDatabaseObjects() {
288:                return selectedDatabaseObjects;
289:            }
290:
291:            /* (non-Javadoc)
292:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getCopyDestSession()
293:             */
294:            public ISession getDiffDestSession() {
295:                return diffDestSession;
296:            }
297:
298:            /* (non-Javadoc)
299:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#setDestCopySession(net.sourceforge.squirrel_sql.client.session.ISession)
300:             */
301:            public void setDestDiffSession(ISession session) {
302:                diffDestSession = session;
303:            }
304:
305:            /* (non-Javadoc)
306:             * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getDestSelectedDatabaseObject()
307:             */
308:            public IDatabaseObjectInfo[] getDestSelectedDatabaseObjects() {
309:                return selectedDestDatabaseObjects;
310:            }
311:
312:            public void setDestSelectedDatabaseObjects(
313:                    IDatabaseObjectInfo[] info) {
314:                selectedDestDatabaseObjects = info;
315:            }
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.