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.XMLBeanWriter;
030: import net.sourceforge.squirrel_sql.fw.xml.XMLException;
031:
032: import net.sourceforge.squirrel_sql.client.preferences.SquirrelPreferences;
033: import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
034:
035: import net.sourceforge.squirrel_sql.plugins.exportconfig.ExportConfigPlugin;
036:
037: /**
038: * This command allow the user to save the application settings to the file system.
039: *
040: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
041: */
042: class ExportSettingsCommand extends AbstractSaveCommand {
043: private static final StringManager s_stringMgr = StringManagerFactory
044: .getStringManager(ExportSettingsCommand.class);
045:
046: /** Logger for this class. */
047: private final static ILogger s_log = LoggerController
048: .createLogger(ExportSettingsCommand.class);
049:
050: /** Parent frame. */
051: private final Frame _frame;
052:
053: /** Current plugin. */
054: private ExportConfigPlugin _plugin;
055:
056: /**
057: * Ctor.
058: *
059: * @throws IllegalArgumentException
060: * Thrown if a�<TT>null</TT> <TT>ISession</TT>,
061: * <TT>Resources</TT> or <TT>MysqlPlugin</TT> passed.
062: */
063: public ExportSettingsCommand(Frame frame, ExportConfigPlugin plugin) {
064: super (frame, plugin);
065: _frame = frame;
066: _plugin = plugin;
067: }
068:
069: /**
070: * Save database drivers to <TT>file</TT>.
071: *
072: * @param file The <TT>File</TT> to be written to.
073: *
074: * @throws IOException Thrown if an IO error occurs.
075: */
076: protected void writeToFile(File file) throws IOException,
077: XMLException {
078: final SquirrelPreferences prefs = _plugin.getApplication()
079: .getSquirrelPreferences();
080: new XMLBeanWriter(prefs).save(file);
081: }
082:
083: /**
084: * Retrieve the default file name for the save.
085: *
086: * @return The default file name.
087: */
088: protected String getDefaultFilename() {
089: return new ApplicationFiles().getUserPreferencesFile()
090: .getName();
091: }
092:
093: /**
094: * Retrieve the description of the objects being saved.
095: *
096: * @return description of the objects being saved.
097: */
098: protected String getSaveDescription() {
099: // i18n[exportconfig.applicationSettings=Application Settings]
100: return s_stringMgr
101: .getString("exportconfig.applicationSettings");
102: }
103:
104: }
|