init script's plugin
This commit is contained in:
parent
793e698324
commit
c86b8b9129
|
@ -358,24 +358,8 @@ function Behavior(usePlugin,containerId) {
|
|||
this.initBehaviorList = function(pages){
|
||||
//init page, batch, behavior
|
||||
for(var i=0;i<pages.length;i++){
|
||||
pos = "last";
|
||||
jstreeCreateNode("useBehaviorList","batch","batch",indexId,pos);
|
||||
jstreeSelectNode("useBehaviorList", indexId);
|
||||
indexId++;
|
||||
var batches = scriptObj.pages[pluginIndex].batches;
|
||||
var index2 = 0;
|
||||
while(index2 < batches.length){ //create_node("behavior")
|
||||
jstreeCreateNode("useBehaviorList",batches[index2].behaviors[0].name,batches[index2].behaviors[0].name,indexId,pos);
|
||||
jstreeSelectNode("useBehaviorList", indexId);
|
||||
pos = "after";
|
||||
indexId++;
|
||||
index2++;
|
||||
if(index2 == batches.length)
|
||||
jstreeSelectNode("useBehaviorList", 1);
|
||||
}
|
||||
pluginIndex++;
|
||||
|
||||
}
|
||||
jstreeSelectNode("useBehaviorList", 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,48 +1,16 @@
|
|||
function dataTransfer(serverData) {
|
||||
function dataTransfer(serverData,valueList) {
|
||||
var Container = function(name, children) {
|
||||
this.name = name;
|
||||
this.children = children;
|
||||
|
||||
};
|
||||
var valueMap = getParameterMap(valueList);
|
||||
var editorInfos = new Array();
|
||||
var paramInfos = serverData.paramInfoModels;
|
||||
var groupInfos = serverData.groupModels;
|
||||
if (paramInfos != null) {
|
||||
for ( var i = 0; i < paramInfos.length; i++) {
|
||||
editorInfos.push(paramInfos[i]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (serverData.groupModels != null) {
|
||||
for ( var i = 0; i < groupInfos.length; i++) {
|
||||
var container = new Container(groupInfos[i].name,
|
||||
dataTransfer(groupInfos[i]));
|
||||
editorInfos.push(container);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var editorInfos = editorInfos.sort(function(a, b) {
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
return editorInfos;
|
||||
}
|
||||
|
||||
function dataTransferByValue(serverData,parameters) {
|
||||
var Container = function(name, children) {
|
||||
this.name = name;
|
||||
this.children = children;
|
||||
|
||||
};
|
||||
var paramMap = getParameterMap(parameters);
|
||||
var editorInfos = new Array();
|
||||
var paramInfos = serverData.paramInfoModels;
|
||||
var groupInfos = serverData.groupModels;
|
||||
if (paramInfos != null) {
|
||||
for ( var i = 0; i < paramInfos.length; i++) {
|
||||
var value = paramMap.get(paramInfos[i].name);
|
||||
var value = valueMap.get(paramInfos[i].name);
|
||||
paramInfos[i].value = value;
|
||||
editorInfos.push(paramInfos[i]);
|
||||
|
||||
|
@ -66,8 +34,10 @@ function dataTransferByValue(serverData,parameters) {
|
|||
}
|
||||
function getParameterMap(parameters){
|
||||
var paramMap = new HashMap();
|
||||
for(var i=0;i<parameters.length;i++){
|
||||
paramMap.put(parameters[i].key,parameters[i].value);
|
||||
if(parameters != null && parameters != undefined){
|
||||
for(var i=0;i<parameters.length;i++){
|
||||
paramMap.put(parameters[i].key,parameters[i].value);
|
||||
}
|
||||
}
|
||||
return paramMap;
|
||||
}
|
|
@ -101,12 +101,12 @@ function UsePlugin(behaviorListContainerId) {
|
|||
$.post("getPlugin" + "/" + pluginModel.name, {}, function(data) {
|
||||
if (data.success) {
|
||||
var pluginData = dataTransfer(data.plugin);
|
||||
|
||||
var generator = containerFactory.createEditorContainer(
|
||||
pluginModel.name, "generator", pluginData);
|
||||
$(generator).attr("pluginName", pluginModel.nickName);
|
||||
$(generator).addClass("generator");
|
||||
usePluginEditorMap.put(pluginModel.id, generator);
|
||||
createEditorByData(pluginModel,pluginData);
|
||||
// var generator = containerFactory.createEditorContainer(
|
||||
// pluginModel.name, "generator", pluginData);
|
||||
// $(generator).attr("pluginName", pluginModel.nickName);
|
||||
// $(generator).addClass("generator");
|
||||
// usePluginEditorMap.put(pluginModel.id, generator);
|
||||
//select this new node
|
||||
jstreeSelectNode(containerId, pluginModel.id);
|
||||
|
||||
|
@ -193,7 +193,7 @@ function UsePlugin(behaviorListContainerId) {
|
|||
|
||||
this.initPluginAndPages = function(scriptObj){
|
||||
initPluginList(scriptObj.usePlugins);
|
||||
// behavior.initBehaviorList(scriptObj.pages);
|
||||
behavior.initBehaviorList(scriptObj.pages);
|
||||
}
|
||||
function initPluginList(usePlugins){
|
||||
//init plugin
|
||||
|
@ -215,7 +215,6 @@ function UsePlugin(behaviorListContainerId) {
|
|||
|
||||
//add to editor map
|
||||
getUsePluginEditor(pluginModel,usePlugin.parameters);
|
||||
|
||||
//add to tree
|
||||
jstreeCreateNode("usePluginList",usePlugin.name,usePlugin.nickName,usePlugin.id,"after");
|
||||
}
|
||||
|
@ -223,13 +222,8 @@ function UsePlugin(behaviorListContainerId) {
|
|||
function getUsePluginEditor(pluginModel,parameters){
|
||||
$.post("getPlugin" + "/" + pluginModel.name, {}, function(data) {
|
||||
if (data.success) {
|
||||
var pluginData = dataTransferByValue(data.plugin,parameters);
|
||||
|
||||
var generator = containerFactory.createEditorContainer(
|
||||
pluginModel.name, "generator", pluginData);
|
||||
$(generator).attr("pluginName", pluginModel.nickName);
|
||||
$(generator).addClass("generator");
|
||||
usePluginEditorMap.put(pluginModel.id, generator);
|
||||
var pluginData = dataTransfer(data.plugin,parameters);
|
||||
createEditorByData(pluginModel,pluginData);
|
||||
|
||||
} else {
|
||||
return;
|
||||
|
@ -237,4 +231,12 @@ function UsePlugin(behaviorListContainerId) {
|
|||
|
||||
});
|
||||
}
|
||||
function createEditorByData(pluginModel,pluginData){
|
||||
|
||||
var generator = containerFactory.createEditorContainer(
|
||||
pluginModel.name, "generator", pluginData);
|
||||
$(generator).attr("pluginName", pluginModel.nickName);
|
||||
$(generator).addClass("generator");
|
||||
usePluginEditorMap.put(pluginModel.id, generator);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue