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