refactor plugin

This commit is contained in:
fanfuxiaoran 2014-05-06 18:01:57 +08:00
parent ac96d36e8d
commit 4f56536cc4
12 changed files with 542 additions and 314 deletions

View File

@ -1,48 +1,17 @@
package org.bench4q.master.domain.entity.plugin;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "behaviorInfo")
public class BehaviorInfo {
private int id;
private String name;
public class BehaviorInfo extends ParamsContainer {
private String behavoirType;
private Set<BehaviorParamInfo> params;
private PluginUI pluginUI;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "name", nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "behavoirType")
public String getBehavoirType() {
return behavoirType;
@ -51,16 +20,6 @@ public class BehaviorInfo {
public void setBehavoirType(String behavoirType) {
this.behavoirType = behavoirType;
}
@OneToMany(mappedBy = "behaviorInfo", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<BehaviorParamInfo> getParams() {
return params;
}
public void setParams(Set<BehaviorParamInfo> params) {
this.params = params;
}
@ManyToOne
@JoinColumn(name = "pluginId", nullable = false)
public PluginUI getPluginUI() {

View File

@ -1,23 +0,0 @@
package org.bench4q.master.domain.entity.plugin;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "behaviorParamInfo")
public class BehaviorParamInfo extends ParamInfo {
private BehaviorInfo behaviorInfo;
@ManyToOne
@JoinColumn(name = "behaviorId", nullable = false)
public BehaviorInfo getBehaviorInfo() {
return behaviorInfo;
}
public void setBehaviorInfo(BehaviorInfo behaviorInfo) {
this.behaviorInfo = behaviorInfo;
};
}

View File

@ -0,0 +1,24 @@
package org.bench4q.master.domain.entity.plugin;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "group")
public class Group extends ParamsContainer {
private ParamsContainer paramsContainer;
@ManyToOne
@JoinColumn(name = "paramsContainerId", nullable = false)
public ParamsContainer getParamsContainer() {
return paramsContainer;
}
public void setParamsContainer(ParamsContainer paramsContainer) {
this.paramsContainer = paramsContainer;
}
}

View File

@ -1,60 +1,71 @@
package org.bench4q.master.domain.entity.plugin;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
@MappedSuperclass
public class ParamInfo {
private int id;
private String name;
private String lable;
private ParamType paramType;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "name", nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "lable")
public String getLable() {
return lable;
}
public void setLable(String lable) {
this.lable = lable;
}
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "typeId", nullable = false)
public ParamType getParamType() {
return paramType;
}
public void setParamType(ParamType paramType) {
this.paramType = paramType;
}
}
package org.bench4q.master.domain.entity.plugin;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
@MappedSuperclass
public class ParamInfo {
private int id;
private String name;
private String lable;
private ParamType paramType;
private ParamsContainer paramsContainer;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "name", nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "lable")
public String getLable() {
return lable;
}
public void setLable(String lable) {
this.lable = lable;
}
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "typeId", nullable = false)
public ParamType getParamType() {
return paramType;
}
public void setParamType(ParamType paramType) {
this.paramType = paramType;
}
@ManyToOne
@JoinColumn(name = "paramsContainerId", nullable = false)
public ParamsContainer getParamsContainer() {
return paramsContainer;
}
public void setParamsContainer(ParamsContainer paramsContainer) {
this.paramsContainer = paramsContainer;
}
}

View File

