Browse Source

REPORT-72634 设计器卡顿优化一期

feature/x
John.Ying 2 years ago
parent
commit
4367e08557
  1. 23
      designer-base/src/main/java/com/fr/design/gui/date/JDateDocument.java
  2. 2
      designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java

23
designer-base/src/main/java/com/fr/design/gui/date/JDateDocument.java

@ -10,7 +10,6 @@ import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument; import javax.swing.text.PlainDocument;
/** /**
*
*/ */
public class JDateDocument extends PlainDocument{ public class JDateDocument extends PlainDocument{
private JTextComponent textComponent; //日期输入文本框 private JTextComponent textComponent; //日期输入文本框
@ -36,39 +35,19 @@ public class JDateDocument extends PlainDocument {
SimpleDateFormat dateFormat, SimpleDateFormat dateFormat,
String initDateTime) throws String initDateTime) throws
UnsupportedOperationException { UnsupportedOperationException {
this(tc, dateFormat, initDateTime, false);
}
/**
*
* @param tc
* @param dateFormat
* @param initDateTime
* @param initTime 判断是不是要通过insertString设置默认值
* @throws UnsupportedOperationException
*/
public JDateDocument(JTextComponent tc,
SimpleDateFormat dateFormat,
String initDateTime,
boolean initTime) throws
UnsupportedOperationException {
//设置当前日期格式 //设置当前日期格式
setDateFormat(dateFormat); setDateFormat(dateFormat);
//保存操作的文本框 //保存操作的文本框
textComponent = tc; textComponent = tc;
//设置显示为当前日期,同时完成显示的格式化,如果emptyDateTime为true就设时间为空
if (!initTime) {
try { try {
insertString(0, initDateTime, null); insertString(0, initDateTime, null);
} catch (BadLocationException ex) { } catch (BadLocationException ex) {
throw new UnsupportedOperationException(ex.getMessage()); throw new UnsupportedOperationException(ex.getMessage());
} }
} }
}
/** /**
* 设置当前日期格式 * 设置当前日期格式
*
* @param dateFormat SimpleDateFormat * @param dateFormat SimpleDateFormat
*/ */
public void setDateFormat(SimpleDateFormat dateFormat){ public void setDateFormat(SimpleDateFormat dateFormat){
@ -77,7 +56,6 @@ public class JDateDocument extends PlainDocument {
/** /**
* 取得当前日期格式 * 取得当前日期格式
*
* @return SimpleDateFormat * @return SimpleDateFormat
*/ */
public SimpleDateFormat getDateFormat(){ public SimpleDateFormat getDateFormat(){
@ -86,7 +64,6 @@ public class JDateDocument extends PlainDocument {
/** /**
* 取得当前系统日时 * 取得当前系统日时
*
* @return String * @return String
*/ */
public static String getCurrentDate(SimpleDateFormat smFormat){ public static String getCurrentDate(SimpleDateFormat smFormat){

2
designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java

@ -92,7 +92,7 @@ public class UIDatePicker extends UIComboBox implements Serializable {
//设置编辑器属性(只能输入正确日期) //设置编辑器属性(只能输入正确日期)
JTextField textField = ((JTextField) getEditor().getEditorComponent()); JTextField textField = ((JTextField) getEditor().getEditorComponent());
if (feedbackToolboxDialog != null) { if (feedbackToolboxDialog != null) {
dateDocument = new JDateDocument(textField, this.dateFormat, StringUtils.EMPTY, false); dateDocument = new JDateDocument(textField, this.dateFormat, StringUtils.EMPTY);
this.feedbackToolboxDialog = feedbackToolboxDialog; this.feedbackToolboxDialog = feedbackToolboxDialog;
textField.setHorizontalAlignment(SwingConstants.LEFT); textField.setHorizontalAlignment(SwingConstants.LEFT);
//设置当前选择日期 //设置当前选择日期

Loading…
Cancel
Save