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


001:        package net.sourceforge.squirrel_sql.plugins.graph;
002:
003:        /*
004:         * Copyright (C) 2004 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:
021:        import java.util.Arrays;
022:        import java.util.Hashtable;
023:        import java.util.Vector;
024:
025:        import net.sourceforge.squirrel_sql.client.IApplication;
026:        import net.sourceforge.squirrel_sql.client.action.ActionCollection;
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.plugin.DefaultSessionPlugin;
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.session.IObjectTreeAPI;
034:        import net.sourceforge.squirrel_sql.client.session.ISession;
035:        import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
036:        import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
037:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
038:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
039:        import net.sourceforge.squirrel_sql.plugins.graph.xmlbeans.GraphXmlSerializer;
040:
041:        /**
042:         * The SQL Script plugin class.
043:         */
044:        public class GraphPlugin extends DefaultSessionPlugin {
045:
046:            private Hashtable<IIdentifier, GraphController[]> _grapControllersBySessionID = new Hashtable<IIdentifier, GraphController[]>();
047:
048:            /**
049:             * Logger for this class.
050:             */
051:            @SuppressWarnings("unused")
052:            private static ILogger s_log = LoggerController
053:                    .createLogger(GraphPlugin.class);
054:
055:            private PluginResources _resources;
056:
057:            /**
058:             * Return the internal name of this plugin.
059:             *
060:             * @return the internal name of this plugin.
061:             */
062:            public String getInternalName() {
063:                return "graph";
064:            }
065:
066:            /**
067:             * Return the descriptive name of this plugin.
068:             *
069:             * @return the descriptive name of this plugin.
070:             */
071:            public String getDescriptiveName() {
072:                return "Graph";
073:            }
074:
075:            /**
076:             * Returns the current version of this plugin.
077:             *
078:             * @return the current version of this plugin.
079:             */
080:            public String getVersion() {
081:                return "1.0";
082:            }
083:
084:            /**
085:             * Returns the authors name.
086:             *
087:             * @return the authors name.
088:             */
089:            public String getAuthor() {
090:                return "Gerd Wagner";
091:            }
092:
093:            /**
094:             * Returns the name of the change log for the plugin. This should
095:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
096:             * directory.
097:             *
098:             * @return	the changelog file name or <TT>null</TT> if plugin doesn't have
099:             * a change log.
100:             */
101:            public String getChangeLogFileName() {
102:                return "changes.txt";
103:            }
104:
105:            /**
106:             * Returns the name of the Help file for the plugin. This should
107:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
108:             * directory.
109:             *
110:             * @return	the Help file name or <TT>null</TT> if plugin doesn't have
111:             * a help file.
112:             */
113:            public String getHelpFileName() {
114:                return "readme.html";
115:            }
116:
117:            /**
118:             * Returns the name of the Licence file for the plugin. This should
119:             * be a text or HTML file residing in the <TT>getPluginAppSettingsFolder</TT>
120:             * directory.
121:             *
122:             * @return	the Licence file name or <TT>null</TT> if plugin doesn't have
123:             * a licence file.
124:             */
125:            public String getLicenceFileName() {
126:                return "licence.txt";
127:            }
128:
129:            /**
130:             * Initialize this plugin.
131:             */
132:            public synchronized void initialize() throws PluginException {
133:                super .initialize();
134:                IApplication app = getApplication();
135:
136:                _resources = new PluginResources(
137:                        "net.sourceforge.squirrel_sql.plugins.graph.graph",
138:                        this );
139:
140:                ActionCollection coll = app.getActionCollection();
141:                coll.add(new AddToGraphAction(app, _resources, this ));
142:            }
143:
144:            /**
145:             * Application is shutting down so save data.
146:             */
147:            public void unload() {
148:                super .unload();
149:            }
150:
151:            /**
152:             * Called when a session started. Add commands to popup menu
153:             * in object tree.
154:             *
155:             * @param session The session that is starting.
156:             * @return <TT>true</TT> to indicate that this plugin is
157:             *         applicable to passed session.
158:             */
159:            public PluginSessionCallback sessionStarted(final ISession session) {
160:                GraphXmlSerializer[] serializers = GraphXmlSerializer
161:                        .getGraphXmSerializers(this , session);
162:                GraphController[] controllers = new GraphController[serializers.length];
163:
164:                for (int i = 0; i < controllers.length; i++) {
165:                    controllers[i] = new GraphController(session, this ,
166:                            serializers[i]);
167:                }
168:
169:                _grapControllersBySessionID.put(session.getIdentifier(),
170:                        controllers);
171:
172:                IObjectTreeAPI api = session.getSessionInternalFrame()
173:                        .getObjectTreeAPI();
174:
175:                ActionCollection coll = getApplication().getActionCollection();
176:                api.addToPopup(DatabaseObjectType.TABLE, coll
177:                        .get(AddToGraphAction.class));
178:
179:                PluginSessionCallback ret = new PluginSessionCallback() {
180:                    public void sqlInternalFrameOpened(
181:                            SQLInternalFrame sqlInternalFrame, ISession sess) {
182:                    }
183:
184:                    public void objectTreeInternalFrameOpened(
185:                            ObjectTreeInternalFrame objectTreeInternalFrame,
186:                            ISession sess) {
187:                        // Graphs are only supported on the main session window.
188:                    }
189:                };
190:
191:                return ret;
192:            }
193:
194:            public void sessionEnding(ISession session) {
195:                GraphController[] controllers = _grapControllersBySessionID
196:                        .remove(session.getIdentifier());
197:
198:                for (int i = 0; i < controllers.length; i++) {
199:                    controllers[i].sessionEnding();
200:                }
201:            }
202:
203:            public GraphController[] getGraphControllers(ISession session) {
204:                return _grapControllersBySessionID.get(session.getIdentifier());
205:            }
206:
207:            public String patchName(String name, ISession session) {
208:
209:                int postfix = 0;
210:                if ("Objects".equals(name)) {
211:                    ++postfix;
212:                }
213:
214:                if ("SQL".equals(name)) {
215:                    ++postfix;
216:                }
217:
218:                GraphController[] controllers = _grapControllersBySessionID
219:                        .get(session.getIdentifier());
220:
221:                while (true) {
222:                    boolean incremented = false;
223:                    for (int i = 0; i < controllers.length; i++) {
224:                        if (0 == postfix) {
225:                            if (controllers[i].getTitle().equals(name)) {
226:                                ++postfix;
227:                                incremented = true;
228:                            }
229:                        } else {
230:                            if (controllers[i].getTitle().equals(
231:                                    name + "_" + postfix)) {
232:                                ++postfix;
233:                                incremented = true;
234:                            }
235:                        }
236:                    }
237:
238:                    if (false == incremented) {
239:                        break;
240:                    }
241:                }
242:
243:                if (0 == postfix) {
244:                    return name;
245:                } else {
246:                    return name + "_" + postfix;
247:                }
248:
249:            }
250:
251:            public GraphController createNewGraphControllerForSession(
252:                    ISession session) {
253:                GraphController[] controllers = _grapControllersBySessionID
254:                        .get(session.getIdentifier());
255:
256:                Vector<GraphController> v = new Vector<GraphController>();
257:                if (null != controllers) {
258:                    v.addAll(Arrays.asList(controllers));
259:                }
260:                GraphController ret = new GraphController(session, this , null);
261:                v.add(ret);
262:
263:                controllers = v.toArray(new GraphController[v.size()]);
264:                _grapControllersBySessionID.put(session.getIdentifier(),
265:                        controllers);
266:
267:                return ret;
268:            }
269:
270:            public void removeGraphController(GraphController toRemove,
271:                    ISession session) {
272:                GraphController[] controllers = _grapControllersBySessionID
273:                        .get(session.getIdentifier());
274:                Vector<GraphController> v = new Vector<GraphController>();
275:                for (int i = 0; i < controllers.length; i++) {
276:                    if (false == controllers[i].equals(toRemove)) {
277:                        v.add(controllers[i]);
278:                    }
279:                }
280:
281:                controllers = v.toArray(new GraphController[v.size()]);
282:                _grapControllersBySessionID.put(session.getIdentifier(),
283:                        controllers);
284:
285:            }
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.