diff --git a/designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java b/designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java index 48fb0c8dd..783bc0e6a 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/PageToolBarPane.java @@ -60,7 +60,7 @@ public class PageToolBarPane extends AbstractEditToolBarPane { private UICheckBox isPageFixedRowBox; private UITextField pageFixedRowCountTextField; 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行数据 private static final int MAX_ROW_COUNT = 500; @@ -275,18 +275,21 @@ public class PageToolBarPane extends AbstractEditToolBarPane { @Override public void keyReleased(KeyEvent e) { String rowCount = pageFixedRowCountTextField.getText(); - if (!isRowCountValid(rowCount)) { - pageFixedRowCountTextField.setText(StringUtils.EMPTY); - } + pageFixedRowCountTextField.setText(convert2ValidRowCount(rowCount)); } }; - private boolean isRowCountValid(String rowCount) { + private String convert2ValidRowCount(String rowCount) { Matcher matcher = ROW_COUNT.matcher(rowCount); if (matcher.find()) { 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; } } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java index 98890f6d8..1a3d323e9 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/PageWebSettingPane.java @@ -41,7 +41,7 @@ public class PageWebSettingPane extends WebSettingPane { private UICheckBox isPageFixedRowBox; private UITextField pageFixedRowCountTextField; 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"; //固定行数分页,每页最多500行,最少1行数据 @@ -82,9 +82,7 @@ public class PageWebSettingPane extends WebSettingPane { @Override public void keyReleased(KeyEvent e) { String rowCount = pageFixedRowCountTextField.getText(); - if (!isRowCountValid(rowCount)) { - pageFixedRowCountTextField.setText(StringUtils.EMPTY); - } + pageFixedRowCountTextField.setText(convert2ValidRowCount(rowCount)); } }); pageFixedRowCountTextField.addInputMethodListener(new InputMethodListener() { @@ -207,12 +205,17 @@ public class PageWebSettingPane extends WebSettingPane { reportWebAttr.setWebPage(webContent); } - private boolean isRowCountValid(String rowCount) { + private String convert2ValidRowCount(String rowCount) { Matcher matcher = ROW_COUNT.matcher(rowCount); if (matcher.find()) { 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; } }