Browse Source

Merge pull request #1394 in BA/design from ~MOMEAK/design9.0:release/9.0 to release/9.0

* commit 'c9cc266f07f2b6d816c45d10512596b705d4d14d':
  REPORT-5277 [9.0三轮回归]数字控件设置最大值最小值,移出焦点后不成功
  代码规范
master
superman 7 years ago
parent
commit
a273349a75
  1. 7
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java
  2. 2
      designer_base/src/com/fr/design/gui/itextfield/UINumberField.java
  3. 64
      designer_base/src/com/fr/design/widget/component/NumberEditorValidatePane.java

7
designer_base/src/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java

@ -90,6 +90,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private Parameter[] params; private Parameter[] params;
private JPanel filePath; private JPanel filePath;
private XMLNodeTreePane nodeTreePane; private XMLNodeTreePane nodeTreePane;
private JPanel textSetPanel;
private UICheckBox needColumnNameCheckBox;// 第一行是否作为标题 private UICheckBox needColumnNameCheckBox;// 第一行是否作为标题
private UIRadioButton tableDismemberRadioButton;// 制表符 private UIRadioButton tableDismemberRadioButton;// 制表符
@ -150,8 +151,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
southPanel.add(setPanel, BorderLayout.CENTER); southPanel.add(setPanel, BorderLayout.CENTER);
setPanel.setPreferredSize(new Dimension(setPanelWidth, 460)); setPanel.setPreferredSize(new Dimension(setPanelWidth, 460));
setPanel.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("FR-Designer_Set"))); setPanel.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("FR-Designer_Set")));
JPanel controlPane = textSetPanel(width,height); textSetPanel = textSetPanel(width,height);
setPanel.add(controlPane, BorderLayout.NORTH); setPanel.add(textSetPanel, BorderLayout.NORTH);
fileTypeComboBox.addActionListener(getFileTypeListener(setPanel,width,height)); fileTypeComboBox.addActionListener(getFileTypeListener(setPanel,width,height));
this.add(northPanel, BorderLayout.NORTH); this.add(northPanel, BorderLayout.NORTH);
@ -464,7 +465,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} else if (fileTypeComboBox.getSelectedIndex() == EXCEL) { } else if (fileTypeComboBox.getSelectedIndex() == EXCEL) {
setPanel.add(excelSetPanel(width,height), BorderLayout.NORTH); setPanel.add(excelSetPanel(width,height), BorderLayout.NORTH);
} else { } else {
setPanel.add(textSetPanel(width,height), BorderLayout.NORTH); setPanel.add(textSetPanel, BorderLayout.NORTH);
} }
String tipContent = Inter.getLocText("FR-Designer-Type_Parameter") + "reportlets/excel/FineReport${abc}." + getFileSuffixToString() + "<br>" String tipContent = Inter.getLocText("FR-Designer-Type_Parameter") + "reportlets/excel/FineReport${abc}." + getFileSuffixToString() + "<br>"
+ "http://192.168.100.120:8080/XXServer/Report/excel${abc}.jsp<br>" + "&nbsp</body> </html> "; + "http://192.168.100.120:8080/XXServer/Report/excel${abc}.jsp<br>" + "&nbsp</body> </html> ";

2
designer_base/src/com/fr/design/gui/itextfield/UINumberField.java

@ -185,8 +185,8 @@ public class UINumberField extends UITextField {
// 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难.. // 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难..
private boolean notChange(String strNew) { private boolean notChange(String strNew) {
boolean noChange = false; boolean noChange = false;
strNew = strNew.replaceFirst("-", StringUtils.EMPTY); // 控制能输入负数
boolean isMinus = strNew.startsWith("-"); boolean isMinus = strNew.startsWith("-");
strNew = strNew.replaceFirst("-", StringUtils.EMPTY); // 控制能输入负数
String strIntPart; String strIntPart;
String strDecPart = StringUtils.EMPTY; String strDecPart = StringUtils.EMPTY;
int decPos = strNew.indexOf(CoreConstants.DOT); int decPos = strNew.indexOf(CoreConstants.DOT);

64
designer_base/src/com/fr/design/widget/component/NumberEditorValidatePane.java

@ -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()) {
ob.setMaxValue(Double.parseDouble(StringUtils.EMPTY + maxValueSpinner.getValue())); 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()));
}
} else { } else {
ob.setMaxValue(Double.MAX_VALUE); ob.setMaxValue(Double.MAX_VALUE);
} }
if (setMinValueCheckBox.isSelected()) { if (setMinValueCheckBox.isSelected()) {
ob.setMinValue(Double.parseDouble(StringUtils.EMPTY + minValueSpinner.getValue())); 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()));
}
} else { } else {
ob.setMinValue(-Double.MAX_VALUE); ob.setMinValue(-Double.MAX_VALUE);
} }

Loading…
Cancel
Save