From 9766719fce6422b7bd724239dc7bf5930a979c35 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 8 Oct 2019 15:39:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E5=80=BCAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/form/category/LoadingWidget.java | 3 +- .../api/report/form/category/ValueWidget.java | 94 +++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/fanruan/api/report/form/category/ValueWidget.java diff --git a/src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java b/src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java index bc5eaf6..4d370ce 100644 --- a/src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java +++ b/src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java @@ -2,6 +2,7 @@ package com.fanruan.api.report.form.category; import com.fanruan.api.report.form.BaseWidget; import com.fr.data.act.Producer; +import com.fr.form.ui.DataControl; /** * @author richie @@ -9,6 +10,6 @@ import com.fr.data.act.Producer; * Created by richie on 2019-09-19 * 初始化的时候除了配置,还会有加载数据的控件,典型的控件如下拉框、下拉树、复选框组等 */ -public abstract class LoadingWidget extends BaseWidget implements Producer { +public abstract class LoadingWidget extends BaseWidget implements Producer, DataControl { } diff --git a/src/main/java/com/fanruan/api/report/form/category/ValueWidget.java b/src/main/java/com/fanruan/api/report/form/category/ValueWidget.java new file mode 100644 index 0000000..76132da --- /dev/null +++ b/src/main/java/com/fanruan/api/report/form/category/ValueWidget.java @@ -0,0 +1,94 @@ +package com.fanruan.api.report.form.category; + +import com.fanruan.api.report.form.BaseWidget; +import com.fr.form.ui.DataControl; +import com.fr.form.ui.WidgetValue; +import com.fr.form.ui.WidgetValueUtils; +import com.fr.form.ui.concept.data.ValueInitializer; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.script.CalculatorProvider; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLableReader; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/10/8 + * 会作为参数控件或者决策报表控件并传递参数值的控件接口 + */ +public abstract class ValueWidget extends BaseWidget implements DataControl { + + private ValueInitializer widgetValue; + + @Override + public ValueInitializer getWidgetValue() { + return widgetValue; + } + + @Override + public void setWidgetValue(ValueInitializer value) { + this.widgetValue = value; + } + + /** + * 获取是否为Editor + */ + @Override + public boolean isEditor() { + return false; + } + + /** + * 获取当前对象对参数的依赖关系 + * + * @param ca 当前线程的算子 + * @return 字符串参数数组 + */ + public String[] dependence(CalculatorProvider ca) { + ValueInitializer value = getWidgetValue(); + return value == null ? ArrayUtils.EMPTY_STRING_ARRAY : value.dependence(ca); + } + + /** + * 克隆 + */ + @Override + public Object clone() throws CloneNotSupportedException { + ValueWidget cloned = (ValueWidget) super.clone(); + if (this.widgetValue != null) { + cloned.widgetValue = (WidgetValue) this.widgetValue.clone(); + } + return cloned; + } + + @Override + public void readXML(XMLableReader reader) { + super.readXML(reader); + + if (reader.isChildNode()) { + if (WidgetValue.XML_TAG.equals(reader.getTagName())) { + this.widgetValue = new WidgetValue(); + reader.readXMLObject(widgetValue); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + super.writeXML(writer); + if (widgetValue != null) { + widgetValue.writeXML(writer); + } + } + + @Override + public String getFormatText() { + return StringUtils.EMPTY; + } + + @Override + public String getDataBindDefaultValue(CalculatorProvider calculator) { + return WidgetValueUtils.fillDefaultValue(this, calculator); + } +}