diff --git a/designer_form/src/com/fr/design/designer/creator/ErrorCreator.java b/designer_form/src/com/fr/design/designer/creator/ErrorCreator.java new file mode 100644 index 0000000000..54a679fe14 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/creator/ErrorCreator.java @@ -0,0 +1,28 @@ +package com.fr.design.designer.creator; + +import com.fr.form.ui.ErrorMarker; +import com.fr.form.ui.Widget; +import com.fr.stable.StringUtils; + +import java.awt.*; + +/** + * Created by richie on 2017/6/28. + */ +public class ErrorCreator extends NullCreator { + + public ErrorCreator(Widget widget, Dimension initSize) { + super(widget, initSize); + } + + + @Override + protected String showText() { + ErrorMarker marker = (ErrorMarker)toData(); + String text = marker.getWidgetValue().getDisplayValue(); + if (StringUtils.isEmpty(text)) { + return super.showText(); + } + return text; + } +} diff --git a/designer_form/src/com/fr/design/designer/creator/NullCreator.java b/designer_form/src/com/fr/design/designer/creator/NullCreator.java index 642b74fd0a..6159311b8e 100644 --- a/designer_form/src/com/fr/design/designer/creator/NullCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/NullCreator.java @@ -23,11 +23,15 @@ public class NullCreator extends XWidgetCreator { @Override protected JComponent initEditor() { - UILabel l = new UILabel("UNEXPECTED WIDGET"); + UILabel l = new UILabel(showText()); l.setForeground(Color.red); l.setVerticalAlignment(SwingConstants.CENTER); l.setHorizontalAlignment(SwingConstants.CENTER); setBorder(DEFALUTBORDER); return editor = l; } + + protected String showText() { + return "UNEXPECTED WIDGET"; + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java index 3c58e2f192..9dfc803fa4 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java @@ -73,6 +73,9 @@ public class XCreatorUtils { objectMap.put(NameWidget.class, XNameWidget.class); objectMap.put(CardSwitchButton.class, XCardSwitchButton.class); objectMap.put(CardAddButton.class, XCardAddButton.class); + + objectMap.put(ErrorMarker.class, ErrorCreator.class); + putExtraEditor(); xLayoutMap.put(WAbsoluteLayout.class, XWAbsoluteLayout.class);