001: /*
002: * Copyright (C) 2007 Rob Manning
003: * manningr@users.sourceforge.net
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019: package net.sourceforge.squirrel_sql.plugins.oracle.prefs;
020:
021: import java.awt.GridBagConstraints;
022: import java.awt.Insets;
023:
024: import javax.swing.JCheckBox;
025: import javax.swing.JPanel;
026:
027: import net.sourceforge.squirrel_sql.client.plugin.PluginQueryTokenizerPreferencesManager;
028: import net.sourceforge.squirrel_sql.client.plugin.gui.PluginQueryTokenizerPreferencesPanel;
029: import net.sourceforge.squirrel_sql.fw.preferences.IQueryTokenizerPreferenceBean;
030: import net.sourceforge.squirrel_sql.fw.util.StringManager;
031: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
032:
033: /**
034: * Adds the preference widget for allowing the user to specify whether or not
035: * Oracle 10g recycle bin tables should be hidden.
036: *
037: * @author manningr
038: */
039: public class OraclePluginPreferencesPanel extends
040: PluginQueryTokenizerPreferencesPanel {
041:
042: private static final long serialVersionUID = 1L;
043:
044: /** Internationalized strings for this class. */
045: private static final StringManager s_stringMgr = StringManagerFactory
046: .getStringManager(OraclePluginPreferencesPanel.class);
047:
048: static interface i18n {
049: //i18n[OraclePluginPreferencesPanel.hideRecycleBinCheckBoxLabel=Remove
050: //Recycle Bin Tables from the Object Tree]
051: String HIDE_RECYCLE_BIN_CB_LABEL = s_stringMgr
052: .getString("OraclePluginPreferencesPanel.hideRecycleBinCheckBoxLabel");
053:
054: //i18n[OraclePluginPreferencesPanel.hideRecycleBinCheckBoxToolTip=Recycle
055: //Bin tables are a Flashback Database Option in Oracle 10g]
056: String HIDE_RECYCLE_BIN_CB_TT = s_stringMgr
057: .getString("OraclePluginPreferencesPanel.hideRecycleBinCheckBoxToolTip");
058:
059: //i18n[OraclePluginPreferencesPanel.showErrorOffsetLabel=Show Syntax
060: //Error Offset in SQL Editor]
061: String SHOW_ERROR_OFFSET_LABEL = s_stringMgr
062: .getString("OraclePluginPreferencesPanel.showErrorOffsetLabel");
063:
064: //i18n[OraclePluginPreferencesPanel.showErrorOffsetTT=Creates and uses a
065: //user-defined function that is used to determine the syntax error token]
066: String SHOW_ERROR_OFFSET_TT = s_stringMgr
067: .getString("OraclePluginPreferencesPanel.showErrorOffsetTT");
068: }
069:
070: /** The checkbox for specifying exclusion of recycle bin tables */
071: private final static JCheckBox excludeRecycleBinTablesCheckBox = new JCheckBox(
072: i18n.HIDE_RECYCLE_BIN_CB_LABEL);
073:
074: private final static JCheckBox showErrorOffsetCheckBox = new JCheckBox(
075: i18n.SHOW_ERROR_OFFSET_LABEL);
076:
077: /**
078: * Construct a new PreferencesPanel.
079: * @param prefs
080: * @param databaseName
081: */
082: public OraclePluginPreferencesPanel(
083: PluginQueryTokenizerPreferencesManager prefsMgr) {
084: super (prefsMgr, "Oracle");
085: }
086:
087: /**
088: * @see net.sourceforge.squirrel_sql.client.plugin.gui.PluginQueryTokenizerPreferencesPanel#createTopPanel()
089: */
090: @Override
091: protected JPanel createTopPanel() {
092: JPanel result = super .createTopPanel();
093: int lastY = super .lastY;
094: addRecycleBinCheckBox(result, 0, lastY++);
095: addShowErrorOffsetCheckBox(result, 0, lastY++);
096: return result;
097: }
098:
099: private void addRecycleBinCheckBox(JPanel result, int col, int row) {
100: GridBagConstraints c = new GridBagConstraints();
101: c.gridx = col;
102: c.gridy = row;
103: c.gridwidth = 2; // Span across two columns
104: c.anchor = GridBagConstraints.WEST;
105: c.insets = new Insets(5, 5, 0, 0);
106: excludeRecycleBinTablesCheckBox
107: .setToolTipText(i18n.HIDE_RECYCLE_BIN_CB_TT);
108: result.add(excludeRecycleBinTablesCheckBox, c);
109: }
110:
111: private void addShowErrorOffsetCheckBox(JPanel result, int col,
112: int row) {
113: GridBagConstraints c = new GridBagConstraints();
114: c.gridx = col;
115: c.gridy = row;
116: c.gridwidth = 2; // Span across two columns
117: c.anchor = GridBagConstraints.WEST;
118: c.insets = new Insets(5, 5, 0, 0);
119: showErrorOffsetCheckBox
120: .setToolTipText(i18n.SHOW_ERROR_OFFSET_TT);
121: result.add(showErrorOffsetCheckBox, c);
122: }
123:
124: /**
125: * @see net.sourceforge.squirrel_sql.client.plugin.gui.PluginQueryTokenizerPreferencesPanel#loadData()
126: */
127: @Override
128: protected void loadData() {
129: super .loadData();
130: IQueryTokenizerPreferenceBean prefs = _prefsManager
131: .getPreferences();
132: OraclePreferenceBean oraclePrefs = (OraclePreferenceBean) prefs;
133: excludeRecycleBinTablesCheckBox.setSelected(oraclePrefs
134: .isExcludeRecycleBinTables());
135: showErrorOffsetCheckBox.setSelected(oraclePrefs
136: .isShowErrorOffset());
137: }
138:
139: /**
140: * @see net.sourceforge.squirrel_sql.client.plugin.gui.PluginQueryTokenizerPreferencesPanel#save()
141: */
142: @Override
143: protected void save() {
144: IQueryTokenizerPreferenceBean prefs = _prefsManager
145: .getPreferences();
146: OraclePreferenceBean oraclePrefs = (OraclePreferenceBean) prefs;
147: oraclePrefs
148: .setExcludeRecycleBinTables(excludeRecycleBinTablesCheckBox
149: .isSelected());
150: oraclePrefs.setShowErrorOffset(showErrorOffsetCheckBox
151: .isSelected());
152: super.save();
153: }
154:
155: }
|