001: package net.sourceforge.squirrel_sql.plugins.exportconfig.action;
002:
003: /*
004: * Copyright (C) 2003 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.awt.Frame;
022: import java.io.File;
023: import java.io.IOException;
024:
025: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
026: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
027: import net.sourceforge.squirrel_sql.fw.util.StringManager;
028: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
029: import net.sourceforge.squirrel_sql.fw.xml.XMLException;
030:
031: import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
032:
033: import net.sourceforge.squirrel_sql.plugins.exportconfig.ExportConfigPlugin;
034:
035: /**
036: * This command allow the user to save the database aliases to the file system.
037: *
038: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
039: */
040: class ExportAliasesCommand extends AbstractSaveCommand {
041: private static final StringManager s_stringMgr = StringManagerFactory
042: .getStringManager(ExportAliasesCommand.class);
043:
044: /** Logger for this class. */
045: private final static ILogger s_log = LoggerController
046: .createLogger(ExportAliasesCommand.class);
047:
048: /** Parent frame. */
049: private final Frame _frame;
050:
051: /** Current plugin. */
052: private ExportConfigPlugin _plugin;
053:
054: /**
055: * Ctor.
056: *
057: * @throws IllegalArgumentException
058: * Thrown if a�<TT>null</TT> <TT>ISession</TT>,
059: * <TT>Resources</TT> or <TT>MysqlPlugin</TT> passed.
060: */
061: public ExportAliasesCommand(Frame frame, ExportConfigPlugin plugin) {
062: super (frame, plugin);
063: _frame = frame;
064: _plugin = plugin;
065: }
066:
067: /**
068: * Save database aliases to <TT>file</TT>.
069: *
070: * @param file The <TT>File</TT> to be written to.
071: *
072: * @throws IOException Thrown if an IO error occurs.
073: */
074: protected void writeToFile(File file) throws IOException,
075: XMLException {
076: final net.sourceforge.squirrel_sql.client.gui.db.DataCache cache = _plugin
077: .getApplication().getDataCache();
078: cache.saveAliases(file);
079: }
080:
081: /**
082: * Retrieve the default file name for the save.
083: *
084: * @return The default file name.
085: */
086: protected String getDefaultFilename() {
087: return new ApplicationFiles().getDatabaseAliasesFile()
088: .getName();
089: }
090:
091: /**
092: * Retrieve the description of the objects being saved.
093: *
094: * @return description of the objects being saved.
095: */
096: protected String getSaveDescription() {
097: // i18n[exportconfig.databaseAliases=Database Aliases]
098: return s_stringMgr.getString("exportconfig.databaseAliases");
099: }
100: }
|