001: /*
002: * TableDataSettings.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.dbobjects;
013:
014: import java.awt.event.ActionListener;
015:
016: import workbench.resource.ResourceMgr;
017: import workbench.util.StringUtil;
018:
019: /**
020: *
021: * @author support@sql-workbench.net
022: */
023: public class TableDataSettings extends javax.swing.JPanel implements
024: ActionListener {
025:
026: /** Creates new form ConfigureWarningThreshold */
027: public TableDataSettings() {
028: initComponents();
029: this .checkBoxEnableWarning.addActionListener(this );
030: }
031:
032: /** This method is called from within the constructor to
033: * initialize the form.
034: * WARNING: Do NOT modify this code. The content of this method is
035: * always regenerated by the Form Editor.
036: */
037: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
038: private void initComponents() {
039: java.awt.GridBagConstraints gridBagConstraints;
040:
041: checkBoxEnableWarning = new javax.swing.JCheckBox();
042: autoloadRowCount = new javax.swing.JCheckBox();
043: autoloadData = new javax.swing.JCheckBox();
044: thresholdLabel = new javax.swing.JLabel();
045: textFieldThresholdValue = new javax.swing.JTextField();
046: jPanel1 = new javax.swing.JPanel();
047:
048: setLayout(new java.awt.GridBagLayout());
049:
050: checkBoxEnableWarning.setText(ResourceMgr
051: .getString("LblEnableDataThresholdWarning"));
052: checkBoxEnableWarning.setToolTipText(ResourceMgr
053: .getDescription("LblEnableDataThresholdWarning"));
054: checkBoxEnableWarning
055: .setMargin(new java.awt.Insets(0, 0, 0, 0));
056: gridBagConstraints = new java.awt.GridBagConstraints();
057: gridBagConstraints.gridx = 0;
058: gridBagConstraints.gridy = 0;
059: gridBagConstraints.gridwidth = 2;
060: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
061: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
062: add(checkBoxEnableWarning, gridBagConstraints);
063:
064: autoloadRowCount.setText(ResourceMgr
065: .getString("LblAutoLoadRowCount"));
066: autoloadRowCount.setToolTipText(ResourceMgr
067: .getDescription("LblAutoLoadRowCount"));
068: autoloadRowCount.setMargin(new java.awt.Insets(0, 0, 0, 0));
069: gridBagConstraints = new java.awt.GridBagConstraints();
070: gridBagConstraints.gridx = 0;
071: gridBagConstraints.gridy = 2;
072: gridBagConstraints.gridwidth = 2;
073: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
074: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
075: gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
076: add(autoloadRowCount, gridBagConstraints);
077:
078: autoloadData.setText(ResourceMgr
079: .getString("LblAutoLoadTableData"));
080: autoloadData.setToolTipText(ResourceMgr
081: .getDescription("LblAutoLoadTableData"));
082: autoloadData.setMargin(new java.awt.Insets(0, 0, 0, 0));
083: gridBagConstraints = new java.awt.GridBagConstraints();
084: gridBagConstraints.gridx = 0;
085: gridBagConstraints.gridy = 3;
086: gridBagConstraints.gridwidth = 2;
087: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
088: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
089: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
090: add(autoloadData, gridBagConstraints);
091:
092: thresholdLabel.setText(ResourceMgr
093: .getString("LblThresholdLevel"));
094: thresholdLabel.setToolTipText(ResourceMgr
095: .getDescription("LblThresholdLevel"));
096: gridBagConstraints = new java.awt.GridBagConstraints();
097: gridBagConstraints.gridx = 0;
098: gridBagConstraints.gridy = 1;
099: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
100: add(thresholdLabel, gridBagConstraints);
101:
102: textFieldThresholdValue.setColumns(8);
103: gridBagConstraints = new java.awt.GridBagConstraints();
104: gridBagConstraints.gridx = 1;
105: gridBagConstraints.gridy = 1;
106: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
107: gridBagConstraints.weightx = 1.0;
108: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 9);
109: add(textFieldThresholdValue, gridBagConstraints);
110: gridBagConstraints = new java.awt.GridBagConstraints();
111: gridBagConstraints.gridx = 0;
112: gridBagConstraints.gridy = 4;
113: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
114: gridBagConstraints.weighty = 1.0;
115: add(jPanel1, gridBagConstraints);
116: }// </editor-fold>//GEN-END:initComponents
117:
118: public int getThresholdValue() {
119: if (this .checkBoxEnableWarning.isSelected()) {
120: return StringUtil.getIntValue(this .textFieldThresholdValue
121: .getText(), -1);
122: } else {
123: return -1;
124: }
125: }
126:
127: public void setAutoloadRowCount(boolean flag) {
128: this .autoloadRowCount.setSelected(flag);
129: }
130:
131: public boolean getAutoloadRowCount() {
132: return this .autoloadRowCount.isSelected();
133: }
134:
135: public void setAutoloadData(boolean flag) {
136: this .autoloadData.setSelected(flag);
137: }
138:
139: public boolean getAutoloadData() {
140: return this .autoloadData.isSelected();
141: }
142:
143: public void setThresholdValue(int aValue) {
144: this .checkBoxEnableWarning.setSelected(aValue > 0);
145: this .textFieldThresholdValue.setEnabled(aValue > 0);
146: this .thresholdLabel.setEnabled(aValue > 0);
147: if (aValue <= 0) {
148: this .textFieldThresholdValue.setText("");
149: } else {
150: this .textFieldThresholdValue.setText(Integer
151: .toString(aValue));
152: }
153: }
154:
155: public void actionPerformed(java.awt.event.ActionEvent e) {
156: if (e.getSource() == this .checkBoxEnableWarning) {
157: this .textFieldThresholdValue
158: .setEnabled(this .checkBoxEnableWarning.isSelected());
159: this .thresholdLabel.setEnabled(this .checkBoxEnableWarning
160: .isSelected());
161: }
162: }
163:
164: // Variables declaration - do not modify//GEN-BEGIN:variables
165: private javax.swing.JCheckBox autoloadData;
166: private javax.swing.JCheckBox autoloadRowCount;
167: private javax.swing.JCheckBox checkBoxEnableWarning;
168: private javax.swing.JPanel jPanel1;
169: private javax.swing.JTextField textFieldThresholdValue;
170: private javax.swing.JLabel thresholdLabel;
171: // End of variables declaration//GEN-END:variables
172:
173: }
|