Browse Source

【1004回归】设计面板-超级链接-网络报表-对话框设置 禁止输入负数

feature/big-screen
hades 5 years ago
parent
commit
d5a216c38e
  1. 8
      designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java
  2. 2
      designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java

8
designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java

@ -35,6 +35,7 @@ public class UINumberField extends UITextField {
private double maxValue = Double.MAX_VALUE; private double maxValue = Double.MAX_VALUE;
private boolean isContentChanged = false; private boolean isContentChanged = false;
private boolean fillNegativeNumbers = true;
public UINumberField() { public UINumberField() {
this(MAX_INTEGERLENGTH_32, MAX_DECIMALLENGTH); this(MAX_INTEGERLENGTH_32, MAX_DECIMALLENGTH);
@ -62,6 +63,10 @@ public class UINumberField extends UITextField {
initListener(); initListener();
} }
public void canFillNegativeNumber(boolean canFillNegativeNumbers) {
this.fillNegativeNumbers = canFillNegativeNumbers;
}
public int getMaxIntegerLength() { public int getMaxIntegerLength() {
return maxIntegerLength; return maxIntegerLength;
} }
@ -185,6 +190,9 @@ public class UINumberField extends UITextField {
// kunsnat: 这种限制输入 有个不好的地方, 比如删除时: 10.1 最大值限定100, 那么就删除中间的小数点之后变为101, 超出了100. // kunsnat: 这种限制输入 有个不好的地方, 比如删除时: 10.1 最大值限定100, 那么就删除中间的小数点之后变为101, 超出了100.
// 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难.. // 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难..
private boolean notChange(String strNew) { private boolean notChange(String strNew) {
if (!fillNegativeNumbers && strNew.contains("-")) {
return true;
}
boolean noChange = false; boolean noChange = false;
boolean isMinus = strNew.startsWith("-"); boolean isMinus = strNew.startsWith("-");
strNew = strNew.replaceFirst("-", StringUtils.EMPTY); // 控制能输入负数 strNew = strNew.replaceFirst("-", StringUtils.EMPTY); // 控制能输入负数

2
designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java

@ -368,6 +368,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
sizeJPanel.add(heightLabel); sizeJPanel.add(heightLabel);
UINumberField heightTextFiled = new UINumberField(); UINumberField heightTextFiled = new UINumberField();
heightTextFiled.setMinValue(0); heightTextFiled.setMinValue(0);
heightTextFiled.canFillNegativeNumber(false);
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE)); heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE));
heightTextFiled.setPreferredSize(new Dimension(40, 20)); heightTextFiled.setPreferredSize(new Dimension(40, 20));
sizeJPanel.add(heightTextFiled); sizeJPanel.add(heightTextFiled);
@ -377,6 +378,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
sizeJPanel.add(widthLabel); sizeJPanel.add(widthLabel);
UINumberField widthTextFiled = new UINumberField(); UINumberField widthTextFiled = new UINumberField();
widthTextFiled.setMinValue(0); widthTextFiled.setMinValue(0);
widthTextFiled.canFillNegativeNumber(false);
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE)); widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE));
widthTextFiled.setPreferredSize(new Dimension(40, 20)); widthTextFiled.setPreferredSize(new Dimension(40, 20));
sizeJPanel.add(widthTextFiled); sizeJPanel.add(widthTextFiled);

Loading…
Cancel
Save