001: package net.sourceforge.squirrel_sql.client.session.properties;
002:
003: /*
004: * Copyright (C) 2001-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.Font;
022: import java.beans.PropertyChangeListener;
023: import java.io.Serializable;
024:
025: import javax.swing.SwingConstants;
026:
027: import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetViewerEditableTablePanel;
028: import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetViewerTablePanel;
029: import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetViewerTextPanel;
030: import net.sourceforge.squirrel_sql.fw.gui.FontInfo;
031: import net.sourceforge.squirrel_sql.fw.util.ISessionProperties;
032: import net.sourceforge.squirrel_sql.fw.util.PropertyChangeReporter;
033: import net.sourceforge.squirrel_sql.fw.util.StringUtilities;
034:
035: /**
036: * This class represents the settings for a session.
037: *
038: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
039: */
040: public class SessionProperties implements Cloneable, Serializable,
041: ISessionProperties {
042: public interface IDataSetDestinations {
043: String TEXT = DataSetViewerTextPanel.class.getName();
044: String READ_ONLY_TABLE = DataSetViewerTablePanel.class
045: .getName();
046: String EDITABLE_TABLE = DataSetViewerEditableTablePanel.class
047: .getName();
048: }
049:
050: public interface IPropertyNames {
051: String SQL_RESULT_TAB_LIMIT = "sqlResultTabLimit";
052: String ABORT_ON_ERROR = "abortOnError";
053: String WRITE_SQL_ERRORS_TO_LOG = "writeSQLErrorsToLog";
054: String LOAD_COLUMNS_IN_BACKGROUND = "loadColumnsInBackground";
055: String AUTO_COMMIT = "autoCommit";
056: String CATALOG_PREFIX_LIST = "catalogPrefixList";
057: String COMMIT_ON_CLOSING_CONNECTION = "commitOnClosingConnection";
058: String CONTENTS_LIMIT_ROWS = "contentsLimitRows";
059: String CONTENTS_NBR_ROWS_TO_SHOW = "contentsNbrOfRowsToShow";
060: String FONT_INFO = "fontInfo";
061: String OBJECT_FILTER = "objectFilter";
062: String LARGE_RESULT_SET_OBJECT_INFO = "largeResultSetObjectInfo";
063: String LIMIT_SQL_ENTRY_HISTORY_SIZE = "limitSqlEntryHistorySize";
064: String LOAD_SCHEMAS_CATALOGS = "loadCatalogsSchemas";
065: String MAIN_TAB_PLACEMENT = "mainTabPlacement";
066: String META_DATA_OUTPUT_CLASS_NAME = "metaDataOutputClassName";
067: String OBJECT_TAB_PLACEMENT = "objectTabPlacement";
068: String SCHEMA_PREFIX_LIST = "schemaPrefixList";
069: String SQL_ENTRY_HISTORY_SIZE = "sqlEntryHistorySize";
070: String SHOW_RESULTS_META_DATA = "showResultsMetaData";
071: String SHOW_ROW_COUNT = "showRowCount";
072: String SHOW_TOOL_BAR = "showToolBar";
073: String SQL_SHARE_HISTORY = "sqlShareHistory";
074: String SQL_EXECUTION_TAB_PLACEMENT = "sqlExecutionTabPlacement";
075: String SQL_RESULTS_TAB_PLACEMENT = "sqlResultsTabPlacement";
076: String SQL_LIMIT_ROWS = "sqlLimitRows";
077: String SQL_NBR_ROWS_TO_SHOW = "sqlNbrOfRowsToShow";
078: String SQL_RESULTS_OUTPUT_CLASS_NAME = "sqlResultsOutputClassName";
079: String SQL_START_OF_LINE_COMMENT = "sqlStartOfLineComment";
080: String SQL_STATEMENT_SEPARATOR_STRING = "sqlStatementSeparatorString";
081: String TABLE_CONTENTS_OUTPUT_CLASS_NAME = "tableContentsOutputClassName";
082: String LIMIT_SQL_RESULT_TABS = "limitSqlResultTabs";
083: String REMOVE_MULTI_LINE_COMMENT = "removeMultiLineComment";
084: }
085:
086: private static final FontInfo DEFAULT_FONT_INFO = new FontInfo(
087: new Font("Monospaced", 0, 12));
088:
089: /** Object to handle property change events. */
090: private transient PropertyChangeReporter _propChgReporter;
091:
092: private boolean _autoCommit = true;
093: private int _contentsNbrRowsToShow = 100;
094: private int _sqlNbrRowsToShow = 100;
095:
096: /**
097: * If <CODE>true</CODE> then issue a commit when closing a connection
098: * else issue a rollback. This property is only valid if the
099: * connection is not in auto-commit mode.
100: */
101: private boolean _commitOnClosingConnection = false;
102:
103: private boolean _contentsLimitRows = true;
104: private boolean _sqlLimitRows = true;
105:
106: /**
107: * <CODE>true</CODE> if schemas and catalogs should be loaded in the object
108: * tree.
109: */
110: private boolean _loadSchemasCatalogs = true;
111:
112: /** Limit schema objects to those in this comma-delimited list. */
113: private String _schemaPrefixList = "";
114:
115: /** Limit catalog objects to those in this comma-delimited list. */
116: private String _catalogPrefixList = "";
117:
118: /** Object Filter */
119:
120: private String _objectFilter = "";
121:
122: /** <TT>true</TT> if sql result meta data should be shown. */
123: private boolean _showResultsMetaData = true;
124:
125: /** Name of class to use for metadata output. */
126: private String _metaDataOutputClassName = IDataSetDestinations.READ_ONLY_TABLE;
127:
128: /** Name of class to use for SQL results output. */
129: // private String _sqlOutputMetaDataClassName = IDataSetDestinations.READ_ONLY_TABLE;
130: /** Name of class to use for table contsnts output. */
131: private String _tableContentsClassName = IDataSetDestinations.READ_ONLY_TABLE;
132:
133: /**
134: * The display class for the SQL results may be either editable or read-only.
135: * The functions accessing this must use the appropriate getter to be sure
136: * of getting either the selection made by the user in the Session Properties
137: * or the read-only or the editable version.
138: */
139: private String _sqlResultsOutputClassName = IDataSetDestinations.READ_ONLY_TABLE;
140:
141: /**
142: * <TT>true</TT> if row count should be displayed for every table in object tree.
143: */
144: private boolean _showRowCount = false;
145:
146: /** <TT>true</TT> if toolbar should be shown. */
147: private boolean _showToolbar = true;
148:
149: /** Used to separate SQL multiple statements. */
150: private String _sqlStmtSep = ";";
151:
152: /** Used to indicate a "Start Of Line" comment in SQL. */
153: private String _solComment = "--";
154:
155: private boolean _removeMultiLineComment = true;
156:
157: /** Font information for the SQL entry area. */
158: private FontInfo _fi = (FontInfo) DEFAULT_FONT_INFO.clone();
159:
160: /** Should the number of SQL statements to save in execution history be limited?. */
161: private boolean _limitSqlEntryHistorySize = true;
162:
163: /**
164: * Does this session share its SQL History with other sessions?
165: */
166: private boolean _sqlShareHistory = true;
167:
168: /**
169: * Number of SQL statements to save in execution history. Only applicable
170: * if <TT>_limitSqlEntryHistorySize</TT> is true.
171: */
172: private int _sqlEntryHistorySize = 100;
173:
174: /** Placement of main tabs. See javax.swing.SwingConstants for valid values. */
175: private int _mainTabPlacement = SwingConstants.TOP;
176:
177: /**
178: * Placement of tabs displayed when an object selected in the object
179: * tree. See javax.swing.SwingConstants for valid values.
180: */
181: private int _objectTabPlacement = SwingConstants.TOP;
182:
183: /**
184: * Placement of tabs displayed for SQL execution.
185: * See javax.swing.SwingConstants for valid values.
186: */
187: private int _sqlExecutionTabPlacement = SwingConstants.TOP;
188:
189: /**
190: * Placement of tabs displayed for SQL execution results.
191: * See javax.swing.SwingConstants for valid values.
192: */
193: private int _sqlResultsTabPlacement = SwingConstants.TOP;
194:
195: /**
196: * If <TT>true</TT> then don't execute any further SQL if an error occurs in one.
197: */
198: private boolean _abortOnError = true;
199:
200: /**
201: * If <TT>true</TT> SQL Errors are written to Log.
202: */
203: private boolean _writeSQLErrorsToLog;
204:
205: /**
206: * @see net.sourceforge.squirrel_sql.client.session.schemainfo.SchemaInfo.loadColumns()
207: */
208: private boolean _loadColumnsInBackground;
209:
210: /** Should the number of SQL result tabs be limited?. */
211: private boolean _limitSqlResultTabs = true;
212:
213: /**
214: * The maximum number of open result tabs.
215: * <= 0 means unlimited.
216: */
217: private int _sqlResultTabLimit = 15;
218:
219: /**
220: * Default ctor.
221: */
222: public SessionProperties() {
223: super ();
224: }
225:
226: /**
227: * Return a copy of this object.
228: */
229: public Object clone() {
230: try {
231: SessionProperties props = (SessionProperties) super .clone();
232: props._propChgReporter = null;
233: if (_fi != null) {
234: props.setFontInfo((FontInfo) _fi.clone());
235: }
236:
237: return props;
238: } catch (CloneNotSupportedException ex) {
239: throw new InternalError(ex.getMessage()); // Impossible.
240: }
241: }
242:
243: /**
244: * Normally we display data using the class selected by the user in the
245: * Session Preferences, but there are occasions in which the application
246: * needs to override the user selection and explicitly use either a read-only
247: * or an editable table. These functions provide access to those class names.
248: */
249: public String getReadOnlyTableOutputClassName() {
250: return IDataSetDestinations.READ_ONLY_TABLE;
251: }
252:
253: public String getEditableTableOutputClassName() {
254: return IDataSetDestinations.EDITABLE_TABLE;
255: }
256:
257: /**
258: * Get the name of the read-only form of the user-selected preference,
259: * which may be TEXT or READ_ONLY_TABLE. The user may have selected
260: * EDITABLE_TABLE, but the caller wants to get the read-only version
261: * (because it does not know how to handle and changes the user makes,
262: * e.g. because the data represents a multi-table join).
263: */
264: public String getReadOnlySQLResultsOutputClassName() {
265: if (_sqlResultsOutputClassName
266: .equals(IDataSetDestinations.EDITABLE_TABLE))
267: return IDataSetDestinations.READ_ONLY_TABLE;
268: return _sqlResultsOutputClassName;
269: }
270:
271: public void addPropertyChangeListener(
272: PropertyChangeListener listener) {
273: getPropertyChangeReporter().addPropertyChangeListener(listener);
274: }
275:
276: public void removePropertyChangeListener(
277: PropertyChangeListener listener) {
278: getPropertyChangeReporter().removePropertyChangeListener(
279: listener);
280: }
281:
282: public String getMetaDataOutputClassName() {
283: return _metaDataOutputClassName;
284: }
285:
286: public void setMetaDataOutputClassName(String value) {
287: if (value == null) {
288: value = "";
289: }
290: if (!_metaDataOutputClassName.equals(value)) {
291: final String oldValue = _metaDataOutputClassName;
292: _metaDataOutputClassName = value;
293: getPropertyChangeReporter().firePropertyChange(
294: IPropertyNames.META_DATA_OUTPUT_CLASS_NAME,
295: oldValue, _metaDataOutputClassName);
296: }
297: }
298:
299: public String getTableContentsOutputClassName() {
300: return _tableContentsClassName;
301: }
302:
303: public void setTableContentsOutputClassName(String value) {
304: if (value == null) {
305: value = "";
306: }
307: if (!_tableContentsClassName.equals(value)) {
308: final String oldValue = _tableContentsClassName;
309: _tableContentsClassName = value;
310: getPropertyChangeReporter().firePropertyChange(
311: IPropertyNames.TABLE_CONTENTS_OUTPUT_CLASS_NAME,
312: oldValue, _tableContentsClassName);
313: }
314: }
315:
316: /**
317: * Get the type of output display selected by the user in the
318: * Session Properties, which may be text, read-only table, or editable table;
319: * the caller must be able to handle any of those (especially editable).
320: */
321: public String getSQLResultsOutputClassName() {
322: return _sqlResultsOutputClassName;
323: }
324:
325: /**
326: * Set the type of output display to user selection, which may be
327: * text, read-only table, or editable table. This is called
328: * when the user makes a selection, and also when loading the
329: * preferences object from the saved data during Squirrel startup.
330: */
331: public void setSQLResultsOutputClassName(String value) {
332: if (value == null) {
333: value = "";
334: }
335: if (!_sqlResultsOutputClassName.equals(value)) {
336: final String oldValue = _sqlResultsOutputClassName;
337: _sqlResultsOutputClassName = value;
338: getPropertyChangeReporter().firePropertyChange(
339: IPropertyNames.SQL_RESULTS_OUTPUT_CLASS_NAME,
340: oldValue, _sqlResultsOutputClassName);
341: }
342: }
343:
344: /**
345: * Force a re-build of the GUI when a user makes a table
346: * temporarily editable. The situation is that the current
347: * SessionProperties _tableContentsClassName is a read-only
348: * class (either table or text) and the user has requested that
349: * the information be made editable.
350: * This can only be requested in the ContentsTab
351: * and only when the sqlResults is read-only.
352: * We make the table editable by:
353: * - setting the underlying data model (e.g. ContentsTab) so that it
354: * internally overrides the SessionProperties when getting the
355: * output class name, and
356: * - telling the listeners that the SessionProperties have changed.
357: * This function is called by the underlying data model to tell the
358: * listeners to update the GUI. This is done by pretending that the
359: * SessionPropertied have just changed from being EDITABLE_TABLE to
360: * some read-only class. (We know that the current value of the
361: * _tableContentsClassName is a read-only class.)
362: *
363: * This is not a very nice way to cause the interface to be updated,
364: * but it was the simplest one that I could find. GWG 10/30/02
365: *
366: * CB TODO: (Move this elsewhere).
367: */
368: // public void forceTableContentsOutputClassNameChange()
369: // {
370: // // We need the old value and the new value to be different, or the
371: // // listeners will ignore our property change request (and not rebuild
372: // // the GUI). We know that the current output class is a read-only one
373: // // because this function is only called when the user requests that a
374: // // single table be made editable.
375: // final String oldValue = _tableContentsClassName;
376: // getPropertyChangeReporter().firePropertyChange(
377: // IPropertyNames.TABLE_CONTENTS_OUTPUT_CLASS_NAME,
378: // IDataSetDestinations.EDITABLE_TABLE,
379: // oldValue);
380: // }
381: public boolean getAutoCommit() {
382: return _autoCommit;
383: }
384:
385: public void setAutoCommit(boolean value) {
386: if (_autoCommit != value) {
387: _autoCommit = value;
388: getPropertyChangeReporter().firePropertyChange(
389: IPropertyNames.AUTO_COMMIT, !_autoCommit,
390: _autoCommit);
391: }
392: }
393:
394: public boolean getAbortOnError() {
395: return _abortOnError;
396: }
397:
398: public void setAbortOnError(boolean value) {
399: if (_abortOnError != value) {
400: _abortOnError = value;
401: getPropertyChangeReporter().firePropertyChange(
402: IPropertyNames.ABORT_ON_ERROR, !_abortOnError,
403: _abortOnError);
404: }
405: }
406:
407: public boolean getWriteSQLErrorsToLog() {
408: return _writeSQLErrorsToLog;
409: }
410:
411: public void setWriteSQLErrorsToLog(boolean value) {
412: if (_writeSQLErrorsToLog != value) {
413: _writeSQLErrorsToLog = value;
414: getPropertyChangeReporter().firePropertyChange(
415: IPropertyNames.WRITE_SQL_ERRORS_TO_LOG,
416: !_writeSQLErrorsToLog, _writeSQLErrorsToLog);
417: }
418: }
419:
420: public boolean getLoadColumnsInBackground() {
421: return _loadColumnsInBackground;
422: }
423:
424: public void setLoadColumnsInBackground(boolean value) {
425: if (_loadColumnsInBackground != value) {
426: _loadColumnsInBackground = value;
427: getPropertyChangeReporter()
428: .firePropertyChange(
429: IPropertyNames.LOAD_COLUMNS_IN_BACKGROUND,
430: !_loadColumnsInBackground,
431: _loadColumnsInBackground);
432: }
433: }
434:
435: public boolean getLimitSQLResultTabs() {
436: return _limitSqlResultTabs;
437: }
438:
439: public void setLimitSQLResultTabs(boolean data) {
440: final boolean oldValue = _limitSqlResultTabs;
441: _limitSqlResultTabs = data;
442: getPropertyChangeReporter().firePropertyChange(
443: IPropertyNames.LIMIT_SQL_RESULT_TABS, oldValue,
444: _limitSqlResultTabs);
445: }
446:
447: public int getSqlResultTabLimit() {
448: return _sqlResultTabLimit;
449: }
450:
451: public void setSqlResultTabLimit(int value) {
452: if (_sqlResultTabLimit != value) {
453: int oldValue = _sqlResultTabLimit;
454: _sqlResultTabLimit = value;
455: getPropertyChangeReporter().firePropertyChange(
456: IPropertyNames.SQL_RESULT_TAB_LIMIT, oldValue,
457: _sqlResultTabLimit);
458: }
459: }
460:
461: public boolean getShowToolBar() {
462: return _showToolbar;
463: }
464:
465: public void setShowToolBar(boolean value) {
466: if (_showToolbar != value) {
467: _showToolbar = value;
468: getPropertyChangeReporter().firePropertyChange(
469: IPropertyNames.SHOW_TOOL_BAR, !_showToolbar,
470: _showToolbar);
471: }
472: }
473:
474: public int getContentsNbrRowsToShow() {
475: return _contentsNbrRowsToShow;
476: }
477:
478: public void setContentsNbrRowsToShow(int value) {
479: if (_contentsNbrRowsToShow != value) {
480: final int oldValue = _contentsNbrRowsToShow;
481: _contentsNbrRowsToShow = value;
482: getPropertyChangeReporter().firePropertyChange(
483: IPropertyNames.CONTENTS_NBR_ROWS_TO_SHOW, oldValue,
484: _contentsNbrRowsToShow);
485: }
486: }
487:
488: public int getSQLNbrRowsToShow() {
489: return _sqlNbrRowsToShow;
490: }
491:
492: public void setSQLNbrRowsToShow(int value) {
493: if (_sqlNbrRowsToShow != value) {
494: final int oldValue = _sqlNbrRowsToShow;
495: _sqlNbrRowsToShow = value;
496: getPropertyChangeReporter().firePropertyChange(
497: IPropertyNames.SQL_NBR_ROWS_TO_SHOW, oldValue,
498: _sqlNbrRowsToShow);
499: }
500: }
501:
502: public boolean getContentsLimitRows() {
503: return _contentsLimitRows;
504: }
505:
506: public void setContentsLimitRows(boolean value) {
507: if (_contentsLimitRows != value) {
508: final boolean oldValue = _contentsLimitRows;
509: _contentsLimitRows = value;
510: getPropertyChangeReporter().firePropertyChange(
511: IPropertyNames.CONTENTS_LIMIT_ROWS, oldValue,
512: _contentsLimitRows);
513: }
514: }
515:
516: public boolean getSQLLimitRows() {
517: return _sqlLimitRows;
518: }
519:
520: public void setSQLLimitRows(boolean value) {
521: if (_sqlLimitRows != value) {
522: final boolean oldValue = _sqlLimitRows;
523: _sqlLimitRows = value;
524: getPropertyChangeReporter().firePropertyChange(
525: IPropertyNames.SQL_LIMIT_ROWS, oldValue,
526: _sqlLimitRows);
527: }
528: }
529:
530: /**
531: * Retrieve the string used to separate multiple SQL statements. Possible
532: * examples are ";" or "GO";
533: *
534: * @return String used to separate SQL statements.
535: */
536: public String getSQLStatementSeparator() {
537: return _sqlStmtSep;
538: }
539:
540: /**
541: * Set the string used to separate multiple SQL statements. Possible
542: * examples are ";" or "GO";
543: *
544: * @param value Separator string.
545: */
546: public void setSQLStatementSeparator(String value) {
547: // It causes a lot of pain in serveral places to cope with nulls or
548: // emptys here.
549: if (null == value || 0 == value.trim().length()) {
550: value = ";";
551: }
552:
553: if (!_sqlStmtSep.equals(value)) {
554: final String oldValue = _sqlStmtSep;
555: _sqlStmtSep = value;
556: getPropertyChangeReporter().firePropertyChange(
557: IPropertyNames.SQL_STATEMENT_SEPARATOR_STRING,
558: oldValue, _sqlStmtSep);
559: }
560: }
561:
562: public boolean getCommitOnClosingConnection() {
563: return _commitOnClosingConnection;
564: }
565:
566: public synchronized void setCommitOnClosingConnection(boolean data) {
567: final boolean oldValue = _commitOnClosingConnection;
568: _commitOnClosingConnection = data;
569: getPropertyChangeReporter().firePropertyChange(
570: IPropertyNames.COMMIT_ON_CLOSING_CONNECTION, oldValue,
571: _commitOnClosingConnection);
572: }
573:
574: /**
575: * Return <TT>true</TT> if row count should be displayed for every table in
576: * object tree.
577: */
578: public boolean getShowRowCount() {
579: return _showRowCount;
580: }
581:
582: /**
583: * Specify whether row count should be displayed for every table in
584: * object tree.
585: *
586: * @param data <TT>true</TT> fi row count should be displayed
587: * else <TT>false</TT>.
588: */
589: public synchronized void setShowRowCount(boolean data) {
590: final boolean oldValue = _showRowCount;
591: _showRowCount = data;
592: getPropertyChangeReporter().firePropertyChange(
593: IPropertyNames.SHOW_ROW_COUNT, oldValue, _showRowCount);
594: }
595:
596: /**
597: * Return the string used to represent a Start of Line Comment in SQL.
598: */
599: public String getStartOfLineComment() {
600: return _solComment;
601: }
602:
603: /**
604: * Set the string used to represent a Start of Line Comment in SQL.
605: */
606: public synchronized void setStartOfLineComment(String data) {
607: final String oldValue = _solComment;
608: _solComment = data;
609: getPropertyChangeReporter().firePropertyChange(
610: IPropertyNames.SQL_START_OF_LINE_COMMENT, oldValue,
611: _solComment);
612: }
613:
614: public boolean getRemoveMultiLineComment() {
615: return _removeMultiLineComment;
616: }
617:
618: public synchronized void setRemoveMultiLineComment(boolean data) {
619: final boolean oldValue = _removeMultiLineComment;
620: _removeMultiLineComment = data;
621: getPropertyChangeReporter().firePropertyChange(
622: IPropertyNames.REMOVE_MULTI_LINE_COMMENT, oldValue,
623: _removeMultiLineComment);
624: }
625:
626: public FontInfo getFontInfo() {
627: return _fi;
628: }
629:
630: public void setFontInfo(FontInfo data) {
631: if (_fi == null || !_fi.equals(data)) {
632: final FontInfo oldValue = _fi;
633: _fi = data != null ? data : (FontInfo) DEFAULT_FONT_INFO
634: .clone();
635: getPropertyChangeReporter().firePropertyChange(
636: IPropertyNames.FONT_INFO, oldValue, _fi);
637: }
638: }
639:
640: public boolean getLimitSQLEntryHistorySize() {
641: return _limitSqlEntryHistorySize;
642: }
643:
644: public void setLimitSQLEntryHistorySize(boolean data) {
645: final boolean oldValue = _limitSqlEntryHistorySize;
646: _limitSqlEntryHistorySize = data;
647: getPropertyChangeReporter().firePropertyChange(
648: IPropertyNames.LIMIT_SQL_ENTRY_HISTORY_SIZE, oldValue,
649: _limitSqlEntryHistorySize);
650: }
651:
652: /**
653: * Does this session share its SQL History with other sessions?
654: *
655: * @return <TT>true</TT> if this session shares its history.
656: */
657: public boolean getSQLShareHistory() {
658: return _sqlShareHistory;
659: }
660:
661: /**
662: * Set whether this session shares its SQL History with other sessions.
663: *
664: * @param data <TT>true</TT> if this session shares its history.
665: */
666: public void setSQLShareHistory(boolean data) {
667: final boolean oldValue = _sqlShareHistory;
668: _sqlShareHistory = data;
669: getPropertyChangeReporter().firePropertyChange(
670: IPropertyNames.SQL_SHARE_HISTORY, oldValue,
671: _sqlShareHistory);
672: }
673:
674: public int getSQLEntryHistorySize() {
675: return _sqlEntryHistorySize;
676: }
677:
678: public void setSQLEntryHistorySize(int data) {
679: final int oldValue = _sqlEntryHistorySize;
680: _sqlEntryHistorySize = data;
681: getPropertyChangeReporter().firePropertyChange(
682: IPropertyNames.SQL_ENTRY_HISTORY_SIZE, oldValue,
683: _sqlEntryHistorySize);
684: }
685:
686: public int getMainTabPlacement() {
687: return _mainTabPlacement;
688: }
689:
690: public void setMainTabPlacement(int value) {
691: if (_mainTabPlacement != value) {
692: final int oldValue = _mainTabPlacement;
693: _mainTabPlacement = value;
694: getPropertyChangeReporter().firePropertyChange(
695: IPropertyNames.MAIN_TAB_PLACEMENT, oldValue,
696: _mainTabPlacement);
697: }
698: }
699:
700: public int getObjectTabPlacement() {
701: return _objectTabPlacement;
702: }
703:
704: public void setObjectTabPlacement(int value) {
705: if (_objectTabPlacement != value) {
706: final int oldValue = _objectTabPlacement;
707: _objectTabPlacement = value;
708: getPropertyChangeReporter().firePropertyChange(
709: IPropertyNames.OBJECT_TAB_PLACEMENT, oldValue,
710: _objectTabPlacement);
711: }
712: }
713:
714: public int getSQLExecutionTabPlacement() {
715: return _sqlExecutionTabPlacement;
716: }
717:
718: public void setSQLExecutionTabPlacement(int value) {
719: if (_sqlExecutionTabPlacement != value) {
720: final int oldValue = _sqlExecutionTabPlacement;
721: _sqlExecutionTabPlacement = value;
722: getPropertyChangeReporter().firePropertyChange(
723: IPropertyNames.SQL_EXECUTION_TAB_PLACEMENT,
724: oldValue, _sqlExecutionTabPlacement);
725: }
726: }
727:
728: public int getSQLResultsTabPlacement() {
729: return _sqlResultsTabPlacement;
730: }
731:
732: public void setSQLResultsTabPlacement(int value) {
733: if (_sqlResultsTabPlacement != value) {
734: // if(value == SwingConstants.BOTTOM)
735: // {
736: // // Some way this property slipt into older Property files but it was never
737: // // used earlier. We use this little (ugly) trick to keep users being confused by
738: // // a bottom tab placing. This was introduced for 1.2 beta 7.
739: // // TODO: Remove some time later
740: // if(Preferences.userRoot().getBoolean("Squirrel.TabPlacementCorrectionONFirstStartOf1_2_beta7", true))
741: // {
742: // value = SwingConstants.TOP;
743: // Preferences.userRoot().putBoolean("Squirrel.TabPlacementCorrectionONFirstStartOf1_2_beta7", false);
744: // }
745: // }
746:
747: final int oldValue = _sqlResultsTabPlacement;
748: _sqlResultsTabPlacement = value;
749: getPropertyChangeReporter().firePropertyChange(
750: IPropertyNames.SQL_RESULTS_TAB_PLACEMENT, oldValue,
751: _sqlResultsTabPlacement);
752: }
753: }
754:
755: /**
756: * Return comma-separated list of schema prefixes to display in the object
757: * tree.
758: */
759: public String getSchemaPrefixList() {
760: return _schemaPrefixList;
761: }
762:
763: /**
764: * Return array of schema prefixes to display in the object tree.
765: */
766: public String[] getSchemaPrefixArray() {
767: return StringUtilities.split(_schemaPrefixList, ',', true);
768: }
769:
770: /**
771: * Set the comma-separated list of schema prefixes to display in the object tree.
772: */
773: public synchronized void setSchemaPrefixList(String data) {
774: final String oldValue = _schemaPrefixList;
775: _schemaPrefixList = data;
776: getPropertyChangeReporter().firePropertyChange(
777: IPropertyNames.SCHEMA_PREFIX_LIST, oldValue,
778: _schemaPrefixList);
779: }
780:
781: /**
782: * Return comma-separated catalog of schema prefixes to display in the
783: * object tree.
784: */
785: public String getCatalogPrefixList() {
786: return _catalogPrefixList;
787: }
788:
789: public String getObjectFilter() {
790: return _objectFilter;
791: }
792:
793: /**
794: * Return array of catalog prefixes to display in the object tree.
795: */
796: public String[] getCatalogPrefixArray() {
797: return StringUtilities.split(_catalogPrefixList, ',', true);
798: }
799:
800: /**
801: * Set the comma-separated list of catalog prefixes to display in the object tree.
802: */
803: public synchronized void setCatalogPrefixList(String data) {
804: final String oldValue = _catalogPrefixList;
805: _catalogPrefixList = data;
806: getPropertyChangeReporter().firePropertyChange(
807: IPropertyNames.CATALOG_PREFIX_LIST, oldValue,
808: _catalogPrefixList);
809: }
810:
811: /**
812: * Set the objectFilter
813: */
814:
815: public synchronized void setObjectFilter(String data) {
816: final String oldValue = _objectFilter;
817: _objectFilter = data;
818: getPropertyChangeReporter().firePropertyChange(
819: IPropertyNames.OBJECT_FILTER, oldValue, _objectFilter);
820: }
821:
822: /**
823: * Return <CODE>true</CODE> if schemas and catalogs should be loaded into
824: * the object tree.
825: */
826: public boolean getLoadSchemasCatalogs() {
827: return _loadSchemasCatalogs;
828: }
829:
830: /**
831: * Set <CODE>true</CODE> if schemas and catalogs should be loaded into the
832: * object tree.
833: */
834: public synchronized void setLoadSchemasCatalogs(boolean data) {
835: final boolean oldValue = _loadSchemasCatalogs;
836: _loadSchemasCatalogs = data;
837: getPropertyChangeReporter().firePropertyChange(
838: IPropertyNames.LOAD_SCHEMAS_CATALOGS, oldValue,
839: _loadSchemasCatalogs);
840: }
841:
842: /**
843: * Set <CODE>true</CODE> if sql results meta data should be loaded.
844: */
845: public synchronized void setShowResultsMetaData(boolean data) {
846: final boolean oldValue = _showResultsMetaData;
847: _showResultsMetaData = data;
848: getPropertyChangeReporter().firePropertyChange(
849: IPropertyNames.SHOW_RESULTS_META_DATA, oldValue,
850: _showResultsMetaData);
851: }
852:
853: /**
854: * Return <CODE>true</CODE> if sql results meta data should be loaded.
855: */
856: public boolean getShowResultsMetaData() {
857: return _showResultsMetaData;
858: }
859:
860: private synchronized PropertyChangeReporter getPropertyChangeReporter() {
861: if (_propChgReporter == null) {
862: _propChgReporter = new PropertyChangeReporter(this);
863: }
864: return _propChgReporter;
865: }
866: }
|