Main.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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. "isResize": true,
  13. "isMax": true,
  14. "layout": {
  15. "type": "leftRight",
  16. "percent": 0.3
  17. },
  18. "title": MWF.xApplication.FindDesigner.LP.title
  19. },
  20. onQueryLoad: function(){
  21. this.lp = MWF.xApplication.FindDesigner.LP;
  22. this.filterOption = {
  23. "keyword": "",
  24. "designerTypes": [],
  25. "caseSensitive": false,
  26. "matchWholeWord": false,
  27. "matchRegExp": false,
  28. "moduleList": []
  29. }
  30. this.selectedModules = [];
  31. this.selectedRange = [];
  32. o2.UD.getDataJson("findDesignerLayout", function(json){
  33. this.setOptions(json);
  34. }.bind(this), false);
  35. },
  36. loadApplication: function(callback){
  37. var url = this.path+this.options.style+"/view.html";
  38. this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){
  39. this.setSizeNode();
  40. if (callback) callback();
  41. }.bind(this));
  42. },
  43. initLayout: function(){
  44. this.listNode.set("style", "");
  45. this.previewNode.set("style", "");
  46. if (this.resizeDrag) this.resizeDrag.detach();
  47. if (this.sizeNodeFun) this.removeEvent("resize", this.sizeNodeFun);
  48. if (this.options.layout.type=="leftRight"){
  49. this.toLeftRight();
  50. }else{
  51. this.toTopBottom();
  52. }
  53. },
  54. setSizeNode: function(){
  55. this.initLayout();
  56. this["sizeNode_"+this.options.layout.type]();
  57. this["setResizeNode_"+this.options.layout.type]();
  58. this.sizeNodeFun = null;
  59. this.sizeNodeFun = this["sizeNode_"+this.options.layout.type].bind(this);
  60. this.addEvent("resize", this.sizeNodeFun);
  61. },
  62. sizeResultNode: function(){
  63. var size = this.content.getSize();
  64. var filterSzie = this.filterNode.getSize();
  65. var keywordSize = this.keywordNode.getSize();
  66. var rangeSize = this.rangeNode.getSize();
  67. var h = size.y-filterSzie.y-keywordSize.y-rangeSize.y;
  68. this.resultNode.setStyle("height", ""+h+"px");
  69. return h;
  70. },
  71. sizeNode_topBottom: function(){
  72. var h = this.sizeResultNode();
  73. var listHeight = h*this.options.layout.percent;
  74. this.listNode.setStyle("height", ""+listHeight+"px");
  75. var previewHeight = h*(1-this.options.layout.percent);
  76. this.previewNode.setStyle("height", ""+previewHeight+"px");
  77. var listTitleSize = this.listTitleNode.getSize();
  78. var listContentHeight = listHeight - listTitleSize.y;
  79. this.listAreaNode.setStyle("height", ""+listContentHeight+"px");
  80. var previewSeparatorSize = this.previewSeparatorNode.getSize();
  81. var previewTitleSize = this.previewTitleNode.getSize();
  82. var previewContentHeight = previewHeight - previewSeparatorSize.y - previewTitleSize.y;
  83. this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
  84. },
  85. sizeNode_leftRight: function(){
  86. var h = this.sizeResultNode();
  87. var w = this.resultNode.getSize().x;
  88. var listWidth = w*this.options.layout.percent;
  89. this.listNode.setStyle("width", ""+listWidth+"px");
  90. this.previewNode.setStyle("margin-left", ""+listWidth+"px");
  91. var listTitleSize = this.listTitleNode.getSize();
  92. var listContentHeight = h - listTitleSize.y;
  93. this.listAreaNode.setStyle("height", ""+listContentHeight+"px");
  94. var previewTitleSize = this.previewTitleNode.getSize();
  95. var previewContentHeight = h - previewTitleSize.y;
  96. this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
  97. },
  98. setResizeNode_topBottom: function(){
  99. if (this.previewSeparatorNode){
  100. this.resizeDrag = new Drag(this.previewSeparatorNode, {
  101. "onStart": function(el, e){
  102. el.store("position", o2.eventPosition(e));
  103. el.store("initialSize", this.listNode.getSize());
  104. }.bind(this),
  105. "onDrag": function(el, e){
  106. var p = o2.eventPosition(e);
  107. var position = el.retrieve("position");
  108. var initialSize = el.retrieve("initialSize");
  109. var dy = position.y.toFloat()-p.y.toFloat();
  110. var height = initialSize.y-dy;
  111. var size = this.resultNode.getSize();
  112. this.options.layout.percent = height/size.y;
  113. if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
  114. if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
  115. this.sizeNode_topBottom();
  116. }.bind(this),
  117. "onComplete": function(){
  118. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  119. }.bind(this)
  120. });
  121. }
  122. },
  123. setResizeNode_leftRight: function(){
  124. if (this.previewSeparatorNode){
  125. this.resizeDrag = new Drag(this.previewSeparatorNode, {
  126. "onStart": function(el, e){
  127. el.store("position", o2.eventPosition(e));
  128. el.store("initialSize", this.listNode.getSize());
  129. }.bind(this),
  130. "onDrag": function(el, e){
  131. var p = o2.eventPosition(e);
  132. var position = el.retrieve("position");
  133. var initialSize = el.retrieve("initialSize");
  134. var dx = position.x.toFloat()-p.x.toFloat();
  135. var width = initialSize.x-dx;
  136. var size = this.resultNode.getSize();
  137. this.options.layout.percent = width/size.x;
  138. if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
  139. if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
  140. this.sizeNode_leftRight();
  141. }.bind(this),
  142. "onComplete": function(){
  143. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  144. }.bind(this)
  145. });
  146. }
  147. },
  148. checkFilter: function(e){
  149. if (e.target.hasClass("filterNode_item")) e.target.getElement("input").click();
  150. e.stopPropagation();
  151. },
  152. checkRange: function(e){
  153. if (e.target.hasClass("rangeType_Item")) e.target.getElement("input").click();
  154. e.stopPropagation();
  155. },
  156. overKeywordOption: function(e){
  157. if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")){
  158. if (!e.target.hasClass("optionItem_over")) e.target.addClass("optionItem_over");
  159. }
  160. },
  161. outKeywordOption: function(e){
  162. if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")) e.target.removeClass("optionItem_over");
  163. },
  164. setCaseSensitive: function(e){
  165. this.filterOption.caseSensitive = !this.filterOption.caseSensitive;
  166. this.caseSensitiveNode.removeClass("caseSensitiveNode_"+!this.filterOption.caseSensitive);
  167. this.caseSensitiveNode.addClass("caseSensitiveNode_"+this.filterOption.caseSensitive);
  168. },
  169. setMatchWholeWord: function(e){
  170. this.filterOption.matchWholeWord = !this.filterOption.matchWholeWord;
  171. this.matchWholeWordNode.removeClass("matchWholeWordNode_"+!this.filterOption.matchWholeWord);
  172. this.matchWholeWordNode.addClass("matchWholeWordNode_"+this.filterOption.matchWholeWord);
  173. },
  174. setMatchRegExp: function(e){
  175. this.filterOption.matchRegExp = !this.filterOption.matchRegExp;
  176. this.matchRegExpNode.removeClass("matchRegExpNode_"+!this.filterOption.matchRegExp);
  177. this.matchRegExpNode.addClass("matchRegExpNode_"+this.filterOption.matchRegExp);
  178. },
  179. layoutAddClass: function(flag){
  180. flag = flag || "";
  181. this.listNode.addClass("listNode"+flag);
  182. this.previewNode.addClass("previewNode"+flag);
  183. this.previewSeparatorNode.addClass("previewNode_separator"+flag);
  184. this.previewTitleNode.addClass("previewNode_title"+flag);
  185. this.previewTitleActionNode.addClass("previewNode_title_action"+flag);
  186. this.previewContentNode.addClass("previewNode_content"+flag);
  187. },
  188. layoutRemoveClass: function(flag){
  189. flag = flag || "";
  190. this.listNode.removeClass("listNode"+flag);
  191. this.previewNode.removeClass("previewNode"+flag);
  192. this.previewSeparatorNode.removeClass("previewNode_separator"+flag);
  193. this.previewTitleNode.removeClass("previewNode_title"+flag);
  194. this.previewTitleActionNode.removeClass("previewNode_title_action"+flag);
  195. this.previewContentNode.removeClass("previewNode_content"+flag);
  196. },
  197. toLeftRight: function(){
  198. this.layoutAddClass("_lr");
  199. this.layoutRemoveClass();
  200. this.options.layout.type="leftRight";
  201. },
  202. toTopBottom: function(){
  203. this.layoutAddClass();
  204. this.layoutRemoveClass("_lr");
  205. this.options.layout.type="topBottom";
  206. },
  207. changeLayout: function(){
  208. if (this.options.layout.type=="leftRight"){
  209. this.options.layout.type="topBottom";
  210. }else{
  211. this.options.layout.type="leftRight";
  212. }
  213. this.setSizeNode();
  214. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  215. },
  216. getSelectedRange: function(){
  217. this.selectedRange = [];
  218. var rangeInputs = this.rangeContentNode.getElements("input");
  219. rangeInputs.each(function(input){
  220. if (input.checked) this.selectedRange.push(input.get("value"));
  221. }.bind(this));
  222. },
  223. setSelectedRange: function(){
  224. if (this.selectedRange && this.selectedRange.length){
  225. var rangeInputs = this.rangeContentNode.getElements("input");
  226. rangeInputs.each(function(input){
  227. if (this.selectedRange.indexOf(input.get("value"))!=-1) input.set("checked", true);
  228. }.bind(this));
  229. }
  230. },
  231. removeRangeItem: function(item){
  232. item.destroy();
  233. var itemNodes = this.rangeSelectedContentNode.getChildren();
  234. if (!itemNodes.length) this.setSelectedRange();
  235. },
  236. selectFindRange: function(loadFun){
  237. o2.requireApp("Selector", "package", function(){
  238. new o2.O2Selector(this.content, {
  239. "values": this.selectedModules,
  240. "type": "PlatApp",
  241. "selectAllEnable": true,
  242. "onLoad": function(){
  243. if (loadFun && o2.typeOf(loadFun)=="function") loadFun();
  244. },
  245. "onComplete": function(list){
  246. this.rangeSelectedContentNode.empty();
  247. //this.selectedModules = [];
  248. if (list.length){
  249. this.getSelectedRange();
  250. this.rangeContentNode.getElements("input").set("checked", false);
  251. o2.require("o2.widget.O2Identity", function(){
  252. list.each(function(app){
  253. //this.selectedModules.push(app.data);
  254. app.data.name = this.lp.service + "-" + app.data.name;
  255. var item = new o2.widget.O2Other(app.data, this.rangeSelectedContentNode, {"canRemove": true, "style": "find", "onRemove": function(item){this.removeRangeItem(item);}.bind(this)});
  256. item.node.store("data", item.data);
  257. }.bind(this));
  258. }.bind(this));
  259. }else{
  260. this.setSelectedRange();
  261. }
  262. }.bind(this)
  263. });
  264. }.bind(this));
  265. },
  266. getFindOption: function(){
  267. var filterTypes = [];
  268. filterItems = this.filterNode.getElements("input");
  269. filterItems.each(function(item){
  270. if (item.checked) filterTypes.push(item.get("value"));
  271. }.bind(this));
  272. var keyword = this.keywordInputNode.get("value");
  273. var moduleList = [];
  274. var itemNodes = this.rangeSelectedContentNode.getChildren();
  275. if (!itemNodes.length){
  276. this.getSelectedRange();
  277. this.selectedRange.each(function(type){
  278. moduleList.push({"moduleType": type, "flagList": []});
  279. });
  280. }else{
  281. var rangeApp = {};
  282. itemNodes.each(function(node){
  283. var data = node.retrieve("data");
  284. if (!rangeApp[data.moduleType]) rangeApp[data.moduleType] = [];
  285. rangeApp[data.moduleType].push({"id": data.id});
  286. }.bind(this));
  287. Object.keys(rangeApp).each(function(k){
  288. moduleList.push({"moduleType": k, "flagList": rangeApp[k]});
  289. });
  290. }
  291. this.filterOption.keyword = keyword;
  292. this.filterOption.designerTypes = filterTypes;
  293. this.filterOption.moduleList = moduleList;
  294. return this.filterOption;
  295. },
  296. checkFindDesigner: function(e){
  297. if (e.keyCode===13){
  298. this.getFindOption();
  299. if (!this.filterOption.keyword){
  300. this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind_keyword);
  301. return false;
  302. }
  303. if (!this.filterOption.designerTypes.length){
  304. this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind_noFilter);
  305. return false;
  306. }
  307. if (!this.filterOption.moduleList.length){
  308. this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind_noRange);
  309. return false;
  310. }
  311. this.findDesigner();
  312. }
  313. },
  314. getFindWorker: function(){
  315. if (!this.findWorker) this.findWorker = new Worker("../x_component_FindDesigner/FindWorker.js");
  316. this.findWorker.onmessage = function(e) {
  317. if (e.data && e.data.type=="receive") this.setReceiveMessage();
  318. if (e.data && e.data.type=="ready") this.setReadyMessage(e.data);
  319. if (e.data && e.data.type=="find") this.doFindResult(e.data);
  320. }.bind(this);
  321. },
  322. doFindResult: function(){
  323. this.findOptionModuleProcessed++;
  324. this.updateFindProgress();
  325. },
  326. setReceiveMessage: function(){
  327. this.listTitleInfoNode.set("text", this.lp.receiveToFind);
  328. },
  329. setReadyMessage: function(data){
  330. this.findOptionModuleCount = data.count;
  331. this.findOptionModuleProcessed = 0;
  332. this.updateFindProgress();
  333. this.listTitleInfoNode.set("text", this.lp.readyToFind.replace("{n}", data.count));
  334. },
  335. updateFindProgress: function(){
  336. var percent = (this.findOptionModuleProcessed/this.findOptionModuleCount)*100;
  337. this.listTitleProgressNode.setStyle("width", ""+percent+"%");
  338. },
  339. getActionsUrl:function(){
  340. var processHost = o2.Actions.getHost("x_processplatform_assemble_designer");
  341. var cmsHost = o2.Actions.getHost("x_cms_assemble_control");
  342. var portalHost = o2.Actions.getHost("x_portal_assemble_designer");
  343. var queryHost = o2.Actions.getHost("x_query_assemble_designer");
  344. var serviceHost = o2.Actions.getHost("x_program_center");
  345. var findHost = o2.Actions.getHost("x_query_service_processing");
  346. var actions = {
  347. "listProcess": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/application/list"),
  348. "listProcessProcess": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/process/application/{applicationId}"),
  349. "listProcessForm": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/form/list/application/{applicationId}"),
  350. "listProcessScript": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/script/application/{applicationId}"),
  351. "getProcessProcess": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/process/{id}"),
  352. "getProcessForm": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/form/{id}"),
  353. "getProcessScript": o2.filterUrl(processHost+"/x_processplatform_assemble_designer/jaxrs/script/{id}"),
  354. "listCms": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/appinfo/list/manage"),
  355. "listCmsForm": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/form/list/app/{appId}"),
  356. "listCmsScript": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/script/list/app/{flag}"),
  357. "getCmsForm": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/form/{id}"),
  358. "getCmsScript": o2.filterUrl(cmsHost+"/x_cms_assemble_control/jaxrs/script/{id}"),
  359. "listPortal": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/portal/list"),
  360. "listPortalPage": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/page/list/portal/{portalId}"),
  361. "listPortalScript": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/script/list/portal/{portalId}"),
  362. "listPortalWidget": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/widget/list/portal/{portalId}"),
  363. "getPortalPage": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/page/{id}"),
  364. "getPortalScript": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/script/{id}"),
  365. "getPortalWidget": o2.filterUrl(portalHost+"/x_portal_assemble_designer/jaxrs/widget/{id}"),
  366. "listQuery": o2.filterUrl(queryHost+"/x_query_assemble_designer/jaxrs/query/list/summary"),
  367. "listQueryView": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/view/list/query/{flag}"),
  368. "listQueryStat": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/stat/list/query/{flag}"),
  369. "listQueryStatement": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/statement/list/query/{flag}"),
  370. "getQueryView": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/view/{id}"),
  371. "getQueryStat": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/stat/{id}"),
  372. "getQueryStatement": o2.filterUrl(portalHost+"/x_query_assemble_designer/jaxrs/statement/{id}"),
  373. "listInvoke": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/invoke"),
  374. "listAgent": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/agent"),
  375. "getInvoke": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/invoke/{flag}"),
  376. "getAgent": o2.filterUrl(serviceHost+"/x_program_center/jaxrs/agent/{flag}"),
  377. "findAction": o2.filterUrl(findHost+"/x_query_service_processing/jaxrs/design/search")
  378. };
  379. return actions;
  380. },
  381. findDesigner: function(){
  382. this.getFindWorker();
  383. var actions = this.getActionsUrl();
  384. var workerMessage = {
  385. actions:actions,
  386. filterOption: this.filterOption,
  387. debug: (window.layout && layout["debugger"]),
  388. token: (window.layout && layout.session && layout.session.user) ? layout.session.user.token : ""
  389. }
  390. this.findWorker.postMessage(workerMessage);
  391. },
  392. //------------------------------------------------------------
  393. findDesigner_bak: function(){
  394. this.listContentNode.hide();
  395. this.listInfoNode.show().getFirst().set("text", "");
  396. this.listInfoNode.addClass("loadding")
  397. o2.Actions.load("x_query_service_processing").DesignAction.search(this.filterOption, function(json){
  398. if ((json.data.processPlatformList && json.data.processPlatformList.length) ||
  399. (json.data.cmsList && json.data.cmsList.length) ||
  400. (json.data.portalList && json.data.portalList.length) ||
  401. (json.data.queryList && json.data.queryList.length) ||
  402. (json.data.serviceList && json.data.serviceList.length)){
  403. this.listInfoNode.hide();
  404. this.listFindResult(json.data);
  405. }else{
  406. this.listInfoNode.show().removeClass("loadding").getFirst().set("text", this.lp.nothingFind);
  407. }
  408. }.bind(this));
  409. },
  410. createResultCategroyItem: function(text, title, tree){
  411. var obj = {
  412. "title": title,
  413. "text": "<span style='font-weight: bold'>"+text+"</span>",
  414. "icon": ""
  415. }
  416. return tree.appendChild(obj);
  417. },
  418. createResultAppItem: function(text, title, tree){
  419. var obj = {
  420. "title": title,
  421. "text": "<span style='font-weight: bold; color: #4A90E2'>"+text+"</span>",
  422. "icon": ""
  423. }
  424. return tree.appendChild(obj);
  425. },
  426. createResultDesignerItem: function(designer, tree){
  427. var title = this.lp[designer.designerType]+ ": "+ designer.designerName + " ("+designer.designerId+")";
  428. var text = this.lp[designer.designerType]+ ": <b>"+ designer.designerName+"</b>";
  429. var obj = {
  430. "expand": false,
  431. "title": title,
  432. "text": text,
  433. "icon": ""
  434. }
  435. var item = tree.appendChild(obj);
  436. item.designer = designer;
  437. item.appendChild({ "expand": false, "text": "loading...", "icon": "" });
  438. return item;
  439. },
  440. listFindResult: function(data){
  441. this.listContentNode.empty();
  442. this.listContentNode.show();
  443. o2.require("o2.widget.Tree", function(){
  444. var tree = new o2.widget.Tree(this.listContentNode, {
  445. "onQueryExpand": function(item){
  446. if (item.designer) this.loadDesignerPattern(item);
  447. }.bind(this)
  448. });
  449. tree.load();
  450. if (data.processPlatformList && data.processPlatformList.length){
  451. var platformItem = this.createResultCategroyItem(this.lp.processPlatform, this.lp.processPlatform, tree);
  452. this.listProcessResult(platformItem, data.processPlatformList, "processPlatform");
  453. }
  454. if (data.cmsList && data.cmsList.length){
  455. var platformItem = this.createResultCategroyItem(this.lp.cms, this.lp.cms, tree);
  456. //this.listProcessResult(categroyItem, data.cmsList);
  457. }
  458. if (data.portalList && data.portalList.length){
  459. var platformItem = this.createResultCategroyItem(this.lp.portal, this.lp.portal, tree);
  460. }
  461. if (data.queryList && data.queryList.length){
  462. var platformItem = this.createResultCategroyItem(this.lp.query, this.lp.query, tree);
  463. }
  464. if (data.serviceList && data.serviceList.length){
  465. var platformItem = this.createResultCategroyItem(this.lp.service, this.lp.service, tree);
  466. }
  467. }.bind(this));
  468. },
  469. addPatternCount: function(item, count){
  470. if (!item.count) item.count = 0;
  471. item.count += count;
  472. var t = this.lp.patternCount.replace("{n}", item.count);
  473. var textDivNode = item.textNode.getElement("div");
  474. if (textDivNode){
  475. var html = item.options.text;
  476. textDivNode.set("html", html+" <span style=''>( "+t+" )</span>");
  477. }
  478. },
  479. listProcessResult: function(platformItem, list, platform){
  480. var applicationItems = {};
  481. list.each(function(designer){
  482. if (designer.patternList && designer.patternList.length){
  483. var appItem = applicationItems[designer.appId];
  484. if (!appItem){
  485. applicationItems[designer.appId] = appItem = this.createResultAppItem(designer.appName, designer.appName+" ("+designer.appId+")", platformItem);
  486. }
  487. designer.platform = platform;
  488. var designerItem = this.createResultDesignerItem(designer, appItem);
  489. var count=0;
  490. designer.patternList.each(function(p){
  491. if (p.lines && p.lines.length){
  492. count += p.lines.length;
  493. }else{
  494. count++;
  495. }
  496. });
  497. // var count = designer.patternList.length;
  498. this.addPatternCount(designerItem, count);
  499. this.addPatternCount(appItem, count);
  500. this.addPatternCount(platformItem, count);
  501. }
  502. }.bind(this));
  503. },
  504. getDesignerObject: function(designer){
  505. switch (designer.platform){
  506. case "processPlatform":
  507. var action = this.Actions.load("x_processplatform_assemble_designer");
  508. switch (designer.designerType){
  509. case "script":
  510. return action.ScriptAction.get(designer.designerId, function(json){return json.data;});
  511. case "form":
  512. return action.FomrAction.get(designer.designerId, function(json){return json.data;});
  513. case "process":
  514. return action.ProcessAction.get(designer.designerId, function(json){return json.data;});
  515. }
  516. case "cms":
  517. var action = this.Actions.load("x_cms_assemble_control");
  518. switch (designer.designerType){
  519. case "script":
  520. return action.ScriptAction.get(designer.designerId, function(json){return json.data;});
  521. case "form":
  522. return action.FormAction.get(designer.designerId, function(json){return json.data;});
  523. }
  524. case "portal":
  525. var action = this.Actions.load("x_portal_assemble_designer");
  526. switch (designer.designerType){
  527. case "script":
  528. return action.ScriptAction.get(designer.designerId, function(json){return json.data;});
  529. case "page":
  530. return action.PageAction.get(designer.designerId, function(json){return json.data;});
  531. case "widget":
  532. return action.WidgetAction.get(designer.designerId, function(json){return json.data;});
  533. }
  534. case "query":
  535. var action = this.Actions.load("x_query_assemble_designer");
  536. switch (designer.designerType){
  537. case "view":
  538. return action.ViewAction.get(designer.designerId, function(json){return json.data;});
  539. case "statement":
  540. return action.StatementAction.get(designer.designerId, function(json){return json.data;});
  541. case "stat":
  542. return action.StatAction.get(designer.designerId, function(json){return json.data;});
  543. }
  544. case "service":
  545. var action = this.Actions.load("x_program_center");
  546. switch (designer.appId){
  547. case "invoke":
  548. return action.InvokeAction.get(designer.designerId, function(json){return json.data;});
  549. case "agent":
  550. return action.AgentAction.get(designer.designerId, function(json){return json.data;});
  551. }
  552. }
  553. },
  554. loadDesignerPattern: function(item){
  555. if (item.firstChild && item.firstChild.options.text==="loading..."){
  556. item.firstChild.destroy();
  557. var root, actionName, fun;
  558. switch (designer.platform) {
  559. case "processPlatform":
  560. root = "x_processplatform_assemble_designer";
  561. switch (designer.designerType) {
  562. case "script": actionName = "ScriptAction"; fun = "listProcessScriptPattern";
  563. case "form": actionName = "FomrAction"; fun = "listProcessFormPattern";
  564. case "process": actionName = "ProcessAction"; fun = "listProcessProcessPattern";
  565. }
  566. case "cms":
  567. root = "x_cms_assemble_control";
  568. switch (designer.designerType) {
  569. case "script": actionName = "ScriptAction"; fun = "listCmsScriptPattern";
  570. case "form": actionName = "FormAction"; fun = "listCmsFormPattern";
  571. }
  572. case "portal":
  573. root = "x_portal_assemble_designer";
  574. switch (designer.designerType) {
  575. case "script": actionName = "ScriptAction"; fun = "listPortalScriptPattern";
  576. case "page": actionName = "PageAction"; fun = "listPortalPagePattern";
  577. case "widget": actionName = "WidgetAction"; fun = "listPortalWidgetPattern";
  578. }
  579. case "query":
  580. root = "x_query_assemble_designer";
  581. switch (designer.designerType) {
  582. case "view": actionName = "ViewAction"; fun = "listQueryViewPattern";
  583. case "statement": actionName = "StatementAction"; fun = "listQueryStatementPattern";
  584. case "stat": actionName = "StatAction"; fun = "listQueryStatPattern";
  585. }
  586. case "service":
  587. root = "x_program_center";
  588. switch (designer.appId) {
  589. case "invoke": actionName = "InvokeAction"; fun = "listServiceInvokePattern";
  590. case "agent": actionName = "AgentAction"; fun = "listServiceAgentPattern";
  591. }
  592. }
  593. this.Actions.load(root)[actionName].get(designer.designerId, function(json){
  594. this[fun](json.data, designer.patternList, item);
  595. }.bind(this))
  596. }
  597. },
  598. getFindRegExp: function(){
  599. var flag = "gm";
  600. var keyword = this.filterOption.keyword;
  601. if (!this.filterOption.caseSensitive) flag+="i";
  602. if (this.filterOption.matchRegExp){
  603. return new RegExp(keyword, flag)
  604. }else{
  605. if (this.filterOption.matchWholeWord) keyword = "\\b"+keyword+"\\b";
  606. return new RegExp(keyword, flag)
  607. }
  608. },
  609. //启动一个webworker处理
  610. listProcessScriptPattern: function (data, patternList, item){
  611. patternList.each(function(pattern){
  612. if (pattern.property == "text"){
  613. var textArr = data.split("\n");
  614. var regex = this.getFindRegExp();
  615. pattern.lines.each(function(line){
  616. var text = textArr[line];
  617. }.bind(this));
  618. }else{
  619. }
  620. }.bind(this));
  621. }
  622. });