Main.js 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455
  1. MWF.xApplication.FindDesigner.options.multitask = false;
  2. MWF.xApplication.FindDesigner.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "name": "FindDesigner",
  8. "mvcStyle": "style.css",
  9. "icon": "icon.png",
  10. "width": "1200",
  11. "height": "800",
  12. "filter": null,
  13. "isResize": true,
  14. "isMax": true,
  15. "layout": {
  16. "type": "leftRight",
  17. "percent": 0.3
  18. },
  19. "title": MWF.xApplication.FindDesigner.LP.title
  20. },
  21. onQueryLoad: function(){
  22. this.lp = MWF.xApplication.FindDesigner.LP;
  23. this.filterOption = {
  24. "keyword": "",
  25. "designerTypes": [],
  26. "caseSensitive": false,
  27. "matchWholeWord": false,
  28. "matchRegExp": false,
  29. "moduleList": []
  30. }
  31. this.selectedModules = [];
  32. this.selectedRange = [];
  33. o2.UD.getDataJson("findDesignerLayout", function(json){
  34. this.setOptions(json);
  35. }.bind(this), false);
  36. },
  37. loadApplication: function(callback){
  38. var url = this.path+this.options.style+"/view.html";
  39. this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){
  40. this.setSizeNode();
  41. this.createToolbar();
  42. debugger;
  43. this.initFilter();
  44. if (callback) callback();
  45. }.bind(this));
  46. },
  47. initFilter: function(){
  48. if (this.options.filter){
  49. if (this.options.filter.moduleList){
  50. var inputs = this.rangeContentNode.getElements("input");
  51. inputs.forEach(function(input){
  52. if (input.get("value").indexOf(this.options.filter.moduleList) !== -1){
  53. input.set("checked", true);
  54. }else{
  55. input.set("checked", false);
  56. }
  57. }.bind(this));
  58. }
  59. if (this.options.filter.appList){
  60. o2.require("o2.widget.O2Identity", function(){
  61. this.options.filter.appList.each(function(app){
  62. app.name = this.lp[app.moduleType] + "-" + app.name;
  63. var item = new o2.widget.O2Other(app, this.rangeSelectedContentNode, {"canRemove": true, "style": "find", "onRemove": function(item){this.removeRangeItem(item);}.bind(this)});
  64. item.node.store("data", item.data);
  65. }.bind(this));
  66. }.bind(this));
  67. }
  68. }
  69. },
  70. createToolbar: function(){
  71. o2.require("o2.widget.Toolbar", function(){
  72. this.previewToolbar = new o2.widget.Toolbar(this.previewTitleToolbar, {"style": "findDesigner"}, this);
  73. this.previewToolbar.load();
  74. this.previewToolbar.childrenButton[0].disable();
  75. this.previewToolbar.childrenButton[1].disable();
  76. }.bind(this));
  77. },
  78. initLayout: function(){
  79. this.listNode.set("style", "");
  80. this.previewNode.set("style", "");
  81. if (this.resizeDrag) this.resizeDrag.detach();
  82. if (this.sizeNodeFun) this.removeEvent("resize", this.sizeNodeFun);
  83. if (this.options.layout.type=="leftRight"){
  84. this.toLeftRight();
  85. }else{
  86. this.toTopBottom();
  87. }
  88. },
  89. setSizeNode: function(){
  90. this.initLayout();
  91. this["sizeNode_"+this.options.layout.type]();
  92. this["setResizeNode_"+this.options.layout.type]();
  93. this.sizeNodeFun = null;
  94. this.sizeNodeFun = this["sizeNode_"+this.options.layout.type].bind(this);
  95. this.addEvent("resize", this.sizeNodeFun);
  96. },
  97. sizeResultNode: function(){
  98. var size = this.content.getSize();
  99. var filterSzie = this.filterNode.getSize();
  100. var keywordSize = this.keywordNode.getSize();
  101. var rangeSize = this.rangeNode.getSize();
  102. var h = size.y-filterSzie.y-keywordSize.y-rangeSize.y;
  103. this.resultNode.setStyle("height", ""+h+"px");
  104. return h;
  105. },
  106. sizeNode_topBottom: function(){
  107. var h = this.sizeResultNode();
  108. var listHeight = h*this.options.layout.percent;
  109. this.listNode.setStyle("height", ""+listHeight+"px");
  110. var previewHeight = h*(1-this.options.layout.percent);
  111. this.previewNode.setStyle("height", ""+previewHeight+"px");
  112. var listTitleSize = this.listTitleNode.getSize();
  113. var listContentHeight = listHeight - listTitleSize.y;
  114. this.listAreaNode.setStyle("height", ""+listContentHeight+"px");
  115. var previewSeparatorSize = this.previewSeparatorNode.getSize();
  116. var previewTitleSize = this.previewTitleNode.getSize();
  117. var previewContentHeight = previewHeight - previewSeparatorSize.y - previewTitleSize.y;
  118. this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
  119. },
  120. sizeNode_leftRight: function(){
  121. var h = this.sizeResultNode();
  122. var w = this.resultNode.getSize().x;
  123. var listWidth = w*this.options.layout.percent;
  124. this.listNode.setStyle("width", ""+listWidth+"px");
  125. this.previewNode.setStyle("margin-left", ""+listWidth+"px");
  126. var listTitleSize = this.listTitleNode.getSize();
  127. var listContentHeight = h - listTitleSize.y;
  128. this.listAreaNode.setStyle("height", ""+listContentHeight+"px");
  129. var previewTitleSize = this.previewTitleNode.getSize();
  130. var previewContentHeight = h - previewTitleSize.y;
  131. this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
  132. },
  133. setResizeNode_topBottom: function(){
  134. if (this.previewSeparatorNode){
  135. this.resizeDrag = new Drag(this.previewSeparatorNode, {
  136. "onStart": function(el, e){
  137. el.store("position", o2.eventPosition(e));
  138. el.store("initialSize", this.listNode.getSize());
  139. }.bind(this),
  140. "onDrag": function(el, e){
  141. var p = o2.eventPosition(e);
  142. var position = el.retrieve("position");
  143. var initialSize = el.retrieve("initialSize");
  144. var dy = position.y.toFloat()-p.y.toFloat();
  145. var height = initialSize.y-dy;
  146. var size = this.resultNode.getSize();
  147. this.options.layout.percent = height/size.y;
  148. if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
  149. if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
  150. this.sizeNode_topBottom();
  151. if (this.editor) if(this.editor.resize) this.editor.resize();
  152. }.bind(this),
  153. "onComplete": function(){
  154. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  155. }.bind(this)
  156. });
  157. }
  158. },
  159. setResizeNode_leftRight: function(){
  160. if (this.previewSeparatorNode){
  161. this.resizeDrag = new Drag(this.previewSeparatorNode, {
  162. "onStart": function(el, e){
  163. el.store("position", o2.eventPosition(e));
  164. el.store("initialSize", this.listNode.getSize());
  165. }.bind(this),
  166. "onDrag": function(el, e){
  167. var p = o2.eventPosition(e);
  168. var position = el.retrieve("position");
  169. var initialSize = el.retrieve("initialSize");
  170. var dx = position.x.toFloat()-p.x.toFloat();
  171. var width = initialSize.x-dx;
  172. var size = this.resultNode.getSize();
  173. this.options.layout.percent = width/size.x;
  174. if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
  175. if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
  176. this.sizeNode_leftRight();
  177. if (this.editor) if(this.editor.resize) this.editor.resize();
  178. }.bind(this),
  179. "onComplete": function(){
  180. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  181. }.bind(this)
  182. });
  183. }
  184. },
  185. checkFilter: function(e){
  186. if (e.target.hasClass("filterNode_item")) e.target.getElement("input").click();
  187. e.stopPropagation();
  188. },
  189. checkRange: function(e){
  190. if (e.target.hasClass("rangeType_Item")) e.target.getElement("input").click();
  191. e.stopPropagation();
  192. },
  193. overKeywordOption: function(e){
  194. if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")){
  195. if (!e.target.hasClass("optionItem_over")) e.target.addClass("optionItem_over");
  196. }
  197. },
  198. outKeywordOption: function(e){
  199. if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")) e.target.removeClass("optionItem_over");
  200. },
  201. setCaseSensitive: function(e){
  202. this.filterOption.caseSensitive = !this.filterOption.caseSensitive;
  203. this.caseSensitiveNode.removeClass("caseSensitiveNode_"+!this.filterOption.caseSensitive);
  204. this.caseSensitiveNode.addClass("caseSensitiveNode_"+this.filterOption.caseSensitive);
  205. },
  206. setMatchWholeWord: function(e){
  207. this.filterOption.matchWholeWord = !this.filterOption.matchWholeWord;
  208. this.matchWholeWordNode.removeClass("matchWholeWordNode_"+!this.filterOption.matchWholeWord);
  209. this.matchWholeWordNode.addClass("matchWholeWordNode_"+this.filterOption.matchWholeWord);
  210. },
  211. setMatchRegExp: function(e){
  212. this.filterOption.matchRegExp = !this.filterOption.matchRegExp;
  213. this.matchRegExpNode.removeClass("matchRegExpNode_"+!this.filterOption.matchRegExp);
  214. this.matchRegExpNode.addClass("matchRegExpNode_"+this.filterOption.matchRegExp);
  215. },
  216. layoutAddClass: function(flag){
  217. flag = flag || "";
  218. this.listNode.addClass("listNode"+flag);
  219. this.previewNode.addClass("previewNode"+flag);
  220. this.previewSeparatorNode.addClass("previewNode_separator"+flag);
  221. this.previewTitleNode.addClass("previewNode_title"+flag);
  222. this.previewTitleActionNode.addClass("previewNode_title_action"+flag);
  223. this.previewContentNode.addClass("previewNode_content"+flag);
  224. },
  225. layoutRemoveClass: function(flag){
  226. flag = flag || "";
  227. this.listNode.removeClass("listNode"+flag);
  228. this.previewNode.removeClass("previewNode"+flag);
  229. this.previewSeparatorNode.removeClass("previewNode_separator"+flag);
  230. this.previewTitleNode.removeClass("previewNode_title"+flag);
  231. this.previewTitleActionNode.removeClass("previewNode_title_action"+flag);
  232. this.previewContentNode.removeClass("previewNode_content"+flag);
  233. },
  234. toLeftRight: function(){
  235. this.layoutAddClass("_lr");
  236. this.layoutRemoveClass();
  237. this.options.layout.type="leftRight";
  238. },
  239. toTopBottom: function(){
  240. this.layoutAddClass();
  241. this.layoutRemoveClass("_lr");
  242. this.options.layout.type="topBottom";
  243. },
  244. changeLayout: function(){
  245. if (this.options.layout.type=="leftRight"){
  246. this.options.layout.type="topBottom";
  247. }else{
  248. this.options.layout.type="leftRight";
  249. }
  250. this.setSizeNode();
  251. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  252. },
  253. getSelectedRange: function(){
  254. this.selectedRange = [];
  255. var rangeInputs = this.rangeContentNode.getElements("input");
  256. rangeInputs.each(function(input){
  257. if (input.checked) this.selectedRange.push(input.get("value"));
  258. }.bind(this));
  259. },
  260. setSelectedRange: function(){
  261. if (this.selectedRange && this.selectedRange.length){
  262. var rangeInputs = this.rangeContentNode.getElements("input");
  263. rangeInputs.each(function(input){
  264. if (this.selectedRange.indexOf(input.get("value"))!=-1) input.set("checked", true);
  265. }.bind(this));
  266. }
  267. },
  268. removeRangeItem: function(item){
  269. item.destroy();
  270. var itemNodes = this.rangeSelectedContentNode.getChildren();
  271. if (!itemNodes.length) this.setSelectedRange();
  272. },
  273. selectFindRange: function(loadFun){
  274. debugger;
  275. o2.requireApp("Selector", "package", function(){
  276. new o2.O2Selector(this.content, {
  277. "values": this.selectedModules,
  278. "type": "PlatApp",
  279. "selectAllEnable": true,
  280. "onLoad": function(){
  281. if (loadFun && o2.typeOf(loadFun)=="function") loadFun();
  282. },
  283. "onComplete": function(list){
  284. this.rangeSelectedContentNode.empty();
  285. //this.selectedModules = [];
  286. if (list.length){
  287. this.getSelectedRange();
  288. this.rangeContentNode.getElements("input").set("checked", false);
  289. o2.require("o2.widget.O2Identity", function(){
  290. list.each(function(app){
  291. //this.selectedModules.push(app.data);
  292. debugger;
  293. app.data.name = this.lp[app.data.moduleType] + "-" + app.data.name;
  294. var item = new o2.widget.O2Other(app.data, this.rangeSelectedContentNode, {"canRemove": true, "style": "find", "onRemove": function(item){this.removeRangeItem(item);}.bind(this)});
  295. item.node.store("data", item.data);
  296. }.bind(this));
  297. }.bind(this));
  298. }else{
  299. this.setSelectedRange();
  300. }
  301. }.bind(this)
  302. });
  303. }.bind(this));
  304. },
  305. getFindOption: function(){
  306. var filterTypes = [];
  307. filterItems = this.filterNode.getElements("input");
  308. filterItems.each(function(item){
  309. if (item.checked) filterTypes.push(item.get("value"));
  310. }.bind(this));
  311. var keyword = this.keywordInputNode.get("value");
  312. var moduleList = [];
  313. var itemNodes = this.rangeSelectedContentNode.getChildren();
  314. if (!itemNodes.length){
  315. this.getSelectedRange();
  316. this.selectedRange.each(function(type){
  317. moduleList.push({"moduleType": type, "flagList": []});
  318. });
  319. }else{
  320. var rangeApp = {};
  321. itemNodes.each(function(node){
  322. var data = node.retrieve("data");
  323. if (!rangeApp[data.moduleType]) rangeApp[data.moduleType] = [];
  324. rangeApp[data.moduleType].push({"id": data.id});
  325. }.bind(this));
  326. Object.keys(rangeApp).each(function(k){
  327. moduleList.push({"moduleType": k, "flagList": rangeApp[k]});
  328. });
  329. }
  330. this.filterOption.keyword = keyword;
  331. this.filterOption.designerTypes = filterTypes;
  332. this.filterOption.moduleList = moduleList;
  333. return this.filterOption;
  334. },
  335. checkFindDesigner: function(e){
  336. if (e.keyCode===13){
  337. this.findDesigner();
  338. }
  339. },
  340. getFindWorker: function(){
  341. if (!this.findWorker) this.findWorker = new Worker("../x_component_FindDesigner/FindWorker.js");
  342. this.findWorker.onmessage = function(e) {
  343. if (e.data && e.data.type=="receive") this.setReceiveMessage();
  344. if (e.data && e.data.type=="ready") this.setReadyMessage(e.data);
  345. if (e.data && e.data.type=="done") this.doFindOptionResult(e.data);
  346. if (e.data && e.data.type=="find") this.doFindResult(e.data);
  347. if (e.data && e.data.type=="completed") this.doFindCompleted(e.data);
  348. }.bind(this);
  349. },
  350. doFindCompleted: function(){
  351. if (!this.tree || !this.tree.children.length){
  352. //not find
  353. this.listContentNode.hide();
  354. this.listContentNode.empty();
  355. this.listInfoNode.removeClass("loadding");
  356. this.listInfoNode.show().getFirst().set("text", this.lp.nothingFind);
  357. }
  358. if (!this.patternCount) this.patternCount = 0;
  359. var t = this.lp.findPatternCountCompleted.replace("{n}", this.patternCount);
  360. this.listTitleInfoNode.set("text", t);
  361. },
  362. doFindOptionResult: function(){
  363. // this.listInfoNode.hide();
  364. // this.listContentNode.show();
  365. // moduleNode = this.createResultCategroyItem("xxxx", "", this.tree);
  366. this.findOptionModuleProcessed++;
  367. this.updateFindProgress();
  368. },
  369. doFindResult: function(data){
  370. debugger
  371. if (data.data) this.showFindResult(data.data, data.option);
  372. },
  373. getResultTree: function(callback){
  374. if (!this.tree){
  375. o2.require("o2.widget.Tree", function(){
  376. this.tree = new o2.widget.Tree(this.listContentNode, {
  377. "style": "findDesigner"
  378. // "onQueryExpand": function(item){
  379. // if (item.designer) this.loadDesignerPattern(item);
  380. // }.bind(this)
  381. });
  382. this.tree.load();
  383. if (callback) callback();
  384. }.bind(this), null, false);
  385. }else{
  386. if (callback) callback();
  387. }
  388. },
  389. createResultCategroyItem: function(text, title, tree){
  390. var obj = {
  391. "title": title,
  392. "text": "<span style='font-weight: bold'>"+text+"</span>",
  393. "icon": ""
  394. }
  395. return tree.appendChild(obj);
  396. },
  397. createResultAppItem: function(text, title, tree){
  398. var obj = {
  399. "title": title,
  400. "text": "<span style='font-weight: bold; color: #0b58a2'>"+text+"</span>",
  401. "icon": ""
  402. }
  403. return tree.appendChild(obj);
  404. },
  405. createResultTypeItem: function(text, title, tree){
  406. var obj = {
  407. "title": title,
  408. "text": "<span style='color: #333333'>"+text+"</span>",
  409. "icon": ""
  410. }
  411. return tree.appendChild(obj);
  412. },
  413. createResultDesignerItem: function(text, title, tree){
  414. var obj = {
  415. "expand": false,
  416. "title": title,
  417. "text": "<span style='color: #333333'>"+text+"</span>",
  418. "icon": ""
  419. }
  420. return tree.appendChild(obj);
  421. },
  422. createResultPatternItem: function(text, title, tree, icon, action, treeNode){
  423. var obj = {
  424. "title": title,
  425. "text": "<span style='color: #000000'>"+text+"</span>",
  426. "icon": icon||"",
  427. "action": action || null
  428. }
  429. var node = (treeNode) ? treeNode.insertChild(obj) : tree.appendChild(obj);
  430. node.addEvent("unselect", function(){
  431. if (this.editor){
  432. if (this.editor.pattern.designerType === "script"){
  433. if (this.scriptDesignerDataObject && this.scriptDesignerDataObject[this.editor.pattern.designerId]){
  434. this.scriptDesignerDataObject[this.editor.pattern.designerId].text = this.editor.getValue();
  435. }
  436. }else{
  437. debugger;
  438. if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]){
  439. var d = this.designerDataObject[this.editor.pattern.designerId];
  440. switch (this.editor.pattern.pattern.propertyType){
  441. case "duty":
  442. if (this.editor.pattern.pattern.path){
  443. var path = this.editor.pattern.pattern.path;
  444. for (var i=0; i<path.length-1; i++){
  445. if (path[i]==this.editor.pattern.pattern.key){
  446. d[path[i]] = JSON.parse(d[path[i]]);
  447. d = d[path[i]];
  448. }else{
  449. d = d[path[i]];
  450. }
  451. }
  452. d[path[path.length-1]] = this.editor.getValue();
  453. d = this.designerDataObject[this.editor.pattern.designerId];
  454. for (var i=0; i<path.length-1; i++){
  455. if (path[i]==this.editor.pattern.pattern.key){
  456. d[path[i]] = JSON.stringify(d[path[i]]);
  457. break;
  458. }else{
  459. d = d[path[i]];
  460. }
  461. }
  462. }
  463. break;
  464. default:
  465. if (this.editor.getValue){
  466. if (this.editor.pattern.pattern.path){
  467. var path = this.editor.pattern.pattern.path;
  468. for (var i=0; i<path.length-1; i++){
  469. d = d[path[i]];
  470. }
  471. }
  472. if (path[path.length-1]=="styles"){
  473. d["recoveryStyles"] = this.editor.getValue();
  474. }else if (path[path.length-1]=="inputStyles"){
  475. d["recoveryInputStyles"] = this.editor.getValue();
  476. }
  477. d[path[path.length-1]] = this.editor.getValue();
  478. }
  479. }
  480. }
  481. }
  482. this.editor.destroy();
  483. this.editor = null;
  484. this.previewInforNode.show().inject(this.previewContentNode);
  485. }
  486. }.bind(this));
  487. return node;
  488. },
  489. updatePatternCount: function(node){
  490. node.patternCount++;
  491. var textDivNode = node.textNode.getElement("div");
  492. if (textDivNode){
  493. var text = this.lp.patternCount.replace("{n}", node.patternCount)
  494. var t = node.options.text+"&nbsp;&nbsp;<span style='color: #666666'>("+text+")</span>>";
  495. //var html = item.options.text;
  496. textDivNode.set("html", t);
  497. }
  498. },
  499. subPatternCount: function(node){
  500. node.patternCount--;
  501. if (node.patternCount<0) node.patternCount=0;
  502. var textDivNode = node.textNode.getElement("div");
  503. if (textDivNode){
  504. var text = this.lp.patternCount.replace("{n}", node.patternCount)
  505. var t = node.options.text+"&nbsp;&nbsp;<span style='color: #666666'>("+text+")</span>>";
  506. //var html = item.options.text;
  507. textDivNode.set("html", t);
  508. }
  509. },
  510. addResultTitle: function(){
  511. if (!this.patternCount) this.patternCount = 0;
  512. this.patternCount++;
  513. var t = this.lp.findPatternCount.replace("{n}", this.patternCount);
  514. this.listTitleInfoNode.set("text", t);
  515. },
  516. subResultTitle: function(){
  517. if (!this.patternCount) this.patternCount = 1;
  518. this.patternCount--;
  519. var t = this.lp.findPatternCount.replace("{n}", this.patternCount);
  520. this.listTitleInfoNode.set("text", t);
  521. },
  522. showFindResult: function(data,option, treeNode){
  523. this.addResultTitle();
  524. this.listInfoNode.hide();
  525. this.listContentNode.show();
  526. var regexp = this.getFilterOptionRegex(option);
  527. var moduleNode = (this.tree.modules) ? this.tree.modules[data.module] : null;
  528. if (!moduleNode){
  529. moduleNode = this.createResultCategroyItem(this.lp[data.module], this.lp[data.module], this.tree);
  530. moduleNode.patternCount = 0;
  531. if (!this.tree.modules) this.tree.modules = {};
  532. this.tree.modules[data.module] = moduleNode;
  533. }
  534. this.updatePatternCount(moduleNode);
  535. debugger;
  536. var appNode = (moduleNode.apps) ? moduleNode.apps[data.appId] : null;
  537. if (!appNode){
  538. appNode = this.createResultAppItem(data.appName, data.appName, moduleNode);
  539. appNode.patternCount = 0;
  540. if (!moduleNode.apps) moduleNode.apps = {};
  541. moduleNode.apps[data.appId] = appNode;
  542. }
  543. this.updatePatternCount(appNode);
  544. var typeNode = (appNode.types) ? appNode.types[data.designerType] : null;
  545. if (!typeNode){
  546. typeNode = this.createResultTypeItem(this.lp[data.designerType], this.lp[data.designerType], appNode);
  547. typeNode.patternCount = 0;
  548. if (!appNode.types) appNode.types = {};
  549. appNode.types[data.designerType] = typeNode;
  550. }
  551. this.updatePatternCount(typeNode);
  552. var designerNode = (typeNode.designers) ? typeNode.designers[data.designerId] : null;
  553. if (!designerNode){
  554. designerNode = this.createResultDesignerItem(data.designerName, data.designerName, typeNode);
  555. designerNode.patternCount = 0;
  556. if (!typeNode.designers) typeNode.designers = {};
  557. typeNode.designers[data.designerId] = designerNode;
  558. }
  559. this.updatePatternCount(designerNode);
  560. switch (data.designerType){
  561. case "script":
  562. this.createScriptPatternNode(data, designerNode, regexp, treeNode);
  563. break;
  564. case "form":
  565. case "page":
  566. case "widget":
  567. case "view":
  568. case "statement":
  569. case "process":
  570. this.createFormPatternNode(data, designerNode, regexp, treeNode);
  571. break;
  572. // case "process":
  573. // this.createProcessPatternNode(data, designerNode, regexp, treeNode);
  574. // break;
  575. }
  576. },
  577. // createProcessPatternNode: function(data, node, regexp){
  578. // var text = this.lp.elementPattern.replace("{element}", "&lt;"+data.pattern.type+"&gt;"+data.pattern.name).
  579. // replace("{property}", "{"+data.pattern.key+"}"+data.pattern.propertyName);
  580. // text = "<span style='color: #666666'>"+text+"</span>&nbsp;&nbsp;"
  581. //
  582. // if (data.pattern.line){
  583. // if (data.pattern.evkey){
  584. // text += "<b>["+data.pattern.evkey+"]</b>&nbsp;"+((data.pattern.line) ? data.pattern.line+"&nbsp;&nbsp;" : "" )+this.getPatternValue(data.pattern.value, regexp);
  585. // }else{
  586. // text += ((data.pattern.line) ? data.pattern.line+"&nbsp;&nbsp;" : "" )+this.getPatternValue(data.pattern.value, regexp);
  587. // }
  588. // }else{
  589. // text += this.getPatternValue(data.pattern.value, regexp);
  590. // }
  591. // if (data.pattern.mode){
  592. // text = "<b>["+data.pattern.mode+"]</b>&nbsp;"+text;
  593. // }
  594. //
  595. // patternNode = this.createResultPatternItem(text, "", node, "icon_"+data.pattern.propertyType+".png");
  596. // },
  597. getPatternValueText: function(data, regexp){
  598. var text = "";
  599. if (data.pattern.line){
  600. if (data.pattern.evkey){
  601. text += "<b>["+data.pattern.evkey+"]</b>&nbsp;"+((data.pattern.line) ? data.pattern.line+"&nbsp;&nbsp;" : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern);
  602. }else{
  603. text += ((data.pattern.line) ? data.pattern.line+"&nbsp;&nbsp;" : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern);
  604. }
  605. }else{
  606. text += this.getPatternValue(data.pattern.value, regexp, data.pattern);
  607. }
  608. return text;
  609. },
  610. getFormPatternNodeText: function(data, regexp){
  611. var text = this.lp.elementPattern.replace("{element}", "&lt;"+data.pattern.type+"&gt;"+data.pattern.name).
  612. replace("{property}", "{"+data.pattern.key+"}"+data.pattern.propertyName);
  613. text = "<span style='color: #666666'>"+text+"</span>&nbsp;&nbsp;";
  614. text += this.getPatternValueText(data, regexp);
  615. // if (data.pattern.line){
  616. // if (data.pattern.evkey){
  617. // text += "<b>["+data.pattern.evkey+"]</b>&nbsp;"+((data.pattern.line) ? data.pattern.line+"&nbsp;&nbsp;" : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern);
  618. // }else{
  619. // text += ((data.pattern.line) ? data.pattern.line+"&nbsp;&nbsp;" : "" )+this.getPatternValue(data.pattern.value, regexp, data.pattern);
  620. // }
  621. // }else{
  622. // text += this.getPatternValue(data.pattern.value, regexp, data.pattern);
  623. // }
  624. if (data.pattern.mode){
  625. text = "<b>["+data.pattern.mode+"]</b>&nbsp;"+text;
  626. }
  627. return text;
  628. },
  629. createFormPatternNode: function(data, node, regexp, treeNode){
  630. var text = this.getFormPatternNodeText(data, regexp)
  631. var openScript = function(node){
  632. this.openPatternForm(node);
  633. }.bind(this);
  634. patternNode = this.createResultPatternItem(text, "", node, "icon_"+data.pattern.propertyType+".png", openScript, treeNode);
  635. patternNode.pattern = data;
  636. },
  637. getPatternValue: function(value, regexp, pattern){
  638. regexp.lastIndex = 0;
  639. var valueHtml = "";
  640. var idx = 0;
  641. while ((arr = regexp.exec(value)) !== null) {
  642. if (pattern){
  643. if (!pattern.cols) pattern.cols = [];
  644. pattern.cols.push({"start": arr.index+1, "end": regexp.lastIndex+1});
  645. }
  646. valueHtml += o2.common.encodeHtml(value.substring(idx, arr.index));
  647. valueHtml += "<span style='background-color: #ffef8f'>"+o2.common.encodeHtml(value.substring(arr.index, regexp.lastIndex))+"</span>";
  648. idx = regexp.lastIndex;
  649. }
  650. valueHtml += o2.common.encodeHtml(value.substring(idx, value.length));
  651. return valueHtml;
  652. },
  653. createScriptPatternNode: function(data, node, regexp){
  654. var patternNode;
  655. var text;
  656. var openScript = function(node){
  657. this.openPatternScript(node);
  658. }.bind(this);
  659. if (data.pattern.property=="text"){
  660. text = "<span style='color: #666666'>"+data.pattern.line+"</span>&nbsp;&nbsp;"+this.getPatternValue(data.pattern.value, regexp, data.pattern);
  661. patternNode = this.createResultPatternItem(text, "", node, "icon_script.png", openScript);
  662. }else{
  663. text = this.lp.property+":&nbsp;<b>"+data.pattern.property+"</b> "+this.lp.value+":&nbsp;"+this.getPatternValue(data.pattern.value, regexp);
  664. patternNode = this.createResultPatternItem(text, "", node, "icon_text.png", openScript);
  665. }
  666. patternNode.pattern = data;
  667. },
  668. openPatternForm: function(node){
  669. var pattern = node.pattern;
  670. if (this.editor && this.editor.pattern.designerId === node.pattern.designerId && this.editor.pattern.module === node.pattern.module){
  671. this.resetFormEditor(node.pattern);
  672. }else{
  673. if (this.editor){
  674. if (this.editor.pattern.designerType === "script"){
  675. if (this.scriptDesignerDataObject && this.scriptDesignerDataObject[this.editor.pattern.designerId]){
  676. this.scriptDesignerDataObject[this.editor.pattern.designerId].text = this.editor.getValue();
  677. }
  678. }else{
  679. if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]){
  680. var d = this.designerDataObject[this.editor.pattern.designerId];
  681. switch (this.editor.pattern.pattern.propertyType){
  682. case "duty":
  683. if (this.editor.pattern.pattern.path){
  684. var path = this.editor.pattern.pattern.path;
  685. for (var i=0; i<path.length-1; i++){
  686. if (path[i]==this.editor.pattern.pattern.key){
  687. d[path[i]] = JSON.parse(d[path[i]]);
  688. d = d[path[i]];
  689. }else{
  690. d = d[path[i]];
  691. }
  692. }
  693. d[path[path.length-1]] = this.editor.getValue();
  694. d = this.designerDataObject[this.editor.pattern.designerId];
  695. for (var i=0; i<path.length-1; i++){
  696. if (path[i]==this.editor.pattern.pattern.key){
  697. d[path[i]] = JSON.stringify(d[path[i]]);
  698. break;
  699. }else{
  700. d = d[path[i]];
  701. }
  702. }
  703. }
  704. break;
  705. default:
  706. if (this.editor.getValue){
  707. if (this.editor.pattern.pattern.path){
  708. var path = this.editor.pattern.pattern.path;
  709. for (var i=0; i<path.length-1; i++){
  710. d = d[path[i]];
  711. }
  712. }
  713. if (path[path.length-1]=="styles"){
  714. d["recoveryStyles"] = this.editor.getValue();
  715. }else if (path[path.length-1]=="inputStyles"){
  716. d["recoveryInputStyles"] = this.editor.getValue();
  717. }
  718. d[path[path.length-1]] = this.editor.getValue();
  719. }
  720. }
  721. // if (this.editor.pattern.pattern.path){
  722. // var path = this.editor.pattern.pattern.path;
  723. // for (var i=0; i<path.length-1; i++){
  724. // d = d[path[i]];
  725. // }
  726. // }
  727. // d[path[path.length-1]] = this.editor.getValue();
  728. }
  729. }
  730. this.editor.destroy();
  731. }
  732. this.editor = null;
  733. this.previewInforNode.hide().dispose();
  734. var m;
  735. switch (node.pattern.module){
  736. case "processPlatform":
  737. if (node.pattern.designerType==="form"){
  738. m = o2.Actions.load("x_processplatform_assemble_designer").FormAction.get;
  739. break;
  740. }
  741. if (node.pattern.designerType==="process"){
  742. m = o2.Actions.load("x_processplatform_assemble_designer").ProcessAction.get;
  743. break;
  744. }
  745. break;
  746. case "cms":
  747. m = o2.Actions.load("x_cms_assemble_control").FormAction.get;
  748. //m = o2.Actions.load("x_cms_assemble_control").ScriptAction.get;
  749. break;
  750. case "portal":
  751. if (node.pattern.designerType==="page"){
  752. m = o2.Actions.load("x_portal_assemble_designer").PageAction.get;
  753. break;
  754. }
  755. if (node.pattern.designerType==="widget"){
  756. m = o2.Actions.load("x_portal_assemble_designer").WidgetAction.get;
  757. break;
  758. }
  759. break;
  760. case "query":
  761. if (node.pattern.designerType==="view"){
  762. m = o2.Actions.load("x_query_assemble_designer").ViewAction.get;
  763. break;
  764. }
  765. if (node.pattern.designerType==="statement"){
  766. m = o2.Actions.load("x_query_assemble_designer").StatementAction.get;
  767. break;
  768. }
  769. break;
  770. case "service":
  771. //m = (node.pattern.appId==="invoke") ? o2.Actions.load("x_program_center").InvokeAction.get : o2.Actions.load("x_program_center").AgentAction.get;
  772. break;
  773. }
  774. if (m) this.openPatternFormWithData(m, node);
  775. }
  776. },
  777. resetFormEditor: function(pattern){
  778. switch (pattern.pattern.propertyType){
  779. case "html":
  780. case "script":
  781. case "css":
  782. case "sql":
  783. case "events":
  784. this.reLocationEditor(pattern);
  785. break;
  786. case "duty":
  787. if (pattern.pattern.valueKey=="code") this.reLocationEditor(pattern);
  788. break;
  789. case "map":
  790. this.reLocationMapEditor(pattern);
  791. break;
  792. case "array":
  793. this.reLocationArrayEditor(pattern);
  794. break;
  795. }
  796. },
  797. reLocationArrayEditor: function(pattern){
  798. if (this.editor){
  799. var i = pattern.pattern.line-1;
  800. if (this.editor.items[i]) this.editor.items[i].editValue();
  801. }
  802. },
  803. reLocationMapEditor: function(pattern){
  804. if (this.editor){
  805. var keyv = pattern.pattern.value.split(":");
  806. var key = keyv[0];
  807. for (var i=0; i<this.editor.items.length; i++){
  808. if (this.editor.items[i].key===key){
  809. this.editor.items[i].editValue();
  810. break;
  811. }
  812. }
  813. }
  814. },
  815. openPatternFormWithData: function(m, node){
  816. if (this.designerDataObject && this.designerDataObject[node.pattern.designerId]){
  817. this.openPatternFormEditor(this.designerDataObject[node.pattern.designerId], node);
  818. }else{
  819. if (m) m(node.pattern.designerId).then(function(json){
  820. if (json.data){
  821. var d = json.data;
  822. if (node.pattern.designerType=="form" || node.pattern.designerType=="page" || node.pattern.designerType=="widget"){
  823. var pcData = JSON.decode(MWF.decodeJsonString(json.data.data));
  824. var mobileData = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)) : null;
  825. d = {"data": pcData, "mobileData": mobileData};
  826. }
  827. if (node.pattern.designerType=="view"){
  828. var dataJson = JSON.decode(json.data.data);
  829. d.application = d.query
  830. d.applicationName = d.queryName;
  831. d.data = dataJson;
  832. }
  833. if (node.pattern.designerType=="statement"){
  834. d.application = d.query
  835. d.applicationName = d.queryName;
  836. var viewJson = JSON.decode(d.view);
  837. d.view = viewJson;
  838. }
  839. if (!this.designerDataObject) this.designerDataObject = {};
  840. this.designerDataObject[node.pattern.designerId] = d;
  841. this.openPatternFormEditor(d, node);
  842. }
  843. }.bind(this), function(){});
  844. }
  845. },
  846. openPatternFormEditor: function(data, node){
  847. switch (node.pattern.pattern.propertyType){
  848. case "html":
  849. case "script":
  850. case "css":
  851. case "sql":
  852. case "events":
  853. this.openPatternFormEditor_script(data, node);
  854. break;
  855. case "map":
  856. this.openPatternFormEditor_map(data, node);
  857. break;
  858. case "array":
  859. this.openPatternFormEditor_array(data, node);
  860. break;
  861. case "duty":
  862. this.openPatternFormEditor_duty(data, node);
  863. break;
  864. default:
  865. this.openPatternFormEditor_default(data, node);
  866. }
  867. },
  868. getValueWithPath: function(data, pattern, offset){
  869. var path = pattern.pattern.path;
  870. var d = data;
  871. var i=0;
  872. var oset = (offset) ? offset.toInt() : 0;
  873. while (i<(path.length-oset)){
  874. if (path[i]=="styles"){
  875. d.styles = d.recoveryStyles;
  876. }else if (path[i]=="inputStyles"){
  877. d.inputStyles = d.recoveryInputStyles;
  878. }
  879. d = d[path[i]];
  880. i++;
  881. }
  882. return d;
  883. },
  884. getTitleWithPath: function(data, pattern){
  885. var el = this.lp.elementPattern.replace("{element}", "&lt;"+pattern.pattern.type+"&gt;"+pattern.pattern.name).
  886. replace("{property}", pattern.pattern.propertyName+"{"+pattern.pattern.key+"}");
  887. var title = "<b>"+this.lp[pattern.module]+":&nbsp;<span style='color: #4A90E2'>"+pattern.appName+"</span></b>->"+": "+"<b>["+pattern.pattern.mode+this.lp[pattern.designerType]+"]</b>&nbsp;"+pattern.designerName+"->"+el;
  888. return "<div style='line-height: 30px'>"+title+"</div>"
  889. },
  890. getDefaultEditorContent: function(data, pattern){
  891. var el = this.lp.elementPattern.replace("{element}", "&lt;"+pattern.pattern.type+"&gt;"+pattern.pattern.name).
  892. replace("{property}", pattern.pattern.propertyName+"{"+pattern.pattern.key+"}");
  893. var html = "<div style='padding: 20px;'>" +
  894. "<div style='height: 40px; line-height: 40px; font-size: 18px'>"+this.lp.findInfor+"</div>" +
  895. "<div style='padding-left: 10px; padding: 30px; border: 1px solid #eeeeee; background-color: #f9f9f9; border-radius: 5px; float: left'>" +
  896. "<div style='padding-left: 20px; height: 30px; line-height: 30px'><b>"+this.lp[pattern.module]+":&nbsp;<span style='color: #4A90E2'>"+pattern.appName+"</span></b></div>" +
  897. "<div style='padding-left: 40px; height: 30px; line-height: 30px'><b>["+(pattern.pattern.mode || "")+this.lp[pattern.designerType]+"]</b>&nbsp;"+pattern.designerName+"</div>" +
  898. "<div style='padding-left: 60px; height: 30px; line-height: 30px'><b>"+this.lp.element+":</b>&nbsp;"+"&lt;"+pattern.pattern.type+"&gt;"+pattern.pattern.name+"</div>" +
  899. "<div style='padding-left: 80px; height: 30px; line-height: 30px'><div style='float: left'><b>"+this.lp.property+":</b>&nbsp;"+pattern.pattern.propertyName+"{"+pattern.pattern.key+"}:&nbsp;"+"</div>" +
  900. "<div style='margin-left: 10px; float:left; height: 30px; padding: 0px 10px; line-height: 30px; border-radius: 5px; background-color: #eeeeee;'>"+this.getPatternValueText(pattern, this.getFindRegExp())+"</div></div></div>" +
  901. "<div style='float:left; margin-top:20px; clear:both; height: 40px; line-height: 40px; cursor: pointer; font-size: 18px; color: #0b58a2'>"+this.lp.findInforOpen+"</div>" +
  902. "</div>";
  903. return html;
  904. },
  905. commonEditor: new Class({
  906. Implements: [Events],
  907. initialize: function(node){
  908. this.node = $(node);
  909. this.container = new Element("div", {
  910. "styles": {
  911. "padding": "10px"
  912. }
  913. });
  914. },
  915. load : function(title){
  916. this.container.set("html", title).inject(this.node);
  917. },
  918. destroy: function(){
  919. this.fireEvent("destroy");
  920. this.container.destroy();
  921. o2.release(this);
  922. },
  923. // getValue: function(){
  924. // return this.value;
  925. // },
  926. getContent: function(){
  927. }
  928. }),
  929. openPatternFormEditor_default: function(data, node){
  930. debugger;
  931. // var d = this.getValueWithPath(data, node.pattern);
  932. // if (d){
  933. debugger;
  934. var content = this.getDefaultEditorContent(data, node.pattern);
  935. this.editor = new this.commonEditor(this.previewContentNode);
  936. this.editor.addEvent("destroy", function(){
  937. this.previewToolbar.childrenButton[0].disable();
  938. this.previewToolbar.childrenButton[1].disable();
  939. }.bind(this));
  940. this.editor.pattern = node.pattern;
  941. this.editor.designerNode = node;
  942. this.editor.designerData = data;
  943. this.editor.load(content);
  944. this.editor.container.getFirst().getLast().addEvent("click", function(){
  945. this.openDesinger();
  946. }.bind(this));
  947. this.previewToolbar.childrenButton[0].disable();
  948. this.previewToolbar.childrenButton[1].enable();
  949. // }
  950. },
  951. openPatternFormEditor_duty: function(data, node){
  952. debugger;
  953. if (node.pattern.pattern.valueKey=="name"){
  954. this.openPatternFormEditor_default(data, node)
  955. }else {
  956. var d = this.getValueWithPath(data, node.pattern, 2);
  957. if (d){
  958. var json = JSON.parse(d);
  959. var idx = node.pattern.pattern.idx.toInt();
  960. var code = json[idx].code;
  961. o2.require("o2.widget.JavascriptEditor", function(){
  962. this.editor = new o2.widget.JavascriptEditor(this.previewContentNode, {
  963. "option": {
  964. "value": code,
  965. "mode": "javascript"
  966. }
  967. });
  968. this.editor.pattern = node.pattern;
  969. this.editor.designerNode = node;
  970. this.editor.designerData = data;
  971. this.editor.load(function(){
  972. if (this.previewToolbar){
  973. this.previewToolbar.childrenButton[0].enable();
  974. this.previewToolbar.childrenButton[1].enable();
  975. }
  976. this.editor.addEvent("change", function(){
  977. this.editor.isRefind = true;
  978. }.bind(this));
  979. this.editor.addEvent("blur", function(){
  980. if (this.editor.isRefind) this.reFindInFormDesigner();
  981. }.bind(this));
  982. this.editor.addEvent("destroy", function(){
  983. this.previewToolbar.childrenButton[0].disable();
  984. this.previewToolbar.childrenButton[1].disable();
  985. }.bind(this));
  986. this.editor.addEvent("save", function(){
  987. this.saveDesigner();
  988. }.bind(this));
  989. this.resetFormEditor(node.pattern);
  990. }.bind(this));
  991. }.bind(this));
  992. }
  993. }
  994. //var d = this.getValueWithPath(data, node.pattern);
  995. },
  996. openPatternFormEditor_array: function(data, node){
  997. var d = this.getValueWithPath(data, node.pattern);
  998. if (d){
  999. var title = this.getTitleWithPath(data, node.pattern);
  1000. o2.require("o2.widget.Arraylist", function(){
  1001. this.editor = new o2.widget.Arraylist(this.previewContentNode, {
  1002. "htmlTitle": title,
  1003. "style": "findDesigner",
  1004. "onChange": function(){
  1005. this.reFindInFormDesigner();
  1006. }.bind(this),
  1007. "onPostLoad": function(){
  1008. if (this.previewToolbar){
  1009. this.previewToolbar.childrenButton[0].enable();
  1010. this.previewToolbar.childrenButton[1].enable();
  1011. }
  1012. }.bind(this),
  1013. });
  1014. this.editor.addEvent("destroy", function(){
  1015. this.previewToolbar.childrenButton[0].disable();
  1016. this.previewToolbar.childrenButton[1].disable();
  1017. }.bind(this));
  1018. this.editor.pattern = node.pattern;
  1019. this.editor.designerNode = node;
  1020. this.editor.designerData = data;
  1021. this.editor.load(d);
  1022. this.resetFormEditor(node.pattern);
  1023. }.bind(this))
  1024. }
  1025. },
  1026. openPatternFormEditor_map: function(data, node){
  1027. debugger;
  1028. var d = this.getValueWithPath(data, node.pattern);
  1029. if (d){
  1030. var title = this.getTitleWithPath(data, node.pattern);
  1031. o2.require("o2.widget.Maplist", function(){
  1032. this.editor = new o2.widget.Maplist(this.previewContentNode, {
  1033. "htmlTitle": title,
  1034. "style": "findDesigner",
  1035. "onChange": function(){
  1036. this.reFindInFormDesigner();
  1037. }.bind(this),
  1038. "onPostLoad": function(){
  1039. if (this.previewToolbar){
  1040. this.previewToolbar.childrenButton[0].enable();
  1041. this.previewToolbar.childrenButton[1].enable();
  1042. }
  1043. }.bind(this),
  1044. });
  1045. this.editor.addEvent("destroy", function(){
  1046. this.previewToolbar.childrenButton[0].disable();
  1047. this.previewToolbar.childrenButton[1].disable();
  1048. }.bind(this));
  1049. this.editor.pattern = node.pattern;
  1050. this.editor.designerNode = node;
  1051. this.editor.designerData = data;
  1052. this.editor.load(d);
  1053. this.resetFormEditor(node.pattern);
  1054. }.bind(this))
  1055. }
  1056. },
  1057. openPatternFormEditor_script: function(data, node){
  1058. var path = node.pattern.pattern.path;
  1059. var d = data;
  1060. var i=0;
  1061. while (i<path.length){
  1062. d = d[path[i]];
  1063. i++;
  1064. }
  1065. if (d){
  1066. o2.require("o2.widget.JavascriptEditor", function(){
  1067. this.editor = new o2.widget.JavascriptEditor(this.previewContentNode, {
  1068. "option": {
  1069. "value": d,
  1070. "mode": (!node.pattern.pattern.propertyType || node.pattern.pattern.propertyType==="script" || node.pattern.pattern.propertyType==="events") ? "javascript" : node.pattern.pattern.propertyType
  1071. }
  1072. });
  1073. this.editor.pattern = node.pattern;
  1074. this.editor.designerNode = node;
  1075. this.editor.designerData = data;
  1076. this.editor.load(function(){
  1077. if (this.previewToolbar){
  1078. this.previewToolbar.childrenButton[0].enable();
  1079. this.previewToolbar.childrenButton[1].enable();
  1080. }
  1081. this.editor.addEvent("change", function(){
  1082. this.editor.isRefind = true;
  1083. }.bind(this));
  1084. this.editor.addEvent("blur", function(){
  1085. if (this.editor.isRefind) this.reFindInFormDesigner();
  1086. }.bind(this));
  1087. this.editor.addEvent("destroy", function(){
  1088. this.previewToolbar.childrenButton[0].disable();
  1089. this.previewToolbar.childrenButton[1].disable();
  1090. }.bind(this));
  1091. this.editor.addEvent("save", function(){
  1092. this.saveDesigner();
  1093. }.bind(this));
  1094. this.resetFormEditor(node.pattern);
  1095. }.bind(this));
  1096. }.bind(this));
  1097. }
  1098. },
  1099. openPatternScript: function(node){
  1100. var pattern = node.pattern;
  1101. if (this.editor && this.editor.pattern.designerId === node.pattern.designerId && this.editor.pattern.module === node.pattern.module){
  1102. this.reLocationEditor(node.pattern);
  1103. }else{
  1104. if (this.editor){
  1105. if (this.editor.pattern.designerType === "script"){
  1106. if (this.scriptDesignerDataObject && this.scriptDesignerDataObject[this.editor.pattern.designerId]){
  1107. this.scriptDesignerDataObject[this.editor.pattern.designerId].text = this.editor.getValue();
  1108. }
  1109. }else{
  1110. if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]){
  1111. this.designerDataObject[this.editor.pattern.designerId] = this.editor.designerData;
  1112. }
  1113. }
  1114. this.editor.destroy();
  1115. }
  1116. this.editor = null;
  1117. this.previewInforNode.hide().dispose();
  1118. var m;
  1119. switch (node.pattern.module){
  1120. case "processPlatform":
  1121. m = o2.Actions.load("x_processplatform_assemble_designer").ScriptAction.get;
  1122. break;
  1123. case "cms":
  1124. m = o2.Actions.load("x_cms_assemble_control").ScriptAction.get;
  1125. break;
  1126. case "portal":
  1127. m = o2.Actions.load("x_portal_assemble_designer").ScriptAction.get;
  1128. break;
  1129. case "service":
  1130. switch (node.pattern.appId) {
  1131. case "invoke":
  1132. m = o2.Actions.load("x_program_center").InvokeAction.get;
  1133. break;
  1134. case "script":
  1135. m = o2.Actions.load("x_program_center").ScriptAction.get;
  1136. break;
  1137. default:
  1138. m = o2.Actions.load("x_program_center").AgentAction.get;
  1139. break;
  1140. }
  1141. // m = (node.pattern.appId==="invoke") ? o2.Actions.load("x_program_center").InvokeAction.get : o2.Actions.load("x_program_center").AgentAction.get;
  1142. break;
  1143. }
  1144. this.openPatternScriptWithData(m, node);
  1145. }
  1146. },
  1147. openPatternScriptWithData: function(m, node){
  1148. if (this.scriptDesignerDataObject && this.scriptDesignerDataObject[node.pattern.designerId]){
  1149. this.openPatternScriptEditor(this.scriptDesignerDataObject[node.pattern.designerId], node);
  1150. }else{
  1151. if (m) m(node.pattern.designerId).then(function(json){
  1152. if (!this.scriptDesignerDataObject) this.scriptDesignerDataObject = {};
  1153. this.scriptDesignerDataObject[node.pattern.designerId] = json.data;
  1154. if (json.data) this.openPatternScriptEditor(json.data, node);
  1155. }.bind(this), function(){});
  1156. }
  1157. },
  1158. openPatternScriptEditor: function(data, node){
  1159. o2.require("o2.widget.JavascriptEditor", function(){
  1160. this.editor = new o2.widget.JavascriptEditor(this.previewContentNode, {
  1161. "option": {"value": data.text}
  1162. });
  1163. this.editor.pattern = node.pattern;
  1164. this.editor.designerNode = node.parentNode;
  1165. this.editor.designerData = data;
  1166. this.editor.load(function(){
  1167. if (this.previewToolbar){
  1168. this.previewToolbar.childrenButton[0].enable();
  1169. this.previewToolbar.childrenButton[1].enable();
  1170. }
  1171. this.editor.addEvent("change", function(){
  1172. this.editor.isRefind = true;
  1173. }.bind(this));
  1174. this.editor.addEvent("blur", function(){
  1175. if (this.editor.isRefind) this.reFindInDesigner();
  1176. }.bind(this));
  1177. this.editor.addEvent("destroy", function(){
  1178. this.previewToolbar.childrenButton[0].disable();
  1179. this.previewToolbar.childrenButton[1].disable();
  1180. }.bind(this));
  1181. this.editor.addEvent("save", function(){
  1182. this.saveDesigner();
  1183. }.bind(this));
  1184. //var idx = node.parentNode.children.indexOf(node);
  1185. //this.reFindInDesigner();
  1186. this.reLocationEditor(node.pattern);
  1187. //if (node.parentNode.children[idx]) node.parentNode.children[idx].clickNode();
  1188. }.bind(this));
  1189. }.bind(this));
  1190. },
  1191. findScriptLineValue: function(result, code, preLine, preIndex, len, regex){
  1192. var lineRegexp = /\r\n|\n|\r/g;
  1193. var preText = code.substring(preIndex, result.index);
  1194. var m = preText.match(lineRegexp);
  1195. preLine += (m) ? m.length : 0;
  1196. var value = result[0];
  1197. var n = result.index-1;
  1198. var char = code.charAt(n);
  1199. while (!lineRegexp.test(char) && n>=0){
  1200. value = char+value;
  1201. n--;
  1202. char = code.charAt(n);
  1203. }
  1204. n = regex.lastIndex;
  1205. char = code.charAt(n);
  1206. while (!lineRegexp.test(char) && n<len){
  1207. value = value+char;
  1208. n++;
  1209. char = code.charAt(n);
  1210. }
  1211. preIndex = regex.lastIndex = n;
  1212. return {"value": value, "preLine": preLine, "preIndex": preIndex};
  1213. },
  1214. subResultCount: function(pattern){
  1215. this.subResultTitle();
  1216. var moduleNode = (this.tree.modules) ? this.tree.modules[pattern.module] : null;
  1217. if (moduleNode) this.subPatternCount(moduleNode);
  1218. var appNode = (moduleNode.apps) ? moduleNode.apps[pattern.appId] : null;
  1219. if (appNode) this.subPatternCount(appNode);
  1220. var typeNode = (appNode.types) ? appNode.types[pattern.designerType] : null;
  1221. if (typeNode) this.subPatternCount(typeNode);
  1222. var designerNode = (typeNode.designers) ? typeNode.designers[pattern.designerId] : null;
  1223. if (designerNode) this.subPatternCount(designerNode);
  1224. },
  1225. reFindInFormDesigner: function(){
  1226. debugger;
  1227. if (this.editor && this.editor.designerNode){
  1228. var pathStr = this.editor.pattern.pattern.path.join(".");
  1229. var pNode = this.editor.designerNode.parentNode;
  1230. var removeNodes = [];
  1231. pNode.children.forEach(function(n){
  1232. if (n.pattern.pattern.path && n.pattern.pattern.path.join(".")===pathStr) removeNodes.push(n);
  1233. }.bind(this));
  1234. var pattern = this.editor.pattern;
  1235. debugger;
  1236. switch (pattern.pattern.propertyType){
  1237. case "html":
  1238. case "script":
  1239. case "css":
  1240. case "sql":
  1241. case "events":
  1242. if (removeNodes.length>1){
  1243. for (var i=1; i<removeNodes.length; i++){
  1244. removeNodes[i].destroy();
  1245. this.subResultCount(this.editor.pattern);
  1246. }
  1247. }
  1248. flagNode = removeNodes[0];
  1249. this.reFindInFormDesigner_script(flagNode, pattern);
  1250. break;
  1251. case "duty":
  1252. if (removeNodes.length>1){
  1253. for (var i=1; i<removeNodes.length; i++){
  1254. removeNodes[i].destroy();
  1255. this.subResultCount(this.editor.pattern);
  1256. }
  1257. }
  1258. flagNode = removeNodes[0];
  1259. this.reFindInFormDesigner_duty(flagNode, pattern);
  1260. break;
  1261. case "map":
  1262. this.reFindInFormDesigner_map(removeNodes, pattern);
  1263. break;
  1264. case "array":
  1265. this.reFindInFormDesigner_array(removeNodes, pattern);
  1266. break;
  1267. }
  1268. this.subResultCount(this.editor.pattern);
  1269. }
  1270. this.editor.isRefind = false;
  1271. },
  1272. reFindInFormDesigner_duty: function(removeNodes, pattern){
  1273. var code = this.editor.getValue();
  1274. if (code){
  1275. var regex = this.getFilterOptionRegex(this.filterOption)
  1276. regex.lastIndex = 0;
  1277. var len = code.length;
  1278. var preLine = 0;
  1279. var preIndex = 0;
  1280. var result;
  1281. while ((result = regex.exec(code)) !== null){
  1282. var obj = this.findScriptLineValue(result, code, preLine, preIndex, len, regex);
  1283. preLine = obj.preLine;
  1284. preIndex = obj.preIndex;
  1285. this.showFindResult(this._createFindMessageReplyData( this.editor.pattern.module, this.editor.pattern, "", {
  1286. "type": pattern.pattern.type,
  1287. "propertyType": pattern.pattern.propertyType,
  1288. "propertyName": pattern.pattern.propertyName,
  1289. "name": pattern.pattern.name,
  1290. "id": pattern.pattern.id,
  1291. "key": pattern.pattern.key,
  1292. "evkey": pattern.pattern.evkey,
  1293. "idx": pattern.pattern.idx,
  1294. "valueKey": pattern.pattern.valueKey,
  1295. "value": obj.value,
  1296. "line": preLine+1,
  1297. "mode": pattern.pattern.mode,
  1298. "path": pattern.pattern.path
  1299. }), this.filterOption, flagNode);
  1300. }
  1301. }
  1302. if (flagNode) flagNode.destroy();
  1303. },
  1304. reFindInFormDesigner_array: function(removeNodes, pattern){
  1305. var arr = this.editor.getValue();
  1306. if (arr){
  1307. var regex = this.getFilterOptionRegex(this.filterOption)
  1308. removeNodes.forEach(function(i){
  1309. var idx = i.pattern.pattern.line.toInt()-1;
  1310. var value = arr[idx] || "";
  1311. if (i.pattern.pattern.value!=value){
  1312. i.pattern.pattern.value = value;
  1313. var text = this.getFormPatternNodeText(i.pattern, regex)
  1314. var textDivNode = i.textNode.getElement("div");
  1315. if (textDivNode){
  1316. textDivNode.set("html", "<span style='color: #000000'>"+text+"</span>");
  1317. }
  1318. }
  1319. }.bind(this));
  1320. arr.forEach(function(v, i) {
  1321. regex.lastIndex = 0;
  1322. var text = v.toString();
  1323. if (regex.test(text)){
  1324. var n = removeNodes.filter(function(n){
  1325. var idx = n.pattern.pattern.line.toInt()-1;
  1326. return (idx==i);
  1327. });
  1328. if (!n.length){
  1329. this.showFindResult(this._createFindMessageReplyData(this.editor.pattern.module, this.editor.pattern, "", {
  1330. "type": pattern.pattern.type,
  1331. "propertyType": pattern.pattern.propertyType,
  1332. "propertyName": pattern.pattern.propertyName,
  1333. "name": pattern.pattern.name,
  1334. "id": pattern.pattern.id,
  1335. "line": i+1,
  1336. "key": pattern.pattern.key,
  1337. "value": text,
  1338. "mode": pattern.pattern.mode,
  1339. "path": pattern.pattern.path
  1340. }), this.filterOption, removeNodes[removeNodes.length-1].nextSibling);
  1341. }
  1342. }
  1343. }.bind(this));
  1344. }
  1345. },
  1346. reFindInFormDesigner_map: function(removeNodes, pattern){
  1347. var map = this.editor.getValue();
  1348. if (map){
  1349. var regex = this.getFilterOptionRegex(this.filterOption)
  1350. removeNodes.forEach(function(i){
  1351. var k = i.pattern.pattern.value.split(":")[0];
  1352. if (i.pattern.pattern.value!=(k+": "+map[k])){
  1353. i.pattern.pattern.value = k+": "+(map[k] || "");
  1354. var text = this.getFormPatternNodeText(i.pattern, regex)
  1355. var textDivNode = i.textNode.getElement("div");
  1356. if (textDivNode){
  1357. textDivNode.set("html", "<span style='color: #000000'>"+text+"</span>");
  1358. }
  1359. }
  1360. }.bind(this));
  1361. Object.keys(map).forEach(function(evkey) {
  1362. regex.lastIndex = 0;
  1363. var text = map[evkey];
  1364. if (text){
  1365. if ((typeof text)=="string") {
  1366. if (regex.test(text)) {
  1367. var n = removeNodes.filter(function(i){
  1368. var k = i.pattern.pattern.value.split(":")[0];
  1369. return (k==evkey)
  1370. });
  1371. if (!n.length){
  1372. this.showFindResult(this._createFindMessageReplyData(this.editor.pattern.module, this.editor.pattern, "", {
  1373. "type": pattern.pattern.type,
  1374. "propertyType": pattern.pattern.propertyType,
  1375. "propertyName": pattern.pattern.propertyName,
  1376. "name": pattern.pattern.name,
  1377. "id": pattern.pattern.id,
  1378. "key": pattern.pattern.key,
  1379. "value": evkey + ": " + text,
  1380. "mode": pattern.pattern.mode,
  1381. "path": pattern.pattern.path
  1382. }), this.filterOption, removeNodes[removeNodes.length-1].nextSibling);
  1383. }
  1384. }
  1385. }
  1386. }
  1387. }.bind(this));
  1388. }
  1389. },
  1390. reFindInFormDesigner_script: function(flagNode){
  1391. var code = this.editor.getValue();
  1392. if (code){
  1393. var regex = this.getFilterOptionRegex(this.filterOption)
  1394. regex.lastIndex = 0;
  1395. var len = code.length;
  1396. var preLine = 0;
  1397. var preIndex = 0;
  1398. var result;
  1399. while ((result = regex.exec(code)) !== null){
  1400. var obj = this.findScriptLineValue(result, code, preLine, preIndex, len, regex);
  1401. preLine = obj.preLine;
  1402. preIndex = obj.preIndex;
  1403. var pattern = this.editor.pattern;
  1404. this.showFindResult(this._createFindMessageReplyData( this.editor.pattern.module, this.editor.pattern, "", {
  1405. "type": pattern.pattern.type,
  1406. "propertyType": pattern.pattern.propertyType,
  1407. "propertyName": pattern.pattern.propertyName,
  1408. "name": pattern.pattern.name,
  1409. "id": pattern.pattern.id,
  1410. "key": pattern.pattern.key,
  1411. "evkey": pattern.pattern.evkey,
  1412. "value": obj.value,
  1413. "line": preLine+1,
  1414. "mode": pattern.pattern.mode,
  1415. "path": pattern.pattern.path
  1416. }), this.filterOption, flagNode);
  1417. }
  1418. }
  1419. if (flagNode) flagNode.destroy();
  1420. },
  1421. reFindInDesigner: function(){
  1422. if (this.editor && this.editor.designerNode){
  1423. while (this.editor.designerNode.firstChild){
  1424. this.editor.designerNode.firstChild.destroy();
  1425. this.subResultCount(this.editor.pattern);
  1426. }
  1427. var code = this.editor.getValue();
  1428. if (code){
  1429. var regex = this.getFilterOptionRegex(this.filterOption)
  1430. regex.lastIndex = 0;
  1431. var len = code.length;
  1432. var preLine = 0;
  1433. var preIndex = 0;
  1434. var result;
  1435. while ((result = regex.exec(code)) !== null){
  1436. var obj = this.findScriptLineValue(result, code, preLine, preIndex, len, regex);
  1437. preLine = obj.preLine;
  1438. preIndex = obj.preIndex;
  1439. this.showFindResult(this._createFindMessageReplyData( this.editor.pattern.module, this.editor.pattern, "", {
  1440. "property": "text",
  1441. "value": obj.value,
  1442. "line": preLine+1
  1443. }), this.filterOption);
  1444. }
  1445. }
  1446. }
  1447. this.editor.isRefind = false;
  1448. },
  1449. saveDesigner: function(){
  1450. debugger;
  1451. if (this.editor && this.editor.pattern){
  1452. var pattern = this.editor.pattern;
  1453. var data = this.editor.designerData;
  1454. switch (pattern.designerType){
  1455. case "script":
  1456. var m;
  1457. switch (pattern.module){
  1458. case "processPlatform":
  1459. m = o2.Actions.load("x_processplatform_assemble_designer").ScriptAction.put;
  1460. break;
  1461. case "cms":
  1462. m = o2.Actions.load("x_cms_assemble_control").ScriptAction.put;
  1463. break;
  1464. case "portal":
  1465. m = o2.Actions.load("x_portal_assemble_designer").ScriptAction.edit;
  1466. break;
  1467. case "service":
  1468. switch (pattern.appId) {
  1469. case "invoke":
  1470. m = o2.Actions.load("x_program_center").InvokeAction.edit;
  1471. break;
  1472. case "script":
  1473. m = o2.Actions.load("x_program_center").ScriptAction.edit;
  1474. break;
  1475. default:
  1476. m = o2.Actions.load("x_program_center").AgentAction.edit;
  1477. break;
  1478. }
  1479. //m = (pattern.appId==="invoke") ? o2.Actions.load("x_program_center").InvokeAction.edit : o2.Actions.load("x_program_center").AgentAction.edit;
  1480. break;
  1481. }
  1482. data.text = this.editor.getValue();
  1483. if (m) m(data.id, data).then(function(){
  1484. this.notice(this.lp.notice.save_success, "success", this.previewContentNode, {"x": "left", "y": "bottom"});
  1485. }.bind(this), function(){});
  1486. break;
  1487. case "form":
  1488. case "page":
  1489. case "widget":
  1490. switch (pattern.module){
  1491. case "processPlatform":
  1492. var action = MWF.Actions.get("x_processplatform_assemble_designer");
  1493. m = action.saveForm.bind(action);
  1494. if(data.data)data.data.isNewForm = false;
  1495. break;
  1496. case "cms":
  1497. var action = MWF.Actions.get("x_cms_assemble_control");
  1498. m = action.saveForm.bind(action);
  1499. if(data.data)data.data.isNewForm = false;
  1500. break;
  1501. case "portal":
  1502. var action = MWF.Actions.get("x_portal_assemble_designer");
  1503. m = (pattern.designerType=="page") ? action.savePage.bind(action) : action.saveWidget.bind(action);
  1504. if(data.data)data.data.isNewPage = false;
  1505. break;
  1506. }
  1507. if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]){
  1508. var d = this.designerDataObject[this.editor.pattern.designerId];
  1509. switch (this.editor.pattern.pattern.propertyType){
  1510. case "duty":
  1511. if (this.editor.pattern.pattern.path){
  1512. var path = this.editor.pattern.pattern.path;
  1513. for (var i=0; i<path.length-1; i++){
  1514. if (path[i]==this.editor.pattern.pattern.key){
  1515. d[path[i]] = JSON.parse(d[path[i]]);
  1516. d = d[path[i]];
  1517. }else{
  1518. d = d[path[i]];
  1519. }
  1520. }
  1521. d[path[path.length-1]] = this.editor.getValue();
  1522. d = this.designerDataObject[this.editor.pattern.designerId];
  1523. for (var i=0; i<path.length-1; i++){
  1524. if (path[i]==this.editor.pattern.pattern.key){
  1525. d[path[i]] = JSON.stringify(d[path[i]]);
  1526. break;
  1527. }else{
  1528. d = d[path[i]];
  1529. }
  1530. }
  1531. }
  1532. break;
  1533. default:
  1534. if (this.editor.getValue){
  1535. if (this.editor.pattern.pattern.path){
  1536. var path = this.editor.pattern.pattern.path;
  1537. for (var i=0; i<path.length-1; i++){
  1538. d = d[path[i]];
  1539. }
  1540. }
  1541. if (path[path.length-1]=="styles"){
  1542. d["recoveryStyles"] = this.editor.getValue();
  1543. }else if (path[path.length-1]=="inputStyles"){
  1544. d["recoveryInputStyles"] = this.editor.getValue();
  1545. }
  1546. d[path[path.length-1]] = this.editor.getValue();
  1547. }
  1548. }
  1549. }
  1550. if (m) m(data.data, data.mobileData, null, function(){
  1551. this.notice(this.lp.notice.save_success, "success", this.previewContentNode, {"x": "left", "y": "bottom"});
  1552. }.bind(this), function(){});
  1553. break;
  1554. case "process":
  1555. var action = MWF.Actions.get("x_processplatform_assemble_designer");
  1556. m = action.saveProcess.bind(action);
  1557. if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]) {
  1558. var d = this.designerDataObject[this.editor.pattern.designerId];
  1559. if (this.editor.getValue){
  1560. if (this.editor.pattern.pattern.path){
  1561. var path = this.editor.pattern.pattern.path;
  1562. for (var i=0; i<path.length-1; i++){
  1563. d = d[path[i]];
  1564. }
  1565. }
  1566. d[path[path.length-1]] = this.editor.getValue();
  1567. }
  1568. }
  1569. if (m) m(data, function(){
  1570. this.notice(this.lp.notice.save_success, "success", this.previewContentNode, {"x": "left", "y": "bottom"});
  1571. }.bind(this), function(){});
  1572. break;
  1573. case "view":
  1574. var action = MWF.Actions.get("x_query_assemble_designer");
  1575. m = action.saveView.bind(action);
  1576. if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]) {
  1577. var d = this.designerDataObject[this.editor.pattern.designerId];
  1578. if (this.editor.getValue){
  1579. if (this.editor.pattern.pattern.path){
  1580. var path = this.editor.pattern.pattern.path;
  1581. for (var i=0; i<path.length-1; i++){
  1582. d = d[path[i]];
  1583. }
  1584. }
  1585. d[path[path.length-1]] = this.editor.getValue();
  1586. }
  1587. }
  1588. if (m) m(data, function(){
  1589. this.notice(this.lp.notice.save_success, "success", this.previewContentNode, {"x": "left", "y": "bottom"});
  1590. }.bind(this), function(){});
  1591. break;
  1592. case "statement":
  1593. var action = MWF.Actions.get("x_query_assemble_designer");
  1594. m = action.saveStatement.bind(action);
  1595. if (this.designerDataObject && this.designerDataObject[this.editor.pattern.designerId]) {
  1596. var d = this.designerDataObject[this.editor.pattern.designerId];
  1597. if (this.editor.getValue){
  1598. if (this.editor.pattern.pattern.path){
  1599. var path = this.editor.pattern.pattern.path;
  1600. for (var i=0; i<path.length-1; i++){
  1601. d = d[path[i]];
  1602. }
  1603. }
  1604. d[path[path.length-1]] = this.editor.getValue();
  1605. }
  1606. }
  1607. var viewText = JSON.stringify(data.view);
  1608. data.view = viewText;
  1609. if (m) m(data, function(){
  1610. this.notice(this.lp.notice.save_success, "success", this.previewContentNode, {"x": "left", "y": "bottom"});
  1611. }.bind(this), function(){});
  1612. break;
  1613. }
  1614. }
  1615. },
  1616. openDesinger: function(){
  1617. if (this.editor && this.editor.pattern){
  1618. var pattern = this.editor.pattern;
  1619. switch (pattern.designerType){
  1620. case "script":
  1621. var m;
  1622. switch (pattern.module){
  1623. case "processPlatform":
  1624. var options = {
  1625. "appId": "process.ScriptDesigner"+pattern.designerId,
  1626. "id": pattern.designerId,
  1627. "application": {"id": pattern.appId},
  1628. };
  1629. layout.openApplication(null, "process.ScriptDesigner", options);
  1630. break;
  1631. case "cms":
  1632. var options = {
  1633. "appId": "cms.ScriptDesigner"+pattern.designerId,
  1634. "id": pattern.designerId,
  1635. "application": {"id": pattern.appId},
  1636. };
  1637. layout.openApplication(null, "cms.ScriptDesigner", options);
  1638. break;
  1639. case "portal":
  1640. var options = {
  1641. "appId": "portal.ScriptDesigner"+pattern.designerId,
  1642. "id": pattern.designerId,
  1643. "application": {"id": pattern.appId},
  1644. };
  1645. layout.openApplication(null, "portal.ScriptDesigner", options);
  1646. break;
  1647. case "service":
  1648. if (pattern.appId==="invoke") {
  1649. var options = {
  1650. "appId": "service.InvokeDesigner" + pattern.designerId,
  1651. "id": pattern.designerId,
  1652. };
  1653. layout.openApplication(null, "service.InvokeDesigner", options);
  1654. }else if(pattern.appId==="script"){
  1655. var options = {
  1656. "appId": "service.ScriptDesigner" + pattern.designerId,
  1657. "id": pattern.designerId,
  1658. };
  1659. layout.openApplication(null, "service.ScriptDesigner", options);
  1660. }else{
  1661. var options = {
  1662. "appId": "service.AgentDesigner"+pattern.designerId,
  1663. "id": pattern.designerId,
  1664. };
  1665. layout.openApplication(null, "service.AgentDesigner", options);
  1666. }
  1667. break;
  1668. }
  1669. break;
  1670. case "form":
  1671. switch (pattern.module) {
  1672. case "processPlatform":
  1673. var _self = this;
  1674. var options = {
  1675. "style": layout.desktop.formDesignerStyle || "default",
  1676. "appId": "process.FormDesigner"+pattern.designerId,
  1677. "id": pattern.designerId,
  1678. "onPostFormLoad": function(){
  1679. _self.checkSelectDesignerElement_form(this, pattern, 0);
  1680. }
  1681. };
  1682. layout.openApplication(null, "process.FormDesigner", options);
  1683. break;
  1684. case "cms":
  1685. var _self = this;
  1686. var options = {
  1687. "style": layout.desktop.formDesignerStyle || "default",
  1688. "appId": "cms.FormDesigner"+pattern.designerId,
  1689. "id": pattern.designerId,
  1690. "onPostFormLoad": function(){
  1691. _self.checkSelectDesignerElement_form(this, pattern, 0);
  1692. }
  1693. };
  1694. layout.openApplication(null, "cms.FormDesigner", options);
  1695. break;
  1696. }
  1697. //this.createFormPatternNode(data, designerNode, regexp);
  1698. break;
  1699. case "process":
  1700. var _self = this;
  1701. var options = {
  1702. "appId": "process.ProcessDesigner"+pattern.designerId,
  1703. "id": pattern.designerId,
  1704. "onPostProcessLoad": function(){
  1705. _self.checkSelectDesignerElement_process(this, pattern, 0);
  1706. }
  1707. };
  1708. layout.openApplication(null, "process.ProcessDesigner", options);
  1709. break;
  1710. case "page":
  1711. var _self = this;
  1712. var options = {
  1713. "appId": "portal.PageDesigner"+pattern.designerId,
  1714. "id": pattern.designerId,
  1715. "onPostPageLoad": function(){
  1716. _self.checkSelectDesignerElement_form(this, pattern, 0);
  1717. }
  1718. };
  1719. layout.openApplication(null, "portal.PageDesigner", options);
  1720. break;
  1721. case "widget":
  1722. var _self = this;
  1723. var options = {
  1724. "appId": "portal.WidgetDesigner"+pattern.designerId,
  1725. "id": pattern.designerId,
  1726. "onPostWidgetLoad": function(){
  1727. _self.checkSelectDesignerElement_form(this, pattern, 0);
  1728. }
  1729. };
  1730. layout.openApplication(null, "portal.WidgetDesigner", options);
  1731. break;
  1732. case "view":
  1733. var _self = this;
  1734. var options = {
  1735. "appId": "query.ViewDesigner"+pattern.designerId,
  1736. "id": pattern.designerId,
  1737. "application": {"id": pattern.appId },
  1738. "onPostViewLoad": function(){
  1739. _self.checkSelectDesignerElement_view(this, pattern, 0);
  1740. }
  1741. };
  1742. layout.openApplication(null, "query.ViewDesigner", options);
  1743. break;
  1744. case "statement":
  1745. var _self = this;
  1746. var options = {
  1747. "appId": "query.StatementDesigner"+pattern.designerId,
  1748. "id": pattern.designerId,
  1749. "application": { "id": pattern.appId }
  1750. };
  1751. layout.openApplication(null, "query.StatementDesigner", options);
  1752. break;
  1753. }
  1754. if (this.editor.getValue) window.setTimeout(function(){
  1755. if (this.scriptDesignerDataObject && this.scriptDesignerDataObject[this.editor.pattern.designerId]){
  1756. this.scriptDesignerDataObject[this.editor.pattern.designerId] = null;
  1757. delete this.scriptDesignerDataObject[this.editor.pattern.designerId];
  1758. }
  1759. if (this.editor) this.editor.destroy();
  1760. this.editor = null;
  1761. this.previewInforNode.show().inject(this.previewContentNode);
  1762. }.bind(this), 100);
  1763. }
  1764. },
  1765. checkSelectDesignerElement_view: function(app, pattern, idx){
  1766. var flag = false;
  1767. var view = app.view;
  1768. if (view){
  1769. var type = pattern.pattern.type.toLowerCase();
  1770. switch (type){
  1771. case "view":
  1772. flag = true;
  1773. break;
  1774. case "column":
  1775. for (var i=0; i<view.items.length; i++){
  1776. var m = view.items[i];
  1777. if (m.json.id==pattern.pattern.id || m.json.name==pattern.pattern.id){
  1778. window.setTimeout(function(){
  1779. if (m.view) m.view.unSelected();
  1780. m.selected();
  1781. }, 500);
  1782. flag = true;
  1783. break;
  1784. }
  1785. }
  1786. break;
  1787. case "actionbar":
  1788. for (var i=0; i<view.actionbarList.length; i++){
  1789. var m = view.actionbarList[i];
  1790. if (m.json.id==pattern.pattern.id || m.json.name==pattern.pattern.id){
  1791. window.setTimeout(function(){
  1792. if (m.view) m.view.unSelected();
  1793. m.selected();
  1794. }, 500);
  1795. flag = true;
  1796. break;
  1797. }
  1798. }
  1799. break;
  1800. case "paging":
  1801. for (var i=0; i<view.pagingList.length; i++){
  1802. var m = view.pagingList[i];
  1803. if (m.json.id==pattern.pattern.id || m.json.name==pattern.pattern.id){
  1804. window.setTimeout(function(){
  1805. if (m.view) m.view.unSelected();
  1806. m.selected();
  1807. }, 500);
  1808. flag = true;
  1809. break;
  1810. }
  1811. }
  1812. break;
  1813. }
  1814. }
  1815. if (!flag){
  1816. idx++;
  1817. if (idx<10) window.setTimeout(function(){
  1818. this.checkSelectDesignerElement_view(app, pattern, idx);
  1819. }.bind(this), 300);
  1820. }
  1821. },
  1822. checkSelectDesignerElement_process: function(app, pattern, idx){
  1823. var flag = false;
  1824. var process = app.process;
  1825. if (process){
  1826. var type = pattern.pattern.type.toLowerCase();
  1827. switch (type){
  1828. case "process":
  1829. flag = true;
  1830. break;
  1831. case "route":
  1832. if (process.routes && process.routes[pattern.pattern.id]){
  1833. process.routes[pattern.pattern.id].selected();
  1834. flag = true;
  1835. }
  1836. break;
  1837. case "begin":
  1838. if (process.begin){
  1839. process.begin.selected();
  1840. flag = true;
  1841. }
  1842. break;
  1843. default:
  1844. if (process[type+"s"] && process[type+"s"][pattern.pattern.id]){
  1845. process[type+"s"][pattern.pattern.id].selected();
  1846. flag = true;
  1847. }
  1848. }
  1849. }
  1850. if (!flag){
  1851. idx++;
  1852. if (idx<10) window.setTimeout(function(){
  1853. this.checkSelectDesignerElement_process(app, pattern, idx);
  1854. }.bind(this), 300);
  1855. }
  1856. },
  1857. checkSelectDesignerElement_form: function(app, pattern, idx){
  1858. var flag = false;
  1859. var form;
  1860. debugger;
  1861. try{
  1862. if (pattern.pattern.mode=="PC"){
  1863. app.changeDesignerModeToPC();
  1864. form = app.pcForm || app.pcPage;
  1865. }else{
  1866. app.changeDesignerModeToMobile();
  1867. form = app.mobileForm || app.mobilePage;
  1868. }
  1869. }catch(e){}
  1870. if (form && pattern.pattern.mode=="PC"){
  1871. if (pattern.pattern.type.toLowerCase()!="form"){
  1872. for (var i=0; i<form.moduleList.length; i++){
  1873. var m = form.moduleList[i];
  1874. if (m.json.id==pattern.pattern.name || m.json.name==pattern.pattern.name){
  1875. window.setTimeout(function(){
  1876. if (m.form) m.form.unSelected();
  1877. m.selected()
  1878. }, 500);
  1879. flag = true;
  1880. break;
  1881. }
  1882. }
  1883. }else{
  1884. flag = true;
  1885. }
  1886. }
  1887. if (!flag){
  1888. idx++;
  1889. if (idx<10) window.setTimeout(function(){
  1890. this.checkSelectDesignerElement_form(app, pattern, idx);
  1891. }.bind(this), 300);
  1892. }
  1893. },
  1894. _createFindMessageReplyData: function(module, designer, aliase, pattern){
  1895. return {
  1896. "module": module,
  1897. "appId": designer.appId,
  1898. "appName": designer.appName,
  1899. "designerId": designer.designerId,
  1900. "designerName": designer.designerName,
  1901. "designerType": designer.designerType,
  1902. "designerAliase": aliase,
  1903. "pattern": pattern
  1904. };
  1905. },
  1906. reLocationEditor: function(pattern){
  1907. this.editor.pattern = pattern;
  1908. this.editor.gotoLine(pattern.pattern.line, 1);
  1909. if (pattern.pattern.cols && pattern.pattern.cols.length){
  1910. var rs = [];
  1911. pattern.pattern.cols.forEach(function(col){
  1912. rs.push(this.editor.getRange(pattern.pattern.line,col.start, pattern.pattern.line, col.end));
  1913. }.bind(this));
  1914. this.editor.selectRange(rs);
  1915. }else{
  1916. this.editor.selectRange(this.editor.getRange(pattern.pattern.line,0));
  1917. }
  1918. },
  1919. getFilterOptionRegex: function(option){
  1920. var keyword = option.keyword;
  1921. if (option.matchRegExp){
  1922. var flag = (option.caseSensitive) ? "gm" : "gmi";
  1923. return new RegExp(keyword, flag);
  1924. }else{
  1925. keyword = keyword.replace("[", "\\[").replace("]", "\\]").replace("(", "\\(").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}")
  1926. .replace("^", "\\^").replace("$", "\\$").replace(".", "\\.").replace("?", "\\?").replace("+", "\\+").replace("*", "\\*").replace("|", "\\|");
  1927. var flag = (option.caseSensitive) ? "gm" : "gmi";
  1928. keyword = (option.matchWholeWord) ? "\\b"+keyword+"\\b" : keyword;
  1929. return new RegExp(keyword, flag);
  1930. }
  1931. },
  1932. setReceiveMessage: function(){
  1933. this.listTitleInfoNode.set("text", this.lp.receiveToFind);
  1934. },
  1935. setReadyMessage: function(data){
  1936. this.findOptionModuleCount = data.count;
  1937. this.findOptionModuleProcessed = 0;
  1938. this.updateFindProgress();
  1939. this.listTitleInfoNode.set("text", this.lp.readyToFind.replace("{n}", data.count));
  1940. },
  1941. updateFindProgress: function(){
  1942. var percent = (this.findOptionModuleProcessed/this.findOptionModuleCount)*100;
  1943. this.listTitleProgressNode.setStyle("width", ""+percent+"%");
  1944. },
  1945. getActionsUrl:function(){
  1946. var processHost = o2.Actions.getHost("x_processplatform_assemble_designer");
  1947. var cmsHost = o2.Actions.getHost("x_cms_assemble_control");
  1948. var portalHost = o2.Actions.getHost("x_portal_assemble_designer");
  1949. var queryHost = o2.Actions.getHost("x_query_assemble_designer");
  1950. var serviceHost = o2.Actions.getHost("x_program_center");
  1951. var findHost = o2.Actions.getHost("x_query_service_processing");
  1952. var actions = {
  1953. "listProcess": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/application/list"),
  1954. "listProcessProcess": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/process/application/{applicationId}"),
  1955. "listProcessForm": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/form/list/application/{applicationId}"),
  1956. "listProcessScript": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/script/application/{applicationId}"),
  1957. "getProcessProcess": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/process/{id}"),
  1958. "getProcessForm": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/form/{id}"),
  1959. "getProcessScript": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/script/{id}"),
  1960. "listCms": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/appinfo/list/manage"),
  1961. "listCmsForm": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/form/list/app/{appId}"),
  1962. "listCmsScript": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/script/list/app/{flag}"),
  1963. "getCmsForm": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/form/{id}"),
  1964. "getCmsScript": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/script/{id}"),
  1965. "listPortal": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/portal/list"),
  1966. "listPortalPage": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/page/list/portal/{portalId}"),
  1967. "listPortalScript": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/script/list/portal/{portalId}"),
  1968. "listPortalWidget": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/widget/list/portal/{portalId}"),
  1969. "getPortalPage": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/page/{id}"),
  1970. "getPortalScript": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/script/{id}"),
  1971. "getPortalWidget": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/widget/{id}"),
  1972. "listQuery": o2.filterUrl(queryHost+"/x_query_assemble_designer/jaxrs/query/list/summary"),
  1973. "listQueryView": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/view/list/query/{flag}"),
  1974. "listQueryStat": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/stat/list/query/{flag}"),
  1975. "listQueryStatement": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/statement/list/query/{flag}"),
  1976. "getQueryView": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/view/{id}"),
  1977. "getQueryStat": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/stat/{id}"),
  1978. "getQueryStatement": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/statement/{id}"),
  1979. "listInvoke": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/invoke"),
  1980. "listAgent": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/agent"),
  1981. "listScript": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/script/list"),
  1982. "getInvoke": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/invoke/{flag}"),
  1983. "getAgent": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/agent/{flag}"),
  1984. "getScript": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/script/{flag}"),
  1985. "findAction": o2.filterUrl(findHost+"/x_query_service_processing/jaxrs/design/search")
  1986. };
  1987. return actions;
  1988. },
  1989. findDesigner: function(){
  1990. this.getFindOption();
  1991. if (!this.filterOption.keyword){
  1992. this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind_keyword);
  1993. return false;
  1994. }
  1995. if (!this.filterOption.designerTypes.length){
  1996. this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind_noFilter);
  1997. return false;
  1998. }
  1999. if (!this.filterOption.moduleList.length){
  2000. this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind_noRange);
  2001. return false;
  2002. }
  2003. this.listContentNode.hide();
  2004. this.listContentNode.empty();
  2005. this.listInfoNode.show().getFirst().set("text", "");
  2006. this.listInfoNode.addClass("loadding");
  2007. this.patternCount = 0;
  2008. if (this.editor) this.editor.destroy();
  2009. this.editor = null;
  2010. this.previewInforNode.show().inject(this.previewContentNode);
  2011. this.scriptDesignerDataObject = null;
  2012. this.designerDataObject = null;
  2013. this.getFindWorker();
  2014. var actions = this.getActionsUrl();
  2015. this.tree = null;
  2016. this.getResultTree(function(){
  2017. var workerMessage = {
  2018. actions:actions,
  2019. filterOption: this.filterOption,
  2020. debug: (window.layout && layout["debugger"]),
  2021. token: (window.layout && layout.session && layout.session.user) ? layout.session.user.token : "",
  2022. tokenName: o2.tokenName
  2023. };
  2024. this.findWorker.postMessage(workerMessage);
  2025. }.bind(this));
  2026. },
  2027. getFindRegExp: function(){
  2028. var flag = "gm";
  2029. var keyword = this.filterOption.keyword;
  2030. if (!this.filterOption.caseSensitive) flag+="i";
  2031. if (this.filterOption.matchRegExp){
  2032. return new RegExp(keyword, flag)
  2033. }else{
  2034. keyword = keyword.replace("[", "\\[").replace("]", "\\]").replace("(", "\\(").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}")
  2035. .replace("^", "\\^").replace("$", "\\$").replace(".", "\\.").replace("?", "\\?").replace("+", "\\+").replace("*", "\\*").replace("|", "\\|");
  2036. if (this.filterOption.matchWholeWord) keyword = "\\b"+keyword+"\\b";
  2037. return new RegExp(keyword, flag)
  2038. }
  2039. }
  2040. //------------------------------------------------------------
  2041. //------------------------------------------------------------
  2042. //------------------------------------------------------------
  2043. //------------------------------------------------------------
  2044. //------------------------------------------------------------
  2045. //------------------------------------------------------------
  2046. //------------------------------------------------------------
  2047. //------------------------------------------------------------
  2048. //------------------------------------------------------------
  2049. //------------------------------------------------------------
  2050. // ------------------------------------------------------------
  2051. // ------------------------------------------------------------
  2052. // findDesigner_bak: function(){
  2053. // this.listContentNode.hide();
  2054. // this.listInfoNode.show().getFirst().set("text", "");
  2055. // this.listInfoNode.addClass("loadding")
  2056. // o2.Actions.load("x_query_service_processing").DesignAction.search(this.filterOption, function(json){
  2057. // if ((json.data.processPlatformList && json.data.processPlatformList.length) ||
  2058. // (json.data.cmsList && json.data.cmsList.length) ||
  2059. // (json.data.portalList && json.data.portalList.length) ||
  2060. // (json.data.queryList && json.data.queryList.length) ||
  2061. // (json.data.serviceList && json.data.serviceList.length)){
  2062. //
  2063. // this.listInfoNode.hide();
  2064. // this.listFindResult(json.data);
  2065. //
  2066. // }else{
  2067. // this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind);
  2068. // }
  2069. // }.bind(this));
  2070. // },
  2071. //
  2072. //
  2073. // createResultAppItem: function(text, title, tree){
  2074. // var obj = {
  2075. // "title": title,
  2076. // "text": "<span style='font-weight: bold; color: #4A90E2'>"+text+"</span>",
  2077. // "icon": ""
  2078. // }
  2079. // return tree.appendChild(obj);
  2080. // },
  2081. // // createResultDesignerItem: function(designer, tree){
  2082. // // var title = this.lp[designer.designerType]+ ": "+ designer.designerName + " ("+designer.designerId+")";
  2083. // // var text = this.lp[designer.designerType]+ ": <b>"+ designer.designerName+"</b>";
  2084. // // var obj = {
  2085. // // "expand": false,
  2086. // // "title": title,
  2087. // // "text": text,
  2088. // // "icon": ""
  2089. // // }
  2090. // // var item = tree.appendChild(obj);
  2091. // // item.designer = designer;
  2092. // // item.appendChild({ "expand": false, "text": "loading...", "icon": "" });
  2093. // // return item;
  2094. // // },
  2095. // listFindResult: function(data){
  2096. // this.listContentNode.empty();
  2097. // this.listContentNode.show();
  2098. // o2.require("o2.widget.Tree", function(){
  2099. // var tree = new o2.widget.Tree(this.listContentNode, {
  2100. // "onQueryExpand": function(item){
  2101. // if (item.designer) this.loadDesignerPattern(item);
  2102. // }.bind(this)
  2103. // });
  2104. // tree.load();
  2105. // if (data.processPlatformList && data.processPlatformList.length){
  2106. // var platformItem = this.createResultCategroyItem(this.lp.processPlatform, this.lp.processPlatform, tree);
  2107. // this.listProcessResult(platformItem, data.processPlatformList, "processPlatform");
  2108. // }
  2109. // if (data.cmsList && data.cmsList.length){
  2110. // var platformItem = this.createResultCategroyItem(this.lp.cms, this.lp.cms, tree);
  2111. // //this.listProcessResult(categroyItem, data.cmsList);
  2112. // }
  2113. // if (data.portalList && data.portalList.length){
  2114. // var platformItem = this.createResultCategroyItem(this.lp.portal, this.lp.portal, tree);
  2115. //
  2116. // }
  2117. // if (data.queryList && data.queryList.length){
  2118. // var platformItem = this.createResultCategroyItem(this.lp.query, this.lp.query, tree);
  2119. // }
  2120. // if (data.serviceList && data.serviceList.length){
  2121. // var platformItem = this.createResultCategroyItem(this.lp.service, this.lp.service, tree);
  2122. // }
  2123. //
  2124. //
  2125. // }.bind(this));
  2126. // },
  2127. // addPatternCount: function(item, count){
  2128. // if (!item.count) item.count = 0;
  2129. // item.count += count;
  2130. // var t = this.lp.patternCount.replace("{n}", item.count);
  2131. // var textDivNode = item.textNode.getElement("div");
  2132. // if (textDivNode){
  2133. // var html = item.options.text;
  2134. // textDivNode.set("html", html+" <span style=''>( "+t+" )</span>");
  2135. // }
  2136. // },
  2137. // listProcessResult: function(platformItem, list, platform){
  2138. // var applicationItems = {};
  2139. // list.each(function(designer){
  2140. // if (designer.patternList && designer.patternList.length){
  2141. // var appItem = applicationItems[designer.appId];
  2142. // if (!appItem){
  2143. // applicationItems[designer.appId] = appItem = this.createResultAppItem(designer.appName, designer.appName+" ("+designer.appId+")", platformItem);
  2144. // }
  2145. // designer.platform = platform;
  2146. // var designerItem = this.createResultDesignerItem(designer, appItem);
  2147. // var count=0;
  2148. // designer.patternList.each(function(p){
  2149. // if (p.lines && p.lines.length){
  2150. // count += p.lines.length;
  2151. // }else{
  2152. // count++;
  2153. // }
  2154. // });
  2155. // // var count = designer.patternList.length;
  2156. //
  2157. // this.addPatternCount(designerItem, count);
  2158. // this.addPatternCount(appItem, count);
  2159. // this.addPatternCount(platformItem, count);
  2160. // }
  2161. // }.bind(this));
  2162. // },
  2163. //
  2164. // getDesignerObject: function(designer){
  2165. // switch (designer.platform){
  2166. // case "processPlatform":
  2167. // var action = this.Actions.load("x_processplatform_assemble_designer");
  2168. // switch (designer.designerType){
  2169. // case "script":
  2170. // return action.ScriptAction.get(designer.designerId, function(json){return json.data;});
  2171. // case "form":
  2172. // return action.FomrAction.get(designer.designerId, function(json){return json.data;});
  2173. // case "process":
  2174. // return action.ProcessAction.get(designer.designerId, function(json){return json.data;});
  2175. // }
  2176. // case "cms":
  2177. // var action = this.Actions.load("x_cms_assemble_control");
  2178. // switch (designer.designerType){
  2179. // case "script":
  2180. // return action.ScriptAction.get(designer.designerId, function(json){return json.data;});
  2181. // case "form":
  2182. // return action.FormAction.get(designer.designerId, function(json){return json.data;});
  2183. // }
  2184. //
  2185. // case "portal":
  2186. // var action = this.Actions.load("x_portal_assemble_designer");
  2187. // switch (designer.designerType){
  2188. // case "script":
  2189. // return action.ScriptAction.get(designer.designerId, function(json){return json.data;});
  2190. // case "page":
  2191. // return action.PageAction.get(designer.designerId, function(json){return json.data;});
  2192. // case "widget":
  2193. // return action.WidgetAction.get(designer.designerId, function(json){return json.data;});
  2194. // }
  2195. // case "query":
  2196. // var action = this.Actions.load("x_query_assemble_designer");
  2197. // switch (designer.designerType){
  2198. // case "view":
  2199. // return action.ViewAction.get(designer.designerId, function(json){return json.data;});
  2200. // case "statement":
  2201. // return action.StatementAction.get(designer.designerId, function(json){return json.data;});
  2202. // case "stat":
  2203. // return action.StatAction.get(designer.designerId, function(json){return json.data;});
  2204. // }
  2205. // case "service":
  2206. // var action = this.Actions.load("x_program_center");
  2207. // switch (designer.appId){
  2208. // case "invoke":
  2209. // return action.InvokeAction.get(designer.designerId, function(json){return json.data;});
  2210. // case "agent":
  2211. // return action.AgentAction.get(designer.designerId, function(json){return json.data;});
  2212. // }
  2213. // }
  2214. // },
  2215. // loadDesignerPattern: function(item){
  2216. // if (item.firstChild && item.firstChild.options.text==="loading..."){
  2217. // item.firstChild.destroy();
  2218. //
  2219. // var root, actionName, fun;
  2220. // switch (designer.platform) {
  2221. // case "processPlatform":
  2222. // root = "x_processplatform_assemble_designer";
  2223. // switch (designer.designerType) {
  2224. // case "script": actionName = "ScriptAction"; fun = "listProcessScriptPattern";
  2225. // case "form": actionName = "FomrAction"; fun = "listProcessFormPattern";
  2226. // case "process": actionName = "ProcessAction"; fun = "listProcessProcessPattern";
  2227. // }
  2228. // case "cms":
  2229. // root = "x_cms_assemble_control";
  2230. // switch (designer.designerType) {
  2231. // case "script": actionName = "ScriptAction"; fun = "listCmsScriptPattern";
  2232. // case "form": actionName = "FormAction"; fun = "listCmsFormPattern";
  2233. // }
  2234. //
  2235. // case "portal":
  2236. // root = "x_portal_assemble_designer";
  2237. // switch (designer.designerType) {
  2238. // case "script": actionName = "ScriptAction"; fun = "listPortalScriptPattern";
  2239. // case "page": actionName = "PageAction"; fun = "listPortalPagePattern";
  2240. // case "widget": actionName = "WidgetAction"; fun = "listPortalWidgetPattern";
  2241. // }
  2242. // case "query":
  2243. // root = "x_query_assemble_designer";
  2244. // switch (designer.designerType) {
  2245. // case "view": actionName = "ViewAction"; fun = "listQueryViewPattern";
  2246. // case "statement": actionName = "StatementAction"; fun = "listQueryStatementPattern";
  2247. // case "stat": actionName = "StatAction"; fun = "listQueryStatPattern";
  2248. // }
  2249. // case "service":
  2250. // root = "x_program_center";
  2251. // switch (designer.appId) {
  2252. // case "invoke": actionName = "InvokeAction"; fun = "listServiceInvokePattern";
  2253. // case "agent": actionName = "AgentAction"; fun = "listServiceAgentPattern";
  2254. // }
  2255. // }
  2256. // this.Actions.load(root)[actionName].get(designer.designerId, function(json){
  2257. // this[fun](json.data, designer.patternList, item);
  2258. // }.bind(this))
  2259. // }
  2260. // },
  2261. //
  2262. //
  2263. //
  2264. // //启动一个webworker处理
  2265. // listProcessScriptPattern: function (data, patternList, item){
  2266. // patternList.each(function(pattern){
  2267. // if (pattern.property == "text"){
  2268. // var textArr = data.split("\n");
  2269. // var regex = this.getFindRegExp();
  2270. // pattern.lines.each(function(line){
  2271. // var text = textArr[line];
  2272. //
  2273. //
  2274. //
  2275. // }.bind(this));
  2276. // }else{
  2277. //
  2278. // }
  2279. // }.bind(this));
  2280. // }
  2281. });