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 javax.swing.JInternalFrame;
022:
023: import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
024: import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
025: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
026: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
027:
028: import net.sourceforge.squirrel_sql.client.IApplication;
029: import net.sourceforge.squirrel_sql.client.gui.WindowManager;
030:
031: /**
032: * This class manages the windows relating to JDBC drivers.
033: *
034: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
035: * @author <A HREF="mailto:jmheight@users.sourceforge.net">Jason Height</A>
036: */
037: public class DriverWindowManager {
038: /** Logger for this class. */
039: private static final ILogger s_log = LoggerController
040: .createLogger(WindowManager.class);
041:
042: /** Application API. */
043: private final IApplication _app;
044:
045: /** Window Factory for driver maintenace windows. */
046: private final DriverWindowFactory _driverWinFactory;
047:
048: /**
049: * Ctor.
050: *
051: * @param app Application API.
052: *
053: * @throws IllegalArgumentException
054: * Thrown if <TT>null</TT> <TT>IApplication</TT> passed.
055: */
056: public DriverWindowManager(IApplication app) {
057: super ();
058: if (app == null) {
059: throw new IllegalArgumentException("IApplication == null");
060: }
061:
062: _app = app;
063: _driverWinFactory = new DriverWindowFactory(_app);
064: }
065:
066: /**
067: * Get a maintenance sheet for the passed driver. If a maintenance sheet
068: * already exists it will be brought to the front. If one doesn't exist
069: * it will be created.
070: *
071: * @param driver The driver that user has requested to modify.
072: *
073: * @throws IllegalArgumentException
074: * Thrown if a <TT>null</TT> <TT>ISQLDriver</TT> passed.
075: */
076: public void showModifyDriverInternalFrame(final ISQLDriver driver) {
077: if (driver == null) {
078: throw new IllegalArgumentException("ISQLDriver == null");
079: }
080:
081: moveToFront(_driverWinFactory.getModifySheet(driver));
082: }
083:
084: /**
085: * Create and show a new maintenance window to allow the user to create a
086: * new driver.
087: */
088: public void showNewDriverInternalFrame() {
089: moveToFront(_driverWinFactory.getCreateSheet());
090: }
091:
092: /**
093: * Create and show a new maintenance sheet that will allow the user to
094: * create a new driver that is a copy of the passed one.
095: *
096: * @return The new maintenance sheet.
097: *
098: * @throws IllegalArgumentException
099: * Thrown if a <TT>null</TT> <TT>ISQLDriver</TT> passed.
100: */
101: public void showCopyDriverInternalFrame(final ISQLDriver driver) {
102: if (driver == null) {
103: throw new IllegalArgumentException("ISQLDriver == null");
104: }
105:
106: moveToFront(_driverWinFactory.showCopySheet(driver));
107: }
108:
109: public void moveToFront(final JInternalFrame fr) {
110: if (fr != null) {
111: GUIUtils.processOnSwingEventThread(new Runnable() {
112: public void run() {
113: GUIUtils.moveToFront(fr);
114: }
115: });
116: } else {
117: s_log.debug("JInternalFrame == null");
118: }
119: }
120: }
|