001: /*
002: * The contents of this file are subject to the Mozilla Public License
003: * Version 1.1 (the "License"); you may not use this file except in
004: * compliance with the License. You may obtain a copy of the License at
005: * http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009: * License for the specific language governing rights and limitations
010: * under the License.
011: *
012: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013: *
014: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016: *
017: * Contributor(s):
018: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019: *
020: * If you didn't download this code from the following link, you should check
021: * if you aren't using an obsolete version: http://www.isqlviewer.com
022: */
023: package org.isqlviewer.ui;
024:
025: import java.awt.GridBagConstraints;
026: import java.awt.GridBagLayout;
027: import java.util.prefs.Preferences;
028:
029: import javax.swing.BorderFactory;
030: import javax.swing.Box;
031: import javax.swing.BoxLayout;
032: import javax.swing.JCheckBox;
033: import javax.swing.JComponent;
034: import javax.swing.JLabel;
035: import javax.swing.JMenuBar;
036: import javax.swing.JPanel;
037: import javax.swing.JSpinner;
038: import javax.swing.SpinnerNumberModel;
039:
040: import org.isqlviewer.sql.ConnectionProfile;
041: import org.isqlviewer.swing.action.SwingEventManager;
042: import org.isqlviewer.util.LocalMessages;
043:
044: /**
045: * @author Mark A. Kobold <mkobold at isqlviewer dot com>
046: * @version 1.0
047: */
048: public class ConnectionProfileEditor extends AbstractApplicationView {
049:
050: private LocalMessages messages = new LocalMessages(
051: "org.isqlviewer.ui.ResourceBundle");
052: private JComponent componentOwner = null;
053:
054: public void configureMenubar(JMenuBar menuBar) {
055:
056: }
057:
058: public void disposeView(Preferences preferences) {
059:
060: componentOwner.removeAll();
061: componentOwner = null;
062: }
063:
064: public void doLayout(JComponent parentComponent,
065: Preferences preferences, SwingEventManager eventManager) {
066:
067: this .componentOwner = parentComponent;
068: parentComponent.setLayout(new BoxLayout(parentComponent,
069: BoxLayout.Y_AXIS));
070:
071: JPanel panel = new JPanel();
072: panel.setLayout(new GridBagLayout());
073: GridBagConstraints constraint = null;
074: String title = messages
075: .format("connection_profile.jdbc_options");
076: String tip = null;
077: JLabel label = null;
078: panel.setBorder(BorderFactory.createTitledBorder(BorderFactory
079: .createLoweredBevelBorder(), title));
080:
081: title = messages.format("connection_profile.maximum_rows");
082: tip = messages.format("connection_profile.maximum_rows.tip");
083: JComponent component = new JSpinner();
084: ((JSpinner) component).setModel(new SpinnerNumberModel(0, 0,
085: Integer.MAX_VALUE, 1));
086: ((JSpinner) component).setEditor(new JSpinner.NumberEditor(
087: (JSpinner) component));
088: component.setName(ConnectionProfile.JDBC_MAX_ROWS);
089: component.setToolTipText(tip);
090: constraint = constrain(0, 0, 1, 1, 0.0, 0.0,
091: GridBagConstraints.WEST, GridBagConstraints.NONE);
092: label = new JLabel(title);
093: label.setLabelFor(component);
094: panel.add(label, constraint);
095: constraint = constrain(1, 0, 1, 1, 1.0, 0.0,
096: GridBagConstraints.CENTER,
097: GridBagConstraints.HORIZONTAL);
098: panel.add(component, constraint);
099:
100: title = messages
101: .format("connection_profile.maximum_field_size");
102: tip = messages
103: .format("connection_profile.maximum_field_size.tip");
104: component = new JSpinner();
105: ((JSpinner) component).setModel(new SpinnerNumberModel(0, 0,
106: Integer.MAX_VALUE, 1));
107: ((JSpinner) component).setEditor(new JSpinner.NumberEditor(
108: (JSpinner) component));
109:
110: component.setName(ConnectionProfile.JDBC_MAX_FIELD_SIZE);
111: component.setToolTipText(tip);
112: constraint = constrain(0, 1, 1, 1, 0.0, 0.0,
113: GridBagConstraints.WEST, GridBagConstraints.NONE);
114: label = new JLabel(title);
115: label.setLabelFor(component);
116: panel.add(label, constraint);
117: constraint = constrain(1, 1, 1, 1, 1.0, 0.0,
118: GridBagConstraints.CENTER,
119: GridBagConstraints.HORIZONTAL);
120: panel.add(component, constraint);
121:
122: title = messages
123: .format("connection_profile.is_escape_processing");
124: tip = messages
125: .format("connection_profile.is_escape_processing.tip");
126: component = new JCheckBox(title);
127: component.setName(ConnectionProfile.JDBC_ESCAPE_PROC);
128: component.setToolTipText(tip);
129: constraint = constrain(0, 2, 2, 1, 1.0, 0.0,
130: GridBagConstraints.CENTER,
131: GridBagConstraints.HORIZONTAL);
132: panel.add(component, constraint);
133:
134: title = messages.format("connection_profile.tracing_enabled");
135: tip = messages.format("connection_profile.tracing_enabled.tip");
136: component = new JCheckBox(title);
137: component.setName(ConnectionProfile.JDBC_TRACE_ENABLED);
138: component.setToolTipText(tip);
139: constraint = constrain(0, 3, 2, 1, 1.0, 0.0,
140: GridBagConstraints.CENTER,
141: GridBagConstraints.HORIZONTAL);
142: panel.add(component, constraint);
143:
144: title = messages
145: .format("connection_profile.use_reverse_fetching");
146: tip = messages
147: .format("connection_profile.use_reverse_fetching.tip");
148: component = new JCheckBox(title);
149: component.setName(ConnectionProfile.JDBC_REVERSE_FETCHING);
150: component.setToolTipText(tip);
151: constraint = constrain(0, 4, 2, 1, 1.0, 0.0,
152: GridBagConstraints.CENTER,
153: GridBagConstraints.HORIZONTAL);
154: panel.add(component, constraint);
155:
156: title = messages
157: .format("connection_profile.generate_resultset_keys");
158: tip = messages
159: .format("connection_profile.generate_resultset_keys.tip");
160: component = new JCheckBox(title);
161: component.setName(ConnectionProfile.JDBC_GENERATE_KEYS);
162: component.setToolTipText(tip);
163: constraint = constrain(0, 5, 2, 1, 1.0, 0.0,
164: GridBagConstraints.CENTER,
165: GridBagConstraints.HORIZONTAL);
166: panel.add(component, constraint);
167:
168: component = (JComponent) Box.createVerticalGlue();
169: component.setName("GLUE");
170: component.setToolTipText(tip);
171: constraint = constrain(0, 6, 2, 1, 0.0, 1.0,
172: GridBagConstraints.CENTER, GridBagConstraints.VERTICAL);
173: panel.add(component, constraint);
174:
175: parentComponent.add(panel);
176: }
177:
178: public void initializeView() {
179:
180: }
181:
182: }
|