Browse Source

控件值API

master
richie 5 years ago
parent
commit
9766719fce
  1. 3
      src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java
  2. 94
      src/main/java/com/fanruan/api/report/form/category/ValueWidget.java

3
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.fanruan.api.report.form.BaseWidget;
import com.fr.data.act.Producer; import com.fr.data.act.Producer;
import com.fr.form.ui.DataControl;
/** /**
* @author richie * @author richie
@ -9,6 +10,6 @@ import com.fr.data.act.Producer;
* Created by richie on 2019-09-19 * Created by richie on 2019-09-19
* 初始化的时候除了配置还会有加载数据的控件典型的控件如下拉框下拉树复选框组等 * 初始化的时候除了配置还会有加载数据的控件典型的控件如下拉框下拉树复选框组等
*/ */
public abstract class LoadingWidget extends BaseWidget implements Producer { public abstract class LoadingWidget extends BaseWidget implements Producer, DataControl {
} }

94
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);
}
}
Loading…
Cancel
Save