|
|
@ -9,13 +9,15 @@ import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.form.ui.NumberEditor; |
|
|
|
import com.fr.form.ui.NumberEditor; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
|
|
|
@ -23,6 +25,7 @@ import java.awt.event.ActionListener; |
|
|
|
* Created by kerry on 2017/9/10. |
|
|
|
* Created by kerry on 2017/9/10. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class NumberEditorValidatePane extends JPanel { |
|
|
|
public class NumberEditorValidatePane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
private UICheckBox allowDecimalsCheckBox; |
|
|
|
private UICheckBox allowDecimalsCheckBox; |
|
|
|
private UICheckBox allowNegativeCheckBox; |
|
|
|
private UICheckBox allowNegativeCheckBox; |
|
|
|
private UICheckBox setMaxValueCheckBox; |
|
|
|
private UICheckBox setMaxValueCheckBox; |
|
|
@ -104,6 +107,7 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
private void initListeners() { |
|
|
|
private void initListeners() { |
|
|
|
allowDecimalsListener = new ActionListener() { |
|
|
|
allowDecimalsListener = new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (allowDecimalsCheckBox.isSelected()) { |
|
|
|
if (allowDecimalsCheckBox.isSelected()) { |
|
|
|
limitNumberPane.setVisible(true); |
|
|
|
limitNumberPane.setVisible(true); |
|
|
@ -129,8 +133,8 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
if (!setMinValueCheckBox.isSelected()) { |
|
|
|
if (!setMinValueCheckBox.isSelected()) { |
|
|
|
maxValueSpinner.getTextField().setMinValue(0.0); |
|
|
|
maxValueSpinner.getTextField().setMinValue(0.0); |
|
|
|
} |
|
|
|
} |
|
|
|
Double minValue = Double.parseDouble("" + minValueSpinner.getValue()); |
|
|
|
double minValue = Double.parseDouble("" + minValueSpinner.getValue()); |
|
|
|
Double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); |
|
|
|
double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); |
|
|
|
if (minValue < 0.0) { |
|
|
|
if (minValue < 0.0) { |
|
|
|
minValueSpinner.setValue(0.0); |
|
|
|
minValueSpinner.setValue(0.0); |
|
|
|
} |
|
|
|
} |
|
|
@ -143,10 +147,11 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setMaxListener = new ActionListener() { |
|
|
|
setMaxListener = new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
maxValueSpinner.setEnabled(true); |
|
|
|
maxValueSpinner.setEnabled(true); |
|
|
|
Double value = new Double(0); |
|
|
|
Double value = (double) 0; |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
Double minValue = Double.parseDouble("" + minValueSpinner.getValue()); |
|
|
|
Double minValue = Double.parseDouble("" + minValueSpinner.getValue()); |
|
|
|
if (minValue > value) { |
|
|
|
if (minValue > value) { |
|
|
@ -163,10 +168,11 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setMinListener = new ActionListener() { |
|
|
|
setMinListener = new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
minValueSpinner.setEnabled(true); |
|
|
|
minValueSpinner.setEnabled(true); |
|
|
|
Double value = new Double(0); |
|
|
|
Double value = (double) 0; |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
Double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); |
|
|
|
Double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); |
|
|
|
if (maxValue < value) { |
|
|
|
if (maxValue < value) { |
|
|
@ -177,7 +183,7 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
maxValueSpinner.getTextField().setMinValue(value); |
|
|
|
maxValueSpinner.getTextField().setMinValue(value); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
minValueSpinner.setEnabled(false); |
|
|
|
minValueSpinner.setEnabled(false); |
|
|
|
maxValueSpinner.getTextField().setMinValue(allowNegativeCheckBox.isSelected() ? (-Double.MAX_VALUE) : new Double(0)); |
|
|
|
maxValueSpinner.getTextField().setMinValue(allowNegativeCheckBox.isSelected() ? (-Double.MAX_VALUE) : (double) 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -222,23 +228,23 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
allowNegativeCheckBox.setSelected(e.isAllowNegative()); |
|
|
|
allowNegativeCheckBox.setSelected(e.isAllowNegative()); |
|
|
|
if (e.getMaxValue() == Double.MAX_VALUE) { |
|
|
|
if (e.getMaxValue() == Double.MAX_VALUE) { |
|
|
|
setMaxValueCheckBox.setSelected(false); |
|
|
|
setMaxValueCheckBox.setSelected(false); |
|
|
|
maxValueSpinner.setValue(new Double(Double.MAX_VALUE)); |
|
|
|
maxValueSpinner.setValue(Double.MAX_VALUE); |
|
|
|
maxValueSpinner.setEnabled(false); |
|
|
|
maxValueSpinner.setEnabled(false); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setMaxValueCheckBox.setSelected(true); |
|
|
|
setMaxValueCheckBox.setSelected(true); |
|
|
|
maxValueSpinner.setEnabled(true); |
|
|
|
maxValueSpinner.setEnabled(true); |
|
|
|
maxValueSpinner.setValue(new Double(e.getMaxValue())); |
|
|
|
maxValueSpinner.setValue(e.getMaxValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.getMinValue() == -Double.MAX_VALUE) { |
|
|
|
if (e.getMinValue() == -Double.MAX_VALUE) { |
|
|
|
setMinValueCheckBox.setSelected(false); |
|
|
|
setMinValueCheckBox.setSelected(false); |
|
|
|
minValueSpinner.setValue(new Double(-Double.MAX_VALUE)); |
|
|
|
minValueSpinner.setValue(-Double.MAX_VALUE); |
|
|
|
minValueSpinner.setEnabled(false); |
|
|
|
minValueSpinner.setEnabled(false); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setMinValueCheckBox.setSelected(true); |
|
|
|
setMinValueCheckBox.setSelected(true); |
|
|
|
minValueSpinner.setEnabled(true); |
|
|
|
minValueSpinner.setEnabled(true); |
|
|
|
minValueSpinner.setValue(new Double(e.getMinValue())); |
|
|
|
minValueSpinner.setValue(e.getMinValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()) { |
|
|
|
errorMsgTextFieldPane.setVisible(true); |
|
|
|
errorMsgTextFieldPane.setVisible(true); |
|
|
@ -259,10 +265,14 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
ob.setMinValue(minValueSpinner.getValue()); |
|
|
|
ob.setMinValue(minValueSpinner.getValue()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ob.setMinValue(-Double.MAX_VALUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
ob.setMaxValue(maxValueSpinner.getValue()); |
|
|
|
ob.setMaxValue(maxValueSpinner.getValue()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ob.setMaxValue(Double.MAX_VALUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()) { |
|
|
|