@ -41,7 +41,7 @@ public class PageWebSettingPane extends WebSettingPane<WebPage> {
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<WebPage> {
@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<WebPage> {
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 ;
}
}