001: package net.sourceforge.squirrel_sql.plugins.exportconfig;
002:
003: import java.io.File;
004: import java.io.IOException;
005:
006: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
007: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
008: import net.sourceforge.squirrel_sql.fw.util.StringManager;
009: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
010:
011: import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
012:
013: /*
014: * Copyright (C) 2003 Colin Bell
015: * colbell@users.sourceforge.net
016: *
017: * This library is free software; you can redistribute it and/or
018: * modify it under the terms of the GNU Lesser General Public
019: * License as published by the Free Software Foundation; either
020: * version 2.1 of the License, or (at your option) any later version.
021: *
022: * This library is distributed in the hope that it will be useful,
023: * but WITHOUT ANY WARRANTY; without even the implied warranty of
024: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
025: * Lesser General Public License for more details.
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: /**
033: * Preferences for this plugin.
034: *
035: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
036: */
037: public class ExportConfigPreferences {
038: private static final StringManager s_stringMgr = StringManagerFactory
039: .getStringManager(ExportConfigPreferences.class);
040:
041: /** Logger for this class. */
042: private final static ILogger s_log = LoggerController
043: .createLogger(ExportConfigPreferences.class);
044:
045: /** If <TT>true</TT> then export preferences. */
046: private boolean _exportPreferences = true;
047:
048: /** If <TT>true</TT> then export drivers. */
049: private boolean _exportDrivers = true;
050:
051: /** If <TT>true</TT> then export aliases. */
052: private boolean _exportAliases = true;
053:
054: /** If <TT>true</TT> then include user names in aliases export. */
055: private boolean _includeUserNames = true;
056:
057: /** If <TT>true</TT> then include passwords in aliases export. */
058: private boolean _includePasswords = true;
059:
060: /** Name of file to export preferences to. */
061: private String _preferencesFileName;
062:
063: /** Name of file to export preferences to. */
064: private String _driversFileName;
065:
066: /** Name of file to export aliases to. */
067: private String _aliasesFileName;
068:
069: /**
070: * Default ctor.
071: */
072: public ExportConfigPreferences() {
073: super ();
074:
075: final File here = new File(".");
076: final ApplicationFiles appFiles = new ApplicationFiles();
077: _preferencesFileName = getFileName(here, appFiles
078: .getUserPreferencesFile().getName());
079: _driversFileName = getFileName(here, appFiles
080: .getDatabaseDriversFile().getName());
081: _aliasesFileName = getFileName(here, appFiles
082: .getDatabaseAliasesFile().getName());
083: }
084:
085: /**
086: * If <TT>true</TT> then export preferences.
087: *
088: * @return <TT>true</TT> if preferences are to be exported.
089: */
090: public boolean getExportPreferences() {
091: return _exportPreferences;
092: }
093:
094: /**
095: * Specify whether to export preferences.
096: *
097: * @param value <TT>true</TT> if preferences are to be exported.
098: */
099: public void setExportPreferences(boolean value) {
100: _exportPreferences = value;
101: }
102:
103: /**
104: * If <TT>true</TT> then export drivers.
105: *
106: * @return <TT>true</TT> if drivers are to be exported.
107: */
108: public boolean getExportDrivers() {
109: return _exportDrivers;
110: }
111:
112: /**
113: * Specify whether to export drivers.
114: *
115: * @param value <TT>true</TT> if drivers are to be exported.
116: */
117: public void setExportDrivers(boolean value) {
118: _exportDrivers = value;
119: }
120:
121: /**
122: * If <TT>true</TT> then export aliases.
123: *
124: * @return <TT>true</TT> if aliases are to be exported.
125: */
126: public boolean getExportAliases() {
127: return _exportAliases;
128: }
129:
130: /**
131: * Specify whether to export aliases.
132: *
133: * @param value <TT>true</TT> if aliases are to be exported.
134: */
135: public void setExportAliases(boolean value) {
136: _exportAliases = value;
137: }
138:
139: /**
140: * If <TT>true</TT> then include user names in aliases export.
141: *
142: * @return <TT>true</TT> if user names are to be included in aliases
143: * export.
144: */
145: public boolean getIncludeUserNames() {
146: return _includeUserNames;
147: }
148:
149: /**
150: * Specify whether to include user names in aliases export.
151: *
152: * @param value <TT>true</TT> if user names are to be included in
153: * aliases export.
154: */
155: public void setIncludeUserNames(boolean value) {
156: _includeUserNames = value;
157: }
158:
159: /**
160: * If <TT>true</TT> then include passwords in aliases export.
161: *
162: * @return <TT>true</TT> if passwords are to be included in aliases
163: * export.
164: */
165: public boolean getIncludePasswords() {
166: return _includePasswords;
167: }
168:
169: /**
170: * Specify whether to include passwords in aliases export.
171: *
172: * @param value <TT>true</TT> if passwords are to be included in
173: * aliases export.
174: */
175: public void setIncludePasswords(boolean value) {
176: _includePasswords = value;
177: }
178:
179: /**
180: * Retrieve the fully qualified name of the file to save preferences to.
181: *
182: * @return the fully qualified name of the file to save preferences to.
183: */
184: public String getPreferencesFileName() {
185: return _preferencesFileName;
186: }
187:
188: /**
189: * Specify the fully qualified name of the file to save preferences to.
190: *
191: * @param value the fully qualified name of the file to save preferences
192: * to.
193: */
194: public void setPreferencesFileName(String value) {
195: _preferencesFileName = value;
196: }
197:
198: /**
199: * Retrieve the fully qualified name of the file to save drivers to.
200: *
201: * @return the fully qualified name of the file to save drivers to.
202: */
203: public String getDriversFileName() {
204: return _driversFileName;
205: }
206:
207: /**
208: * Specify the fully qualified name of the file to save drivers to.
209: *
210: * @param value the fully qualified name of the file to save drivers
211: * to.
212: */
213: public void setDriversFileName(String value) {
214: _driversFileName = value;
215: }
216:
217: /**
218: * Retrieve the fully qualified name of the file to save aliases to.
219: *
220: * @return the fully qualified name of the file to save aliases to.
221: */
222: public String getAliasesFileName() {
223: return _aliasesFileName;
224: }
225:
226: /**
227: * Specify the fully qualified name of the file to save aliases to.
228: *
229: * @param value the fully qualified name of the file to save aliases
230: * to.
231: */
232: public void setAliasesFileName(String value) {
233: _aliasesFileName = value;
234: }
235:
236: private String getFileName(File dir, String name) {
237:
238: return getFileName(new File(dir, name));
239: }
240:
241: private String getFileName(File file) {
242: try {
243: return file.getCanonicalPath();
244: } catch (IOException ex) {
245: // i18n[exportconfig.errorResolvingFile=Error resolving file name]
246: s_log.error(s_stringMgr
247: .getString("exportconfig.errorResolvingFile"), ex);
248: }
249: return file.getAbsolutePath();
250: }
251: }
|