2017-11-30 11:10:42 +01:00
|
|
|
package models.components.commons.datafield;
|
|
|
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.w3c.dom.Element;
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
|
|
|
import utilities.XmlSerializable;
|
|
|
|
|
2017-12-13 13:01:43 +01:00
|
|
|
public abstract class ComboBoxData<T> extends FieldData<T>{
|
|
|
|
public class Option implements XmlSerializable<Option>{
|
2017-11-30 11:10:42 +01:00
|
|
|
private String label;
|
|
|
|
private String value;
|
|
|
|
public String getLabel() {
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
public void setLabel(String label) {
|
|
|
|
this.label = label;
|
|
|
|
}
|
|
|
|
public String getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
public void setValue(String value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public Element toXml(Document doc) {
|
|
|
|
Element option = doc.createElement("option");
|
|
|
|
option.setAttribute("label", this.label);
|
|
|
|
option.setAttribute("value",this.value);
|
|
|
|
return option;
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public Option fromXml(Element item) {
|
|
|
|
this.label = item.getAttribute("label");
|
|
|
|
this.value = item.getAttribute("value");
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private String type;
|
|
|
|
|
|
|
|
public String getType() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
public void setType(String type) {
|
|
|
|
this.type = type;
|
|
|
|
}
|
2017-12-13 13:01:43 +01:00
|
|
|
|
2017-11-30 11:10:42 +01:00
|
|
|
@Override
|
|
|
|
public Element toXml(Document doc) {
|
|
|
|
Element root = doc.createElement("data");
|
|
|
|
root.setAttribute("type", this.type);
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
@Override
|
2017-12-13 13:01:43 +01:00
|
|
|
public T fromXml(Element item) {
|
2017-11-30 11:10:42 +01:00
|
|
|
|
|
|
|
this.type = item.getAttribute("type");
|
2017-12-13 13:01:43 +01:00
|
|
|
return (T)this;
|
2017-11-30 11:10:42 +01:00
|
|
|
}
|
|
|
|
@Override
|
2017-12-13 13:01:43 +01:00
|
|
|
public T fromData(Object data) {
|
|
|
|
|
2017-11-30 11:10:42 +01:00
|
|
|
if(data!=null){
|
|
|
|
this.type = (String)((Map<String,Object>)data).get("type");
|
|
|
|
}
|
2017-12-05 17:56:21 +01:00
|
|
|
|
2017-12-13 13:01:43 +01:00
|
|
|
return (T)this;
|
2017-11-30 11:10:42 +01:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public Object toData() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|