Browse Source

Merge pull request #6209 in DESIGN/design from final/10.0 to persist/10.0

* commit '9508a0985ddb118050e8536dd746bf4a5c8fde15':
  REPORT-59476 && REPORT-59475 文本控件校验规则支持国际化 && 控件校验错误提示支持公式
persist/10.0 10.0.19.2021.10.13
superman 3 years ago
parent
commit
9aee7403b3
  1. 11
      designer-base/src/main/java/com/fr/design/beans/ErrorMsgTextFieldAdapter.java
  2. 46
      designer-base/src/main/java/com/fr/design/beans/UITextFieldAdapter.java
  3. 11
      designer-base/src/main/java/com/fr/design/fun/RegPaneProvider.java
  4. 11
      designer-base/src/main/java/com/fr/design/fun/TextFieldAdapterProvider.java
  5. 22
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractRegPaneProvider.java
  6. 22
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractTextFieldAdapterProvider.java
  7. 56
      designer-base/src/main/java/com/fr/design/gui/frpane/RegFieldPane.java
  8. 49
      designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java
  9. 29
      designer-form/src/main/java/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java
  10. 38
      designer-realize/src/main/java/com/fr/design/widget/ui/FieldEditorDefinePane.java
  11. 18
      designer-realize/src/main/java/com/fr/design/widget/ui/TextFieldEditorDefinePane.java

11
designer-base/src/main/java/com/fr/design/beans/ErrorMsgTextFieldAdapter.java

@ -0,0 +1,11 @@
package com.fr.design.beans;
import javax.swing.JComponent;
public interface ErrorMsgTextFieldAdapter {
void setText(String str);
String getText();
JComponent getErrorMsgTextField();
}

46
designer-base/src/main/java/com/fr/design/beans/UITextFieldAdapter.java

@ -0,0 +1,46 @@
package com.fr.design.beans;
import com.fr.design.gui.itextfield.UITextField;
import javax.swing.JComponent;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class UITextFieldAdapter implements ErrorMsgTextFieldAdapter {
private final UITextField uiTextField = new UITextField();
public UITextFieldAdapter(){
addDocumentListener();
}
@Override
public void setText(String str) {
uiTextField.setText(str);
}
@Override
public String getText() {
return uiTextField.getText();
}
public void addDocumentListener() {
uiTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
uiTextField.setToolTipText(uiTextField.getText());
}
public void insertUpdate(DocumentEvent e) {
uiTextField.setToolTipText(uiTextField.getText());
}
public void removeUpdate(DocumentEvent e) {
uiTextField.setToolTipText(uiTextField.getText());
}
});
}
@Override
public JComponent getErrorMsgTextField() {
return uiTextField;
}
}

11
designer-base/src/main/java/com/fr/design/fun/RegPaneProvider.java

@ -0,0 +1,11 @@
package com.fr.design.fun;
import com.fr.design.gui.frpane.RegFieldPane;
import com.fr.stable.fun.mark.Immutable;
public interface RegPaneProvider extends Immutable {
int CURRENT_LEVEL = 1;
String XML_TAG = "RegPaneProvider";
RegFieldPane createRegPane();
}

11
designer-base/src/main/java/com/fr/design/fun/TextFieldAdapterProvider.java

@ -0,0 +1,11 @@
package com.fr.design.fun;
import com.fr.design.beans.ErrorMsgTextFieldAdapter;
import com.fr.stable.fun.mark.Immutable;
public interface TextFieldAdapterProvider extends Immutable {
String XML_TAG = "TextFieldAdapterProvider";
int CURRENT_LEVEL = 1;
ErrorMsgTextFieldAdapter createTextFieldAdapter();
}

22
designer-base/src/main/java/com/fr/design/fun/impl/AbstractRegPaneProvider.java

@ -0,0 +1,22 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.RegPaneProvider;
import com.fr.stable.fun.mark.API;
/**
* @author Joe
* 2021/10/8 15:19
*/
@API(level = RegPaneProvider.CURRENT_LEVEL)
public abstract class AbstractRegPaneProvider implements RegPaneProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

22
designer-base/src/main/java/com/fr/design/fun/impl/AbstractTextFieldAdapterProvider.java

@ -0,0 +1,22 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.TextFieldAdapterProvider;
import com.fr.stable.fun.mark.API;
/**
* @author Joe
* 2021/10/8 15:17
*/
@API(level = TextFieldAdapterProvider.CURRENT_LEVEL)
public abstract class AbstractTextFieldAdapterProvider implements TextFieldAdapterProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

