From fdf468ecf326fd24c86c9a7a530fba853dcf9e87 Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 28 Jun 2017 11:13:20 +0800 Subject: [PATCH] =?UTF-8?q?CQ-9=20=E6=B2=A1=E6=9C=89=E8=A3=85=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E8=AE=BE=E8=AE=A1=E6=89=93=E5=BC=80=E5=B8=A6?= =?UTF-8?q?=E6=9C=89=E6=8F=92=E4=BB=B6=E6=8E=A7=E4=BB=B6=E7=9A=84=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E6=97=B6=EF=BC=8C=E9=9C=80=E8=A6=81=E8=83=BD=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E6=89=93=E5=BC=80=E5=B9=B6=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/designer/creator/ErrorCreator.java | 28 +++++++++++++++++++ .../design/designer/creator/NullCreator.java | 6 +++- .../designer/creator/XCreatorUtils.java | 3 ++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 designer_form/src/com/fr/design/designer/creator/ErrorCreator.java 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);