package cn.autoform.web.formula.info.impl.cpn;
|
|
import cn.autoform.db.entity.form.FormCpnInfo;
|
import cn.autoform.web.formula.info.FormCpn;
|
|
public class FormCpnFactory {
|
|
public static FormCpn getFormCpn(FormCpnInfo field){
|
FormCpn cpn = null;
|
switch (field.getTagType()) {
|
case text:
|
cpn = new TextCpn();
|
break;
|
case textarea:
|
cpn = new TextAreaCpn();
|
break;
|
case radio:
|
cpn = new RadioCpn();
|
break;
|
case number:
|
cpn = new NumberCpn();
|
break;
|
case mytext:
|
cpn = new JoinFormCpn();
|
break;
|
case dropdownlist:
|
cpn = new DropdownListCpn();
|
break;
|
case checkbox:
|
cpn = new CheckboxCpn();
|
break;
|
case calendar:
|
cpn = new CalendarCpn();
|
break;
|
case subform:
|
cpn = new ChildCpn();
|
break;
|
case tree:
|
cpn = new TreeCpn();
|
break;
|
default:
|
return cpn;
|
}
|
cpn.init(field);
|
return cpn;
|
}
|
|
/**
|
* 克隆控件
|
* @param formCpn
|
* @return
|
*/
|
public static FormCpn clone(FormCpn formCpn) {
|
Class<?> clazz = formCpn.getClass();
|
FormCpn cloneFormCpn = newInstance(clazz);
|
if(cloneFormCpn == null)
|
return null;
|
cloneFormCpn.putAll(formCpn);
|
cloneFormCpn.setFormCpnListener(formCpn.getFormCpnListener());
|
cloneFormCpn.setFieldId(formCpn.getFieldId());
|
|
return cloneFormCpn;
|
}
|
|
/**
|
* 创建实例
|
* @param clazz
|
* @return
|
*/
|
public static FormCpn newInstance(Class<?> clazz){
|
try {
|
return (FormCpn) clazz.newInstance();
|
} catch (InstantiationException | IllegalAccessException e) {
|
e.printStackTrace();
|
return null;
|
}
|
}
|
}
|