Browse Source

Pull request #7460: REPORT-65502 【外包验收】分页设置-按行分页,设置超过500时值会保存为空而不是1或500

Merge in DESIGN/design from ~PENGDA/design:final/11.0 to final/11.0

* commit '5934ba67635d4a7ed5a87303c8c49edb13042420':
  REPORT-65502 【外包验收】分页设置-按行分页,设置超过500时值会保存为空而不是1或500
new-design
pengda 3 years ago
parent
commit
c157d33aca
  1. 17
      designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java
  2. 17
      designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java

17
designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java

@ -60,7 +60,7 @@ public class PageToolBarPane extends AbstractEditToolBarPane {
private UICheckBox isPageFixedRowBox; private UICheckBox isPageFixedRowBox;
private UITextField pageFixedRowCountTextField; private UITextField pageFixedRowCountTextField;
private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92);
private static final Pattern ROW_COUNT = Pattern.compile("^[1-9][\\d]{0,2}$"); private static final Pattern ROW_COUNT = Pattern.compile("^[1-9][\\d]*$|^0");
//固定行数分页,每页最多500行,最少1行数据 //固定行数分页,每页最多500行,最少1行数据
private static final int MAX_ROW_COUNT = 500; private static final int MAX_ROW_COUNT = 500;
@ -275,18 +275,21 @@ public class PageToolBarPane extends AbstractEditToolBarPane {
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
String rowCount = pageFixedRowCountTextField.getText(); String rowCount = pageFixedRowCountTextField.getText();
if (!isRowCountValid(rowCount)) { pageFixedRowCountTextField.setText(convert2ValidRowCount(rowCount));
pageFixedRowCountTextField.setText(StringUtils.EMPTY);
}
} }
}; };
private boolean isRowCountValid(String rowCount) { private String convert2ValidRowCount(String rowCount) {
Matcher matcher = ROW_COUNT.matcher(rowCount); Matcher matcher = ROW_COUNT.matcher(rowCount);
if (matcher.find()) { if (matcher.find()) {
int count = Integer.parseInt(matcher.group()); int count = Integer.parseInt(matcher.group());
return count >= MIN_ROW_COUNT && count <= MAX_ROW_COUNT; if (count > MAX_ROW_COUNT) {
count = MAX_ROW_COUNT;
} else if (count < MIN_ROW_COUNT) {
count = MIN_ROW_COUNT;
}
return String.valueOf(count);
} }
return false; return StringUtils.EMPTY;
} }
} }

17
designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java

@ -41,7 +41,7 @@ public class PageWebSettingPane extends WebSettingPane<WebPage> {
private UICheckBox isPageFixedRowBox; private UICheckBox isPageFixedRowBox;
private UITextField pageFixedRowCountTextField; private UITextField pageFixedRowCountTextField;
private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92);
private static final Pattern ROW_COUNT = Pattern.compile("^[1-9][\\d]{0,2}$"); private static final Pattern ROW_COUNT = Pattern.compile("^[1-9][\\d]*$|^0");
private static final String DEFAULT_ROW_COUNT = "30"; private static final String DEFAULT_ROW_COUNT = "30";
//固定行数分页,每页最多500行,最少1行数据 //固定行数分页,每页最多500行,最少1行数据
@ -82,9 +82,7 @@ public class PageWebSettingPane extends WebSettingPane<WebPage> {
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
String rowCount = pageFixedRowCountTextField.getText(); String rowCount = pageFixedRowCountTextField.getText();
if (!isRowCountValid(rowCount)) { pageFixedRowCountTextField.setText(convert2ValidRowCount(rowCount));
pageFixedRowCountTextField.setText(StringUtils.EMPTY);
}
} }
}); });
pageFixedRowCountTextField.addInputMethodListener(new InputMethodListener() { pageFixedRowCountTextField.addInputMethodListener(new InputMethodListener() {
@ -207,12 +205,17 @@ public class PageWebSettingPane extends WebSettingPane<WebPage> {
reportWebAttr.setWebPage(webContent); reportWebAttr.setWebPage(webContent);
} }
private boolean isRowCountValid(String rowCount) { private String convert2ValidRowCount(String rowCount) {
Matcher matcher = ROW_COUNT.matcher(rowCount); Matcher matcher = ROW_COUNT.matcher(rowCount);
if (matcher.find()) { if (matcher.find()) {
int count = Integer.parseInt(matcher.group()); int count = Integer.parseInt(matcher.group());
return count >= MIN_ROW_COUNT && count <= MAX_ROW_COUNT; if (count > MAX_ROW_COUNT) {
count = MAX_ROW_COUNT;
} else if (count < MIN_ROW_COUNT) {
count = MIN_ROW_COUNT;
}
return String.valueOf(count);
} }
return false; return StringUtils.EMPTY;
} }
} }

Loading…
Cancel
Save