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.wizards.service;
024:
025: import static java.awt.GridBagConstraints.CENTER;
026: import static java.awt.GridBagConstraints.HORIZONTAL;
027: import static java.awt.GridBagConstraints.NONE;
028: import static java.awt.GridBagConstraints.VERTICAL;
029: import static java.awt.GridBagConstraints.WEST;
030:
031: import java.awt.Container;
032: import java.awt.GridBagLayout;
033: import java.awt.event.ActionEvent;
034: import java.awt.event.ActionListener;
035:
036: import javax.swing.Box;
037: import javax.swing.JCheckBox;
038: import javax.swing.JLabel;
039: import javax.swing.JPanel;
040: import javax.swing.JScrollPane;
041: import javax.swing.JTextField;
042:
043: import org.isqlviewer.sql.ConnectionProfile;
044: import org.isqlviewer.sql.JdbcService;
045: import org.isqlviewer.swing.SwingUtilities;
046: import org.isqlviewer.ui.wizards.AbstractWizardStep;
047: import org.isqlviewer.ui.wizards.WizardContext;
048: import org.isqlviewer.util.LocalMessages;
049:
050: public class ServiceProfileOptions extends AbstractWizardStep implements
051: ActionListener {
052:
053: private LocalMessages messages = new LocalMessages(
054: ServiceWizard.BUNDLE_NAME);
055: private JTextField preferredSchema = new JTextField();
056: private JTextField preferredCatalog = new JTextField();
057: private JCheckBox secureCredentials = new JCheckBox();
058: private JCheckBox serviceDebugging = new JCheckBox();
059: private JCheckBox escapeProcessing = new JCheckBox();
060: private JCheckBox generateKeys = new JCheckBox();
061:
062: public void actionPerformed(ActionEvent event) {
063:
064: }
065:
066: @Override
067: public void activate(WizardContext context) {
068:
069: super .activate(context);
070: JdbcService service = (JdbcService) context
071: .getAttribute(ServiceWizard.ATTRIBUTE_SERVICE);
072: if (service == null) {
073: return;
074: }
075:
076: ConnectionProfile profile = service.getProfile();
077: preferredCatalog.setText(profile.getPreferredCatalog());
078: preferredSchema.setText(profile.getPreferredSchema());
079: secureCredentials.setSelected(profile.isCredentialsSecure());
080: serviceDebugging.setSelected(profile.isDebuggingEnabled());
081: escapeProcessing.setSelected(profile.isEscapeProcessing());
082: generateKeys.setSelected(profile.isResultsetKeys());
083: }
084:
085: public boolean isFirst() {
086:
087: return false;
088: }
089:
090: public boolean isLast() {
091:
092: return false;
093: }
094:
095: @Override
096: public void init(WizardContext context) {
097:
098: super .init(context);
099: setTitle(messages.getMessage("ServiceProfileOptions.title"));
100: setComment(messages.getMessage("ServiceProfileOptions.tip"));
101: setImage(SwingUtilities.loadIconResource("options", 22));
102:
103: Container uiContainer = new JPanel(new GridBagLayout());
104: setView(new JScrollPane(uiContainer));
105:
106: String tip = null;
107: String title = null;
108: JLabel label = null;
109: Object constraint = null;
110:
111: tip = messages
112: .format("ServiceProfileOptions.preferred-catalog.tip");
113: title = messages
114: .format("ServiceProfileOptions.preferred-catalog.title");
115: preferredCatalog.setToolTipText(tip);
116: label = new JLabel(title);
117: label.setToolTipText(tip);
118: label.setLabelFor(preferredCatalog);
119: constraint = ServiceWizard.constrain(0, 0, 1, 1, 0.0, 0.0,
120: WEST, NONE);
121: uiContainer.add(label, constraint);
122: constraint = ServiceWizard.constrain(1, 0, 1, 1, 1.0, 0.0,
123: CENTER, HORIZONTAL);
124: uiContainer.add(preferredCatalog, constraint);
125:
126: tip = messages
127: .format("ServiceProfileOptions.preferred-schema.tip");
128: title = messages
129: .format("ServiceProfileOptions.preferred-schema.title");
130: preferredSchema.setToolTipText(tip);
131: label = new JLabel(title);
132: label.setToolTipText(tip);
133: label.setLabelFor(preferredSchema);
134: constraint = ServiceWizard.constrain(0, 1, 1, 1, 0.0, 0.0,
135: WEST, NONE);
136: uiContainer.add(label, constraint);
137: constraint = ServiceWizard.constrain(1, 1, 1, 1, 1.0, 0.0,
138: CENTER, HORIZONTAL);
139: uiContainer.add(preferredSchema, constraint);
140:
141: tip = messages
142: .format("ServiceProfileOptions.secure-credentials.tip");
143: title = messages
144: .format("ServiceProfileOptions.secure-credentials.title");
145: secureCredentials.setToolTipText(tip);
146: label = new JLabel(title);
147: label.setToolTipText(tip);
148: label.setLabelFor(secureCredentials);
149: constraint = ServiceWizard.constrain(0, 2, 1, 1, 0.0, 0.0,
150: WEST, NONE);
151: uiContainer.add(label, constraint);
152: constraint = ServiceWizard.constrain(1, 2, 1, 1, 1.0, 0.0,
153: CENTER, HORIZONTAL);
154: uiContainer.add(secureCredentials, constraint);
155:
156: tip = messages
157: .format("ServiceProfileOptions.service-debugging.tip");
158: title = messages
159: .format("ServiceProfileOptions.service-debugging.title");
160: serviceDebugging.setToolTipText(tip);
161: label = new JLabel(title);
162: label.setToolTipText(tip);
163: label.setLabelFor(serviceDebugging);
164: constraint = ServiceWizard.constrain(0, 3, 1, 1, 0.0, 0.0,
165: WEST, NONE);
166: uiContainer.add(label, constraint);
167: constraint = ServiceWizard.constrain(1, 3, 1, 1, 1.0, 0.0,
168: CENTER, HORIZONTAL);
169: uiContainer.add(serviceDebugging, constraint);
170:
171: tip = messages
172: .format("ServiceProfileOptions.escape-processing.tip");
173: title = messages
174: .format("ServiceProfileOptions.escape-processing.title");
175: escapeProcessing.setToolTipText(tip);
176: label = new JLabel(title);
177: label.setToolTipText(tip);
178: label.setLabelFor(escapeProcessing);
179: constraint = ServiceWizard.constrain(0, 4, 1, 1, 0.0, 0.0,
180: WEST, NONE);
181: uiContainer.add(label, constraint);
182: constraint = ServiceWizard.constrain(1, 4, 1, 1, 1.0, 0.0,
183: CENTER, HORIZONTAL);
184: uiContainer.add(escapeProcessing, constraint);
185:
186: tip = messages
187: .format("ServiceProfileOptions.generate-keys.tip");
188: title = messages
189: .format("ServiceProfileOptions.generate-keys.title");
190: generateKeys.setToolTipText(tip);
191: label = new JLabel(title);
192: label.setToolTipText(tip);
193: label.setLabelFor(generateKeys);
194: constraint = ServiceWizard.constrain(0, 5, 1, 1, 0.0, 0.0,
195: WEST, NONE);
196: uiContainer.add(label, constraint);
197: constraint = ServiceWizard.constrain(1, 5, 1, 1, 1.0, 0.0,
198: CENTER, HORIZONTAL);
199: uiContainer.add(generateKeys, constraint);
200:
201: constraint = ServiceWizard.constrain(0, 6, 2, 1, 1.0, 1.0,
202: CENTER, VERTICAL);
203: uiContainer.add(Box.createVerticalGlue(), constraint);
204: }
205:
206: public boolean isValid(WizardContext context) {
207:
208: JdbcService service = (JdbcService) context
209: .getAttribute(ServiceWizard.ATTRIBUTE_SERVICE);
210: if (service == null) {
211: return false;
212: }
213: ConnectionProfile profile = service.getProfile();
214: profile.setPreferredCatalog(preferredCatalog.getText());
215: profile.setPreferredSchema(preferredSchema.getText());
216: profile.setCredentialsSecure(secureCredentials.isSelected());
217: profile.setDebuggingEnabled(serviceDebugging.isSelected());
218: profile.setEscapeProcessing(escapeProcessing.isSelected());
219: profile.setResultsetKeys(generateKeys.isSelected());
220: return true;
221: }
222: }
|