001: /*
002: * DataEditOptionsPanel.java
003: *
004: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005: *
006: * Copyright 2002-2008, Thomas Kellerer
007: * No part of this code maybe reused without the permission of the author
008: *
009: * To contact the author please send an email to: support@sql-workbench.net
010: *
011: */
012: package workbench.gui.settings;
013:
014: import javax.swing.JPanel;
015: import workbench.gui.components.FlatButton;
016: import workbench.gui.components.WbCheckBoxLabel;
017: import workbench.resource.ResourceMgr;
018: import workbench.resource.Settings;
019: import workbench.util.FileDialogUtil;
020:
021: /**
022: * A panel to edit the options for data editing, such as the font to be
023: * used in the JTable, the PK Mapping file, colors used for required
024: * fields and alternating row coloring.
025: *
026: * @author support@sql-workbench.net
027: */
028: public class DataEditOptionsPanel extends JPanel implements
029: java.awt.event.ActionListener, workbench.interfaces.Restoreable {
030:
031: public DataEditOptionsPanel() {
032: initComponents();
033: }
034:
035: public void restoreSettings() {
036: pkMapFile.setCaretPosition(0);
037: previewDml.setSelected(Settings.getInstance().getPreviewDml());
038: requiredFieldColor.setSelectedColor(Settings.getInstance()
039: .getRequiredFieldColor());
040: highlightRequired.setSelected(Settings.getInstance()
041: .getHighlightRequiredFields());
042: pkMapFile
043: .setText(Settings.getInstance().getPKMappingFilename());
044: }
045:
046: public void saveSettings() {
047: Settings set = Settings.getInstance();
048: set
049: .setRequiredFieldColor(requiredFieldColor
050: .getSelectedColor());
051: set.setHighlightRequiredFields(this .highlightRequired
052: .isSelected());
053: set.setPreviewDml(this .previewDml.isSelected());
054: set.setPKMappingFilename(pkMapFile.getText());
055: }
056:
057: /** This method is called from within the constructor to
058: * initialize the form.
059: * WARNING: Do NOT modify this code. The content of this method is
060: * always regenerated by the Form Editor.
061: */
062: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
063: private void initComponents() {
064: java.awt.GridBagConstraints gridBagConstraints;
065:
066: pkMapFileLabel = new javax.swing.JLabel();
067: jPanel3 = new javax.swing.JPanel();
068: pkMapFile = new javax.swing.JTextField();
069: selectMapFile = new FlatButton();
070: previewDmlLabel = new WbCheckBoxLabel();
071: previewDml = new javax.swing.JCheckBox();
072: requiredFieldLabel = new javax.swing.JLabel();
073: requiredFieldColor = new workbench.gui.components.WbColorPicker();
074: highlightRequiredLabel = new WbCheckBoxLabel();
075: highlightRequired = new javax.swing.JCheckBox();
076: dummyPanel = new javax.swing.JPanel();
077:
078: setLayout(new java.awt.GridBagLayout());
079:
080: pkMapFileLabel.setText(ResourceMgr.getString("LblPKMapFile"));
081: pkMapFileLabel.setToolTipText(ResourceMgr
082: .getDescription("LblPKMapFile"));
083: gridBagConstraints = new java.awt.GridBagConstraints();
084: gridBagConstraints.gridx = 0;
085: gridBagConstraints.gridy = 5;
086: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
087: gridBagConstraints.insets = new java.awt.Insets(11, 12, 0, 0);
088: add(pkMapFileLabel, gridBagConstraints);
089:
090: jPanel3.setLayout(new java.awt.BorderLayout(5, 0));
091:
092: pkMapFile.setHorizontalAlignment(javax.swing.JTextField.LEFT);
093: pkMapFile
094: .setMaximumSize(new java.awt.Dimension(2147483647, 22));
095: pkMapFile.setMinimumSize(new java.awt.Dimension(6, 22));
096: pkMapFile.setPreferredSize(new java.awt.Dimension(72, 22));
097: jPanel3.add(pkMapFile, java.awt.BorderLayout.CENTER);
098:
099: selectMapFile.setText("...");
100: selectMapFile.setMaximumSize(new java.awt.Dimension(22, 22));
101: selectMapFile.setMinimumSize(new java.awt.Dimension(22, 22));
102: selectMapFile.setPreferredSize(new java.awt.Dimension(22, 22));
103: selectMapFile.addActionListener(this );
104: jPanel3.add(selectMapFile, java.awt.BorderLayout.EAST);
105:
106: gridBagConstraints = new java.awt.GridBagConstraints();
107: gridBagConstraints.gridx = 1;
108: gridBagConstraints.gridy = 5;
109: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
110: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
111: gridBagConstraints.insets = new java.awt.Insets(7, 8, 0, 15);
112: add(jPanel3, gridBagConstraints);
113:
114: previewDmlLabel.setLabelFor(previewDml);
115: previewDmlLabel.setText(ResourceMgr.getString("LblPreviewDml"));
116: previewDmlLabel.setToolTipText(ResourceMgr
117: .getDescription("LblPreviewDml"));
118: gridBagConstraints = new java.awt.GridBagConstraints();
119: gridBagConstraints.gridx = 0;
120: gridBagConstraints.gridy = 0;
121: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
122: gridBagConstraints.insets = new java.awt.Insets(10, 12, 0, 0);
123: add(previewDmlLabel, gridBagConstraints);
124:
125: previewDml.setFont(null);
126: previewDml.setText(" ");
127: previewDml.setBorder(null);
128: previewDml
129: .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
130: previewDml
131: .setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
132: previewDml.setIconTextGap(5);
133: gridBagConstraints = new java.awt.GridBagConstraints();
134: gridBagConstraints.gridx = 1;
135: gridBagConstraints.gridy = 0;
136: gridBagConstraints.gridwidth = 3;
137: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
138: gridBagConstraints.insets = new java.awt.Insets(10, 9, 0, 11);
139: add(previewDml, gridBagConstraints);
140:
141: requiredFieldLabel.setText(ResourceMgr
142: .getString("LblReqFldColor"));
143: gridBagConstraints = new java.awt.GridBagConstraints();
144: gridBagConstraints.gridx = 0;
145: gridBagConstraints.gridy = 3;
146: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
147: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
148: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
149: add(requiredFieldLabel, gridBagConstraints);
150: gridBagConstraints = new java.awt.GridBagConstraints();
151: gridBagConstraints.gridx = 1;
152: gridBagConstraints.gridy = 3;
153: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
154: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
155: gridBagConstraints.insets = new java.awt.Insets(8, 4, 0, 25);
156: add(requiredFieldColor, gridBagConstraints);
157:
158: highlightRequiredLabel.setLabelFor(highlightRequired);
159: highlightRequiredLabel.setText(ResourceMgr
160: .getString("LblHiliteRqd"));
161: highlightRequiredLabel.setToolTipText(ResourceMgr
162: .getDescription("LblHiliteRqd"));
163: gridBagConstraints = new java.awt.GridBagConstraints();
164: gridBagConstraints.gridx = 0;
165: gridBagConstraints.gridy = 2;
166: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
167: gridBagConstraints.insets = new java.awt.Insets(8, 12, 0, 0);
168: add(highlightRequiredLabel, gridBagConstraints);
169:
170: highlightRequired.setFont(null);
171: highlightRequired.setBorder(null);
172: highlightRequired
173: .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
174: highlightRequired
175: .setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
176: highlightRequired.setIconTextGap(5);
177: gridBagConstraints = new java.awt.GridBagConstraints();
178: gridBagConstraints.gridx = 1;
179: gridBagConstraints.gridy = 2;
180: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
181: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
182: gridBagConstraints.insets = new java.awt.Insets(9, 9, 0, 0);
183: add(highlightRequired, gridBagConstraints);
184: gridBagConstraints = new java.awt.GridBagConstraints();
185: gridBagConstraints.gridx = 1;
186: gridBagConstraints.gridy = 6;
187: gridBagConstraints.weightx = 1.0;
188: gridBagConstraints.weighty = 1.0;
189: add(dummyPanel, gridBagConstraints);
190: }
191:
192: // Code for dispatching events from components to event handlers.
193:
194: public void actionPerformed(java.awt.event.ActionEvent evt) {
195: if (evt.getSource() == selectMapFile) {
196: DataEditOptionsPanel.this .selectMapFile(evt);
197: }
198: }// </editor-fold>//GEN-END:initComponents
199:
200: private void selectMapFile(java.awt.event.ActionEvent evt)//GEN-FIRST:event_selectMapFile
201: {//GEN-HEADEREND:event_selectMapFile
202: String fileName = FileDialogUtil.selectPkMapFile(this );
203: if (fileName != null)
204: pkMapFile.setText(fileName);
205: }//GEN-LAST:event_selectMapFile
206:
207: // Variables declaration - do not modify//GEN-BEGIN:variables
208: private javax.swing.JPanel dummyPanel;
209: private javax.swing.JCheckBox highlightRequired;
210: private javax.swing.JLabel highlightRequiredLabel;
211: private javax.swing.JPanel jPanel3;
212: private javax.swing.JTextField pkMapFile;
213: private javax.swing.JLabel pkMapFileLabel;
214: private javax.swing.JCheckBox previewDml;
215: private javax.swing.JLabel previewDmlLabel;
216: private workbench.gui.components.WbColorPicker requiredFieldColor;
217: private javax.swing.JLabel requiredFieldLabel;
218: private javax.swing.JButton selectMapFile;
219: // End of variables declaration//GEN-END:variables
220:
221: }
|