Source Code Cross Referenced for SquirrelPreferences.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » client » preferences » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.client.preferences 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.client.preferences;
002:
003:        /*
004:         * Copyright (C) 2001-2004 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * Modifications Copyright (C) 2003-2004 Jason Height
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:         */
023:        import net.sourceforge.squirrel_sql.client.action.ActionKeys;
024:        import net.sourceforge.squirrel_sql.client.gui.mainframe.MainFrameWindowState;
025:        import net.sourceforge.squirrel_sql.client.plugin.PluginStatus;
026:        import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
027:        import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
028:        import net.sourceforge.squirrel_sql.fw.util.PropertyChangeReporter;
029:        import net.sourceforge.squirrel_sql.fw.util.ProxySettings;
030:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
031:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
032:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
033:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
034:        import net.sourceforge.squirrel_sql.fw.xml.XMLBeanReader;
035:        import net.sourceforge.squirrel_sql.fw.xml.XMLBeanWriter;
036:
037:        import java.beans.PropertyChangeListener;
038:        import java.io.File;
039:        import java.io.FileNotFoundException;
040:        import java.io.Serializable;
041:        import java.sql.DriverManager;
042:        import java.util.ArrayList;
043:        import java.util.Arrays;
044:        import java.util.Iterator;
045:
046:        /**
047:         * This class represents the application preferences.
048:         *
049:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
050:         */
051:        @SuppressWarnings("serial")
052:        public class SquirrelPreferences implements  Serializable {
053:
054:            public interface IPropertyNames {
055:                String ACTION_KEYS = "actionKeys";
056:                String ALIASES_SELECTED_INDEX = "aliasesSelectdIndex";
057:                String CONFIRM_SESSION_CLOSE = "confirmSessionClose";
058:                String DRIVERS_SELECTED_INDEX = "driversSelectdIndex";
059:                String FIRST_RUN = "firstRun";
060:                String JDBC_DEBUG_TYPE = "jdbcDebugtype";
061:                String LOGIN_TIMEOUT = "loginTimeout";
062:                String LARGE_SCRIPT_STMT_COUNT = "largeScriptStmtCount";
063:                String MAIN_FRAME_STATE = "mainFrameWindowState";
064:                String MAXIMIMIZE_SESSION_SHEET_ON_OPEN = "maximizeSessionSheetOnOpen";
065:                String NEW_SESSION_VIEW = "newSessionView";
066:                String PLUGIN_OBJECTS = "pluginObjects";
067:                String PLUGIN_STATUSES = "pluginStatuses";
068:                String PROXY = "proxyPerferences";
069:                String SCROLLABLE_TABBED_PANES = "getUseScrollableTabbedPanes";
070:                String SESSION_PROPERTIES = "sessionProperties";
071:                String SHOW_ALIASES_TOOL_BAR = "showAliasesToolBar";
072:                String SHOW_CONTENTS_WHEN_DRAGGING = "showContentsWhenDragging";
073:                String SHOW_DRIVERS_TOOL_BAR = "showDriversToolBar";
074:                String SHOW_LOADED_DRIVERS_ONLY = "showLoadedDriversOnly";
075:                String SHOW_MAIN_STATUS_BAR = "showMainStatusBar";
076:                String SHOW_MAIN_TOOL_BAR = "showMainToolBar";
077:                String SHOW_TOOLTIPS = "showToolTips";
078:                String SHOW_COLOR_ICONS_IN_TOOLBAR = "showColorIconsInToolbars";
079:                String SHOW_PLUGIN_FILES_IN_SPLASH_SCREEN = "showPluginFilesInSplashScreen";
080:                String FILE_OPEN_IN_PREVIOUS_DIR = "fileOpenInPreviousDir";
081:                String FILE_OPEN_IN_SPECIFIED_DIR = "fileOpenInSpecifiedDir";
082:                String FILE_SPECIFIED_DIR = "fileSpecifiedDir";
083:                String FILE_PREVIOUS_DIR = "filePreviousdDir";
084:                String WARN_JRE_JDBC_MISMATCH = "warnJreJdbcMismatch";
085:                String WARN_FOR_UNSAVED_FILE_EDITS = "warnForUnsavedFileEdits";
086:                String WARN_FOR_UNSAVED_BUFFER_EDITS = "warnForUnsavedBufferEdits";
087:                String SHOW_SESSION_STARTUP_TIME_HINT = "showSessionStartupTimeHint";
088:                String SHOW_DEBUG_LOG_MESSAGES = "showDebugLogMessages";
089:                String SHOW_INFO_LOG_MESSAGES = "showInfoLogMessages";
090:                String SHOW_ERROR_LOG_MESSAGES = "showErrorLogMessages";
091:                String SAVE_PREFERENCES_IMMEDIATELY = "savePreferencesImmediately";
092:            }
093:
094:            public interface IJdbcDebugTypes {
095:                int NONE = 0;
096:                int TO_STREAM = 1;
097:                int TO_WRITER = 2;
098:            }
099:
100:            /** Internationalized strings for this class. */
101:            private static final StringManager s_stringMgr = StringManagerFactory
102:                    .getStringManager(SquirrelPreferences.class);
103:
104:            /** Logger for this class. */
105:            private final static ILogger s_log = LoggerController
106:                    .createLogger(SquirrelPreferences.class);
107:
108:            /** Bounds of the main frame. */
109:            private MainFrameWindowState _mainFrameState = new MainFrameWindowState();
110:
111:            /** Properties for new sessions. */
112:            private SessionProperties _sessionProps = new SessionProperties();
113:
114:            /**
115:             * Show contents of internal frames when dragging. <CODE>false</CODE> makes
116:             * dragging faster.
117:             */
118:            private boolean _showContentsWhenDragging = false;
119:
120:            private boolean _fileOpenInPreviousDir = true;
121:
122:            private boolean _fileOpenInSpecifiedDir = false;
123:
124:            private String _fileSpecifiedDir = "";
125:
126:            private String _filePreviousDir = System.getProperty("user.home");
127:
128:            /** JDBC Debug Type. */
129:            private int _jdbcDebugType = IJdbcDebugTypes.NONE;
130:
131:            /** Login timeout (seconds). */
132:            private int _loginTimeout = 30;
133:
134:            /** How many statements before we should consider using UI optimizations for
135:             *  large script execution
136:             */
137:            private int _largeScriptStmtCount = 200;
138:
139:            /** The View to start when a new session is created. */
140:            // JASON: What are its valid values?
141:            private String _newSessionView;
142:
143:            /** Show tooltips for controls. */
144:            private boolean _showToolTips = true;
145:
146:            /** Use scrollable tabbed panes. JDK 1.4 and above only. */
147:            private boolean _useScrollableTabbedPanes = false;
148:
149:            /** Show main statusbar. */
150:            private boolean _showMainStatusBar = true;
151:
152:            /** Show main toolbar. */
153:            private boolean _showMainToolBar = true;
154:
155:            /** Show toolbar in the drivers window. */
156:            private boolean _showDriversToolBar = true;
157:
158:            /** Maximize session sheet on open. */
159:            private boolean _maxSessionSheetOnOpen = false;
160:
161:            /** Show toolbar in the aliases window. */
162:            private boolean _showAliasesToolBar = true;
163:
164:            /** Show color icons in toolbars. */
165:            private boolean _showColorIconsInToolbars = true;
166:
167:            /** Show the name of each jar being loaded when loading plugins */
168:            private boolean _showPluginFilesInSplashScreen = false;
169:
170:            /** Accelerators and mnemonics for actions. */
171:            private ActionKeys[] _actionsKeys = new ActionKeys[0];
172:
173:            /** Proxy settings. */
174:            private ProxySettings _proxySettings = new ProxySettings();
175:
176:            /** Index in drivers window to be initially selected. */
177:            private int _driversSelectedIndex = -1;
178:
179:            /** Index in aliases window to be initially selected. */
180:            private int _aliasesSelectedIndex = -1;
181:
182:            /** Show loaded drivers only in the Drivers window. */
183:            private boolean _showLoadedDriversOnly;
184:
185:            /** Is this the first time SQuirreL has been run? */
186:            private boolean _firstRun = true;
187:
188:            /** Confirm closing sessions */
189:            private boolean _confirmSessionClose = true;
190:
191:            /** Warn for JRE/JDBC Driver API Version mismatch */
192:            private boolean _warnJreJdbcMismatch = true;
193:
194:            /** Collection of <TT>PluginStatus</tt> objects. */
195:            private final ArrayList<PluginStatus> _pluginStatusInfoColl = new ArrayList<PluginStatus>();
196:
197:            /** Warning when closing session if a file was edited but not saved. */
198:            private boolean _warnForUnsavedFileEdits = true;
199:
200:            /** Warning when closing session if a buffer was edited but not saved. */
201:            private boolean _warnForUnsavedBufferEdits = true;
202:
203:            /** Hint to Alias Schema Properties when Session startup takes considerable time */
204:            private boolean _showSessionStartupTimeHint = true;
205:
206:            /** Show DEBUG log messages in the log viewer */
207:            private boolean _showDebugLogMessages = true;
208:
209:            /** Show INFO log messages in the log viewer */
210:            private boolean _showInfoLogMessages = true;
211:
212:            /** Show ERROR log messages in the log viewer */
213:            private boolean _showErrorLogMessages = true;
214:
215:            /** Always save preferences immediately when they change, instead of at shutdown */
216:            private boolean _savePreferencesImmediately = true;
217:
218:            /** Object to handle property change events. */
219:            private transient PropertyChangeReporter _propChgReporter;
220:
221:            /**
222:             * Default ctor.
223:             */
224:            public SquirrelPreferences() {
225:                super ();
226:                loadDefaults();
227:            }
228:
229:            public void addPropertyChangeListener(
230:                    PropertyChangeListener listener) {
231:                getPropertyChangeReporter().addPropertyChangeListener(listener);
232:            }
233:
234:            public void removePropertyChangeListener(
235:                    PropertyChangeListener listener) {
236:                getPropertyChangeReporter().removePropertyChangeListener(
237:                        listener);
238:            }
239:
240:            public String getNewSessionView() {
241:                return _newSessionView;
242:            }
243:
244:            public synchronized void setNewSessionView(String data) {
245:                if (((data == null) && (_newSessionView != null))
246:                        || (data != null) && !data.equals(_newSessionView)) {
247:                    final String oldValue = _newSessionView;
248:                    _newSessionView = data;
249:                    getPropertyChangeReporter().firePropertyChange(
250:                            IPropertyNames.NEW_SESSION_VIEW, oldValue,
251:                            _newSessionView);
252:                }
253:            }
254:
255:            public SessionProperties getSessionProperties() {
256:                return _sessionProps;
257:            }
258:
259:            public synchronized void setSessionProperties(SessionProperties data) {
260:                if (_sessionProps != data) {
261:                    final SessionProperties oldValue = _sessionProps;
262:                    _sessionProps = data;
263:                    getPropertyChangeReporter().firePropertyChange(
264:                            IPropertyNames.SESSION_PROPERTIES, oldValue,
265:                            _sessionProps);
266:                }
267:            }
268:
269:            public MainFrameWindowState getMainFrameWindowState() {
270:                return _mainFrameState;
271:            }
272:
273:            // TODO: Only set if changed
274:            public synchronized void setMainFrameWindowState(
275:                    MainFrameWindowState data) {
276:                final MainFrameWindowState oldValue = _mainFrameState;
277:                _mainFrameState = data;
278:                getPropertyChangeReporter().firePropertyChange(
279:                        IPropertyNames.MAIN_FRAME_STATE, oldValue,
280:                        _mainFrameState);
281:            }
282:
283:            public boolean getShowContentsWhenDragging() {
284:                return _showContentsWhenDragging;
285:            }
286:
287:            public synchronized void setShowContentsWhenDragging(boolean data) {
288:                if (data != _showContentsWhenDragging) {
289:                    final boolean oldValue = _showContentsWhenDragging;
290:                    _showContentsWhenDragging = data;
291:                    getPropertyChangeReporter().firePropertyChange(
292:                            IPropertyNames.SHOW_CONTENTS_WHEN_DRAGGING,
293:                            oldValue, _showContentsWhenDragging);
294:                }
295:            }
296:
297:            public boolean getShowMainStatusBar() {
298:                return _showMainStatusBar;
299:            }
300:
301:            public synchronized void setShowMainStatusBar(boolean data) {
302:                if (data != _showMainStatusBar) {
303:                    final boolean oldValue = _showMainStatusBar;
304:                    _showMainStatusBar = data;
305:                    getPropertyChangeReporter().firePropertyChange(
306:                            IPropertyNames.SHOW_MAIN_STATUS_BAR, oldValue,
307:                            _showMainStatusBar);
308:                }
309:            }
310:
311:            public boolean getShowMainToolBar() {
312:                return _showMainToolBar;
313:            }
314:
315:            public synchronized void setShowMainToolBar(boolean data) {
316:                if (data != _showMainToolBar) {
317:                    final boolean oldValue = _showMainToolBar;
318:                    _showMainToolBar = data;
319:                    getPropertyChangeReporter().firePropertyChange(
320:                            IPropertyNames.SHOW_MAIN_TOOL_BAR, oldValue,
321:                            _showMainToolBar);
322:                }
323:            }
324:
325:            public boolean getShowAliasesToolBar() {
326:                return _showAliasesToolBar;
327:            }
328:
329:            public synchronized void setShowAliasesToolBar(boolean data) {
330:                if (data != _showAliasesToolBar) {
331:                    final boolean oldValue = _showAliasesToolBar;
332:                    _showAliasesToolBar = data;
333:                    getPropertyChangeReporter().firePropertyChange(
334:                            IPropertyNames.SHOW_ALIASES_TOOL_BAR, oldValue,
335:                            _showAliasesToolBar);
336:                }
337:            }
338:
339:            public boolean getShowDriversToolBar() {
340:                return _showDriversToolBar;
341:            }
342:
343:            public synchronized void setShowDriversToolBar(boolean data) {
344:                if (data != _showDriversToolBar) {
345:                    final boolean oldValue = _showDriversToolBar;
346:                    _showDriversToolBar = data;
347:                    getPropertyChangeReporter().firePropertyChange(
348:                            IPropertyNames.SHOW_DRIVERS_TOOL_BAR, oldValue,
349:                            _showDriversToolBar);
350:                }
351:            }
352:
353:            public boolean getShowColoriconsInToolbar() {
354:                return _showColorIconsInToolbars;
355:            }
356:
357:            public synchronized void setShowColoriconsInToolbar(boolean data) {
358:                if (data != _showColorIconsInToolbars) {
359:                    final boolean oldValue = _showColorIconsInToolbars;
360:                    _showColorIconsInToolbars = data;
361:                    getPropertyChangeReporter().firePropertyChange(
362:                            IPropertyNames.SHOW_COLOR_ICONS_IN_TOOLBAR,
363:                            oldValue, _showColorIconsInToolbars);
364:                }
365:            }
366:
367:            public boolean getShowPluginFilesInSplashScreen() {
368:                return _showPluginFilesInSplashScreen;
369:            }
370:
371:            public synchronized void setShowPluginFilesInSplashScreen(
372:                    boolean data) {
373:                if (data != _showPluginFilesInSplashScreen) {
374:                    final boolean oldValue = _showPluginFilesInSplashScreen;
375:                    _showPluginFilesInSplashScreen = data;
376:                    getPropertyChangeReporter().firePropertyChange(
377:                            IPropertyNames.SHOW_PLUGIN_FILES_IN_SPLASH_SCREEN,
378:                            oldValue, _showPluginFilesInSplashScreen);
379:                }
380:            }
381:
382:            public int getLoginTimeout() {
383:                return _loginTimeout;
384:            }
385:
386:            public synchronized void setLoginTimeout(int data) {
387:                if (data != _loginTimeout) {
388:                    final int oldValue = _loginTimeout;
389:                    _loginTimeout = data;
390:                    getPropertyChangeReporter().firePropertyChange(
391:                            IPropertyNames.LOGIN_TIMEOUT, oldValue,
392:                            _loginTimeout);
393:                }
394:            }
395:
396:            public int getLargeScriptStmtCount() {
397:                return _largeScriptStmtCount;
398:            }
399:
400:            public synchronized void setLargeScriptStmtCount(int count) {
401:                if (count != _largeScriptStmtCount) {
402:                    final int oldValue = _largeScriptStmtCount;
403:                    _largeScriptStmtCount = count;
404:                    getPropertyChangeReporter().firePropertyChange(
405:                            IPropertyNames.LARGE_SCRIPT_STMT_COUNT, oldValue,
406:                            _largeScriptStmtCount);
407:                }
408:            }
409:
410:            public int getJdbcDebugType() {
411:                return _jdbcDebugType;
412:            }
413:
414:            public synchronized void setJdbcDebugType(int data) {
415:                if (data < IJdbcDebugTypes.NONE
416:                        || data > IJdbcDebugTypes.TO_WRITER) {
417:                    throw new IllegalArgumentException(
418:                            "Invalid setDebugJdbcToStream of :" + data);
419:                }
420:
421:                if (data != _jdbcDebugType) {
422:                    final int oldValue = _jdbcDebugType;
423:                    _jdbcDebugType = data;
424:                    getPropertyChangeReporter().firePropertyChange(
425:                            IPropertyNames.JDBC_DEBUG_TYPE, oldValue,
426:                            _jdbcDebugType);
427:                }
428:            }
429:
430:            public boolean getShowToolTips() {
431:                return _showToolTips;
432:            }
433:
434:            public synchronized void setShowToolTips(boolean data) {
435:                if (data != _showToolTips) {
436:                    final boolean oldValue = _showToolTips;
437:                    _showToolTips = data;
438:                    getPropertyChangeReporter().firePropertyChange(
439:                            IPropertyNames.SHOW_TOOLTIPS, oldValue,
440:                            _showToolTips);
441:                }
442:            }
443:
444:            public boolean getUseScrollableTabbedPanes() {
445:                return _useScrollableTabbedPanes;
446:            }
447:
448:            public synchronized void setUseScrollableTabbedPanes(boolean data) {
449:                if (data != _useScrollableTabbedPanes) {
450:                    final boolean oldValue = _useScrollableTabbedPanes;
451:                    _useScrollableTabbedPanes = data;
452:                    getPropertyChangeReporter().firePropertyChange(
453:                            IPropertyNames.SCROLLABLE_TABBED_PANES, oldValue,
454:                            _useScrollableTabbedPanes);
455:                }
456:            }
457:
458:            public boolean getMaximizeSessionSheetOnOpen() {
459:                return _maxSessionSheetOnOpen;
460:            }
461:
462:            public synchronized void setMaximizeSessionSheetOnOpen(boolean data) {
463:                if (data != _maxSessionSheetOnOpen) {
464:                    final boolean oldValue = _maxSessionSheetOnOpen;
465:                    _maxSessionSheetOnOpen = data;
466:                    getPropertyChangeReporter().firePropertyChange(
467:                            IPropertyNames.MAXIMIMIZE_SESSION_SHEET_ON_OPEN,
468:                            oldValue, _maxSessionSheetOnOpen);
469:                }
470:            }
471:
472:            public ActionKeys[] getActionKeys() {
473:                return _actionsKeys;
474:            }
475:
476:            public ActionKeys getActionKeys(int idx) {
477:                return _actionsKeys[idx];
478:            }
479:
480:            // TODO: Only set if changed? May not be practical.
481:            public synchronized void setActionKeys(ActionKeys[] data) {
482:                final ActionKeys[] oldValue = _actionsKeys;
483:                _actionsKeys = data != null ? data : new ActionKeys[0];
484:                getPropertyChangeReporter().firePropertyChange(
485:                        IPropertyNames.ACTION_KEYS, oldValue, _actionsKeys);
486:            }
487:
488:            // TODO: Only set if changed? May not be practical.
489:            public void setActionKeys(int idx, ActionKeys value) {
490:                final ActionKeys[] oldValue = _actionsKeys;
491:                _actionsKeys[idx] = value;
492:                getPropertyChangeReporter().firePropertyChange(
493:                        IPropertyNames.ACTION_KEYS, oldValue, _actionsKeys);
494:            }
495:
496:            public synchronized PluginStatus[] getPluginStatuses() {
497:                final PluginStatus[] ar = new PluginStatus[_pluginStatusInfoColl
498:                        .size()];
499:                return _pluginStatusInfoColl.toArray(ar);
500:            }
501:
502:            public PluginStatus getPluginStatus(int idx) {
503:                return _pluginStatusInfoColl.get(idx);
504:            }
505:
506:            // TODO: Only set if changed? May not be practical.
507:            public synchronized void setPluginStatuses(PluginStatus[] data) {
508:                if (data == null) {
509:                    data = new PluginStatus[0];
510:                }
511:
512:                PluginStatus[] oldValue = new PluginStatus[_pluginStatusInfoColl
513:                        .size()];
514:                oldValue = _pluginStatusInfoColl.toArray(oldValue);
515:                _pluginStatusInfoColl.clear();
516:                _pluginStatusInfoColl.addAll(Arrays.asList(data));
517:                getPropertyChangeReporter().firePropertyChange(
518:                        IPropertyNames.PLUGIN_STATUSES, oldValue, data);
519:            }
520:
521:            // TODO: Only set if changed? May not be practical.
522:            public synchronized void setPluginStatus(int idx, PluginStatus value) {
523:                _pluginStatusInfoColl.ensureCapacity(idx + 1);
524:                final PluginStatus oldValue = _pluginStatusInfoColl.get(idx);
525:                ;
526:                _pluginStatusInfoColl.set(idx, value);
527:                getPropertyChangeReporter().firePropertyChange(
528:                        IPropertyNames.PLUGIN_STATUSES, oldValue, value);
529:            }
530:
531:            /**
532:             * Retrieve the proxy settings. Note that this method returns a clone
533:             * of the actual proxy settings used.
534:             *
535:             * @return	<TT>ProxySettings</TT> object.
536:             */
537:            public ProxySettings getProxySettings() {
538:                return (ProxySettings) _proxySettings.clone();
539:            }
540:
541:            // TODO: Only set if changed
542:            public synchronized void setProxySettings(ProxySettings data) {
543:                if (data == null) {
544:                    data = new ProxySettings();
545:                }
546:                final ProxySettings oldValue = _proxySettings;
547:                _proxySettings = data;
548:                getPropertyChangeReporter().firePropertyChange(
549:                        IPropertyNames.PROXY, oldValue, _proxySettings);
550:            }
551:
552:            /**
553:             * Retrieve the index of the selected alias in the aliases window.
554:             *
555:             * @return	the index of the selected alias in the aliases window
556:             * 			or -1 if none selected.
557:             */
558:            public int getAliasesSelectedIndex() {
559:                return _aliasesSelectedIndex;
560:            }
561:
562:            /**
563:             * Set the index of the selected alias.
564:             *
565:             * @param	idx	the index of the selected alias in the aliases window
566:             * 				or -1 if none selected.
567:             */
568:            public synchronized void setAliasesSelectedIndex(int idx) {
569:                if (idx != _aliasesSelectedIndex) {
570:                    final int oldValue = _aliasesSelectedIndex;
571:                    _aliasesSelectedIndex = idx;
572:                    getPropertyChangeReporter().firePropertyChange(
573:                            IPropertyNames.ALIASES_SELECTED_INDEX, oldValue,
574:                            _aliasesSelectedIndex);
575:                }
576:            }
577:
578:            /**
579:             * Retrieve the index of the selected driver in the drivers window.
580:             *
581:             * @return	the index of the selected driver in the drivers window
582:             * 			or -1 if none selected.
583:             */
584:            public int getDriversSelectedIndex() {
585:                return _driversSelectedIndex;
586:            }
587:
588:            /**
589:             * Set the index of the selected driver.
590:             *
591:             * @param	idx	the index of the selected driver in the drivers window
592:             * 				or -1 if none selected.
593:             */
594:            public synchronized void setDriversSelectedIndex(int idx) {
595:                if (idx != _driversSelectedIndex) {
596:                    final int oldValue = _driversSelectedIndex;
597:                    _driversSelectedIndex = idx;
598:                    getPropertyChangeReporter().firePropertyChange(
599:                            IPropertyNames.DRIVERS_SELECTED_INDEX, oldValue,
600:                            _driversSelectedIndex);
601:                }
602:            }
603:
604:            /**
605:             * @return	whether only the loaded JDBC drivers are displayed in the
606:             *			Drivers window.
607:             */
608:            public boolean getShowLoadedDriversOnly() {
609:                return _showLoadedDriversOnly;
610:            }
611:
612:            /**
613:             * Set whether only the loaded JDBC drivers are displayed in the
614:             * Drivers window.
615:             *
616:             * @param	data	New value for this property.
617:             */
618:            public synchronized void setShowLoadedDriversOnly(boolean data) {
619:                if (data != _showLoadedDriversOnly) {
620:                    final boolean oldValue = _showLoadedDriversOnly;
621:                    _showLoadedDriversOnly = data;
622:                    getPropertyChangeReporter().firePropertyChange(
623:                            IPropertyNames.SHOW_LOADED_DRIVERS_ONLY, oldValue,
624:                            _showLoadedDriversOnly);
625:                }
626:            }
627:
628:            /**
629:             * Is this the first time SQuirreL has been run?
630:             *
631:             * @return	<tt>true</tt> if this is the first time SQuirreL has been run
632:             *			else <tt>false</tt>.
633:             */
634:            public boolean isFirstRun() {
635:                return _firstRun;
636:            }
637:
638:            public synchronized void setFirstRun(boolean data) {
639:                if (data != _firstRun) {
640:                    final boolean oldValue = _firstRun;
641:                    _firstRun = data;
642:                    getPropertyChangeReporter().firePropertyChange(
643:                            IPropertyNames.FIRST_RUN, oldValue, _firstRun);
644:                }
645:            }
646:
647:            /**
648:             * Should user confirm whether sessions should be closed.
649:             *
650:             * @return	<tt>true</tt> if user should have to confirm session close
651:             *			else <tt>false</tt>.
652:             */
653:            public boolean getConfirmSessionClose() {
654:                return _confirmSessionClose;
655:            }
656:
657:            public synchronized void setConfirmSessionClose(boolean data) {
658:                if (data != _confirmSessionClose) {
659:                    final boolean oldValue = _confirmSessionClose;
660:                    _confirmSessionClose = data;
661:                    getPropertyChangeReporter().firePropertyChange(
662:                            IPropertyNames.CONFIRM_SESSION_CLOSE, oldValue,
663:                            _confirmSessionClose);
664:                }
665:            }
666:
667:            public boolean isFileOpenInPreviousDir() {
668:                return _fileOpenInPreviousDir;
669:            }
670:
671:            public synchronized void setFileOpenInPreviousDir(boolean data) {
672:                if (data != _fileOpenInPreviousDir) {
673:                    final boolean oldValue = _fileOpenInPreviousDir;
674:                    _fileOpenInPreviousDir = data;
675:                    getPropertyChangeReporter().firePropertyChange(
676:                            IPropertyNames.FILE_OPEN_IN_PREVIOUS_DIR, oldValue,
677:                            _fileOpenInPreviousDir);
678:                }
679:            }
680:
681:            public boolean isFileOpenInSpecifiedDir() {
682:                return _fileOpenInSpecifiedDir;
683:            }
684:
685:            public synchronized void setFileOpenInSpecifiedDir(boolean data) {
686:                if (data != _fileOpenInSpecifiedDir) {
687:                    final boolean oldValue = _fileOpenInSpecifiedDir;
688:                    _fileOpenInSpecifiedDir = data;
689:                    getPropertyChangeReporter().firePropertyChange(
690:                            IPropertyNames.FILE_OPEN_IN_SPECIFIED_DIR,
691:                            oldValue, _fileOpenInSpecifiedDir);
692:                }
693:            }
694:
695:            public String getFileSpecifiedDir() {
696:                return _fileSpecifiedDir;
697:            }
698:
699:            public synchronized void setFileSpecifiedDir(String data) {
700:                if (false == ("" + data).equals(_fileSpecifiedDir)) {
701:                    final String oldValue = _fileSpecifiedDir;
702:                    _fileSpecifiedDir = data;
703:                    getPropertyChangeReporter().firePropertyChange(
704:                            IPropertyNames.FILE_SPECIFIED_DIR, oldValue,
705:                            _fileSpecifiedDir);
706:                }
707:            }
708:
709:            public String getFilePreviousDir() {
710:                return _filePreviousDir;
711:            }
712:
713:            public synchronized void setFilePreviousDir(String data) {
714:                if (false == ("" + data).equals(_filePreviousDir)) {
715:                    final String oldValue = _filePreviousDir;
716:                    _filePreviousDir = data;
717:                    getPropertyChangeReporter().firePropertyChange(
718:                            IPropertyNames.FILE_PREVIOUS_DIR, oldValue,
719:                            _filePreviousDir);
720:                }
721:            }
722:
723:            /**
724:             * Helper method.
725:             */
726:            public boolean isJdbcDebugToStream() {
727:                return _jdbcDebugType == IJdbcDebugTypes.TO_STREAM;
728:            }
729:
730:            /**
731:             * Helper method.
732:             */
733:            public boolean isJdbcDebugToWriter() {
734:                return _jdbcDebugType == IJdbcDebugTypes.TO_WRITER;
735:            }
736:
737:            /**
738:             * Helper method.
739:             */
740:            public boolean isJdbcDebugDontDebug() {
741:                return !(isJdbcDebugToStream() || isJdbcDebugToWriter());
742:            }
743:
744:            /**
745:             * Helper method.
746:             */
747:            public void doJdbcDebugToStream() {
748:                setJdbcDebugType(IJdbcDebugTypes.TO_STREAM);
749:            }
750:
751:            /**
752:             * Helper method.
753:             */
754:            public void doJdbcDebugToWriter() {
755:                setJdbcDebugType(IJdbcDebugTypes.TO_WRITER);
756:            }
757:
758:            /**
759:             * Helper method.
760:             */
761:            public void dontDoJdbcDebug() {
762:                setJdbcDebugType(IJdbcDebugTypes.NONE);
763:            }
764:
765:            @SuppressWarnings("unchecked")
766:            public static SquirrelPreferences load() {
767:                File prefsFile = new ApplicationFiles()
768:                        .getUserPreferencesFile();
769:                try {
770:                    XMLBeanReader doc = new XMLBeanReader();
771:                    doc.load(prefsFile);
772:                    Iterator it = doc.iterator();
773:                    if (it.hasNext()) {
774:                        return (SquirrelPreferences) it.next();
775:
776:                    }
777:                } catch (FileNotFoundException ignore) {
778:                    // property file not found for user - first time user ran pgm.
779:                } catch (Exception ex) {
780:                    s_log.error(s_stringMgr.getString(
781:                            "SquirrelPreferences.error.reading", prefsFile
782:                                    .getPath()), ex);
783:                }
784:                return new SquirrelPreferences();
785:            }
786:
787:            /**
788:             * Save preferences to disk.
789:             */
790:            public synchronized void save() {
791:                File prefsFile = new ApplicationFiles()
792:                        .getUserPreferencesFile();
793:                try {
794:                    XMLBeanWriter wtr = new XMLBeanWriter(this );
795:                    wtr.save(prefsFile);
796:                } catch (Exception ex) {
797:                    s_log.error(s_stringMgr.getString(
798:                            "SquirrelPreferences.error.writing", prefsFile
799:                                    .getPath()), ex);
800:                }
801:            }
802:
803:            private void loadDefaults() {
804:                if (_loginTimeout == -1) {
805:                    _loginTimeout = DriverManager.getLoginTimeout();
806:                }
807:            }
808:
809:            private synchronized PropertyChangeReporter getPropertyChangeReporter() {
810:                if (_propChgReporter == null) {
811:                    _propChgReporter = new PropertyChangeReporter(this );
812:                }
813:                return _propChgReporter;
814:            }
815:
816:            /**
817:             * @param data The _warnJreJdbcMismatch to set.
818:             */
819:            public synchronized void setWarnJreJdbcMismatch(boolean data) {
820:                if (data != _warnJreJdbcMismatch) {
821:                    final boolean oldValue = _warnJreJdbcMismatch;
822:                    _warnJreJdbcMismatch = data;
823:                    getPropertyChangeReporter().firePropertyChange(
824:                            IPropertyNames.WARN_JRE_JDBC_MISMATCH, oldValue,
825:                            _warnJreJdbcMismatch);
826:                }
827:            }
828:
829:            /**
830:             * @return Returns the _warnJreJdbcMismatch.
831:             */
832:            public boolean getWarnJreJdbcMismatch() {
833:                return _warnJreJdbcMismatch;
834:            }
835:
836:            /**
837:             * @param data The _warnForUnsaveFileEdits to set.
838:             */
839:            public synchronized void setWarnForUnsavedFileEdits(boolean data) {
840:                if (data != _warnForUnsavedFileEdits) {
841:                    final boolean oldValue = _warnForUnsavedFileEdits;
842:                    _warnForUnsavedFileEdits = data;
843:                    getPropertyChangeReporter().firePropertyChange(
844:                            IPropertyNames.WARN_FOR_UNSAVED_FILE_EDITS,
845:                            oldValue, _warnForUnsavedFileEdits);
846:                }
847:            }
848:
849:            /**
850:             * @return Returns the _warnForUnsaveFileEdits.
851:             */
852:            public boolean getWarnForUnsavedFileEdits() {
853:                return _warnForUnsavedFileEdits;
854:            }
855:
856:            /**
857:             * @param data The _warnForUnsavedBufferEdits to set.
858:             */
859:            public synchronized void setWarnForUnsavedBufferEdits(boolean data) {
860:                if (data != _warnForUnsavedBufferEdits) {
861:                    final boolean oldValue = _warnForUnsavedBufferEdits;
862:                    _warnForUnsavedBufferEdits = data;
863:                    getPropertyChangeReporter().firePropertyChange(
864:                            IPropertyNames.WARN_FOR_UNSAVED_BUFFER_EDITS,
865:                            oldValue, _warnForUnsavedBufferEdits);
866:                }
867:            }
868:
869:            /**
870:             * @return Returns the _warnForUnsaveFileEdits.
871:             */
872:            public boolean getWarnForUnsavedBufferEdits() {
873:                return _warnForUnsavedBufferEdits;
874:            }
875:
876:            /**
877:             * @param data The _warnForUnsavedBufferEdits to set.
878:             */
879:            public synchronized void setShowSessionStartupTimeHint(boolean data) {
880:                if (data != _showSessionStartupTimeHint) {
881:                    final boolean oldValue = _showSessionStartupTimeHint;
882:                    _showSessionStartupTimeHint = data;
883:                    getPropertyChangeReporter().firePropertyChange(
884:                            IPropertyNames.SHOW_SESSION_STARTUP_TIME_HINT,
885:                            oldValue, _showSessionStartupTimeHint);
886:                }
887:            }
888:
889:            /**
890:             * @return Returns the _warnForUnsaveFileEdits.
891:             */
892:            public boolean getShowSessionStartupTimeHint() {
893:                return _showSessionStartupTimeHint;
894:            }
895:
896:            /**
897:             * @param data The _warnForUnsavedBufferEdits to set.
898:             */
899:            public synchronized void setShowDebugLogMessages(boolean data) {
900:                if (data != _showDebugLogMessages) {
901:                    final boolean oldValue = _showDebugLogMessages;
902:                    _showDebugLogMessages = data;
903:                    getPropertyChangeReporter().firePropertyChange(
904:                            IPropertyNames.SHOW_DEBUG_LOG_MESSAGES, oldValue,
905:                            _showDebugLogMessages);
906:                }
907:            }
908:
909:            /**
910:             * @return Returns the _warnForUnsaveFileEdits.
911:             */
912:            public boolean getShowDebugLogMessage() {
913:                return _showDebugLogMessages;
914:            }
915:
916:            /**
917:             * @param data the _showInfoLogMessages to set
918:             */
919:            public void setShowInfoLogMessages(boolean data) {
920:                if (data != _showInfoLogMessages) {
921:                    final boolean oldValue = _showInfoLogMessages;
922:                    _showInfoLogMessages = data;
923:                    getPropertyChangeReporter().firePropertyChange(
924:                            IPropertyNames.SHOW_INFO_LOG_MESSAGES, oldValue,
925:                            _showInfoLogMessages);
926:                }
927:            }
928:
929:            /**
930:             * @return the _showInfoLogMessages
931:             */
932:            public boolean getShowInfoLogMessages() {
933:                return _showInfoLogMessages;
934:            }
935:
936:            /**
937:             * @param data the _showErrorLogMessages to set
938:             */
939:            public void setShowErrorLogMessages(boolean data) {
940:                if (data != _showErrorLogMessages) {
941:                    final boolean oldValue = _showErrorLogMessages;
942:                    _showErrorLogMessages = data;
943:                    getPropertyChangeReporter().firePropertyChange(
944:                            IPropertyNames.SHOW_ERROR_LOG_MESSAGES, oldValue,
945:                            _showErrorLogMessages);
946:                }
947:            }
948:
949:            /**
950:             * @return the _showErrorLogMessages
951:             */
952:            public boolean getShowErrorLogMessages() {
953:                return _showErrorLogMessages;
954:            }
955:
956:            /**
957:             * @param data the _savePreferencesImmediately to set
958:             */
959:            public void setSavePreferencesImmediately(boolean data) {
960:                if (data != _showErrorLogMessages) {
961:                    final boolean oldValue = _savePreferencesImmediately;
962:                    _savePreferencesImmediately = data;
963:                    getPropertyChangeReporter().firePropertyChange(
964:                            IPropertyNames.SAVE_PREFERENCES_IMMEDIATELY,
965:                            oldValue, _savePreferencesImmediately);
966:                }
967:            }
968:
969:            /**
970:             * @return the _showErrorLogMessages
971:             */
972:            public boolean getSavePreferencesImmediately() {
973:                return _savePreferencesImmediately;
974:            }
975:
976:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.