|
|
@ -29,10 +29,8 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
private UICheckBox allowNegativeCheckBox; |
|
|
|
private UICheckBox allowNegativeCheckBox; |
|
|
|
private UICheckBox setMaxValueCheckBox; |
|
|
|
private UICheckBox setMaxValueCheckBox; |
|
|
|
private UICheckBox setMinValueCheckBox; |
|
|
|
private UICheckBox setMinValueCheckBox; |
|
|
|
private UIBasicSpinner maxValueSpinner; |
|
|
|
private UISpinner maxValueSpinner; |
|
|
|
private SpinnerNumberModel maxValueModel; |
|
|
|
private UISpinner minValueSpinner; |
|
|
|
private UIBasicSpinner minValueSpinner; |
|
|
|
|
|
|
|
private SpinnerNumberModel minValueModel; |
|
|
|
|
|
|
|
private UISpinner decimalLength; |
|
|
|
private UISpinner decimalLength; |
|
|
|
private JPanel limitNumberPane; |
|
|
|
private JPanel limitNumberPane; |
|
|
|
private UITextField errorMsgTextField; |
|
|
|
private UITextField errorMsgTextField; |
|
|
@ -66,13 +64,11 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
allowNegativeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
allowNegativeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
this.setMaxValueCheckBox = new UICheckBox(Inter.getLocText("Need_Max_Value"), false); |
|
|
|
this.setMaxValueCheckBox = new UICheckBox(Inter.getLocText("Need_Max_Value"), false); |
|
|
|
setMaxValueCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
setMaxValueCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
this.maxValueSpinner = new UIBasicSpinner(maxValueModel = new SpinnerNumberModel(0D, -Double.MAX_VALUE, Double.MAX_VALUE, 1D)); |
|
|
|
this.maxValueSpinner = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1D, 0D); |
|
|
|
setNotAllowsInvalid(this.maxValueSpinner); |
|
|
|
|
|
|
|
this.setMaxValueCheckBox.addActionListener(setMaxListener); |
|
|
|
this.setMaxValueCheckBox.addActionListener(setMaxListener); |
|
|
|
this.maxValueSpinner.addChangeListener(maxValueChangeListener); |
|
|
|
this.maxValueSpinner.addChangeListener(maxValueChangeListener); |
|
|
|
this.setMinValueCheckBox = new UICheckBox(Inter.getLocText("Need_Min_Value"), false); |
|
|
|
this.setMinValueCheckBox = new UICheckBox(Inter.getLocText("Need_Min_Value"), false); |
|
|
|
this.minValueSpinner = new UIBasicSpinner(minValueModel = new SpinnerNumberModel(0D, -Double.MAX_VALUE, Double.MAX_VALUE, 1D)); |
|
|
|
this.minValueSpinner = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1D, 0D); |
|
|
|
setNotAllowsInvalid(this.minValueSpinner); |
|
|
|
|
|
|
|
minValueSpinner.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
minValueSpinner.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
this.setMinValueCheckBox.addActionListener(setMinListener); |
|
|
|
this.setMinValueCheckBox.addActionListener(setMinListener); |
|
|
|
this.minValueSpinner.addChangeListener(minValueChangeListener); |
|
|
|
this.minValueSpinner.addChangeListener(minValueChangeListener); |
|
|
@ -126,14 +122,14 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (allowNegativeCheckBox.isSelected()) { |
|
|
|
if (allowNegativeCheckBox.isSelected()) { |
|
|
|
minValueModel.setMinimum(-Double.MAX_VALUE); |
|
|
|
minValueSpinner.getTextField().setMinValue(-Double.MAX_VALUE); |
|
|
|
if (!setMinValueCheckBox.isSelected()) { |
|
|
|
if (!setMinValueCheckBox.isSelected()) { |
|
|
|
maxValueModel.setMinimum(-Double.MAX_VALUE); |
|
|
|
maxValueSpinner.getTextField().setMinValue(-Double.MAX_VALUE); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
minValueModel.setMinimum(0.0); |
|
|
|
minValueSpinner.getTextField().setMinValue(0.0); |
|
|
|
if (!setMinValueCheckBox.isSelected()) { |
|
|
|
if (!setMinValueCheckBox.isSelected()) { |
|
|
|
maxValueModel.setMinimum(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()); |
|
|
@ -162,7 +158,7 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
maxValueSpinner.setValue(value); |
|
|
|
maxValueSpinner.setValue(value); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
maxValueSpinner.setEnabled(false); |
|
|
|
maxValueSpinner.setEnabled(false); |
|
|
|
minValueModel.setMaximum(Double.MAX_VALUE); |
|
|
|
minValueSpinner.getTextField().setMaxValue(Double.MAX_VALUE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -180,9 +176,10 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
minValueSpinner.setValue(value); |
|
|
|
minValueSpinner.setValue(value); |
|
|
|
|
|
|
|
maxValueSpinner.getTextField().setMinValue(value); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
minValueSpinner.setEnabled(false); |
|
|
|
minValueSpinner.setEnabled(false); |
|
|
|
maxValueModel.setMinimum(allowNegativeCheckBox.isSelected() ? (-Double.MAX_VALUE) : new Double(0)); |
|
|
|
maxValueSpinner.getTextField().setMinValue(allowNegativeCheckBox.isSelected() ? (-Double.MAX_VALUE) : new Double(0)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -192,8 +189,10 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
if (maxValueSpinner.getValue() >= minValueSpinner.getValue()) { |
|
|
|
minValueModel.setMaximum(Double.parseDouble("" + maxValueSpinner.getValue())); |
|
|
|
minValueSpinner.getTextField().setMaxValue(Double.parseDouble("" + maxValueSpinner.getValue())); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
maxValueSpinner.setValue(minValueSpinner.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -204,26 +203,16 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
if (minValueSpinner.getValue() <= maxValueSpinner.getValue()) { |
|
|
|
maxValueModel.setMinimum(Double.parseDouble("" + minValueSpinner.getValue())); |
|
|
|
maxValueSpinner.getTextField().setMinValue(Double.parseDouble("" + minValueSpinner.getValue())); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
minValueSpinner.setValue(maxValueSpinner.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setNotAllowsInvalid(UIBasicSpinner jspinner) { |
|
|
|
|
|
|
|
JComponent editor = jspinner.getEditor(); |
|
|
|
|
|
|
|
if (editor instanceof UIBasicSpinner.DefaultEditor) { |
|
|
|
|
|
|
|
JFormattedTextField ftf = ((UIBasicSpinner.DefaultEditor) editor).getTextField(); |
|
|
|
|
|
|
|
ftf.setColumns(10); |
|
|
|
|
|
|
|
JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter(); |
|
|
|
|
|
|
|
DefaultFormatter df = (DefaultFormatter) formatter; |
|
|
|
|
|
|
|
df.setAllowsInvalid(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void populate(NumberEditor e) { |
|
|
|
public void populate(NumberEditor e) { |
|
|
|
allowDecimalsCheckBox.setSelected(e.isAllowDecimals()); |
|
|
|
allowDecimalsCheckBox.setSelected(e.isAllowDecimals()); |
|
|
|
if (e.isAllowDecimals()) { |
|
|
|
if (e.isAllowDecimals()) { |
|
|
@ -235,7 +224,6 @@ 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); |
|
|
|
// maxValueFieldPane.setVisible(false);
|
|
|
|
|
|
|
|
maxValueSpinner.setValue(new Double(Double.MAX_VALUE)); |
|
|
|
maxValueSpinner.setValue(new Double(Double.MAX_VALUE)); |
|
|
|
maxValueSpinner.setEnabled(false); |
|
|
|
maxValueSpinner.setEnabled(false); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -271,13 +259,23 @@ public class NumberEditorValidatePane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
ob.setAllowNegative(allowNegativeCheckBox.isSelected()); |
|
|
|
ob.setAllowNegative(allowNegativeCheckBox.isSelected()); |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
if (setMaxValueCheckBox.isSelected()) { |
|
|
|
|
|
|
|
if (maxValueSpinner.getValue() < maxValueSpinner.getTextField().getMinValue()) { |
|
|
|
|
|
|
|
ob.setMaxValue(Double.parseDouble(StringUtils.EMPTY + maxValueSpinner.getTextField().getMinValue())); |
|
|
|
|
|
|
|
maxValueSpinner.getTextField().setValue(maxValueSpinner.getTextField().getMaxValue()); |
|
|
|
|
|
|
|
} else { |
|
|
|
ob.setMaxValue(Double.parseDouble(StringUtils.EMPTY + maxValueSpinner.getValue())); |
|
|
|
ob.setMaxValue(Double.parseDouble(StringUtils.EMPTY + maxValueSpinner.getValue())); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ob.setMaxValue(Double.MAX_VALUE); |
|
|
|
ob.setMaxValue(Double.MAX_VALUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
if (setMinValueCheckBox.isSelected()) { |
|
|
|
|
|
|
|
if (minValueSpinner.getValue() > minValueSpinner.getTextField().getMaxValue()) { |
|
|
|
|
|
|
|
ob.setMinValue(Double.parseDouble(StringUtils.EMPTY + minValueSpinner.getTextField().getMaxValue())); |
|
|
|
|
|
|
|
minValueSpinner.getTextField().setValue(minValueSpinner.getTextField().getMaxValue()); |
|
|
|
|
|
|
|
} else { |
|
|
|
ob.setMinValue(Double.parseDouble(StringUtils.EMPTY + minValueSpinner.getValue())); |
|
|
|
ob.setMinValue(Double.parseDouble(StringUtils.EMPTY + minValueSpinner.getValue())); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ob.setMinValue(-Double.MAX_VALUE); |
|
|
|
ob.setMinValue(-Double.MAX_VALUE); |
|
|
|
} |
|
|
|
} |
|
|
|