MWF.xApplication.FindDesigner.options.multitask = false; MWF.xApplication.FindDesigner.Main = new Class({ Extends: MWF.xApplication.Common.Main, Implements: [Options, Events], options: { "style": "default", "name": "FindDesigner", "mvcStyle": "style.css", "icon": "icon.png", "width": "1200", "height": "800", "filter": null, "isResize": true, "isMax": true, "layout": { "type": "leftRight", "percent": 0.3 }, "title": MWF.xApplication.FindDesigner.LP.title }, onQueryLoad: function(){ this.lp = MWF.xApplication.FindDesigner.LP; this.filterOption = { "keyword": "", "designerTypes": [], "caseSensitive": false, "matchWholeWord": false, "matchRegExp": false, "moduleList": [] } this.selectedModules = []; this.selectedRange = []; o2.UD.getDataJson("findDesignerLayout", function(json){ this.setOptions(json); }.bind(this), false); }, loadApplication: function(callback){ var url = this.path+this.options.style+"/view.html"; this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){ this.setSizeNode(); this.createToolbar(); debugger; this.initFilter(); if (callback) callback(); }.bind(this)); }, initFilter: function(){ if (this.options.filter){ if (this.options.filter.moduleList){ var inputs = this.rangeContentNode.getElements("input"); inputs.forEach(function(input){ if (input.get("value").indexOf(this.options.filter.moduleList) !== -1){ input.set("checked", true); }else{ input.set("checked", false); } }.bind(this)); } if (this.options.filter.appList){ o2.require("o2.widget.O2Identity", function(){ this.options.filter.appList.each(function(app){ app.name = this.lp[app.moduleType] + "-" + app.name; var item = new o2.widget.O2Other(app, this.rangeSelectedContentNode, {"canRemove": true, "style": "find", "onRemove": function(item){this.removeRangeItem(item);}.bind(this)}); item.node.store("data", item.data); }.bind(this)); }.bind(this)); } } }, createToolbar: function(){ o2.require("o2.widget.Toolbar", function(){ this.previewToolbar = new o2.widget.Toolbar(this.previewTitleToolbar, {"style": "findDesigner"}, this); this.previewToolbar.load(); this.previewToolbar.childrenButton[0].disable(); this.previewToolbar.childrenButton[1].disable(); }.bind(this)); }, initLayout: function(){ this.listNode.set("style", ""); this.previewNode.set("style", ""); if (this.resizeDrag) this.resizeDrag.detach(); if (this.sizeNodeFun) this.removeEvent("resize", this.sizeNodeFun); if (this.options.layout.type=="leftRight"){ this.toLeftRight(); }else{ this.toTopBottom(); } }, setSizeNode: function(){ this.initLayout(); this["sizeNode_"+this.options.layout.type](); this["setResizeNode_"+this.options.layout.type](); this.sizeNodeFun = null; this.sizeNodeFun = this["sizeNode_"+this.options.layout.type].bind(this); this.addEvent("resize", this.sizeNodeFun); }, sizeResultNode: function(){ var size = this.content.getSize(); var filterSzie = this.filterNode.getSize(); var keywordSize = this.keywordNode.getSize(); var rangeSize = this.rangeNode.getSize(); var h = size.y-filterSzie.y-keywordSize.y-rangeSize.y; this.resultNode.setStyle("height", ""+h+"px"); return h; }, sizeNode_topBottom: function(){ var h = this.sizeResultNode(); var listHeight = h*this.options.layout.percent; this.listNode.setStyle("height", ""+listHeight+"px"); var previewHeight = h*(1-this.options.layout.percent); this.previewNode.setStyle("height", ""+previewHeight+"px"); var listTitleSize = this.listTitleNode.getSize(); var listContentHeight = listHeight - listTitleSize.y; this.listAreaNode.setStyle("height", ""+listContentHeight+"px"); var previewSeparatorSize = this.previewSeparatorNode.getSize(); var previewTitleSize = this.previewTitleNode.getSize(); var previewContentHeight = previewHeight - previewSeparatorSize.y - previewTitleSize.y; this.previewContentNode.setStyle("height", ""+previewContentHeight+"px"); }, sizeNode_leftRight: function(){ var h = this.sizeResultNode(); var w = this.resultNode.getSize().x; var listWidth = w*this.options.layout.percent; this.listNode.setStyle("width", ""+listWidth+"px"); this.previewNode.setStyle("margin-left", ""+listWidth+"px"); var listTitleSize = this.listTitleNode.getSize(); var listContentHeight = h - listTitleSize.y; this.listAreaNode.setStyle("height", ""+listContentHeight+"px"); var previewTitleSize = this.previewTitleNode.getSize(); var previewContentHeight = h - previewTitleSize.y; this.previewContentNode.setStyle("height", ""+previewContentHeight+"px"); }, setResizeNode_topBottom: function(){ if (this.previewSeparatorNode){ this.resizeDrag = new Drag(this.previewSeparatorNode, { "onStart": function(el, e){ el.store("position", o2.eventPosition(e)); el.store("initialSize", this.listNode.getSize()); }.bind(this), "onDrag": function(el, e){ var p = o2.eventPosition(e); var position = el.retrieve("position"); var initialSize = el.retrieve("initialSize"); var dy = position.y.toFloat()-p.y.toFloat(); var height = initialSize.y-dy; var size = this.resultNode.getSize(); this.options.layout.percent = height/size.y; if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1; if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85; this.sizeNode_topBottom(); if (this.editor) if(this.editor.resize) this.editor.resize(); }.bind(this), "onComplete": function(){ o2.UD.putData("findDesignerLayout", {"layout": this.options.layout}); }.bind(this) }); } }, setResizeNode_leftRight: function(){ if (this.previewSeparatorNode){ this.resizeDrag = new Drag(this.previewSeparatorNode, { "onStart": function(el, e){ el.store("position", o2.eventPosition(e)); el.store("initialSize", this.listNode.getSize()); }.bind(this), "onDrag": function(el, e){ var p = o2.eventPosition(e); var position = el.retrieve("position"); var initialSize = el.retrieve("initialSize"); var dx = position.x.toFloat()-p.x.toFloat(); var width = initialSize.x-dx; var size = this.resultNode.getSize(); this.options.layout.percent = width/size.x; if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1; if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85; this.sizeNode_leftRight(); if (this.editor) if(this.editor.resize) this.editor.resize(); }.bind(this), "onComplete": function(){ o2.UD.putData("findDesignerLayout", {"layout": this.options.layout}); }.bind(this) }); } }, checkFilter: function(e){ if (e.target.hasClass("filterNode_item")) e.target.getElement("input").click(); e.stopPropagation(); }, checkRange: function(e){ if (e.target.hasClass("rangeType_Item")) e.target.getElement("input").click(); e.stopPropagation(); }, overKeywordOption: function(e){ if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")){ if (!e.target.hasClass("optionItem_over")) e.target.addClass("optionItem_over"); } }, outKeywordOption: function(e){ if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")) e.target.removeClass("optionItem_over"); }, setCaseSensitive: function(e){ this.filterOption.caseSensitive = !this.filterOption.caseSensitive; this.caseSensitiveNode.removeClass("caseSensitiveNode_"+!this.filterOption.caseSensitive); this.caseSensitiveNode.addClass("caseSensitiveNode_"+this.filterOption.caseSensitive); }, setMatchWholeWord: function(e){ this.filterOption.matchWholeWord = !this.filterOption.matchWholeWord; this.matchWholeWordNode.removeClass("matchWholeWordNode_"+!this.filterOption.matchWholeWord); this.matchWholeWordNode.addClass("matchWholeWordNode_"+this.filterOption.matchWholeWord); }, setMatchRegExp: function(e){ this.filterOption.matchRegExp = !this.filterOption.matchRegExp; this.matchRegExpNode.removeClass("matchRegExpNode_"+!this.filterOption.matchRegExp); this.matchRegExpNode.addClass("matchRegExpNode_"+this.filterOption.matchRegExp); }, layoutAddClass: function(flag){ flag = flag || ""; this.listNode.addClass("listNode"+flag); this.previewNode.addClass("previewNode"+flag); this.previewSeparatorNode.addClass("previewNode_separator"+flag); this.previewTitleNode.addClass("previewNode_title"+flag); this.previewTitleActionNode.addClass("previewNode_title_action"+flag); this.previewContentNode.addClass("previewNode_content"+flag); }, layoutRemoveClass: function(flag){ flag = flag || ""; this.listNode.removeClass("listNode"+flag); this.previewNode.removeClass("previewNode"+flag); this.previewSeparatorNode.removeClass("previewNode_separator"+flag); this.previewTitleNode.removeClass("previewNode_title"+flag); this.previewTitleActionNode.removeClass("previewNode_title_action"+flag); this.previewContentNode.removeClass("previewNode_content"+flag); }, toLeftRight: function(){ this.layoutAddClass("_lr"); this.layoutRemoveClass(); this.options.layout.type="leftRight"; }, toTopBottom: function(){ this.layoutAddClass(); this.layoutRemoveClass("_lr"); this.options.layout.type="topBottom"; }, changeLayout: function(){ if (this.options.layout.type=="leftRight"){ this.options.layout.type="topBottom"; }else{ this.options.layout.type="leftRight"; } this.setSizeNode(); o2.UD.putData("findDesignerLayout", {"layout": this.options.layout}); }, getSelectedRange: function(){ this.selectedRange = []; var rangeInputs = this.rangeContentNode.getElements("input"); rangeInputs.each(function(input){ if (input.checked) this.selectedRange.push(input.get("value")); }.bind(this)); }, setSelectedRange: function(){ if (this.selectedRange && this.selectedRange.length){ var rangeInputs = this.rangeContentNode.getElements("input"); rangeInputs.each(function(input){ if (this.selectedRange.indexOf(input.get("value"))!=-1) input.set("checked", true); }.bind(this)); } }, removeRangeItem: function(item){ item.destroy(); var itemNodes = this.rangeSelectedContentNode.getChildren(); if (!itemNodes.length) this.setSelectedRange(); }, selectFindRange: function(loadFun){ debugger; o2.requireApp("Selector", "package", function(){ new o2.O2Selector(this.content, { "values": this.selectedModules, "type": "PlatApp", "selectAllEnable": true, "onLoad": function(){ if (loadFun && o2.typeOf(loadFun)=="function") loadFun(); }, "onComplete": function(list){ this.rangeSelectedContentNode.empty(); //this.selectedModules = []; if (list.length){ this.getSelectedRange(); this.rangeContentNode.getElements("input").set("checked", false); o2.require("o2.widget.O2Identity", function(){ list.each(function(app){ //this.selectedModules.push(app.data); debugger; app.data.name = this.lp[app.data.moduleType] + "-" + app.data.name; var item = new o2.widget.O2Other(app.data, this.rangeSelectedContentNode, {"canRemove": true, "style": "find", "onRemove": function(item){this.removeRangeItem(item);}.bind(this)}); item.node.store("data", item.data); }.bind(this)); }.bind(this)); }else{ this.setSelectedRange(); } }.bind(this) }); }.bind(this)); }, getFindOption: function(){ var filterTypes = []; filterItems = this.filterNode.getElements("input"); filterItems.each(function(item){ if (item.checked) filterTypes.push(item.get("value")); }.bind(this)); var keyword = this.keywordInputNode.get("value"); var moduleList = []; var itemNodes = this.rangeSelectedContentNode.getChildren(); if (!itemNodes.length){ this.getSelectedRange(); this.selectedRange.each(function(type){ moduleList.push({"moduleType": type, "flagList": []}); }); }else{ var rangeApp = {}; itemNodes.each(function(node){ var data = node.retrieve("data"); if (!rangeApp[data.moduleType]) rangeApp[data.moduleType] = []; rangeApp[data.moduleType].push({"id": data.id}); }.bind(this)); Object.keys(rangeApp).each(function(k){ moduleList.push({"moduleType": k, "flagList": rangeApp[k]}); }); } this.filterOption.keyword = keyword; this.filterOption.designerTypes = filterTypes; this.filterOption.moduleList = moduleList; return this.filterOption; }, checkFindDesigner: function(e){ if (e.keyCode===13){ this.findDesigner(); } }, getFindWorker: function(){ if (!this.findWorker) this.findWorker = new Worker("../x_component_FindDesigner/FindWorker.js"); this.findWorker.onmessage = function(e) { if (e.data && e.data.type=="receive") this.setReceiveMessage(); if (e.data && e.data.type=="ready") this.setReadyMessage(e.data); if (e.data && e.data.type=="done") this.doFindOptionResult(e.data); if (e.data && e.data.type=="find") this.doFindResult(e.data); if (e.data && e.data.type=="completed") this.doFindCompleted(e.data); }.bind(this); }, doFindCompleted: function(){ if (!this.tree || !this.tree.children.length){ //not find this.listContentNode.hide(); this.listContentNode.empty(); this.listInfoNode.removeClass("loadding"); this.listInfoNode.show().getFirst().set("text", this.lp.nothingFind); } if (!this.patternCount) this.patternCount = 0; var t = this.lp.findPatternCountCompleted.replace("{n}", this.patternCount); this.listTitleInfoNode.set("text", t); }, doFindOptionResult: function(){ // this.listInfoNode.hide(); // this.listContentNode.show(); // moduleNode = this.createResultCategroyItem("xxxx", "", this.tree); this.findOptionModuleProcessed++; this.updateFindProgress(); }, doFindResult: function(data){ debugger if (data.data) this.showFindResult(data.data, data.option); }, getResultTree: function(callback){ if (!this.tree){ o2.require("o2.widget.Tree", function(){ this.tree = new o2.widget.Tree(this.listContentNode, { "style": "findDesigner" // "onQueryExpand": function(item){ // if (item.designer) this.loadDesignerPattern(item); // }.bind(this) }); this.tree.load(); if (callback) callback(); }.bind(this), null, false); }else{ if (callback) callback(); } }, createResultCategroyItem: function(text, title, tree){ var obj = { "title": title, "text": ""+text+"", "icon": "" } return tree.appendChild(obj); }, createResultAppItem: function(text, title, tree){ var obj = { "title": title, "text": ""+text+"", "icon": "" } return tree.appendChild(obj); }, createResultTypeItem: function(text, title, tree){ var obj = { "title": title, "text": ""+text+"", "icon": "" } return tree.appendChild(obj); }, createResultDesignerItem: function(text, title, tree){ var obj = { "expand": false, "title": title, "text": ""+text+"", "icon": "" } return tree.appendChild(obj); }, createResultPatternItem: function(text, title, tree, icon, action, treeNode){ var obj = { "title": title, "text": ""+text+"", "icon": icon||"", "action": action || null } var node = (treeNode) ? treeNode.insertChild(obj) : tree.appendChild(obj); node.addEvent("unselect", function(){ if (this.editor){ if (this.editor.pattern.designerType === "script"){ if (this.scriptDesignerDataObject && this.scriptDesignerDataObject[this.editor.pattern.designerId]){ this.scriptDesignerDataObject[this.editor.pattern.designerId].text = this.editor.getValue(); } }else{ debugger; if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]){ var d = this.designerDataObject[this.editor.pattern.designerId]; switch (this.editor.pattern.pattern.propertyType){ case "duty": if (this.editor.pattern.pattern.path){ var path = this.editor.pattern.pattern.path; for (var i=0; i("+text+")>"; //var html = item.options.text; textDivNode.set("html", t); } }, subPatternCount: function(node){ node.patternCount--; if (node.patternCount<0) node.patternCount=0; var textDivNode = node.textNode.getElement("div"); if (textDivNode){ var text = this.lp.patternCount.replace("{n}", node.patternCount) var t = node.options.text+"  ("+text+")>"; //var html = item.options.text; textDivNode.set("html", t); } }, addResultTitle: function(){ if (!this.patternCount) this.patternCount = 0; this.patternCount++; var t = this.lp.findPatternCount.replace("{n}", this.patternCount); this.listTitleInfoNode.set("text", t); }, subResultTitle: function(){ if (!this.patternCount) this.patternCount = 1; this.patternCount--; var t = this.lp.findPatternCount.replace("{n}", this.patternCount); this.listTitleInfoNode.set("text", t); }, showFindResult: function(data,option, treeNode){ this.addResultTitle(); this.listInfoNode.hide(); this.listContentNode.show(); var regexp = this.getFilterOptionRegex(option); var moduleNode = (this.tree.modules) ? this.tree.modules[data.module] : null; if (!moduleNode){ moduleNode = this.createResultCategroyItem(this.lp[data.module], this.lp[data.module], this.tree); moduleNode.patternCount = 0; if (!this.tree.modules) this.tree.modules = {}; this.tree.modules[data.module] = moduleNode; } this.updatePatternCount(moduleNode); debugger; var appNode = (moduleNode.apps) ? moduleNode.apps[data.appId] : null; if (!appNode){ appNode = this.createResultAppItem(data.appName, data.appName, moduleNode); appNode.patternCount = 0; if (!moduleNode.apps) moduleNode.apps = {}; moduleNode.apps[data.appId] = appNode; } this.updatePatternCount(appNode); var typeNode = (appNode.types) ? appNode.types[data.designerType] : null; if (!typeNode){ typeNode = this.createResultTypeItem(this.lp[data.designerType], this.lp[data.designerType], appNode); typeNode.patternCount = 0; if (!appNode.types) appNode.types = {}; appNode.types[data.designerType] = typeNode; } this.updatePatternCount(typeNode); var designerNode = (typeNode.designers) ? typeNode.designers[data.designerId] : null; if (!designerNode){ designerNode = this.createResultDesignerItem(data.designerName, data.designerName, typeNode); designerNode.patternCount = 0; if (!typeNode.designers) typeNode.designers = {}; typeNode.designers[data.designerId] = designerNode; } this.updatePatternCount(designerNode); switch (data.designerType){ case "script": this.createScriptPatternNode(data, designerNode, regexp, treeNode); break; case "form": case "page": case "widget": case "view": case "statement": case "process": this.createFormPatternNode(data, designerNode, regexp, treeNode); break; // case "process": // this.createProcessPatternNode(data, designerNode, regexp, treeNode); // break; } }, // createProcessPatternNode: function(data, node, regexp){ // var text = this.lp.elementPattern.replace("{element}", "<"+data.pattern.type+">"+data.pattern.name). // replace("{property}", "{"+data.pattern.key+"}"+data.pattern.propertyName); // text = ""+text+"  " // // if (data.pattern.line){ // if (data.pattern.evkey){ // text += "["+data.pattern.evkey+"] "+((data.pattern.line) ? data.pattern.line+"  " : "" )+this.getPatternValue(data.pattern.value, regexp); // }else{ // text += ((data.pattern.line) ? data.pattern.line+"  " : "" )+this.getPatternValue(data.pattern.value, regexp); // } // }else{ // text += this.getPatternValue(data.pattern.value, regexp); // } // if (data.pattern.mode){ // text = "["+data.pattern.mode+"] "+text; // } // // patternNode = this.createResultPatternItem(text, "", node, "icon_"+data.pattern.propertyType+".png"); // }, getPatternValueText: function(data, regexp){ var text = ""; if (data.pattern.line){ if (data.pattern.evkey){ text += "["+data.pattern.evkey+"] "+((data.pattern.line) ? data.pattern.line+"  " : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern); }else{ text += ((data.pattern.line) ? data.pattern.line+"  " : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern); } }else{ text += this.getPatternValue(data.pattern.value, regexp, data.pattern); } return text; }, getFormPatternNodeText: function(data, regexp){ var text = this.lp.elementPattern.replace("{element}", "<"+data.pattern.type+">"+data.pattern.name). replace("{property}", "{"+data.pattern.key+"}"+data.pattern.propertyName); text = ""+text+"  "; text += this.getPatternValueText(data, regexp); // if (data.pattern.line){ // if (data.pattern.evkey){ // text += "["+data.pattern.evkey+"] "+((data.pattern.line) ? data.pattern.line+"  " : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern); // }else{ // text += ((data.pattern.line) ? data.pattern.line+"  " : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern); // } // }else{ // text += this.getPatternValue(data.pattern.value, regexp, data.pattern); // } if (data.pattern.mode){ text = "["+data.pattern.mode+"] "+text; } return text; }, createFormPatternNode: function(data, node, regexp, treeNode){ var text = this.getFormPatternNodeText(data, regexp) var openScript = function(node){ this.openPatternForm(node); }.bind(this); patternNode = this.createResultPatternItem(text, "", node, "icon_"+data.pattern.propertyType+".png", openScript, treeNode); patternNode.pattern = data; }, getPatternValue: function(value, regexp, pattern){ regexp.lastIndex = 0; var valueHtml = ""; var idx = 0; while ((arr = regexp.exec(value)) !== null) { if (pattern){ if (!pattern.cols) pattern.cols = []; pattern.cols.push({"start": arr.index+1, "end": regexp.lastIndex+1}); } valueHtml += o2.common.encodeHtml(value.substring(idx, arr.index)); valueHtml += ""+o2.common.encodeHtml(value.substring(arr.index, regexp.lastIndex))+""; idx = regexp.lastIndex; } valueHtml += o2.common.encodeHtml(value.substring(idx, value.length)); return valueHtml; }, createScriptPatternNode: function(data, node, regexp){ var patternNode; var text; var openScript = function(node){ this.openPatternScript(node); }.bind(this); if (data.pattern.property=="text"){ text = ""+data.pattern.line+"  "+this.getPatternValue(data.pattern.value, regexp, data.pattern); patternNode = this.createResultPatternItem(text, "", node, "icon_script.png", openScript); }else{ text = this.lp.property+": "+data.pattern.property+" "+this.lp.value+": "+this.getPatternValue(data.pattern.value, regexp); patternNode = this.createResultPatternItem(text, "", node, "icon_text.png", openScript); } patternNode.pattern = data; }, openPatternForm: function(node){ var pattern = node.pattern; if (this.editor && this.editor.pattern.designerId === node.pattern.designerId && this.editor.pattern.module === node.pattern.module){ this.resetFormEditor(node.pattern); }else{ if (this.editor){ if (this.editor.pattern.designerType === "script"){ if (this.scriptDesignerDataObject && this.scriptDesignerDataObject[this.editor.pattern.designerId]){ this.scriptDesignerDataObject[this.editor.pattern.designerId].text = this.editor.getValue(); } }else{ if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]){ var d = this.designerDataObject[this.editor.pattern.designerId]; switch (this.editor.pattern.pattern.propertyType){ case "duty": if (this.editor.pattern.pattern.path){ var path = this.editor.pattern.pattern.path; for (var i=0; i"+pattern.appName+"->"+": "+"["+pattern.pattern.mode+this.lp[pattern.designerType]+"] "+pattern.designerName+"->"+el; return "
"+title+"
" }, getDefaultEditorContent: function(data, pattern){ var el = this.lp.elementPattern.replace("{element}", "<"+pattern.pattern.type+">"+pattern.pattern.name). replace("{property}", pattern.pattern.propertyName+"{"+pattern.pattern.key+"}"); var html = "
" + "
"+this.lp.findInfor+"
" + "
" + "
"+this.lp[pattern.module]+": "+pattern.appName+"
" + "
["+(pattern.pattern.mode || "")+this.lp[pattern.designerType]+"] "+pattern.designerName+"
" + "
"+this.lp.element+": "+"<"+pattern.pattern.type+">"+pattern.pattern.name+"
" + "
"+this.lp.property+": "+pattern.pattern.propertyName+"{"+pattern.pattern.key+"}: "+"
" + "
"+this.getPatternValueText(pattern, this.getFindRegExp())+"
" + "
"+this.lp.findInforOpen+"
" + "
"; return html; }, commonEditor: new Class({ Implements: [Events], initialize: function(node){ this.node = $(node); this.container = new Element("div", { "styles": { "padding": "10px" } }); }, load : function(title){ this.container.set("html", title).inject(this.node); }, destroy: function(){ this.fireEvent("destroy"); this.container.destroy(); o2.release(this); }, // getValue: function(){ // return this.value; // }, getContent: function(){ } }), openPatternFormEditor_default: function(data, node){ debugger; // var d = this.getValueWithPath(data, node.pattern); // if (d){ debugger; var content = this.getDefaultEditorContent(data, node.pattern); this.editor = new this.commonEditor(this.previewContentNode); this.editor.addEvent("destroy", function(){ this.previewToolbar.childrenButton[0].disable(); this.previewToolbar.childrenButton[1].disable(); }.bind(this)); this.editor.pattern = node.pattern; this.editor.designerNode = node; this.editor.designerData = data; this.editor.load(content); this.editor.container.getFirst().getLast().addEvent("click", function(){ this.openDesinger(); }.bind(this)); this.previewToolbar.childrenButton[0].disable(); this.previewToolbar.childrenButton[1].enable(); // } }, openPatternFormEditor_duty: function(data, node){ debugger; if (node.pattern.pattern.valueKey=="name"){ this.openPatternFormEditor_default(data, node) }else { var d = this.getValueWithPath(data, node.pattern, 2); if (d){ var json = JSON.parse(d); var idx = node.pattern.pattern.idx.toInt(); var code = json[idx].code; o2.require("o2.widget.JavascriptEditor", function(){ this.editor = new o2.widget.JavascriptEditor(this.previewContentNode, { "option": { "value": code, "mode": "javascript" } }); this.editor.pattern = node.pattern; this.editor.designerNode = node; this.editor.designerData = data; this.editor.load(function(){ if (this.previewToolbar){ this.previewToolbar.childrenButton[0].enable(); this.previewToolbar.childrenButton[1].enable(); } this.editor.addEvent("change", function(){ this.editor.isRefind = true; }.bind(this)); this.editor.addEvent("blur", function(){ if (this.editor.isRefind) this.reFindInFormDesigner(); }.bind(this)); this.editor.addEvent("destroy", function(){ this.previewToolbar.childrenButton[0].disable(); this.previewToolbar.childrenButton[1].disable(); }.bind(this)); this.editor.addEvent("save", function(){ this.saveDesigner(); }.bind(this)); this.resetFormEditor(node.pattern); }.bind(this)); }.bind(this)); } } //var d = this.getValueWithPath(data, node.pattern); }, openPatternFormEditor_array: function(data, node){ var d = this.getValueWithPath(data, node.pattern); if (d){ var title = this.getTitleWithPath(data, node.pattern); o2.require("o2.widget.Arraylist", function(){ this.editor = new o2.widget.Arraylist(this.previewContentNode, { "htmlTitle": title, "style": "findDesigner", "onChange": function(){ this.reFindInFormDesigner(); }.bind(this), "onPostLoad": function(){ if (this.previewToolbar){ this.previewToolbar.childrenButton[0].enable(); this.previewToolbar.childrenButton[1].enable(); } }.bind(this), }); this.editor.addEvent("destroy", function(){ this.previewToolbar.childrenButton[0].disable(); this.previewToolbar.childrenButton[1].disable(); }.bind(this)); this.editor.pattern = node.pattern; this.editor.designerNode = node; this.editor.designerData = data; this.editor.load(d); this.resetFormEditor(node.pattern); }.bind(this)) } }, openPatternFormEditor_map: function(data, node){ debugger; var d = this.getValueWithPath(data, node.pattern); if (d){ var title = this.getTitleWithPath(data, node.pattern); o2.require("o2.widget.Maplist", function(){ this.editor = new o2.widget.Maplist(this.previewContentNode, { "htmlTitle": title, "style": "findDesigner", "onChange": function(){ this.reFindInFormDesigner(); }.bind(this), "onPostLoad": function(){ if (this.previewToolbar){ this.previewToolbar.childrenButton[0].enable(); this.previewToolbar.childrenButton[1].enable(); } }.bind(this), }); this.editor.addEvent("destroy", function(){ this.previewToolbar.childrenButton[0].disable(); this.previewToolbar.childrenButton[1].disable(); }.bind(this)); this.editor.pattern = node.pattern; this.editor.designerNode = node; this.editor.designerData = data; this.editor.load(d); this.resetFormEditor(node.pattern); }.bind(this)) } }, openPatternFormEditor_script: function(data, node){ var path = node.pattern.pattern.path; var d = data; var i=0; while (i=0){ value = char+value; n--; char = code.charAt(n); } n = regex.lastIndex; char = code.charAt(n); while (!lineRegexp.test(char) && n1){ for (var i=1; i1){ for (var i=1; i"+text+""); } } }.bind(this)); arr.forEach(function(v, i) { regex.lastIndex = 0; var text = v.toString(); if (regex.test(text)){ var n = removeNodes.filter(function(n){ var idx = n.pattern.pattern.line.toInt()-1; return (idx==i); }); if (!n.length){ this.showFindResult(this._createFindMessageReplyData(this.editor.pattern.module, this.editor.pattern, "", { "type": pattern.pattern.type, "propertyType": pattern.pattern.propertyType, "propertyName": pattern.pattern.propertyName, "name": pattern.pattern.name, "id": pattern.pattern.id, "line": i+1, "key": pattern.pattern.key, "value": text, "mode": pattern.pattern.mode, "path": pattern.pattern.path }), this.filterOption, removeNodes[removeNodes.length-1].nextSibling); } } }.bind(this)); } }, reFindInFormDesigner_map: function(removeNodes, pattern){ var map = this.editor.getValue(); if (map){ var regex = this.getFilterOptionRegex(this.filterOption) removeNodes.forEach(function(i){ var k = i.pattern.pattern.value.split(":")[0]; if (i.pattern.pattern.value!=(k+": "+map[k])){ i.pattern.pattern.value = k+": "+(map[k] || ""); var text = this.getFormPatternNodeText(i.pattern, regex) var textDivNode = i.textNode.getElement("div"); if (textDivNode){ textDivNode.set("html", ""+text+""); } } }.bind(this)); Object.keys(map).forEach(function(evkey) { regex.lastIndex = 0; var text = map[evkey]; if (text){ if ((typeof text)=="string") { if (regex.test(text)) { var n = removeNodes.filter(function(i){ var k = i.pattern.pattern.value.split(":")[0]; return (k==evkey) }); if (!n.length){ this.showFindResult(this._createFindMessageReplyData(this.editor.pattern.module, this.editor.pattern, "", { "type": pattern.pattern.type, "propertyType": pattern.pattern.propertyType, "propertyName": pattern.pattern.propertyName, "name": pattern.pattern.name, "id": pattern.pattern.id, "key": pattern.pattern.key, "value": evkey + ": " + text, "mode": pattern.pattern.mode, "path": pattern.pattern.path }), this.filterOption, removeNodes[removeNodes.length-1].nextSibling); } } } } }.bind(this)); } }, reFindInFormDesigner_script: function(flagNode){ var code = this.editor.getValue(); if (code){ var regex = this.getFilterOptionRegex(this.filterOption) regex.lastIndex = 0; var len = code.length; var preLine = 0; var preIndex = 0; var result; while ((result = regex.exec(code)) !== null){ var obj = this.findScriptLineValue(result, code, preLine, preIndex, len, regex); preLine = obj.preLine; preIndex = obj.preIndex; var pattern = this.editor.pattern; this.showFindResult(this._createFindMessageReplyData( this.editor.pattern.module, this.editor.pattern, "", { "type": pattern.pattern.type, "propertyType": pattern.pattern.propertyType, "propertyName": pattern.pattern.propertyName, "name": pattern.pattern.name, "id": pattern.pattern.id, "key": pattern.pattern.key, "evkey": pattern.pattern.evkey, "value": obj.value, "line": preLine+1, "mode": pattern.pattern.mode, "path": pattern.pattern.path }), this.filterOption, flagNode); } } if (flagNode) flagNode.destroy(); }, reFindInDesigner: function(){ if (this.editor && this.editor.designerNode){ while (this.editor.designerNode.firstChild){ this.editor.designerNode.firstChild.destroy(); this.subResultCount(this.editor.pattern); } var code = this.editor.getValue(); if (code){ var regex = this.getFilterOptionRegex(this.filterOption) regex.lastIndex = 0; var len = code.length; var preLine = 0; var preIndex = 0; var result; while ((result = regex.exec(code)) !== null){ var obj = this.findScriptLineValue(result, code, preLine, preIndex, len, regex); preLine = obj.preLine; preIndex = obj.preIndex; this.showFindResult(this._createFindMessageReplyData( this.editor.pattern.module, this.editor.pattern, "", { "property": "text", "value": obj.value, "line": preLine+1 }), this.filterOption); } } } this.editor.isRefind = false; }, saveDesigner: function(){ debugger; if (this.editor && this.editor.pattern){ var pattern = this.editor.pattern; var data = this.editor.designerData; switch (pattern.designerType){ case "script": var m; switch (pattern.module){ case "processPlatform": m = o2.Actions.load("x_processplatform_assemble_designer").ScriptAction.put; break; case "cms": m = o2.Actions.load("x_cms_assemble_control").ScriptAction.put; break; case "portal": m = o2.Actions.load("x_portal_assemble_designer").ScriptAction.edit; break; case "service": switch (pattern.appId) { case "invoke": m = o2.Actions.load("x_program_center").InvokeAction.edit; break; case "script": m = o2.Actions.load("x_program_center").ScriptAction.edit; break; default: m = o2.Actions.load("x_program_center").AgentAction.edit; break; } //m = (pattern.appId==="invoke") ? o2.Actions.load("x_program_center").InvokeAction.edit : o2.Actions.load("x_program_center").AgentAction.edit; break; } data.text = this.editor.getValue(); if (m) m(data.id, data).then(function(){ this.notice(this.lp.notice.save_success, "success", this.previewContentNode, {"x": "left", "y": "bottom"}); }.bind(this), function(){}); break; case "form": case "page": case "widget": switch (pattern.module){ case "processPlatform": var action = MWF.Actions.get("x_processplatform_assemble_designer"); m = action.saveForm.bind(action); if(data.data)data.data.isNewForm = false; break; case "cms": var action = MWF.Actions.get("x_cms_assemble_control"); m = action.saveForm.bind(action); if(data.data)data.data.isNewForm = false; break; case "portal": var action = MWF.Actions.get("x_portal_assemble_designer"); m = (pattern.designerType=="page") ? action.savePage.bind(action) : action.saveWidget.bind(action); if(data.data)data.data.isNewPage = false; break; } if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]){ var d = this.designerDataObject[this.editor.pattern.designerId]; switch (this.editor.pattern.pattern.propertyType){ case "duty": if (this.editor.pattern.pattern.path){ var path = this.editor.pattern.pattern.path; for (var i=0; i"+text+"", // "icon": "" // } // return tree.appendChild(obj); // }, // // createResultDesignerItem: function(designer, tree){ // // var title = this.lp[designer.designerType]+ ": "+ designer.designerName + " ("+designer.designerId+")"; // // var text = this.lp[designer.designerType]+ ": "+ designer.designerName+""; // // var obj = { // // "expand": false, // // "title": title, // // "text": text, // // "icon": "" // // } // // var item = tree.appendChild(obj); // // item.designer = designer; // // item.appendChild({ "expand": false, "text": "loading...", "icon": "" }); // // return item; // // }, // listFindResult: function(data){ // this.listContentNode.empty(); // this.listContentNode.show(); // o2.require("o2.widget.Tree", function(){ // var tree = new o2.widget.Tree(this.listContentNode, { // "onQueryExpand": function(item){ // if (item.designer) this.loadDesignerPattern(item); // }.bind(this) // }); // tree.load(); // if (data.processPlatformList && data.processPlatformList.length){ // var platformItem = this.createResultCategroyItem(this.lp.processPlatform, this.lp.processPlatform, tree); // this.listProcessResult(platformItem, data.processPlatformList, "processPlatform"); // } // if (data.cmsList && data.cmsList.length){ // var platformItem = this.createResultCategroyItem(this.lp.cms, this.lp.cms, tree); // //this.listProcessResult(categroyItem, data.cmsList); // } // if (data.portalList && data.portalList.length){ // var platformItem = this.createResultCategroyItem(this.lp.portal, this.lp.portal, tree); // // } // if (data.queryList && data.queryList.length){ // var platformItem = this.createResultCategroyItem(this.lp.query, this.lp.query, tree); // } // if (data.serviceList && data.serviceList.length){ // var platformItem = this.createResultCategroyItem(this.lp.service, this.lp.service, tree); // } // // // }.bind(this)); // }, // addPatternCount: function(item, count){ // if (!item.count) item.count = 0; // item.count += count; // var t = this.lp.patternCount.replace("{n}", item.count); // var textDivNode = item.textNode.getElement("div"); // if (textDivNode){ // var html = item.options.text; // textDivNode.set("html", html+" ( "+t+" )"); // } // }, // listProcessResult: function(platformItem, list, platform){ // var applicationItems = {}; // list.each(function(designer){ // if (designer.patternList && designer.patternList.length){ // var appItem = applicationItems[designer.appId]; // if (!appItem){ // applicationItems[designer.appId] = appItem = this.createResultAppItem(designer.appName, designer.appName+" ("+designer.appId+")", platformItem); // } // designer.platform = platform; // var designerItem = this.createResultDesignerItem(designer, appItem); // var count=0; // designer.patternList.each(function(p){ // if (p.lines && p.lines.length){ // count += p.lines.length; // }else{ // count++; // } // }); // // var count = designer.patternList.length; // // this.addPatternCount(designerItem, count); // this.addPatternCount(appItem, count); // this.addPatternCount(platformItem, count); // } // }.bind(this)); // }, // // getDesignerObject: function(designer){ // switch (designer.platform){ // case "processPlatform": // var action = this.Actions.load("x_processplatform_assemble_designer"); // switch (designer.designerType){ // case "script": // return action.ScriptAction.get(designer.designerId, function(json){return json.data;}); // case "form": // return action.FomrAction.get(designer.designerId, function(json){return json.data;}); // case "process": // return action.ProcessAction.get(designer.designerId, function(json){return json.data;}); // } // case "cms": // var action = this.Actions.load("x_cms_assemble_control"); // switch (designer.designerType){ // case "script": // return action.ScriptAction.get(designer.designerId, function(json){return json.data;}); // case "form": // return action.FormAction.get(designer.designerId, function(json){return json.data;}); // } // // case "portal": // var action = this.Actions.load("x_portal_assemble_designer"); // switch (designer.designerType){ // case "script": // return action.ScriptAction.get(designer.designerId, function(json){return json.data;}); // case "page": // return action.PageAction.get(designer.designerId, function(json){return json.data;}); // case "widget": // return action.WidgetAction.get(designer.designerId, function(json){return json.data;}); // } // case "query": // var action = this.Actions.load("x_query_assemble_designer"); // switch (designer.designerType){ // case "view": // return action.ViewAction.get(designer.designerId, function(json){return json.data;}); // case "statement": // return action.StatementAction.get(designer.designerId, function(json){return json.data;}); // case "stat": // return action.StatAction.get(designer.designerId, function(json){return json.data;}); // } // case "service": // var action = this.Actions.load("x_program_center"); // switch (designer.appId){ // case "invoke": // return action.InvokeAction.get(designer.designerId, function(json){return json.data;}); // case "agent": // return action.AgentAction.get(designer.designerId, function(json){return json.data;}); // } // } // }, // loadDesignerPattern: function(item){ // if (item.firstChild && item.firstChild.options.text==="loading..."){ // item.firstChild.destroy(); // // var root, actionName, fun; // switch (designer.platform) { // case "processPlatform": // root = "x_processplatform_assemble_designer"; // switch (designer.designerType) { // case "script": actionName = "ScriptAction"; fun = "listProcessScriptPattern"; // case "form": actionName = "FomrAction"; fun = "listProcessFormPattern"; // case "process": actionName = "ProcessAction"; fun = "listProcessProcessPattern"; // } // case "cms": // root = "x_cms_assemble_control"; // switch (designer.designerType) { // case "script": actionName = "ScriptAction"; fun = "listCmsScriptPattern"; // case "form": actionName = "FormAction"; fun = "listCmsFormPattern"; // } // // case "portal": // root = "x_portal_assemble_designer"; // switch (designer.designerType) { // case "script": actionName = "ScriptAction"; fun = "listPortalScriptPattern"; // case "page": actionName = "PageAction"; fun = "listPortalPagePattern"; // case "widget": actionName = "WidgetAction"; fun = "listPortalWidgetPattern"; // } // case "query": // root = "x_query_assemble_designer"; // switch (designer.designerType) { // case "view": actionName = "ViewAction"; fun = "listQueryViewPattern"; // case "statement": actionName = "StatementAction"; fun = "listQueryStatementPattern"; // case "stat": actionName = "StatAction"; fun = "listQueryStatPattern"; // } // case "service": // root = "x_program_center"; // switch (designer.appId) { // case "invoke": actionName = "InvokeAction"; fun = "listServiceInvokePattern"; // case "agent": actionName = "AgentAction"; fun = "listServiceAgentPattern"; // } // } // this.Actions.load(root)[actionName].get(designer.designerId, function(json){ // this[fun](json.data, designer.patternList, item); // }.bind(this)) // } // }, // // // // //启动一个webworker处理 // listProcessScriptPattern: function (data, patternList, item){ // patternList.each(function(pattern){ // if (pattern.property == "text"){ // var textArr = data.split("\n"); // var regex = this.getFindRegExp(); // pattern.lines.each(function(line){ // var text = textArr[line]; // // // // }.bind(this)); // }else{ // // } // }.bind(this)); // } });