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.client.gui.db.DataCache;
026: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
027: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
028: import net.sourceforge.squirrel_sql.fw.util.StringManager;
029: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
030: import net.sourceforge.squirrel_sql.fw.xml.XMLException;
031:
032: import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
033:
034: import net.sourceforge.squirrel_sql.plugins.exportconfig.ExportConfigPlugin;
035:
036: /**
037: * This command allow the user to save the database drivers to the file system.
038: *
039: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
040: */
041: class ExportDriversCommand extends AbstractSaveCommand {
042: private static final StringManager s_stringMgr = StringManagerFactory
043: .getStringManager(ExportDriversCommand.class);
044:
045: /** Logger for this class. */
046: private final static ILogger s_log = LoggerController
047: .createLogger(ExportDriversCommand.class);
048:
049: /** Parent frame. */
050: private final Frame _frame;
051:
052: /** Current plugin. */
053: private ExportConfigPlugin _plugin;
054:
055: /**
056: * Ctor.
057: *
058: * @throws IllegalArgumentException
059: * Thrown if a�<TT>null</TT> <TT>ISession</TT>,
060: * <TT>Resources</TT> or <TT>MysqlPlugin</TT> passed.
061: */
062: public ExportDriversCommand(Frame frame, ExportConfigPlugin plugin) {
063: super (frame, plugin);
064: _frame = frame;
065: _plugin = plugin;
066: }
067:
068: /**
069: * Save database drivers to <TT>file</TT>.
070: *
071: * @param file The <TT>File</TT> to be written to.
072: *
073: * @throws IOException Thrown if an IO error occurs.
074: */
075: protected void writeToFile(File file) throws IOException,
076: XMLException {
077: final DataCache cache = _plugin.getApplication().getDataCache();
078: cache.saveDrivers(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().getDatabaseDriversFile()
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.databaseDrivers=Database Drivers]
098: return s_stringMgr.getString("exportconfig.databaseDrivers");
099: }
100: }
|