From 48d530678876a50dcd90f3970e0f73890893898d Mon Sep 17 00:00:00 2001 From: pengda Date: Fri, 7 Jan 2022 11:01:42 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-65502=20=E3=80=90=E5=A4=96=E5=8C=85?= =?UTF-8?q?=E9=AA=8C=E6=94=B6=E3=80=91=E5=88=86=E9=A1=B5=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?-=E6=8C=89=E8=A1=8C=E5=88=86=E9=A1=B5=EF=BC=8C=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=B6=85=E8=BF=87500=E6=97=B6=E5=80=BC=E4=BC=9A?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=B8=BA=E7=A9=BA=E8=80=8C=E4=B8=8D=E6=98=AF?= =?UTF-8?q?1=E6=88=96500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/webattr/PageToolBarPane.java | 17 ++++++++++------- .../fr/design/webattr/PageWebSettingPane.java | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) 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 48fb0c8ddb..783bc0e6a3 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 98890f6d8c..1a3d323e9f 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; } }