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


001:        package net.sourceforge.squirrel_sql.client.plugin;
002:
003:        /*
004:         * Copyright (C) 2001-2004 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * Modifications Copyright (c) 2004 Jason Height.
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:         */
023:        import javax.swing.JMenu;
024:
025:        import net.sourceforge.squirrel_sql.client.session.ISession;
026:        import net.sourceforge.squirrel_sql.client.session.event.SessionAdapter;
027:        import net.sourceforge.squirrel_sql.client.session.event.SessionEvent;
028:        import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
029:        import net.sourceforge.squirrel_sql.client.session.properties.ISessionPropertiesPanel;
030:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
031:        import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
032:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
033:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
034:
035:        public abstract class DefaultSessionPlugin extends DefaultPlugin
036:                implements  ISessionPlugin {
037:            /** Subclasses that create a session JMenu will set this */
038:            private JMenu sessionMenu = null;
039:
040:            /** Logger for this class. */
041:            private static final ILogger s_log = LoggerController
042:                    .createLogger(DefaultSessionPlugin.class);
043:
044:            /**
045:             * A new session has been created. At this point the
046:             * <TT>SessionPanel</TT> does not exist for the new session.
047:             *
048:             * @param	session	 The new session.
049:             *
050:             * @throws	IllegalArgumentException
051:             * 			Thrown if a <TT>null</TT> ISession</TT> passed.
052:             */
053:            public void sessionCreated(ISession session) {
054:                // Empty body.
055:            }
056:
057:            public boolean allowsSessionStartedInBackground() {
058:                return false;
059:            }
060:
061:            /**
062:             * Called when a session shutdown.
063:             *
064:             * @param	session	The session that is ending.
065:             */
066:            public void sessionEnding(ISession session) {
067:                // Empty body.
068:            }
069:
070:            /**
071:             * Override this to create panels for the Session Properties dialog.
072:             *
073:             * @param	session	The session that will be displayed in the properties dialog.
074:             *
075:             * @return	<TT>null</TT> to indicate that this plugin doesn't use session property panels.
076:             */
077:            public ISessionPropertiesPanel[] getSessionPropertiesPanels(
078:                    ISession session) {
079:                return null;
080:            }
081:
082:            /**
083:             * Let app know what extra types of objects in object tree that
084:             * plugin can handle.
085:             */
086:            public IPluginDatabaseObjectType[] getObjectTypes(ISession session) {
087:                return null;
088:            }
089:
090:            /**
091:             * Return a node expander for the object tree for a particular default node type.
092:             * A plugin could return non null here if they wish to override the default node
093:             * expander bahaviour. Most plugins should return null here.
094:             */
095:            public INodeExpander getDefaultNodeExpander(ISession session,
096:                    DatabaseObjectType type) {
097:                return null;
098:            }
099:
100:            /**
101:             * This should be overridden by all databases-specific subclasses so that 
102:             * registerSessionMenu will work correctly. It should return true 
103:             * when the plugin subclass is db-specific and the specified session is for a 
104:             * database that the plugin supports; false is returned otherwise.
105:             */
106:            protected boolean isPluginSession(ISession session) {
107:                if (s_log.isDebugEnabled() && sessionMenu != null) {
108:                    s_log
109:                            .debug("The default isPluginSession() impl was called for session \""
110:                                    + session.getAlias().getName()
111:                                    + "\", but sessionMenu ("
112:                                    + sessionMenu.getText()
113:                                    + ")is not null - this is probably a bug.");
114:                }
115:                return true;
116:            }
117:
118:            /**
119:             * Plugin sub-classes call this to register their session JMenu with this 
120:             * class so that this class can manage it's enabled state, as sessions 
121:             * become activated.
122:             * 
123:             * @param menu the plugin session menu
124:             */
125:            protected void registerSessionMenu(JMenu menu) {
126:                if (menu == null) {
127:                    throw new IllegalArgumentException("menu cannot be null");
128:                }
129:                sessionMenu = menu;
130:                _app.getSessionManager().addSessionListener(
131:                        new SessionListener());
132:            }
133:
134:            /**
135:             * A session listener that is used to determine when sessions are activated
136:             * and to trigger the enable menu task if the session is relevant to this 
137:             * plugin.
138:             */
139:            private class SessionListener extends SessionAdapter {
140:                public void sessionActivated(SessionEvent evt) {
141:                    final ISession session = evt.getSession();
142:                    EnableMenuTask task = new EnableMenuTask(session);
143:                    session.getApplication().getThreadPool().addTask(task);
144:                }
145:            }
146:
147:            /**
148:             * A runnable that implements changing the enabled state of sessionMenu. 
149:             * This class ensures that UI state change occurs in the Swing EDT.
150:             */
151:            private class EnableMenuTask implements  Runnable {
152:
153:                private ISession _session = null;
154:
155:                public EnableMenuTask(ISession session) {
156:                    _session = session;
157:                }
158:
159:                public void run() {
160:                    final boolean enable = isPluginSession(_session);
161:                    GUIUtils.processOnSwingEventThread(new Runnable() {
162:                        public void run() {
163:                            sessionMenu.setEnabled(enable);
164:                        }
165:                    });
166:                }
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.