90 lines
2.6 KiB
Java
90 lines
2.6 KiB
Java
package eu.eudat.models.components.commons.datafield;
|
|
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Element;
|
|
|
|
import java.util.Map;
|
|
|
|
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
|
private String url;
|
|
private Option autoCompleteOptions;
|
|
private String optionsRoot;
|
|
|
|
|
|
public String getOptionsRoot() {
|
|
return optionsRoot;
|
|
}
|
|
|
|
public void setOptionsRoot(String optionsRoot) {
|
|
this.optionsRoot = optionsRoot;
|
|
}
|
|
|
|
public String getUrl() {
|
|
return url;
|
|
}
|
|
|
|
public void setUrl(String url) {
|
|
this.url = url;
|
|
}
|
|
|
|
public Option getAutoCompleteOptions() {
|
|
return autoCompleteOptions;
|
|
}
|
|
|
|
public void setAutoCompleteOptions(Option autoCompleteOptions) {
|
|
this.autoCompleteOptions = autoCompleteOptions;
|
|
}
|
|
|
|
@Override
|
|
public Element toXml(Document doc) {
|
|
Element root = super.toXml(doc);
|
|
|
|
root.setAttribute("url", this.url);
|
|
root.setAttribute("optionsRoot", this.optionsRoot);
|
|
Element element = doc.createElement("option");
|
|
element.setAttribute("label", this.autoCompleteOptions.getLabel());
|
|
element.setAttribute("value", autoCompleteOptions.getValue());
|
|
root.appendChild(element);
|
|
return root;
|
|
}
|
|
|
|
@Override
|
|
public AutoCompleteData fromXml(Element item) {
|
|
super.fromXml(item);
|
|
this.url = item.getAttribute("url");
|
|
this.optionsRoot = item.getAttribute("optionsRoot");
|
|
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
|
if (optionElement != null) {
|
|
this.autoCompleteOptions = new Option();
|
|
this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
|
|
this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
|
|
}
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public AutoCompleteData fromData(Object data) {
|
|
super.fromData(data);
|
|
this.autoCompleteOptions = new Option();
|
|
if (data != null) {
|
|
this.url = (String) ((Map<String, Object>) data).get("url");
|
|
this.optionsRoot = (String) ((Map<String, Object>) data).get("optionsRoot");
|
|
Map<String, String> options = ((Map<String, Map<String, String>>) data).get("autoCompleteOptions");
|
|
if (options != null) {
|
|
this.autoCompleteOptions.setLabel(options.get("label"));
|
|
this.autoCompleteOptions.setValue(options.get("value"));
|
|
}
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Object toData() {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
|
|
}
|