001: package net.sourceforge.squirrel_sql.plugins.sqlval;
002:
003: /*
004: * Copyright (C) 2002-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.GridBagConstraints;
022: import java.awt.GridBagLayout;
023: import java.awt.Insets;
024:
025: import javax.swing.BorderFactory;
026: import javax.swing.JCheckBox;
027: import javax.swing.JLabel;
028: import javax.swing.JPanel;
029:
030: import net.sourceforge.squirrel_sql.fw.gui.OutputLabel;
031: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
032: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
033: import net.sourceforge.squirrel_sql.fw.util.StringManager;
034: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
035:
036: class SessionSettingsPanel extends JPanel {
037: private static final StringManager s_stringMgr = StringManagerFactory
038: .getStringManager(SessionSettingsPanel.class);
039:
040: /** Logger for this class. */
041: private final static ILogger s_log = LoggerController
042: .createLogger(SessionSettingsPanel.class);
043:
044: /** Preferences object. */
045: private final WebServicePreferences _prefs;
046:
047: /** Session properties object. */
048: private final WebServiceSessionProperties _sessionProps;
049:
050: /** Use anonymous DBMS. */
051: // i18n[sqlval.settingsAnon=Anonymous]
052: private JCheckBox _anonDBMSChk = new JCheckBox(s_stringMgr
053: .getString("sqlval.settingsAnon"));
054:
055: /** DBMS name. */
056: private OutputLabel _dbmsNameLbl = new OutputLabel(" ");
057:
058: /** DBMS version. */
059: private OutputLabel _dbmsVersionLbl = new OutputLabel(" ");
060:
061: /** Technology name. */
062: private OutputLabel _techNameLbl = new OutputLabel(" ");
063:
064: /** Technology version. */
065: private OutputLabel _techVersionLbl = new OutputLabel(" ");
066:
067: SessionSettingsPanel(WebServicePreferences prefs,
068: WebServiceSessionProperties sessionProps) {
069: super (new GridBagLayout());
070:
071: if (prefs == null) {
072: throw new IllegalArgumentException(
073: "WebServicePreferences == null");
074: }
075: if (sessionProps == null) {
076: throw new IllegalArgumentException(
077: "WebServiceSessionProperties == null");
078: }
079:
080: _prefs = prefs;
081: _sessionProps = sessionProps;
082: createGUI();
083: loadData();
084: }
085:
086: void loadData() {
087: _anonDBMSChk.setSelected(_sessionProps.getUseAnonymousDBMS());
088: _dbmsNameLbl.setText(_sessionProps.getTargetDBMSName());
089: _dbmsVersionLbl.setText(_sessionProps.getTargetDBMSVersion());
090: _techNameLbl.setText(_sessionProps.getConnectionTechnology());
091: _techVersionLbl.setText(_sessionProps
092: .getConnectionTechnologyVersion());
093: }
094:
095: /**
096: * Save panel contents to perferences.
097: */
098: void save() {
099: _sessionProps.setUseAnonymousDBMS(_anonDBMSChk.isSelected());
100: }
101:
102: /**
103: * Create this panel.
104: */
105: private void createGUI() {
106: setBorder(BorderFactory.createEmptyBorder(1, 4, 1, 4));
107:
108: final GridBagConstraints gbc = new GridBagConstraints();
109: gbc.fill = GridBagConstraints.HORIZONTAL;
110: gbc.insets = new Insets(1, 4, 1, 4);
111: gbc.gridx = 0;
112: gbc.gridy = 0;
113: add(createDBMSPanel(), gbc);
114: }
115:
116: /**
117: * This creates the panel containing the DBMS information.
118: *
119: * @return New panel.
120: */
121: private JPanel createDBMSPanel() {
122: JPanel pnl = new JPanel();
123: // i18n[sqlval.dbms=DBMS]
124: pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr
125: .getString("sqlval.dbms")));
126:
127: pnl.setLayout(new GridBagLayout());
128: final GridBagConstraints gbc = new GridBagConstraints();
129: gbc.fill = GridBagConstraints.HORIZONTAL;
130: gbc.insets = new Insets(2, 4, 2, 4);
131:
132: gbc.gridx = 0;
133: gbc.gridy = 0;
134: gbc.gridwidth = 1;
135: gbc.gridheight = 1;
136: gbc.anchor = GridBagConstraints.NORTHWEST;
137: pnl.add(_anonDBMSChk, gbc);
138:
139: ++gbc.gridy;
140: // i18n[sqlval.dbmsName=DBMS Name:]
141: pnl.add(new JLabel(s_stringMgr.getString("sqlval.dbmsName"),
142: JLabel.RIGHT), gbc);
143:
144: ++gbc.gridy;
145: // i18n[sqlval.dbmsVersion=DBMS Version:]
146: pnl.add(new JLabel(s_stringMgr.getString("sqlval.dbmsVersion"),
147: JLabel.RIGHT), gbc);
148:
149: ++gbc.gridy;
150: // i18n[sqlval.technology=Technology:]
151: pnl.add(new JLabel(s_stringMgr.getString("sqlval.technology"),
152: JLabel.RIGHT), gbc);
153:
154: ++gbc.gridy;
155: // i18n[sqlval.technologyVersion=Technology Version:]
156: pnl.add(new JLabel(s_stringMgr
157: .getString("sqlval.technologyVersion"), JLabel.RIGHT),
158: gbc);
159:
160: gbc.gridx = 1;
161: gbc.gridy = 1;
162: gbc.weightx = 1;
163: pnl.add(_dbmsNameLbl, gbc);
164:
165: ++gbc.gridy;
166: pnl.add(_dbmsVersionLbl, gbc);
167:
168: ++gbc.gridy;
169: pnl.add(_techNameLbl, gbc);
170:
171: ++gbc.gridy;
172: pnl.add(_techVersionLbl, gbc);
173:
174: return pnl;
175: }
176: }
|