@ -0,0 +1,66 @@
package org.bench4q.master.domain.entity.plugin;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "paramsContainer")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class ParamsContainer {
private int id;
private String name;
private Set<ParamInfo> params;
private Set<Group> groups;
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "id", nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "name", nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(mappedBy = "paramsContainer", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<ParamInfo> getParams() {
return params;
}
public void setParams(Set<ParamInfo> params) {
this.params = params;
}
@OneToMany(mappedBy = "paramsContainer", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<Group> getGroups() {
return groups;
}
public void setGroups(Set<Group> groups) {
this.groups = groups;
}
}

View File

@ -1,53 +1,22 @@
package org.bench4q.master.domain.entity.plugin;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "plugin")
public class PluginInfo {
private int id;
private String name;
private Set<PluginParamInfo> pluginParamInfos;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public int getId() {
return id;
@Table(name = "pluginInfo")
public class PluginInfo extends ParamsContainer {
private PluginUI pluginUI;
@ManyToOne
@JoinColumn(name = "pluginId", nullable = false)
public PluginUI getPluginUI() {
return pluginUI;
}
public void setId(int id) {
this.id = id;
public void setPluginUI(PluginUI pluginUI) {
this.pluginUI = pluginUI;
}
@Column(name = "name", nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(mappedBy = "pluginInfo", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<PluginParamInfo> getPluginParamInfos() {
return pluginParamInfos;
}
public void setPluginParamInfos(
Set<PluginParamInfo> pluginParamInfos) {
this.pluginParamInfos = pluginParamInfos;
}
}

View File

@ -1,21 +0,0 @@
package org.bench4q.master.domain.entity.plugin;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "pluginParamInfo")
public class PluginParamInfo extends ParamInfo {
private PluginInfo pluginInfo;
@ManyToOne
@JoinColumn(name = "pluginId", nullable = false)
public PluginInfo getPluginInfo() {
return pluginInfo;
}
public void setPluginInfo(PluginInfo pluginInfo) {
this.pluginInfo = pluginInfo;
}
}

View File

@ -9,16 +9,17 @@ import java.util.Set;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
import org.bench4q.master.domain.entity.plugin.BehaviorParamInfo;
import org.bench4q.master.domain.entity.plugin.CheckBoxType;
import org.bench4q.master.domain.entity.plugin.ChoiceType;
import org.bench4q.master.domain.entity.plugin.ComboType;
import org.bench4q.master.domain.entity.plugin.FieldType;
import org.bench4q.master.domain.entity.plugin.FileType;
import org.bench4q.master.domain.entity.plugin.Group;
import org.bench4q.master.domain.entity.plugin.NFieldType;
import org.bench4q.master.domain.entity.plugin.ParamInfo;
import org.bench4q.master.domain.entity.plugin.ParamType;
import org.bench4q.master.domain.entity.plugin.ParamsContainer;
import org.bench4q.master.domain.entity.plugin.PluginInfo;
import org.bench4q.master.domain.entity.plugin.PluginParamInfo;
import org.bench4q.master.domain.entity.plugin.PluginUI;
import org.bench4q.master.domain.entity.plugin.RadioButtonType;
import org.bench4q.master.domain.entity.plugin.TableType;
@ -57,7 +58,7 @@ public class PluginEntityFactory {
return behaviorInfos;
}
private BehaviorInfo createBehaviorInfoWithOutId(Element element,
private ParamsContainer createBehaviorInfoWithOutId(Element element,
PluginUI pluginUI) {
BehaviorInfo behaviorInfo = new BehaviorInfo();
behaviorInfo.setBehavoirType(element.getName());
@ -122,142 +123,160 @@ public class PluginEntityFactory {
return paramInfos;
}
private BehaviorParamInfo createBehaviorParamInfo(Element element,
BehaviorInfo behaviorInfo) {
if (XmlParseHelper.getAttribute(element, "name") == null)
private ParamInfo createParamInfoWithOutId(Element paramElement,
ParamsContainer paramsContainer) {
if (!paramElement.getName().equals("param")) {
logger.info("element is not a param:" + paramElement.getName());
return null;
BehaviorParamInfo behaviorParamInfo = new BehaviorParamInfo();
behaviorParamInfo.setLable(XmlParseHelper
.getAttribute(element, "label"));
behaviorParamInfo.setName(XmlParseHelper.getAttribute(element, "name"));
ParamTypeFactory paramTypeFactory = new ParamTypeFactory();
behaviorParamInfo.setParamType(paramTypeFactory
.createParamTypeInfo(XmlParseHelper.getSingleChild(element)));
behaviorParamInfo.setBehaviorInfo(behaviorInfo);
System.out.println(behaviorParamInfo.getName());
return behaviorParamInfo;
}
if (XmlParseHelper.getAttribute(paramElement, "name") == null) {
return null;
}
ParamInfo paramInfo = new ParamInfo();
paramInfo.setLable(XmlParseHelper.getAttribute(paramElement, "label"));
paramInfo.setName(XmlParseHelper.getAttribute(paramElement, "name"));
paramInfo.setParamType(ParamTypeFactory
.createParamTypeInfo(XmlParseHelper
.getSingleChild(paramElement)));
paramInfo.setParamsContainer(paramsContainer);
return paramInfo;
}
private PluginParamInfo createPluginParamInfoWithOutId(Element element,
PluginInfo pluginInfo) {
if (XmlParseHelper.getAttribute(element, "name") == null)
private List<ParamInfo> createParamInfos(List<Element> paramElements,
ParamsContainer paramsContainer) {
if (paramElements == null) {
return null;
PluginParamInfo pluginParamInfo = new PluginParamInfo();
pluginParamInfo.setLable(XmlParseHelper.getAttribute(element, "label"));
pluginParamInfo.setName(XmlParseHelper.getAttribute(element, "name"));
ParamTypeFactory paramTypeFactory = new ParamTypeFactory();
pluginParamInfo.setParamType(paramTypeFactory
.createParamTypeInfo(XmlParseHelper.getSingleChild(element)));
pluginParamInfo.setPluginInfo(pluginInfo);
return pluginParamInfo;
}
List<ParamInfo> paramInfos = new LinkedList<ParamInfo>();
for (Element paramElement : paramElements) {
paramInfos.add(createParamInfoWithOutId(paramElement,
paramsContainer));
}
return paramInfos;
}
}
class ParamTypeFactory {
public ParamType createParamTypeInfo(Element element) {
String type = element.getName();
switch (type) {
case "field":
return createFieldType(element);
case "nfield":
return createNFieldType(element);
case "table":
return createTableType(element);
case "radiobutton":
return createRadioButtonType(element);
case "checkbox":
return createCheckBoxType(element);
case "combo":
return createComboType(element);
case "file":
return createFileType(element);
default:
throw new Bench4QRunTimeException("no such type:"+type);
private Group createGroup(Element groupElement,
ParamsContainer paramsContainer) {
if (!groupElement.getName().equals("group")) {
logger.info("element is not a group:" + groupElement.getName());
return null;
}
Group group = new Group();
group.setName(XmlParseHelper.getAttribute(groupElement, "name"));
List<Element> groupElements = XmlParseHelper.getChildElementsByName(
groupElement, "group");
List<Element> paramElements = XmlParseHelper.getChildElementsByName(
groupElement, "param");
I
group.setParamsContainer(paramsContainer);
return group;
}
private static class ParamTypeFactory {
public static ParamType createParamTypeInfo(Element element) {
String type = element.getName();
switch (type) {
case "field":
return createFieldType(element);
case "nfield":
return createNFieldType(element);
case "table":
return createTableType(element);
case "radiobutton":
return createRadioButtonType(element);
case "checkbox":
return createCheckBoxType(element);
case "combo":
return createComboType(element);
case "file":
return createFileType(element);
default:
throw new Bench4QRunTimeException("no such type:" + type);
}
}
}
private FieldType createFieldType(Element element) {
FieldType fieldType = new FieldType();
fieldType.setType("field");
fieldType.setSize(Integer.parseInt(XmlParseHelper.getAttribute(element,
"size")));
fieldType.setText(XmlParseHelper.getAttribute(element, "text"));
return fieldType;
}
private NFieldType createNFieldType(Element element) {
NFieldType nFieldType = new NFieldType();
nFieldType.setType("nfield");
if (XmlParseHelper.getAttribute(element, "size") != null)
nFieldType.setSize(Integer.parseInt(XmlParseHelper.getAttribute(
private static FieldType createFieldType(Element element) {
FieldType fieldType = new FieldType();
fieldType.setType("field");
fieldType.setSize(Integer.parseInt(XmlParseHelper.getAttribute(
element, "size")));
nFieldType.setText(XmlParseHelper.getAttribute(element, "text"));
return nFieldType;
}
private TableType createTableType(Element element) {
TableType tableType = new TableType();
tableType.setType("table");
tableType.setCols(XmlParseHelper.getAttribute(element, "cols"));
return tableType;
}
private RadioButtonType createRadioButtonType(Element element) {
RadioButtonType radioButtonType = new RadioButtonType();
radioButtonType.setType("radioButton");
radioButtonType.setChoices(createChoiceTypes(
XmlParseHelper.getChildElements(element), radioButtonType));
return radioButtonType;
}
private CheckBoxType createCheckBoxType(Element element) {
CheckBoxType checkBoxType = new CheckBoxType();
checkBoxType.setType("checkBox");
checkBoxType.setChoiceList(createChoiceTypes(
XmlParseHelper.getChildElements(element), checkBoxType));
return checkBoxType;
}
private ComboType createComboType(Element element) {
ComboType comboType = new ComboType();
comboType.setType("combo");
comboType.setChoiceList(createChoiceTypes(
XmlParseHelper.getChildElements(element), comboType));
return comboType;
}
private List<ChoiceType> createChoiceTypes(List<Element> elements,
ParamType parentContainer) {
List<ChoiceType> choiceTypes = new LinkedList<ChoiceType>();
for (Element element : elements) {
choiceTypes.add(createChoiceType(element, parentContainer));
fieldType.setText(XmlParseHelper.getAttribute(element, "text"));
return fieldType;
}
return choiceTypes;
private static NFieldType createNFieldType(Element element) {
NFieldType nFieldType = new NFieldType();
nFieldType.setType("nfield");
if (XmlParseHelper.getAttribute(element, "size") != null)
nFieldType.setSize(Integer.parseInt(XmlParseHelper
.getAttribute(element, "size")));
nFieldType.setText(XmlParseHelper.getAttribute(element, "text"));
return nFieldType;
}
private static TableType createTableType(Element element) {
TableType tableType = new TableType();
tableType.setType("table");
tableType.setCols(XmlParseHelper.getAttribute(element, "cols"));
return tableType;
}
private static RadioButtonType createRadioButtonType(Element element) {
RadioButtonType radioButtonType = new RadioButtonType();
radioButtonType.setType("radioButton");
radioButtonType.setChoices(createChoiceTypes(
XmlParseHelper.getChildElements(element), radioButtonType));
return radioButtonType;
}
private static CheckBoxType createCheckBoxType(Element element) {
CheckBoxType checkBoxType = new CheckBoxType();
checkBoxType.setType("checkBox");
checkBoxType.setChoiceList(createChoiceTypes(
XmlParseHelper.getChildElements(element), checkBoxType));
return checkBoxType;
}
private static ComboType createComboType(Element element) {
ComboType comboType = new ComboType();
comboType.setType("combo");
comboType.setChoiceList(createChoiceTypes(
XmlParseHelper.getChildElements(element), comboType));
return comboType;
}
private static List<ChoiceType> createChoiceTypes(
List<Element> elements, ParamType parentContainer) {
List<ChoiceType> choiceTypes = new LinkedList<ChoiceType>();
for (Element element : elements) {
choiceTypes.add(createChoiceType(element, parentContainer));
}
return choiceTypes;
}
private static ChoiceType createChoiceType(Element element,
ParamType parentContainer) {
ChoiceType choiceType = new ChoiceType();
choiceType.setValue(XmlParseHelper.getAttribute(element, "value"));
choiceType.setDefaultValue(Boolean.getBoolean(XmlParseHelper
.getAttribute(element, "default")));
choiceType.setParentContainer(parentContainer);
return choiceType;
}
private static FileType createFileType(Element element) {
FileType fileType = new FileType();
fileType.setText(XmlParseHelper.getAttribute(element, "text"));
fileType.setType("file");
return fileType;
}
}
private ChoiceType createChoiceType(Element element,
ParamType parentContainer) {
ChoiceType choiceType = new ChoiceType();
choiceType.setValue(XmlParseHelper.getAttribute(element, "value"));
choiceType.setDefaultValue(Boolean.getBoolean(XmlParseHelper
.getAttribute(element, "default")));
choiceType.setParentContainer(parentContainer);
return choiceType;
}
private FileType createFileType(Element element) {
FileType fileType = new FileType();
fileType.setText(XmlParseHelper.getAttribute(element, "text"));
fileType.setType("file");
return fileType;
}
}
class XmlParseHelper {

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<meta charset="utf-8">
<title>Bench4Q</title>
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link rel="shortcut icon" href="images/bench4q.png">
</head>
<body>
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<div class="container-fluid">
<div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<div id="content" class="span10" id="devices">
<button type="button" class="btn btn-primary " id="add-device">添加设备</button>
<button type="button" class="btn btn-primary " id="del-device">删除设备</button>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,14 @@
var EditorType = function(name, type, options) {
this.name = name;
this.type = type;
this.options = options;
}
$(function() {
var editorTypeMap = new HashMap();
var dataType=new EditorType("dataType","select","int;double");
editorTypeMap.put("dataType",dataType);
var generator=new EditorType("generator","select","sin;cosin");
edtiorTypeMap.put("generator",generator);
var min=new EditorType("min")
});

View File

@ -0,0 +1,167 @@
$(function() {
$('#test').append(createContainer("test", "test"));
});
function baseCreateEditor(label, id) {
var div = document.createElement("div");
$(div).addClass("editor");
$(div).attr("id", id);
var p = document.createElement("p")
$(p).html(label);
$(div).append(p);
return div;
}
function createField(label, name, size, id) {
var div = baseCreateEditor(label, id);
$(div).append(createFieldLine(size, name));
return div;
}
function createFieldLine(size, name) {
if (size <= 0) {
size = 10;
}
var fieldDiv = document.createElement("div");
$(fieldDiv).attr("class", "field");
var fieldName = document.createElement("label");
$(fieldName).html(name + ":");
var field = document.createElement("input");
$(field).attr("type", "text");
$(field).attr("size", size);
$(fieldDiv).append(fieldName.outerHTML + field.outerHTML);
return fieldDiv;
}
function createMultiField(label, name, size, id) {
var div = createField(label, name, size, id);
var addFieldButton = document.createElement("button");
$(addFieldButton).html("add")
$(addFieldButton).attr("type", "submit");
$(addFieldButton).click(function(event) {
event.preventDefault()
$(createFieldLine(size, name)).insertBefore($(this));
});
var removeFieldButton = document.createElement("button");
$(removeFieldButton).html("remove")
$(removeFieldButton).attr("type", "submit");
$(removeFieldButton).click(function(event) {
event.preventDefault();
$(this).parent().children(".field").last().remove();
});
$(div).append(addFieldButton).append(removeFieldButton);
return div;
}
function createFileEditor(label, name, size, id) {
var div = baseCreateEditor(label, id);
var fileEditor = document.createElement("div");
var fieldName = document.createElement("label");
$(fieldName).html(name + ":");
var file = document.createElement("input");
$(file).attr("type", "file");
$(file).attr("size", size);
$(fileEditor).append(fieldName.outerHTML + file.outerHTML);
$(div).append(fileEditor);
return div;
}
function createTableEditor(label, name, cols, id) {
var div = baseCreateEditor(label, id);
var headers = getHeaders(cols);
$(div).append(createTable(cols, name, headers));
var addButton = document.createElement("button");
$(addButton).html("add");
$(addButton).click(
{
headers : headers
},
function(event) {
event.preventDefault();
$(this).parent().children("table").children("tbody").append(
createTr(event.data.headers));
});
var deleteButton = document.createElement("button");
$(deleteButton).html("delete");
$(deleteButton).click(
function(event) {
event.preventDefault();
$(this).parent().children("table").children("tbody").children(
"tr").last().remove();
});
$(div).append(addButton);
$(div).append(deleteButton);
return div;
function getHeaders(col) {
var headers = new Array();
headers.push("name");
var cols = col.split(";");
for ( var i = 0; i < cols.length; i++) {
headers.push(cols[i]);
}
return headers;
}
function createTable(cols, name, headers) {
var table = document.createElement("table");
var thead = document.createElement("thead");
var tbody = document.createElement("tbody");
$(thead).append(createHeader(headers));
$(tbody).append(createTr(headers, name));
$(table).append(thead);
$(table).append(tbody);
return table;
}
function createHeader(headers) {
var tr = document.createElement("tr");
for ( var i = 0; i < headers.length; i++) {
var th = document.createElement("th");
th.appendChild(document.createTextNode(headers[i]));
tr.appendChild(th);
}
return tr;
}
function createTr(headers, name) {
var tr = document.createElement("tr");
var td = document.createElement("td");
$(td).html(name);
$(tr).append(td);
for ( var i = 0; i < headers.length; i++) {
var input = document.createElement("input");
$(input).attr("type", "text");
var td = document.createElement("td");
$(td).append(input);
$(tr).append(td);
}
return tr;
}
}
function createContainer(id, name) {
var div = document.createElement("div");
$(div).attr("id", id);
$(div).append(createMultiField("test", "name", 10, "test"));
$(div).append(createFileEditor("file", "file name", 10, "file"));
$(div).append(createField("field", "field name", 10, "field"));
$(div).append(createTableEditor("table","input","td1;td1;td3","id"));
return div;
}

View File

@ -0,0 +1,16 @@
var Device=function();
Device.prototype.createDevice=function(){
}