Browse Source

Pull request #6145: REPORT-59476 && REPORT-59475 文本控件校验规则支持国际化 && 控件校验错误提示支持公式

Merge in DESIGN/design from ~YUAN.WANG/design:release/10.0 to release/10.0

* commit '81bf9616db12bd64fcff3b2ca10001de3eb60f2c':
  REPORT-59475 控件校验错误提示支持公式
  REPORT-59475 控件校验错误提示支持公式
  REPORT-59476 && REPORT-59475 1、文本控件校验规则支持国际化 2、控件校验错误提示支持公式
zheng-1641779399395
Yuan.Wang 3 years ago
parent
commit
b400506417
  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. 50
      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. 21
      designer-form/src/main/java/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java
  10. 36
      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 = "ErrorMesPaneWrapperProvider";
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;
}
}

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

@ -1,21 +1,25 @@
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.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.TextFieldAdapterProvider;
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.TableLayoutHelper;
import com.fr.form.ui.TextEditor;
import com.fr.form.ui.reg.NoneReg;
import com.fr.form.ui.reg.RegExp;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* Created by kerry on 2017/9/4.
@ -67,33 +71,35 @@ public class RegFieldPane extends RegPane {
}
private static class RegErrorMsgPane extends BasicPane {
private UITextField regErrorMsgField;
private ErrorMsgTextFieldAdapter errorMsgTextFieldAdapter;
public RegErrorMsgPane() {
initRegErrorMsgField();
setStyle();
}
private void setStyle() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
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"));
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);
}
private void initRegErrorMsgField() {
regErrorMsgField = new UITextField();
regErrorMsgField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
regErrorMsgField.setToolTipText(regErrorMsgField.getText());
}
public void insertUpdate(DocumentEvent e) {
regErrorMsgField.setToolTipText(regErrorMsgField.getText());
TextFieldAdapterProvider provider = ExtraDesignClassManager.getInstance().getSingle(TextFieldAdapterProvider.XML_TAG);
if (provider == null) {
errorMsgTextFieldAdapter = new UITextFieldAdapter();
return;
}
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
@ -102,11 +108,11 @@ public class RegFieldPane extends RegPane {
}
public void populate(TextEditor textEditor) {
regErrorMsgField.setText(textEditor.getRegErrorMessage());
errorMsgTextFieldAdapter.setText(textEditor.getRegErrorMessage());
}
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;
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.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.fun.TextFieldAdapterProvider;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
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.widget.ui.designer.component.FontSizeComboPane;
import com.fr.form.ui.FieldEditor;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> {
protected UICheckBox allowBlankCheckBox;
// richer:错误信息,是所有控件共有的属性,所以放到这里来
protected UITextField errorMsgTextField;
protected ErrorMsgTextFieldAdapter errorMsgTextField;
protected JPanel validatePane;
protected FontSizeComboPane fontSizePane;
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.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
fontSizePane = new FontSizeComboPane();
errorMsgTextField = new UITextField();
JPanel contentPane = this.setFirstContentPane();
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.add(contentPane, BorderLayout.CENTER);
@ -76,23 +83,17 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
protected void initErrorMsgPane() {
// 错误信息
errorMsgTextField = new UITextField();
// // richer:主要为了方便查看比较长的错误信息
errorMsgTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
TextFieldAdapterProvider provider = ExtraDesignClassManager.getInstance().getSingle(TextFieldAdapterProvider.XML_TAG);
if (provider == null) {
errorMsgTextField = new UITextFieldAdapter();
return;
}
public void insertUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
try {
errorMsgTextField = provider.createTextFieldAdapter();
} 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();
final UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"));
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));
borderPane.add(errorTipPane, BorderLayout.CENTER);
allowBlankCheckBox.addItemListener(new ItemListener() {

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

@ -1,7 +1,9 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.IntervalConstants;
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.RegPane;
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.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.TextEditor;
import com.fr.log.FineLoggerFactory;
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.KeyEvent;
@ -83,11 +87,20 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
}
protected RegFieldPane createRegPane() {
RegPaneProvider provider = ExtraDesignClassManager.getInstance().getSingle(RegPaneProvider.XML_TAG);
if (provider == null) {
return new RegFieldPane();
}
try {
return provider.createRegPane();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new RegFieldPane();
}
}
@Override
public String title4PopupWindow() {
return "text";

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

@ -1,19 +1,21 @@
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.designer.IntervalConstants;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.fun.TextFieldAdapterProvider;
import com.fr.design.gui.icheckbox.UICheckBox;
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.TableLayoutHelper;
import com.fr.form.ui.FieldEditor;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ItemEvent;
@ -22,7 +24,7 @@ import java.awt.event.ItemListener;
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> {
protected UICheckBox allowBlankCheckBox;
// richer:错误信息,是所有控件共有的属性,所以放到这里来
protected UITextField errorMsgTextField;
protected ErrorMsgTextFieldAdapter errorMsgTextField;
protected JPanel validatePane;
public FieldEditorDefinePane() {
@ -45,23 +47,17 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
protected void initErrorMsgPane() {
// 错误信息
errorMsgTextField = new UITextField();
// // richer:主要为了方便查看比较长的错误信息
errorMsgTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
}
public void insertUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
TextFieldAdapterProvider provider = ExtraDesignClassManager.getInstance().getSingle(TextFieldAdapterProvider.XML_TAG);
if (provider == null) {
errorMsgTextField = new UITextFieldAdapter();
return;
}
public void removeUpdate(DocumentEvent e) {
errorMsgTextField.setToolTipText(errorMsgTextField.getText());
try {
errorMsgTextField = provider.createTextFieldAdapter();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
errorMsgTextField = new UITextFieldAdapter();
}
});
}
@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.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
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));
borderPane.add(errorTipPane, BorderLayout.CENTER);
allowBlankCheckBox.addItemListener(new ItemListener() {

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

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

Loading…
Cancel
Save