56
designer-base/src/main/java/com/fr/design/gui/frpane/RegFieldPane.java

@ -1,21 +1,25 @@
package com.fr.design.gui.frpane; package com.fr.design.gui.frpane;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.ErrorMsgTextFieldAdapter;
import com.fr.design.beans.UITextFieldAdapter;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.TextFieldAdapterProvider;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
import com.fr.form.ui.reg.NoneReg; import com.fr.form.ui.reg.NoneReg;
import com.fr.form.ui.reg.RegExp; import com.fr.form.ui.reg.RegExp;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.event.DocumentEvent; import java.awt.BorderLayout;
import javax.swing.event.DocumentListener; import java.awt.Component;
import java.awt.*; import java.awt.Dimension;
/** /**
* Created by kerry on 2017/9/4. * Created by kerry on 2017/9/4.
@ -23,7 +27,7 @@ import java.awt.*;
public class RegFieldPane extends RegPane { public class RegFieldPane extends RegPane {
protected RegErrorMsgPane regErrorMsgPane; protected RegErrorMsgPane regErrorMsgPane;
public RegFieldPane(){ public RegFieldPane() {
this(ALL_REG_TYPE); this(ALL_REG_TYPE);
} }
@ -39,8 +43,8 @@ public class RegFieldPane extends RegPane {
@Override @Override
public void regChangeAction() { public void regChangeAction() {
RegExp regExp = (RegExp)getRegComboBox().getSelectedItem(); RegExp regExp = (RegExp) getRegComboBox().getSelectedItem();
if(regExp instanceof NoneReg){ if (regExp instanceof NoneReg) {
regErrorMsgPane.setVisible(false); regErrorMsgPane.setVisible(false);
return; return;
} }
@ -67,33 +71,35 @@ public class RegFieldPane extends RegPane {
} }
private static class RegErrorMsgPane extends BasicPane { private static class RegErrorMsgPane extends BasicPane {
private UITextField regErrorMsgField; private ErrorMsgTextFieldAdapter errorMsgTextFieldAdapter;
public RegErrorMsgPane() { public RegErrorMsgPane() {
initRegErrorMsgField();
setStyle();
}
private void setStyle() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, 0, 0)); this.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, 0, 0));
initRegErrorMsgField();
UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip")); UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"));
tipLabel.setPreferredSize(new Dimension(60, 20)); tipLabel.setPreferredSize(new Dimension(60, 20));
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{tipLabel, regErrorMsgField}}, TableLayoutHelper.FILL_LASTCOLUMN, 10, LayoutConstants.VGAP_MEDIUM); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{tipLabel, errorMsgTextFieldAdapter.getErrorMsgTextField()}}, TableLayoutHelper.FILL_LASTCOLUMN, 10, LayoutConstants.VGAP_MEDIUM);
this.add(panel); this.add(panel);
} }
private void initRegErrorMsgField() { private void initRegErrorMsgField() {
regErrorMsgField = new UITextField(); TextFieldAdapterProvider provider = ExtraDesignClassManager.getInstance().getSingle(TextFieldAdapterProvider.XML_TAG);
regErrorMsgField.getDocument().addDocumentListener(new DocumentListener() { if (provider == null) {
public void changedUpdate(DocumentEvent e) { errorMsgTextFieldAdapter = new UITextFieldAdapter();
regErrorMsgField.setToolTipText(regErrorMsgField.getText()); return;
}
public void insertUpdate(DocumentEvent e) {
regErrorMsgField.setToolTipText(regErrorMsgField.getText());
} }
try {
errorMsgTextFieldAdapter = provider.createTextFieldAdapter();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
errorMsgTextFieldAdapter = new UITextFieldAdapter();
public void removeUpdate(DocumentEvent e) {
regErrorMsgField.setToolTipText(regErrorMsgField.getText());
} }
});
} }
@Override @Override
@ -102,11 +108,11 @@ public class RegFieldPane extends RegPane {
} }
public void populate(TextEditor textEditor) { public void populate(TextEditor textEditor) {
regErrorMsgField.setText(textEditor.getRegErrorMessage()); errorMsgTextFieldAdapter.setText(textEditor.getRegErrorMessage());
} }
public void update(TextEditor textEditor) { public void update(TextEditor textEditor) {
textEditor.setRegErrorMessage(regErrorMsgField.getText()); textEditor.setRegErrorMessage(errorMsgTextFieldAdapter.getText());
} }
} }

49
designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java

@ -1,9 +1,17 @@
package com.fr.design.widget.ui.designer; package com.fr.design.widget.ui.designer;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.ErrorMsgTextFieldAdapter;
import com.fr.design.beans.UITextFieldAdapter;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.fun.TextFieldAdapterProvider;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
@ -11,19 +19,19 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.component.FontSizeComboPane; import com.fr.design.widget.ui.designer.component.FontSizeComboPane;
import com.fr.form.ui.FieldEditor; import com.fr.form.ui.FieldEditor;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.event.DocumentEvent; import java.awt.BorderLayout;
import javax.swing.event.DocumentListener; import java.awt.Component;
import java.awt.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> { public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> {
protected UICheckBox allowBlankCheckBox; protected UICheckBox allowBlankCheckBox;
// richer:错误信息,是所有控件共有的属性,所以放到这里来 // richer:错误信息,是所有控件共有的属性,所以放到这里来
protected UITextField errorMsgTextField; protected ErrorMsgTextFieldAdapter errorMsgTextField;
protected JPanel validatePane; protected JPanel validatePane;
protected FontSizeComboPane fontSizePane; protected FontSizeComboPane fontSizePane;
protected UITextField labelNameTextField; protected UITextField labelNameTextField;
@ -40,7 +48,6 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
allowBlankCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Null")); allowBlankCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Null"));
allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
fontSizePane = new FontSizeComboPane(); fontSizePane = new FontSizeComboPane();
errorMsgTextField = new UITextField();
JPanel contentPane = this.setFirstContentPane(); JPanel contentPane = this.setFirstContentPane();
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.add(contentPane, BorderLayout.CENTER); jPanel.add(contentPane, BorderLayout.CENTER);
@ -76,23 +83,17 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
protected void initErrorMsgPane() { protected void initErrorMsgPane() {
// 错误信息 // 错误信息
errorMsgTextField = new UITextField(); TextFieldAdapterProvider provider = ExtraDesignClassManager.getInstance().getSingle(TextFieldAdapterProvider.XML_TAG);
// // richer:主要为了方便查看比较长的错误信息 if (provider == null) {
errorMsgTextField.getDocument().addDocumentListener(new DocumentListener() { errorMsgTextField = new UITextFieldAdapter();
return;
public void changedUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
} }
try {
public void insertUpdate(DocumentEvent e) { errorMsgTextField = provider.createTextFieldAdapter();
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
errorMsgTextField = new UITextFieldAdapter();
} }
public void removeUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
}
});
} }
@ -111,7 +112,7 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
validatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); validatePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
final UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip")); final UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"));
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
final JPanel errorTipPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{uiLabel, errorMsgTextField}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); final JPanel errorTipPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{uiLabel, errorMsgTextField.getErrorMsgTextField()}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
errorTipPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, 0, 0)); errorTipPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, 0, 0));
borderPane.add(errorTipPane, BorderLayout.CENTER); borderPane.add(errorTipPane, BorderLayout.CENTER);
allowBlankCheckBox.addItemListener(new ItemListener() { allowBlankCheckBox.addItemListener(new ItemListener() {

29
designer-form/src/main/java/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java

@ -1,7 +1,9 @@
package com.fr.design.widget.ui.designer; package com.fr.design.widget.ui.designer;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.fun.RegPaneProvider;
import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegFieldPane;
import com.fr.design.gui.frpane.RegPane; import com.fr.design.gui.frpane.RegPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -11,10 +13,12 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane; import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*; import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -70,24 +74,33 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size"), SwingConstants.LEFT), fontSizePane} new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size"), SwingConstants.LEFT), fontSizePane}
}; };
double[] rowSize = {p, p, p, p, p, p}; double[] rowSize = {p, p, p, p, p, p};
double[] columnSize = {p,f}; double[] columnSize = {p, f};
int[][] rowCount = {{1, 1},{1, 3},{1, 1},{1, 1}}; int[][] rowCount = {{1, 1}, {1, 3}, {1, 1}, {1, 1}};
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
boundsPane.add(panel); boundsPane.add(panel);
return boundsPane; return boundsPane;
} }
public JPanel setValidatePane(){ public JPanel setValidatePane() {
return regPane; return regPane;
} }
protected RegFieldPane createRegPane() { protected RegFieldPane createRegPane() {
RegPaneProvider provider = ExtraDesignClassManager.getInstance().getSingle(RegPaneProvider.XML_TAG);
if (provider == null) {
return new RegFieldPane(); return new RegFieldPane();
} }
try {
return provider.createRegPane();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new RegFieldPane();
}
}
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return "text"; return "text";
@ -102,7 +115,7 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
@Override @Override
protected TextEditor updateSubFieldEditorBean() { protected TextEditor updateSubFieldEditorBean() {
TextEditor ob = (TextEditor)creator.toData(); TextEditor ob = (TextEditor) creator.toData();
this.regPane.update(ob); this.regPane.update(ob);
ob.setWaterMark(waterMarkDictPane.getText()); ob.setWaterMark(waterMarkDictPane.getText());
formWidgetValuePane.update(ob); formWidgetValuePane.update(ob);

38
designer-realize/src/main/java/com/fr/design/widget/ui/FieldEditorDefinePane.java

@ -1,19 +1,21 @@
package com.fr.design.widget.ui; package com.fr.design.widget.ui;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.ErrorMsgTextFieldAdapter;
import com.fr.design.beans.UITextFieldAdapter;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.fun.TextFieldAdapterProvider;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.form.ui.FieldEditor; import com.fr.form.ui.FieldEditor;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -22,7 +24,7 @@ import java.awt.event.ItemListener;
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> { public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> {
protected UICheckBox allowBlankCheckBox; protected UICheckBox allowBlankCheckBox;
// richer:错误信息,是所有控件共有的属性,所以放到这里来 // richer:错误信息,是所有控件共有的属性,所以放到这里来
protected UITextField errorMsgTextField; protected ErrorMsgTextFieldAdapter errorMsgTextField;
protected JPanel validatePane; protected JPanel validatePane;
public FieldEditorDefinePane() { public FieldEditorDefinePane() {
@ -45,23 +47,17 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
protected void initErrorMsgPane() { protected void initErrorMsgPane() {
// 错误信息 // 错误信息
errorMsgTextField = new UITextField(); TextFieldAdapterProvider provider = ExtraDesignClassManager.getInstance().getSingle(TextFieldAdapterProvider.XML_TAG);
// // richer:主要为了方便查看比较长的错误信息 if (provider == null) {
errorMsgTextField.getDocument().addDocumentListener(new DocumentListener() { errorMsgTextField = new UITextFieldAdapter();
return;
public void changedUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
}
public void insertUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
} }
try {
public void removeUpdate(DocumentEvent e) { errorMsgTextField = provider.createTextFieldAdapter();
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
errorMsgTextField = new UITextFieldAdapter();
} }
});
} }
@Override @Override
@ -101,7 +97,7 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
allowBlankCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Null")); allowBlankCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Null"));
allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
final JPanel errorTipPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{uiLabel, errorMsgTextField}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); final JPanel errorTipPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{uiLabel, errorMsgTextField.getErrorMsgTextField()}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
errorTipPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L5, 0, 0)); errorTipPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L5, 0, 0));
borderPane.add(errorTipPane, BorderLayout.CENTER); borderPane.add(errorTipPane, BorderLayout.CENTER);
allowBlankCheckBox.addItemListener(new ItemListener() { allowBlankCheckBox.addItemListener(new ItemListener() {
@ -117,7 +113,7 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
new Component[]{allowBlankCheckBox}, new Component[]{allowBlankCheckBox},
new Component[]{borderPane}, new Component[]{borderPane},
}; };
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components,TableLayoutHelper.FILL_LASTCOLUMN, 5, 5); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, 5, 5);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L6, 0)); panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L6, 0));
validatePane.add(panel, BorderLayout.NORTH); validatePane.add(panel, BorderLayout.NORTH);

18
designer-realize/src/main/java/com/fr/design/widget/ui/TextFieldEditorDefinePane.java

@ -1,14 +1,16 @@
package com.fr.design.widget.ui; package com.fr.design.widget.ui;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.RegPaneProvider;
import com.fr.design.gui.frpane.RegFieldPane; import com.fr.design.gui.frpane.RegFieldPane;
import com.fr.design.gui.frpane.RegPane; import com.fr.design.gui.frpane.RegPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.JPanel;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -60,9 +62,19 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
protected RegFieldPane createRegPane() { protected RegFieldPane createRegPane() {
RegPaneProvider provider = ExtraDesignClassManager.getInstance().getSingle(RegPaneProvider.XML_TAG);
if (provider == null) {
return new RegFieldPane(); return new RegFieldPane();
} }
try {
return provider.createRegPane();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new RegFieldPane();
}
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "text"; return "text";

Loading…
Cancel
Save