0001: /*
0002: * ConnectionEditorPanel.java
0003: *
0004: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
0005: *
0006: * Copyright 2002-2008, Thomas Kellerer
0007: * No part of this code maybe reused without the permission of the author
0008: *
0009: * To contact the author please send an email to: support@sql-workbench.net
0010: *
0011: */
0012: package workbench.gui.profiles;
0013:
0014: import java.awt.Color;
0015: import java.awt.Component;
0016: import java.awt.Container;
0017: import java.awt.Dialog;
0018: import java.awt.EventQueue;
0019: import java.awt.Frame;
0020: import java.awt.event.ActionListener;
0021: import java.awt.event.ItemEvent;
0022: import java.beans.PropertyChangeEvent;
0023: import java.beans.PropertyChangeListener;
0024: import java.util.Collections;
0025: import java.util.Iterator;
0026: import java.util.LinkedList;
0027: import java.util.List;
0028: import java.util.Properties;
0029:
0030: import javax.swing.DefaultComboBoxModel;
0031: import javax.swing.JOptionPane;
0032: import javax.swing.JPanel;
0033: import javax.swing.JTextField;
0034: import javax.swing.SwingUtilities;
0035: import javax.swing.border.Border;
0036: import javax.swing.border.CompoundBorder;
0037: import javax.swing.border.EmptyBorder;
0038: import javax.swing.border.LineBorder;
0039:
0040: import workbench.db.ConnectionMgr;
0041: import workbench.db.ConnectionProfile;
0042: import workbench.db.DbDriver;
0043: import workbench.gui.WbSwingUtilities;
0044: import workbench.gui.components.BooleanPropertyEditor;
0045: import workbench.gui.components.DelimiterDefinitionPanel;
0046: import workbench.gui.components.FlatButton;
0047: import workbench.gui.components.IntegerPropertyEditor;
0048: import workbench.gui.components.PasswordPropertyEditor;
0049: import workbench.gui.components.StringPropertyEditor;
0050: import workbench.gui.components.TextComponentMouseListener;
0051: import workbench.gui.components.WbButton;
0052: import workbench.gui.components.WbCheckBoxLabel;
0053: import workbench.gui.components.WbColorPicker;
0054: import workbench.gui.components.WbTraversalPolicy;
0055: import workbench.gui.help.HelpManager;
0056: import workbench.interfaces.SimplePropertyEditor;
0057: import workbench.interfaces.ValidatingComponent;
0058: import workbench.log.LogMgr;
0059: import workbench.resource.ResourceMgr;
0060: import workbench.sql.DelimiterDefinition;
0061: import workbench.util.FileDialogUtil;
0062:
0063: /**
0064: *
0065: * @author support@sql-workbench.net
0066: */
0067: public class ConnectionEditorPanel extends JPanel implements
0068: PropertyChangeListener, ActionListener, ValidatingComponent {
0069: private ConnectionProfile currentProfile;
0070: private ProfileListModel sourceModel;
0071: private boolean init;
0072: private List<SimplePropertyEditor> editors;
0073:
0074: public ConnectionEditorPanel() {
0075: this .initComponents();
0076:
0077: WbTraversalPolicy policy = new WbTraversalPolicy();
0078: policy.addComponent(tfProfileName);
0079: policy.addComponent(cbDrivers);
0080: policy.addComponent(tfURL);
0081: policy.addComponent(tfUserName);
0082: policy.addComponent(tfPwd);
0083: policy.addComponent(showPassword);
0084: policy.addComponent(tfFetchSize);
0085: policy.addComponent(cbAutocommit);
0086: policy.addComponent(extendedProps);
0087: policy.addComponent(cbStorePassword);
0088: policy.addComponent(cbSeparateConnections);
0089: policy.addComponent(cbIgnoreDropErrors);
0090: policy.addComponent(emptyStringIsNull);
0091: policy.addComponent(removeComments);
0092: policy.addComponent(rollbackBeforeDisconnect);
0093: policy.addComponent(confirmUpdates);
0094: policy.addComponent(includeNull);
0095: policy.addComponent(rememberExplorerSchema);
0096: policy.addComponent(trimCharData);
0097: policy.addComponent(confirmUpdates);
0098: policy.addComponent(editConnectionScriptsButton);
0099: policy.addComponent(altDelimiter.getTextField());
0100: policy.addComponent(altDelimiter.getCheckBox());
0101: policy.addComponent(tfWorkspaceFile);
0102: policy.setDefaultComponent(tfProfileName);
0103:
0104: this .setFocusCycleRoot(false);
0105: this .setFocusTraversalPolicy(policy);
0106:
0107: this .initEditorList();
0108:
0109: this .selectWkspButton.addActionListener(this );
0110: this .showPassword.addActionListener(this );
0111: this .infoColor.setActionListener(this );
0112: }
0113:
0114: public void setFocusToTitle() {
0115: EventQueue.invokeLater(new Runnable() {
0116: public void run() {
0117: tfProfileName.requestFocusInWindow();
0118: tfProfileName.selectAll();
0119: }
0120: });
0121: }
0122:
0123: private void initEditorList() {
0124: this .editors = new LinkedList<SimplePropertyEditor>();
0125: initEditorList(this );
0126: altDelimiter.addPropertyChangeListener(
0127: DelimiterDefinitionPanel.PROP_SLD, this );
0128: altDelimiter.addPropertyChangeListener(
0129: DelimiterDefinitionPanel.PROP_DELIM, this );
0130: }
0131:
0132: private void initEditorList(Container parent) {
0133: for (int i = 0; i < parent.getComponentCount(); i++) {
0134: Component c = parent.getComponent(i);
0135: if (c instanceof SimplePropertyEditor) {
0136: SimplePropertyEditor ed = (SimplePropertyEditor) c;
0137: this .editors.add(ed);
0138: String name = c.getName();
0139: c.addPropertyChangeListener(name, this );
0140: ed.setImmediateUpdate(true);
0141: } else if (c instanceof JPanel
0142: && !(c instanceof DelimiterDefinitionPanel)) {
0143: initEditorList((JPanel) c);
0144: }
0145: }
0146: }
0147:
0148: /** This method is called from within the constructor to
0149: * initialize the form.
0150: * WARNING: Do NOT modify this code. The content of this method is
0151: * always regenerated by the Form Editor.
0152: */
0153: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
0154: private void initComponents() {
0155: java.awt.GridBagConstraints gridBagConstraints;
0156:
0157: tfProfileName = new StringPropertyEditor();
0158: cbDrivers = new javax.swing.JComboBox();
0159: tfURL = new StringPropertyEditor();
0160: tfUserName = new StringPropertyEditor();
0161: tfPwd = new PasswordPropertyEditor();
0162: cbAutocommit = new BooleanPropertyEditor();
0163: lblUsername = new javax.swing.JLabel();
0164: lblPwd = new javax.swing.JLabel();
0165: lblDriver = new javax.swing.JLabel();
0166: lblUrl = new javax.swing.JLabel();
0167: jSeparator2 = new javax.swing.JSeparator();
0168: jSeparator1 = new javax.swing.JSeparator();
0169: manageDriversButton = new WbButton();
0170: helpButton = new WbButton();
0171: tfFetchSize = new IntegerPropertyEditor();
0172: fetchSizeLabel = new javax.swing.JLabel();
0173: showPassword = new FlatButton();
0174: wbOptionsPanel = new javax.swing.JPanel();
0175: cbStorePassword = new BooleanPropertyEditor();
0176: rollbackBeforeDisconnect = new BooleanPropertyEditor();
0177: confirmUpdates = new BooleanPropertyEditor();
0178: cbIgnoreDropErrors = new BooleanPropertyEditor();
0179: cbSeparateConnections = new BooleanPropertyEditor();
0180: emptyStringIsNull = new BooleanPropertyEditor();
0181: includeNull = new BooleanPropertyEditor();
0182: removeComments = new BooleanPropertyEditor();
0183: rememberExplorerSchema = new BooleanPropertyEditor();
0184: editConnectionScriptsButton = new FlatButton();
0185: trimCharData = new BooleanPropertyEditor();
0186: colorPanel = new javax.swing.JPanel();
0187: infoColorLabel = new javax.swing.JLabel();
0188: infoColor = new WbColorPicker(true);
0189: jPanel1 = new javax.swing.JPanel();
0190: tfWorkspaceFile = new StringPropertyEditor();
0191: selectWkspButton = new FlatButton();
0192: workspaceFileLabel = new javax.swing.JLabel();
0193: autoCommitLabel = new WbCheckBoxLabel();
0194: altDelimiter = new workbench.gui.components.DelimiterDefinitionPanel();
0195: altDelimLabel = new javax.swing.JLabel();
0196: jPanel2 = new javax.swing.JPanel();
0197: extendedProps = new FlatButton();
0198: jPanel3 = new javax.swing.JPanel();
0199: propLabel = new javax.swing.JLabel();
0200:
0201: FormListener formListener = new FormListener();
0202:
0203: setMinimumSize(new java.awt.Dimension(220, 200));
0204: setLayout(new java.awt.GridBagLayout());
0205:
0206: tfProfileName
0207: .setHorizontalAlignment(javax.swing.JTextField.LEFT);
0208: tfProfileName.setName("name"); // NOI18N
0209: gridBagConstraints = new java.awt.GridBagConstraints();
0210: gridBagConstraints.gridx = 0;
0211: gridBagConstraints.gridy = 0;
0212: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0213: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0214: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0215: gridBagConstraints.weightx = 1.0;
0216: gridBagConstraints.insets = new java.awt.Insets(10, 5, 5, 5);
0217: add(tfProfileName, gridBagConstraints);
0218:
0219: cbDrivers.setMaximumSize(new java.awt.Dimension(32767, 20));
0220: cbDrivers.setMinimumSize(new java.awt.Dimension(40, 20));
0221: cbDrivers.setName("driverclass"); // NOI18N
0222: cbDrivers.setPreferredSize(new java.awt.Dimension(120, 20));
0223: cbDrivers.setVerifyInputWhenFocusTarget(false);
0224: cbDrivers.addItemListener(formListener);
0225: gridBagConstraints = new java.awt.GridBagConstraints();
0226: gridBagConstraints.gridx = 1;
0227: gridBagConstraints.gridy = 1;
0228: gridBagConstraints.gridwidth = 2;
0229: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0230: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0231: gridBagConstraints.weightx = 0.5;
0232: gridBagConstraints.insets = new java.awt.Insets(0, 4, 2, 6);
0233: add(cbDrivers, gridBagConstraints);
0234:
0235: tfURL.setHorizontalAlignment(javax.swing.JTextField.LEFT);
0236: tfURL.setMaximumSize(new java.awt.Dimension(2147483647, 20));
0237: tfURL.setName("url"); // NOI18N
0238: gridBagConstraints = new java.awt.GridBagConstraints();
0239: gridBagConstraints.gridx = 1;
0240: gridBagConstraints.gridy = 2;
0241: gridBagConstraints.gridwidth = 2;
0242: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0243: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0244: gridBagConstraints.insets = new java.awt.Insets(0, 4, 2, 6);
0245: add(tfURL, gridBagConstraints);
0246:
0247: tfUserName.setHorizontalAlignment(javax.swing.JTextField.LEFT);
0248: tfUserName.setToolTipText("");
0249: tfUserName
0250: .setMaximumSize(new java.awt.Dimension(2147483647, 20));
0251: tfUserName.setName("username"); // NOI18N
0252: gridBagConstraints = new java.awt.GridBagConstraints();
0253: gridBagConstraints.gridx = 1;
0254: gridBagConstraints.gridy = 3;
0255: gridBagConstraints.gridwidth = 2;
0256: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0257: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0258: gridBagConstraints.insets = new java.awt.Insets(0, 4, 2, 6);
0259: add(tfUserName, gridBagConstraints);
0260:
0261: tfPwd.setName("password"); // NOI18N
0262: gridBagConstraints = new java.awt.GridBagConstraints();
0263: gridBagConstraints.gridx = 1;
0264: gridBagConstraints.gridy = 4;
0265: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0266: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0267: gridBagConstraints.weightx = 1.0;
0268: gridBagConstraints.insets = new java.awt.Insets(0, 4, 2, 2);
0269: add(tfPwd, gridBagConstraints);
0270:
0271: cbAutocommit.setName("autocommit"); // NOI18N
0272: gridBagConstraints = new java.awt.GridBagConstraints();
0273: gridBagConstraints.gridx = 1;
0274: gridBagConstraints.gridy = 6;
0275: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0276: gridBagConstraints.insets = new java.awt.Insets(2, 1, 6, 6);
0277: add(cbAutocommit, gridBagConstraints);
0278:
0279: lblUsername.setLabelFor(tfUserName);
0280: lblUsername.setText(ResourceMgr.getString("LblUsername"));
0281: gridBagConstraints = new java.awt.GridBagConstraints();
0282: gridBagConstraints.gridx = 0;
0283: gridBagConstraints.gridy = 3;
0284: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0285: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0286: gridBagConstraints.insets = new java.awt.Insets(0, 5, 2, 0);
0287: add(lblUsername, gridBagConstraints);
0288:
0289: lblPwd.setLabelFor(tfPwd);
0290: lblPwd.setText(ResourceMgr.getString("LblPassword"));
0291: gridBagConstraints = new java.awt.GridBagConstraints();
0292: gridBagConstraints.gridx = 0;
0293: gridBagConstraints.gridy = 4;
0294: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0295: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0296: gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
0297: add(lblPwd, gridBagConstraints);
0298:
0299: lblDriver.setLabelFor(cbDrivers);
0300: lblDriver.setText(ResourceMgr.getString("LblDriver"));
0301: gridBagConstraints = new java.awt.GridBagConstraints();
0302: gridBagConstraints.gridx = 0;
0303: gridBagConstraints.gridy = 1;
0304: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0305: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0306: gridBagConstraints.insets = new java.awt.Insets(0, 5, 2, 0);
0307: add(lblDriver, gridBagConstraints);
0308:
0309: lblUrl.setLabelFor(tfURL);
0310: lblUrl.setText(ResourceMgr.getString("LblDbURL"));
0311: gridBagConstraints = new java.awt.GridBagConstraints();
0312: gridBagConstraints.gridx = 0;
0313: gridBagConstraints.gridy = 2;
0314: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0315: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0316: gridBagConstraints.insets = new java.awt.Insets(0, 5, 2, 0);
0317: add(lblUrl, gridBagConstraints);
0318: gridBagConstraints = new java.awt.GridBagConstraints();
0319: gridBagConstraints.gridx = 0;
0320: gridBagConstraints.gridy = 8;
0321: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0322: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0323: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0324: gridBagConstraints.insets = new java.awt.Insets(0, 0, 3, 0);
0325: add(jSeparator2, gridBagConstraints);
0326: gridBagConstraints = new java.awt.GridBagConstraints();
0327: gridBagConstraints.gridx = 0;
0328: gridBagConstraints.gridy = 15;
0329: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0330: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0331: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
0332: gridBagConstraints.weighty = 1.0;
0333: add(jSeparator1, gridBagConstraints);
0334:
0335: manageDriversButton.setText(ResourceMgr
0336: .getString("LblEditDrivers"));
0337: manageDriversButton.setToolTipText(ResourceMgr
0338: .getDescription("LblEditDrivers"));
0339: manageDriversButton.addActionListener(formListener);
0340: gridBagConstraints = new java.awt.GridBagConstraints();
0341: gridBagConstraints.gridx = 0;
0342: gridBagConstraints.gridy = 17;
0343: gridBagConstraints.gridwidth = 2;
0344: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0345: gridBagConstraints.weightx = 1.0;
0346: gridBagConstraints.insets = new java.awt.Insets(5, 5, 6, 0);
0347: add(manageDriversButton, gridBagConstraints);
0348:
0349: helpButton.setText(ResourceMgr.getString("LblHelp"));
0350: helpButton.addActionListener(formListener);
0351: gridBagConstraints = new java.awt.GridBagConstraints();
0352: gridBagConstraints.gridx = 2;
0353: gridBagConstraints.gridy = 17;
0354: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0355: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 4);
0356: add(helpButton, gridBagConstraints);
0357:
0358: tfFetchSize.setName("defaultFetchSize"); // NOI18N
0359: gridBagConstraints = new java.awt.GridBagConstraints();
0360: gridBagConstraints.gridx = 1;
0361: gridBagConstraints.gridy = 5;
0362: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0363: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0364: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 2);
0365: add(tfFetchSize, gridBagConstraints);
0366:
0367: fetchSizeLabel.setText(ResourceMgr.getString("LblFetchSize"));
0368: fetchSizeLabel.setToolTipText(ResourceMgr
0369: .getDescription("LblFetchSize"));
0370: gridBagConstraints = new java.awt.GridBagConstraints();
0371: gridBagConstraints.gridx = 0;
0372: gridBagConstraints.gridy = 5;
0373: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0374: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0375: gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
0376: add(fetchSizeLabel, gridBagConstraints);
0377:
0378: showPassword.setText(ResourceMgr.getString("LblShowPassword"));
0379: gridBagConstraints = new java.awt.GridBagConstraints();
0380: gridBagConstraints.gridx = 2;
0381: gridBagConstraints.gridy = 4;
0382: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0383: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0384: gridBagConstraints.insets = new java.awt.Insets(0, 2, 2, 6);
0385: add(showPassword, gridBagConstraints);
0386:
0387: wbOptionsPanel.setLayout(new java.awt.GridBagLayout());
0388:
0389: cbStorePassword.setSelected(true);
0390: cbStorePassword.setText(ResourceMgr
0391: .getString("LblSavePassword"));
0392: cbStorePassword.setToolTipText(ResourceMgr
0393: .getDescription("LblSavePassword"));
0394: cbStorePassword.setName("storePassword"); // NOI18N
0395: gridBagConstraints = new java.awt.GridBagConstraints();
0396: gridBagConstraints.gridx = 0;
0397: gridBagConstraints.gridy = 0;
0398: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0399: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0400: gridBagConstraints.insets = new java.awt.Insets(0, 0, 3, 0);
0401: wbOptionsPanel.add(cbStorePassword, gridBagConstraints);
0402:
0403: rollbackBeforeDisconnect.setText(ResourceMgr
0404: .getString("LblRollbackBeforeDisconnect"));
0405: rollbackBeforeDisconnect.setToolTipText(ResourceMgr
0406: .getDescription("LblRollbackBeforeDisconnect"));
0407: rollbackBeforeDisconnect.setName("rollbackBeforeDisconnect"); // NOI18N
0408: gridBagConstraints = new java.awt.GridBagConstraints();
0409: gridBagConstraints.gridx = 1;
0410: gridBagConstraints.gridy = 0;
0411: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0412: gridBagConstraints.insets = new java.awt.Insets(0, 4, 3, 0);
0413: wbOptionsPanel
0414: .add(rollbackBeforeDisconnect, gridBagConstraints);
0415:
0416: confirmUpdates.setText(ResourceMgr
0417: .getString("LblConfirmDbUpdates"));
0418: confirmUpdates.setToolTipText(ResourceMgr
0419: .getDescription("LblConfirmDbUpdates"));
0420: confirmUpdates.setName("confirmUpdates"); // NOI18N
0421: gridBagConstraints = new java.awt.GridBagConstraints();
0422: gridBagConstraints.gridx = 1;
0423: gridBagConstraints.gridy = 1;
0424: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0425: gridBagConstraints.insets = new java.awt.Insets(0, 4, 3, 0);
0426: wbOptionsPanel.add(confirmUpdates, gridBagConstraints);
0427:
0428: cbIgnoreDropErrors.setSelected(true);
0429: cbIgnoreDropErrors.setText(ResourceMgr
0430: .getString("LblIgnoreDropErrors"));
0431: cbIgnoreDropErrors.setToolTipText(ResourceMgr
0432: .getDescription("LblIgnoreDropErrors"));
0433: cbIgnoreDropErrors.setName("ignoreDropErrors"); // NOI18N
0434: gridBagConstraints = new java.awt.GridBagConstraints();
0435: gridBagConstraints.gridx = 0;
0436: gridBagConstraints.gridy = 2;
0437: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0438: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0439: gridBagConstraints.insets = new java.awt.Insets(0, 0, 3, 0);
0440: wbOptionsPanel.add(cbIgnoreDropErrors, gridBagConstraints);
0441:
0442: cbSeparateConnections.setText(ResourceMgr
0443: .getString("LblSeparateConnections"));
0444: cbSeparateConnections.setToolTipText(ResourceMgr
0445: .getDescription("LblSeparateConnections"));
0446: cbSeparateConnections.setName("useSeparateConnectionPerTab"); // NOI18N
0447: gridBagConstraints = new java.awt.GridBagConstraints();
0448: gridBagConstraints.gridx = 0;
0449: gridBagConstraints.gridy = 1;
0450: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0451: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0452: gridBagConstraints.insets = new java.awt.Insets(0, 0, 3, 0);
0453: wbOptionsPanel.add(cbSeparateConnections, gridBagConstraints);
0454:
0455: emptyStringIsNull.setText(ResourceMgr
0456: .getString("LblEmptyStringIsNull"));
0457: emptyStringIsNull.setToolTipText(ResourceMgr
0458: .getDescription("LblEmptyStringIsNull"));
0459: emptyStringIsNull.setName("emptyStringIsNull"); // NOI18N
0460: gridBagConstraints = new java.awt.GridBagConstraints();
0461: gridBagConstraints.gridx = 0;
0462: gridBagConstraints.gridy = 3;
0463: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0464: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0465: gridBagConstraints.insets = new java.awt.Insets(0, 0, 3, 0);
0466: wbOptionsPanel.add(emptyStringIsNull, gridBagConstraints);
0467:
0468: includeNull.setText(ResourceMgr
0469: .getString("LblIncludeNullInInsert"));
0470: includeNull.setToolTipText(ResourceMgr
0471: .getDescription("LblIncludeNullInInsert"));
0472: includeNull.setName("includeNullInInsert"); // NOI18N
0473: gridBagConstraints = new java.awt.GridBagConstraints();
0474: gridBagConstraints.gridx = 1;
0475: gridBagConstraints.gridy = 2;
0476: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0477: gridBagConstraints.insets = new java.awt.Insets(0, 4, 3, 0);
0478: wbOptionsPanel.add(includeNull, gridBagConstraints);
0479:
0480: removeComments.setText(ResourceMgr
0481: .getString("LblRemoveComments"));
0482: removeComments.setToolTipText(ResourceMgr
0483: .getDescription("LblRemoveComments"));
0484: removeComments.setName("removeComments"); // NOI18N
0485: gridBagConstraints = new java.awt.GridBagConstraints();
0486: gridBagConstraints.gridx = 0;
0487: gridBagConstraints.gridy = 4;
0488: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0489: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0490: wbOptionsPanel.add(removeComments, gridBagConstraints);
0491:
0492: rememberExplorerSchema.setText(ResourceMgr
0493: .getString("LblRememberSchema"));
0494: rememberExplorerSchema.setToolTipText(ResourceMgr
0495: .getDescription("LblRememberSchema"));
0496: rememberExplorerSchema.setName("storeExplorerSchema"); // NOI18N
0497: gridBagConstraints = new java.awt.GridBagConstraints();
0498: gridBagConstraints.gridx = 1;
0499: gridBagConstraints.gridy = 3;
0500: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0501: gridBagConstraints.insets = new java.awt.Insets(0, 4, 3, 0);
0502: wbOptionsPanel.add(rememberExplorerSchema, gridBagConstraints);
0503:
0504: editConnectionScriptsButton.setText(ResourceMgr
0505: .getString("LblConnScripts"));
0506: editConnectionScriptsButton.setToolTipText(ResourceMgr
0507: .getDescription("LblConnScripts"));
0508: editConnectionScriptsButton.addActionListener(formListener);
0509: gridBagConstraints = new java.awt.GridBagConstraints();
0510: gridBagConstraints.gridx = 0;
0511: gridBagConstraints.gridy = 5;
0512: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0513: gridBagConstraints.insets = new java.awt.Insets(3, 1, 0, 0);
0514: wbOptionsPanel.add(editConnectionScriptsButton,
0515: gridBagConstraints);
0516:
0517: trimCharData.setText(ResourceMgr.getString("LblTrimCharData"));
0518: trimCharData.setToolTipText(ResourceMgr
0519: .getDescription("LblTrimCharData"));
0520: trimCharData.setName("trimCharData"); // NOI18N
0521: gridBagConstraints = new java.awt.GridBagConstraints();
0522: gridBagConstraints.gridx = 1;
0523: gridBagConstraints.gridy = 4;
0524: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0525: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0526: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
0527: wbOptionsPanel.add(trimCharData, gridBagConstraints);
0528:
0529: colorPanel.setLayout(new java.awt.FlowLayout(
0530: java.awt.FlowLayout.LEFT, 0, 0));
0531:
0532: infoColorLabel
0533: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
0534: infoColorLabel.setText(ResourceMgr.getString("LblInfoColor"));
0535: infoColorLabel.setToolTipText(ResourceMgr
0536: .getDescription("LblInfoColor"));
0537: colorPanel.add(infoColorLabel);
0538:
0539: infoColor.setToolTipText(ResourceMgr
0540: .getDescription("LblInfoColor"));
0541: colorPanel.add(infoColor);
0542:
0543: gridBagConstraints = new java.awt.GridBagConstraints();
0544: gridBagConstraints.gridx = 1;
0545: gridBagConstraints.gridy = 5;
0546: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0547: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0548: gridBagConstraints.weightx = 1.0;
0549: gridBagConstraints.insets = new java.awt.Insets(3, 4, 0, 0);
0550: wbOptionsPanel.add(colorPanel, gridBagConstraints);
0551:
0552: gridBagConstraints = new java.awt.GridBagConstraints();
0553: gridBagConstraints.gridx = 1;
0554: gridBagConstraints.gridy = 9;
0555: gridBagConstraints.gridwidth = 2;
0556: gridBagConstraints.gridheight = 4;
0557: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0558: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0559: gridBagConstraints.weightx = 1.0;
0560: gridBagConstraints.insets = new java.awt.Insets(3, 0, 5, 6);
0561: add(wbOptionsPanel, gridBagConstraints);
0562:
0563: jPanel1.setLayout(new java.awt.GridBagLayout());
0564:
0565: tfWorkspaceFile
0566: .setHorizontalAlignment(javax.swing.JTextField.LEFT);
0567: tfWorkspaceFile.setToolTipText(ResourceMgr
0568: .getDescription("LblOpenWksp"));
0569: tfWorkspaceFile.setMaximumSize(new java.awt.Dimension(
0570: 2147483647, 20));
0571: tfWorkspaceFile.setName("workspaceFile"); // NOI18N
0572: gridBagConstraints = new java.awt.GridBagConstraints();
0573: gridBagConstraints.gridx = 0;
0574: gridBagConstraints.gridy = 0;
0575: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0576: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0577: gridBagConstraints.weightx = 1.0;
0578: jPanel1.add(tfWorkspaceFile, gridBagConstraints);
0579:
0580: selectWkspButton.setText("...");
0581: selectWkspButton.setMaximumSize(new java.awt.Dimension(26, 22));
0582: selectWkspButton.setMinimumSize(new java.awt.Dimension(26, 22));
0583: selectWkspButton
0584: .setPreferredSize(new java.awt.Dimension(26, 22));
0585: gridBagConstraints = new java.awt.GridBagConstraints();
0586: gridBagConstraints.gridx = 1;
0587: gridBagConstraints.gridy = 0;
0588: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0589: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
0590: jPanel1.add(selectWkspButton, gridBagConstraints);
0591:
0592: gridBagConstraints = new java.awt.GridBagConstraints();
0593: gridBagConstraints.gridx = 1;
0594: gridBagConstraints.gridy = 14;
0595: gridBagConstraints.gridwidth = 2;
0596: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0597: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0598: gridBagConstraints.insets = new java.awt.Insets(2, 4, 0, 6);
0599: add(jPanel1, gridBagConstraints);
0600:
0601: workspaceFileLabel.setLabelFor(tfWorkspaceFile);
0602: workspaceFileLabel
0603: .setText(ResourceMgr.getString("LblOpenWksp"));
0604: workspaceFileLabel.setToolTipText(ResourceMgr
0605: .getDescription("LblOpenWksp"));
0606: gridBagConstraints = new java.awt.GridBagConstraints();
0607: gridBagConstraints.gridx = 0;
0608: gridBagConstraints.gridy = 14;
0609: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0610: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0611: gridBagConstraints.insets = new java.awt.Insets(2, 5, 0, 0);
0612: add(workspaceFileLabel, gridBagConstraints);
0613:
0614: autoCommitLabel.setLabelFor(cbAutocommit);
0615: autoCommitLabel.setText("Autocommit");
0616: gridBagConstraints = new java.awt.GridBagConstraints();
0617: gridBagConstraints.gridx = 0;
0618: gridBagConstraints.gridy = 6;
0619: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0620: gridBagConstraints.insets = new java.awt.Insets(0, 5, 3, 0);
0621: add(autoCommitLabel, gridBagConstraints);
0622: gridBagConstraints = new java.awt.GridBagConstraints();
0623: gridBagConstraints.gridx = 1;
0624: gridBagConstraints.gridy = 13;
0625: gridBagConstraints.gridwidth = 2;
0626: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0627: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0628: gridBagConstraints.insets = new java.awt.Insets(2, 4, 0, 0);
0629: add(altDelimiter, gridBagConstraints);
0630:
0631: altDelimLabel.setText(ResourceMgr.getString("LblAltDelimit"));
0632: altDelimLabel.setToolTipText(ResourceMgr
0633: .getDescription("LblAltDelimit"));
0634: gridBagConstraints = new java.awt.GridBagConstraints();
0635: gridBagConstraints.gridx = 0;
0636: gridBagConstraints.gridy = 13;
0637: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0638: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0639: gridBagConstraints.insets = new java.awt.Insets(2, 5, 0, 0);
0640: add(altDelimLabel, gridBagConstraints);
0641:
0642: jPanel2.setLayout(new java.awt.FlowLayout(
0643: java.awt.FlowLayout.LEFT, 0, 0));
0644:
0645: extendedProps.setText(ResourceMgr
0646: .getString("LblConnExtendedProps"));
0647: extendedProps.setToolTipText(ResourceMgr
0648: .getDescription("LblConnExtendedProps"));
0649: extendedProps
0650: .setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
0651: extendedProps
0652: .setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
0653: extendedProps.setIconTextGap(1);
0654: extendedProps.addMouseListener(formListener);
0655: jPanel2.add(extendedProps);
0656:
0657: jPanel3.setMaximumSize(new java.awt.Dimension(2, 10));
0658: jPanel3.setMinimumSize(new java.awt.Dimension(2, 10));
0659: jPanel3.setPreferredSize(new java.awt.Dimension(2, 10));
0660: jPanel2.add(jPanel3);
0661:
0662: propLabel.setIconTextGap(0);
0663: propLabel.setMaximumSize(new java.awt.Dimension(16, 16));
0664: propLabel.setMinimumSize(new java.awt.Dimension(16, 16));
0665: propLabel.setPreferredSize(new java.awt.Dimension(16, 16));
0666: jPanel2.add(propLabel);
0667:
0668: gridBagConstraints = new java.awt.GridBagConstraints();
0669: gridBagConstraints.gridx = 2;
0670: gridBagConstraints.gridy = 6;
0671: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0672: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0673: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 6);
0674: add(jPanel2, gridBagConstraints);
0675: }
0676:
0677: // Code for dispatching events from components to event handlers.
0678:
0679: private class FormListener implements
0680: java.awt.event.ActionListener, java.awt.event.ItemListener,
0681: java.awt.event.MouseListener {
0682: FormListener() {
0683: }
0684:
0685: public void actionPerformed(java.awt.event.ActionEvent evt) {
0686: if (evt.getSource() == manageDriversButton) {
0687: ConnectionEditorPanel.this .showDriverEditorDialog(evt);
0688: } else if (evt.getSource() == helpButton) {
0689: ConnectionEditorPanel.this
0690: .helpButtonActionPerformed(evt);
0691: } else if (evt.getSource() == editConnectionScriptsButton) {
0692: ConnectionEditorPanel.this
0693: .editConnectionScriptsButtonActionPerformed(evt);
0694: }
0695: }
0696:
0697: public void itemStateChanged(java.awt.event.ItemEvent evt) {
0698: if (evt.getSource() == cbDrivers) {
0699: ConnectionEditorPanel.this
0700: .cbDriversItemStateChanged(evt);
0701: }
0702: }
0703:
0704: public void mouseClicked(java.awt.event.MouseEvent evt) {
0705: if (evt.getSource() == extendedProps) {
0706: ConnectionEditorPanel.this
0707: .extendedPropsMouseClicked(evt);
0708: }
0709: }
0710:
0711: public void mouseEntered(java.awt.event.MouseEvent evt) {
0712: }
0713:
0714: public void mouseExited(java.awt.event.MouseEvent evt) {
0715: }
0716:
0717: public void mousePressed(java.awt.event.MouseEvent evt) {
0718: }
0719:
0720: public void mouseReleased(java.awt.event.MouseEvent evt) {
0721: }
0722: }// </editor-fold>//GEN-END:initComponents
0723:
0724: private void helpButtonActionPerformed(
0725: java.awt.event.ActionEvent evt)//GEN-FIRST:event_helpButtonActionPerformed
0726: {//GEN-HEADEREND:event_helpButtonActionPerformed
0727: HelpManager.showProfileHelp();
0728: }//GEN-LAST:event_helpButtonActionPerformed
0729:
0730: private void extendedPropsMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_extendedPropsMouseClicked
0731: {//GEN-HEADEREND:event_extendedPropsMouseClicked
0732: this .editExtendedProperties();
0733: }//GEN-LAST:event_extendedPropsMouseClicked
0734:
0735: private void cbDriversItemStateChanged(java.awt.event.ItemEvent evt)//GEN-FIRST:event_cbDriversItemStateChanged
0736: {//GEN-HEADEREND:event_cbDriversItemStateChanged
0737: if (this .init) {
0738: return;
0739: }
0740: if (evt.getStateChange() == ItemEvent.SELECTED) {
0741: String oldDriver = null;
0742: DbDriver newDriver = null;
0743: try {
0744: oldDriver = this .currentProfile.getDriverclass();
0745: newDriver = (DbDriver) this .cbDrivers.getSelectedItem();
0746: if (this .currentProfile != null) {
0747: this .currentProfile.setDriverclass(newDriver
0748: .getDriverClass());
0749: this .currentProfile.setDriverName(newDriver
0750: .getName());
0751: }
0752: if (oldDriver == null
0753: || !oldDriver
0754: .equals(newDriver.getDriverClass())) {
0755: this .tfURL.setText(newDriver.getSampleUrl());
0756: }
0757: } catch (Exception e) {
0758: LogMgr
0759: .logError(
0760: "ConnectionProfilePanel.cbDriversItemStateChanged()",
0761: "Error changing driver", e);
0762: }
0763:
0764: if (!newDriver.canReadLibrary()) {
0765: if (WbSwingUtilities
0766: .getYesNo(
0767: ConnectionEditorPanel.this ,
0768: ResourceMgr
0769: .getString("MsgDriverLibraryNotReadable"))) {
0770: showDriverEditorDialog(null);
0771: }
0772: }
0773: }
0774: }//GEN-LAST:event_cbDriversItemStateChanged
0775:
0776: private void showDriverEditorDialog(java.awt.event.ActionEvent evt)//GEN-FIRST:event_showDriverEditorDialog
0777: {//GEN-HEADEREND:event_showDriverEditorDialog
0778: final Frame parent = (Frame) (SwingUtilities
0779: .getWindowAncestor(this )).getParent();
0780: final DbDriver drv = (DbDriver) cbDrivers.getSelectedItem();
0781:
0782: EventQueue.invokeLater(new Runnable() {
0783: public void run() {
0784: DriverEditorDialog d = new DriverEditorDialog(parent);
0785: d.setDriverName(drv != null ? drv.getName() : null);
0786: WbSwingUtilities.center(d, parent);
0787: d.setVisible(true);
0788: if (!d.isCancelled()) {
0789: List<DbDriver> drivers = ConnectionMgr
0790: .getInstance().getDrivers();
0791: setDrivers(drivers);
0792: }
0793: d.dispose();
0794: }
0795: });
0796: }//GEN-LAST:event_showDriverEditorDialog
0797:
0798: private void editConnectionScriptsButtonActionPerformed(
0799: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editConnectionScriptsButtonActionPerformed
0800: Dialog d = (Dialog) SwingUtilities.getWindowAncestor(this );
0801: EditConnectScriptsPanel.editScripts(d, this .getProfile());
0802: }//GEN-LAST:event_editConnectionScriptsButtonActionPerformed
0803:
0804: // Variables declaration - do not modify//GEN-BEGIN:variables
0805: protected javax.swing.JLabel altDelimLabel;
0806: protected workbench.gui.components.DelimiterDefinitionPanel altDelimiter;
0807: protected javax.swing.JLabel autoCommitLabel;
0808: protected javax.swing.JCheckBox cbAutocommit;
0809: protected javax.swing.JComboBox cbDrivers;
0810: protected javax.swing.JCheckBox cbIgnoreDropErrors;
0811: protected javax.swing.JCheckBox cbSeparateConnections;
0812: protected javax.swing.JCheckBox cbStorePassword;
0813: protected javax.swing.JPanel colorPanel;
0814: protected javax.swing.JCheckBox confirmUpdates;
0815: protected javax.swing.JButton editConnectionScriptsButton;
0816: protected javax.swing.JCheckBox emptyStringIsNull;
0817: protected javax.swing.JButton extendedProps;
0818: protected javax.swing.JLabel fetchSizeLabel;
0819: protected javax.swing.JButton helpButton;
0820: protected javax.swing.JCheckBox includeNull;
0821: protected workbench.gui.components.WbColorPicker infoColor;
0822: protected javax.swing.JLabel infoColorLabel;
0823: protected javax.swing.JPanel jPanel1;
0824: protected javax.swing.JPanel jPanel2;
0825: protected javax.swing.JPanel jPanel3;
0826: protected javax.swing.JSeparator jSeparator1;
0827: protected javax.swing.JSeparator jSeparator2;
0828: protected javax.swing.JLabel lblDriver;
0829: protected javax.swing.JLabel lblPwd;
0830: protected javax.swing.JLabel lblUrl;
0831: protected javax.swing.JLabel lblUsername;
0832: protected javax.swing.JButton manageDriversButton;
0833: protected javax.swing.JLabel propLabel;
0834: protected javax.swing.JCheckBox rememberExplorerSchema;
0835: protected javax.swing.JCheckBox removeComments;
0836: protected javax.swing.JCheckBox rollbackBeforeDisconnect;
0837: protected javax.swing.JButton selectWkspButton;
0838: protected javax.swing.JButton showPassword;
0839: protected javax.swing.JTextField tfFetchSize;
0840: protected javax.swing.JTextField tfProfileName;
0841: protected javax.swing.JPasswordField tfPwd;
0842: protected javax.swing.JTextField tfURL;
0843: protected javax.swing.JTextField tfUserName;
0844: protected javax.swing.JTextField tfWorkspaceFile;
0845: protected javax.swing.JCheckBox trimCharData;
0846: protected javax.swing.JPanel wbOptionsPanel;
0847: protected javax.swing.JLabel workspaceFileLabel;
0848:
0849: // End of variables declaration//GEN-END:variables
0850: public void setDrivers(List<DbDriver> aDriverList) {
0851: if (aDriverList != null) {
0852: this .init = true;
0853: Object currentDriver = this .cbDrivers.getSelectedItem();
0854: try {
0855: Collections.sort(aDriverList);
0856: this .cbDrivers.setModel(new DefaultComboBoxModel(
0857: aDriverList.toArray()));
0858: if (currentDriver != null) {
0859: this .cbDrivers.setSelectedItem(currentDriver);
0860: }
0861: } catch (Exception e) {
0862: LogMgr.logError("ConnectionEditorPanel.setDrivers()",
0863: "Error when setting new driver list", e);
0864: } finally {
0865: this .init = false;
0866: }
0867: }
0868: }
0869:
0870: public void editExtendedProperties() {
0871: EventQueue.invokeLater(new Runnable() {
0872: public void run() {
0873: ConnectionPropertiesEditor
0874: .editProperties(
0875: SwingUtilities
0876: .getWindowAncestor(ConnectionEditorPanel.this ),
0877: currentProfile);
0878: checkExtendedProps();
0879: }
0880: });
0881: }
0882:
0883: public void selectWorkspace() {
0884: FileDialogUtil util = new FileDialogUtil();
0885: String filename = util.getWorkspaceFilename(SwingUtilities
0886: .getWindowAncestor(this ), false, true);
0887: if (filename == null) {
0888: return;
0889: }
0890: this .tfWorkspaceFile.setText(filename);
0891: }
0892:
0893: public void setSourceList(ProfileListModel aSource) {
0894: this .sourceModel = aSource;
0895: }
0896:
0897: public void updateProfile() {
0898: if (this .init) {
0899: return;
0900: }
0901: if (this .currentProfile == null) {
0902: return;
0903: }
0904: if (this .editors == null) {
0905: return;
0906: }
0907: boolean changed = false;
0908:
0909: Iterator<SimplePropertyEditor> itr = this .editors.iterator();
0910: while (itr.hasNext()) {
0911: SimplePropertyEditor editor = itr.next();
0912: changed = changed || editor.isChanged();
0913: editor.applyChanges();
0914: }
0915:
0916: if (altDelimiter.getDelimiter().isChanged()) {
0917: changed = true;
0918: currentProfile.setAlternateDelimiter(altDelimiter
0919: .getDelimiter());
0920: }
0921:
0922: if (changed) {
0923: this .sourceModel.profileChanged(this .currentProfile);
0924: }
0925: }
0926:
0927: public ConnectionProfile getProfile() {
0928: this .updateProfile();
0929: return this .currentProfile;
0930: }
0931:
0932: private void initPropertyEditors() {
0933: if (this .editors == null) {
0934: return;
0935: }
0936: if (this .currentProfile == null) {
0937: return;
0938: }
0939:
0940: Iterator<SimplePropertyEditor> itr = this .editors.iterator();
0941: while (itr.hasNext()) {
0942: SimplePropertyEditor editor = itr.next();
0943: Component c = (Component) editor;
0944: String property = c.getName();
0945: if (property != null) {
0946: editor.setSourceObject(this .currentProfile, property);
0947: }
0948: }
0949: }
0950:
0951: private void checkExtendedProps() {
0952: Properties props = (currentProfile == null ? null
0953: : currentProfile.getConnectionProperties());
0954: if (props != null && props.size() > 0) {
0955: propLabel.setIcon(ResourceMgr.getPicture("tick"));
0956: } else {
0957: propLabel.setIcon(null);
0958: }
0959: }
0960:
0961: public void setProfile(ConnectionProfile aProfile) {
0962: if (aProfile == null) {
0963: return;
0964: }
0965:
0966: this .currentProfile = aProfile;
0967:
0968: try {
0969: this .init = true;
0970:
0971: this .initPropertyEditors();
0972:
0973: String drvClass = aProfile.getDriverclass();
0974: DbDriver drv = null;
0975: if (drvClass != null) {
0976: String name = aProfile.getDriverName();
0977: drv = ConnectionMgr.getInstance().findDriverByName(
0978: drvClass, name);
0979: }
0980:
0981: this .altDelimiter.setDelimiter(this .currentProfile
0982: .getAlternateDelimiter());
0983: cbDrivers.setSelectedItem(drv);
0984:
0985: Color c = this .currentProfile.getInfoDisplayColor();
0986: this .infoColor.setSelectedColor(c);
0987: checkExtendedProps();
0988: } catch (Exception e) {
0989: LogMgr.logError("ConnectionEditorPanel.setProfile()",
0990: "Error setting profile", e);
0991: } finally {
0992: this .init = false;
0993: }
0994: }
0995:
0996: /** This method gets called when a bound property is changed.
0997: * @param evt A PropertyChangeEvent object describing the event source
0998: * and the property that has changed.
0999: *
1000: */
1001: public void propertyChange(PropertyChangeEvent evt) {
1002: if (!this .init) {
1003: if (evt.getSource() == this .altDelimiter) {
1004: DelimiterDefinition del = altDelimiter.getDelimiter();
1005: // As the alternateDelimiter is a not attached to the profile itself,
1006: // we have to propagate any updated delimiter object to the profile
1007:
1008: this .currentProfile.setAlternateDelimiter(altDelimiter
1009: .getDelimiter());
1010: }
1011: this .sourceModel.profileChanged(this .currentProfile);
1012: }
1013: }
1014:
1015: public void actionPerformed(java.awt.event.ActionEvent e) {
1016: if (e.getSource() == this .selectWkspButton) {
1017: this .selectWorkspace();
1018: } else if (e.getSource() == this .showPassword) {
1019: String pwd = this .getProfile().getInputPassword();
1020: String title = ResourceMgr.getString("LblCurrentPassword");
1021: title += " " + this .getProfile().getUsername();
1022: JTextField f = new JTextField();
1023: f.setDisabledTextColor(Color.BLACK);
1024: f.setEditable(false);
1025: f.setText(pwd);
1026: Border b = new CompoundBorder(new LineBorder(
1027: Color.LIGHT_GRAY), new EmptyBorder(2, 2, 2, 2));
1028: f.setBorder(b);
1029: TextComponentMouseListener l = new TextComponentMouseListener();
1030: f.addMouseListener(l);
1031: //WbSwingUtilities.showMessage(this, f);
1032: JOptionPane.showMessageDialog(this .getParent(), f, title,
1033: JOptionPane.PLAIN_MESSAGE);
1034: } else if (e.getSource() == this .infoColor
1035: && this .currentProfile != null) {
1036: this .currentProfile.setInfoDisplayColor(this .infoColor
1037: .getSelectedColor());
1038: }
1039: }
1040:
1041: public boolean validateInput() {
1042: DelimiterDefinition delim = getProfile()
1043: .getAlternateDelimiter();
1044: if (delim != null && delim.isStandard()) {
1045: WbSwingUtilities.showErrorMessageKey(this ,
1046: "ErrWrongAltDelim");
1047: return false;
1048: }
1049: return true;
1050: }
1051:
1052: public void componentDisplayed() {
1053: // nothing to do
1054: }
1055: }
|