forked from fanruan/finekit
richie
5 years ago
2 changed files with 96 additions and 1 deletions
@ -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…
Reference in new issue