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


001:        package net.sourceforge.squirrel_sql.client.gui.db;
002:
003:        /*
004:         * Copyright (C) 2001-2004 Colin Bell
005:         * colbell@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:        import java.util.HashMap;
022:        import java.util.Map;
023:
024:        import javax.swing.event.InternalFrameAdapter;
025:        import javax.swing.event.InternalFrameEvent;
026:
027:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
028:        import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
029:        import net.sourceforge.squirrel_sql.fw.id.IIdentifierFactory;
030:        import net.sourceforge.squirrel_sql.fw.persist.ValidationException;
031:        import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
032:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
033:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
034:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
035:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
036:
037:        import net.sourceforge.squirrel_sql.client.IApplication;
038:        import net.sourceforge.squirrel_sql.client.util.IdentifierFactory;
039:
040:        /**
041:         * TODO: Move all code other than for window creation up to AliasWindowManager
042:         * Factory to handle creation of maintenance sheets for SQL Driver objects.
043:         *
044:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
045:         */
046:        class DriverWindowFactory implements 
047:                AliasInternalFrame.IMaintenanceType {
048:            /** Logger for this class. */
049:            private static ILogger s_log = LoggerController
050:                    .createLogger(DriverWindowFactory.class);
051:
052:            /** Application API. */
053:            private IApplication _app;
054:
055:            /** Internationalized strings for this class. */
056:            private static final StringManager s_stringMgr = StringManagerFactory
057:                    .getStringManager(DriverWindowFactory.class);
058:
059:            /**
060:             * Collection of <TT>DriverMaintDialog</TT> that are currently visible
061:             * modifying an existing driver. Keyed by
062:             * <TT>ISQLDriver.getIdentifier()</TT>.
063:             */
064:            private final Map<IIdentifier, DriverInternalFrame> _modifySheets = new HashMap<IIdentifier, DriverInternalFrame>();
065:
066:            /**
067:             * ctor.
068:             *
069:             * @param	app		Application API.
070:             *
071:             * @throws	IllegalArgumentException
072:             *			Thrown if <tt>null</tt> <tt>IApplication</tt> passed.
073:             */
074:            public DriverWindowFactory(IApplication app) {
075:                super ();
076:                if (app == null) {
077:                    throw new IllegalArgumentException("IApplication == null");
078:                }
079:
080:                _app = app;
081:            }
082:
083:            /**
084:             * Get a maintenance sheet for the passed driver. If one
085:             * already exists it will be returned, otherwise one will be created.
086:             *
087:             * @param	driver	The driver that user has requested to modify.
088:             *
089:             * @return	The maintenance sheet for the passed driver.
090:             *
091:             * @throws	IllegalArgumentException	if a <TT>null</TT> <TT>ISQLDriver</TT> passed.
092:             */
093:            public synchronized DriverInternalFrame getModifySheet(
094:                    ISQLDriver driver) {
095:                if (driver == null) {
096:                    throw new IllegalArgumentException("ISQLDriver == null");
097:                }
098:
099:                DriverInternalFrame sheet = get(driver);
100:                if (sheet == null) {
101:                    sheet = new DriverInternalFrame(_app, driver, MODIFY);
102:                    _modifySheets.put(driver.getIdentifier(), sheet);
103:                    _app.getMainFrame().addInternalFrame(sheet, true, null);
104:
105:                    sheet.addInternalFrameListener(new InternalFrameAdapter() {
106:                        public void internalFrameClosed(InternalFrameEvent evt) {
107:                            synchronized (DriverWindowFactory.this ) {
108:                                DriverInternalFrame frame = (DriverInternalFrame) evt
109:                                        .getInternalFrame();
110:                                _modifySheets.remove(frame.getSQLDriver()
111:                                        .getIdentifier());
112:                            }
113:                        }
114:                    });
115:                    GUIUtils.centerWithinDesktop(sheet);
116:                }
117:
118:                return sheet;
119:            }
120:
121:            /**
122:             * Create and show a new maintenance sheet to allow the user to create a new driver.
123:             *
124:             * @return	The new maintenance sheet.
125:             */
126:            public DriverInternalFrame getCreateSheet() {
127:                final net.sourceforge.squirrel_sql.client.gui.db.DataCache cache = _app
128:                        .getDataCache();
129:                final IIdentifierFactory factory = IdentifierFactory
130:                        .getInstance();
131:                final ISQLDriver driver = cache.createDriver(factory
132:                        .createIdentifier());
133:                final DriverInternalFrame sheet = new DriverInternalFrame(_app,
134:                        driver, NEW);
135:                _app.getMainFrame().addInternalFrame(sheet, true, null);
136:                GUIUtils.centerWithinDesktop(sheet);
137:                return sheet;
138:            }
139:
140:            /**
141:             * Create and show a new maintenance sheet that will allow the user to create a
142:             * new driver that is a copy of the passed one.
143:             *
144:             * @return	The new maintenance sheet.
145:             *
146:             * @throws	IllegalArgumentException	if a <TT>null</TT> <TT>ISQLDriver</TT> passed.
147:             */
148:            public DriverInternalFrame showCopySheet(ISQLDriver driver) {
149:                if (driver == null) {
150:                    throw new IllegalArgumentException("ISQLDriver == null");
151:                }
152:
153:                final DataCache cache = _app.getDataCache();
154:                final IIdentifierFactory factory = IdentifierFactory
155:                        .getInstance();
156:                ISQLDriver newDriver = cache.createDriver(factory
157:                        .createIdentifier());
158:                try {
159:                    newDriver.assignFrom(driver);
160:                } catch (ValidationException ex) {
161:                    // i18n[DriverWindowFactory.error.copyingdriver=Error occured copying the driver]
162:                    s_log
163:                            .error(
164:                                    s_stringMgr
165:                                            .getString("DriverWindowFactory.error.copyingdriver"),
166:                                    ex);
167:                }
168:                final DriverInternalFrame sheet = new DriverInternalFrame(_app,
169:                        newDriver, COPY);
170:                _app.getMainFrame().addInternalFrame(sheet, true, null);
171:                GUIUtils.centerWithinDesktop(sheet);
172:
173:                return sheet;
174:            }
175:
176:            private DriverInternalFrame get(ISQLDriver driver) {
177:                return _modifySheets.get(driver.getIdentifier());
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.