001: /*
002: * FormatterOptionsPanel.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.WbCheckBoxLabel;
016: import workbench.interfaces.Restoreable;
017: import workbench.resource.ResourceMgr;
018: import workbench.resource.Settings;
019: import workbench.util.StringUtil;
020:
021: /**
022: *
023: * @author support@sql-workbench.net
024: */
025: public class FormatterOptionsPanel extends JPanel implements
026: Restoreable {
027:
028: /** Creates new form FormatterOptionsPanel */
029: public FormatterOptionsPanel() {
030: initComponents();
031: }
032:
033: public void restoreSettings() {
034: funcsLower.setSelected(Settings.getInstance()
035: .getFormatterLowercaseFunctions());
036: }
037:
038: public void saveSettings() {
039: Settings set = Settings.getInstance();
040: set.setMaxNumInListElements(StringUtil.getIntValue(
041: maxNumElements.getText(), -1));
042: set.setMaxCharInListElements(StringUtil.getIntValue(
043: maxCharElements.getText(), -1));
044: set.setFormatterMaxSubselectLength(StringUtil.getIntValue(
045: subselectMaxLength.getText(), 60));
046: set.setFormatterMaxColumnsInSelect(StringUtil.getIntValue(
047: selectColumns.getText(), 1));
048: set.setFormatterLowercaseFunctions(funcsLower.isSelected());
049: }
050:
051: /** This method is called from within the constructor to
052: * initialize the form.
053: * WARNING: Do NOT modify this code. The content of this method is
054: * always regenerated by the Form Editor.
055: */
056: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
057: private void initComponents() {
058: java.awt.GridBagConstraints gridBagConstraints;
059:
060: subselectMaxLabel = new javax.swing.JLabel();
061: subselectMaxLength = new javax.swing.JTextField();
062: maxCharElementsLabel = new javax.swing.JLabel();
063: maxCharElements = new javax.swing.JTextField();
064: maxNumElementsLabel = new javax.swing.JLabel();
065: maxNumElements = new javax.swing.JTextField();
066: selectColumns = new javax.swing.JTextField();
067: selectColumnsLabel = new javax.swing.JLabel();
068: funcsLowerLabel = new WbCheckBoxLabel();
069: funcsLower = new javax.swing.JCheckBox();
070:
071: setLayout(new java.awt.GridBagLayout());
072:
073: subselectMaxLabel
074: .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
075: subselectMaxLabel.setText(ResourceMgr.getString("LblMaxSub"));
076: subselectMaxLabel.setToolTipText(ResourceMgr
077: .getDescription("LblMaxSub"));
078: gridBagConstraints = new java.awt.GridBagConstraints();
079: gridBagConstraints.gridx = 0;
080: gridBagConstraints.gridy = 0;
081: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
082: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
083: gridBagConstraints.insets = new java.awt.Insets(10, 12, 0, 0);
084: add(subselectMaxLabel, gridBagConstraints);
085:
086: subselectMaxLength.setText(Integer.toString(Settings
087: .getInstance().getFormatterMaxSubselectLength()));
088: gridBagConstraints = new java.awt.GridBagConstraints();
089: gridBagConstraints.gridx = 1;
090: gridBagConstraints.gridy = 0;
091: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
092: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
093: gridBagConstraints.weightx = 1.0;
094: gridBagConstraints.insets = new java.awt.Insets(8, 9, 0, 15);
095: add(subselectMaxLength, gridBagConstraints);
096:
097: maxCharElementsLabel
098: .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
099: maxCharElementsLabel.setText(ResourceMgr
100: .getString("LblMaxCharEle"));
101: maxCharElementsLabel.setToolTipText(ResourceMgr
102: .getDescription("LblMaxCharEle"));
103: gridBagConstraints = new java.awt.GridBagConstraints();
104: gridBagConstraints.gridx = 0;
105: gridBagConstraints.gridy = 2;
106: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
107: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
108: gridBagConstraints.insets = new java.awt.Insets(7, 12, 0, 0);
109: add(maxCharElementsLabel, gridBagConstraints);
110:
111: maxCharElements.setText(Integer.toString(Settings.getInstance()
112: .getMaxCharInListElements()));
113: gridBagConstraints = new java.awt.GridBagConstraints();
114: gridBagConstraints.gridx = 1;
115: gridBagConstraints.gridy = 2;
116: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
117: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
118: gridBagConstraints.insets = new java.awt.Insets(5, 9, 0, 15);
119: add(maxCharElements, gridBagConstraints);
120:
121: maxNumElementsLabel
122: .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
123: maxNumElementsLabel.setText(ResourceMgr
124: .getString("LblMaxNumEle"));
125: maxNumElementsLabel.setToolTipText(ResourceMgr
126: .getDescription("LblMaxNumEle"));
127: gridBagConstraints = new java.awt.GridBagConstraints();
128: gridBagConstraints.gridx = 0;
129: gridBagConstraints.gridy = 3;
130: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
132: gridBagConstraints.insets = new java.awt.Insets(7, 12, 0, 0);
133: add(maxNumElementsLabel, gridBagConstraints);
134:
135: maxNumElements.setText(Integer.toString(Settings.getInstance()
136: .getMaxNumInListElements()));
137: gridBagConstraints = new java.awt.GridBagConstraints();
138: gridBagConstraints.gridx = 1;
139: gridBagConstraints.gridy = 3;
140: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
141: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
142: gridBagConstraints.insets = new java.awt.Insets(5, 9, 0, 15);
143: add(maxNumElements, gridBagConstraints);
144:
145: selectColumns.setText(Integer.toString(Settings.getInstance()
146: .getFormatterMaxColumnsInSelect()));
147: gridBagConstraints = new java.awt.GridBagConstraints();
148: gridBagConstraints.gridx = 1;
149: gridBagConstraints.gridy = 1;
150: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
151: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
152: gridBagConstraints.insets = new java.awt.Insets(5, 9, 0, 15);
153: add(selectColumns, gridBagConstraints);
154:
155: selectColumnsLabel
156: .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
157: selectColumnsLabel.setText(ResourceMgr
158: .getString("LblSqlFmtColNum"));
159: selectColumnsLabel.setToolTipText(ResourceMgr
160: .getDescription("LblSqlFmtColNum"));
161: gridBagConstraints = new java.awt.GridBagConstraints();
162: gridBagConstraints.gridx = 0;
163: gridBagConstraints.gridy = 1;
164: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
165: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
166: gridBagConstraints.insets = new java.awt.Insets(7, 12, 0, 0);
167: add(selectColumnsLabel, gridBagConstraints);
168:
169: funcsLowerLabel.setLabelFor(funcsLower);
170: funcsLowerLabel.setText(ResourceMgr
171: .getString("LblFmtFuncLower"));
172: funcsLowerLabel.setToolTipText(ResourceMgr
173: .getDescription("LblFmtFuncLower"));
174: gridBagConstraints = new java.awt.GridBagConstraints();
175: gridBagConstraints.gridx = 0;
176: gridBagConstraints.gridy = 4;
177: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
179: gridBagConstraints.weighty = 1.0;
180: gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 0);
181: add(funcsLowerLabel, gridBagConstraints);
182:
183: funcsLower.setBorder(null);
184: funcsLower.setIconTextGap(0);
185: funcsLower.setMargin(new java.awt.Insets(0, 0, 0, 0));
186: gridBagConstraints = new java.awt.GridBagConstraints();
187: gridBagConstraints.gridx = 1;
188: gridBagConstraints.gridy = 4;
189: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
190: gridBagConstraints.weighty = 1.0;
191: gridBagConstraints.insets = new java.awt.Insets(8, 9, 0, 0);
192: add(funcsLower, gridBagConstraints);
193: }// </editor-fold>//GEN-END:initComponents
194:
195: // Variables declaration - do not modify//GEN-BEGIN:variables
196: private javax.swing.JCheckBox funcsLower;
197: private javax.swing.JLabel funcsLowerLabel;
198: private javax.swing.JTextField maxCharElements;
199: private javax.swing.JLabel maxCharElementsLabel;
200: private javax.swing.JTextField maxNumElements;
201: private javax.swing.JLabel maxNumElementsLabel;
202: private javax.swing.JTextField selectColumns;
203: private javax.swing.JLabel selectColumnsLabel;
204: private javax.swing.JLabel subselectMaxLabel;
205: private javax.swing.JTextField subselectMaxLength;
206: // End of variables declaration//GEN-END:variables
207:
208: }
|