Statement.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. MWF.xApplication = MWF.xApplication || {};
  2. MWF.xApplication.query = MWF.xApplication.query || {};
  3. MWF.xApplication.query.StatementDesigner = MWF.xApplication.query.StatementDesigner || {};
  4. MWF.APPDSMD = MWF.xApplication.query.StatementDesigner;
  5. MWF.xDesktop.requireApp("query.StatementDesigner", "lp." + MWF.language, null, false);
  6. MWF.xDesktop.requireApp("query.StatementDesigner", "Property", null, false);
  7. MWF.xDesktop.requireApp("query.ViewDesigner", "View", null, false);
  8. o2.require("o2.widget.JavascriptEditor", null, false);
  9. o2.require("o2.widget.UUID", null, false);
  10. MWF.xApplication.query.StatementDesigner.Statement = new Class({
  11. Extends: MWF.widget.Common,
  12. Implements: [Options, Events],
  13. options: {
  14. "style": "default",
  15. "isView": false,
  16. "showTab": true,
  17. "propertyPath": "../x_component_query_StatementDesigner/$Statement/statement.html"
  18. },
  19. initialize: function (designer, data, options) {
  20. this.setOptions(options);
  21. this.path = "../x_component_query_StatementDesigner/$Statement/";
  22. this.cssPath = "../x_component_query_StatementDesigner/$Statement/" + this.options.style + "/css.wcss";
  23. this._loadCss();
  24. this.designer = designer;
  25. this.data = data;
  26. this.parseData();
  27. this.node = this.designer.designNode;
  28. this.areaNode = new Element("div", {"styles": {"height": "100%", "overflow": "auto"}});
  29. //this.statementRunNode = this.designer.designerStatementArea;
  30. if (this.designer.application) this.data.applicationName = this.designer.application.name;
  31. if (this.designer.application) this.data.application = this.designer.application.id;
  32. this.isNewStatement = (this.data.id) ? false : true;
  33. this.view = this;
  34. this.autoSave();
  35. this.designer.addEvent("queryClose", function () {
  36. if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  37. }.bind(this));
  38. },
  39. parseData: function () {
  40. this.json = this.data;
  41. if (!this.json.type) this.json.type = "select";
  42. if (!this.json.format) this.json.format = "jpql";
  43. if (!this.json.entityCategory) this.json.entityCategory = "official";
  44. if (!this.json.entityClassName) this.json.entityClassName = "com.x.processplatform.core.entity.content.Task";
  45. },
  46. autoSave: function () {
  47. this.autoSaveTimerID = window.setInterval(function () {
  48. if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFAutoSaveCheck");
  49. if (this.autoSaveCheckNode) {
  50. if (this.autoSaveCheckNode.get("checked")) {
  51. this.save();
  52. }
  53. }
  54. }.bind(this), 60000);
  55. },
  56. load: function () {
  57. // this.setAreaNodeSize();
  58. // this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  59. this.areaNode.inject(this.node);
  60. this.designer.statementListAreaNode.getChildren().each(function (node) {
  61. var statement = node.retrieve("statement");
  62. if (statement.id == this.data.id) {
  63. if (this.designer.currentListStatementItem) {
  64. this.designer.currentListStatementItem.setStyles(this.designer.css.listStatementItem);
  65. }
  66. node.setStyles(this.designer.css.listStatementItem_current);
  67. this.designer.currentListStatementItem = node;
  68. this.lisNode = node;
  69. }
  70. }.bind(this));
  71. this.loadStatement();
  72. // this.showProperty();
  73. this.selected();
  74. },
  75. selected: function () {
  76. if (this.currentSelectedModule) {
  77. if (this.currentSelectedModule == this) {
  78. return true;
  79. } else {
  80. this.currentSelectedModule.unSelected();
  81. }
  82. }
  83. if (this.view && this.view.domListNode) {
  84. this.view.domListNode.hide();
  85. }
  86. this.currentSelectedModule = this;
  87. this.isSelected = true;
  88. this.showProperty();
  89. },
  90. unSelected: function () {
  91. this.currentSelectedModule = null;
  92. this.isSelected = false;
  93. this.hideProperty();
  94. },
  95. showProperty: function () {
  96. if (!this.property) {
  97. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.designer.designerContentArea, this.designer, {
  98. "path": this.options.propertyPath,
  99. "onPostLoad": function () {
  100. this.property.show();
  101. }.bind(this)
  102. });
  103. this.property.load();
  104. } else {
  105. this.property.show();
  106. }
  107. },
  108. hideProperty: function () {
  109. if (this.property) this.property.hide();
  110. },
  111. loadJpqlTab: function (callback) {
  112. var _self = this;
  113. MWF.require("MWF.widget.Tab", null, false);
  114. this.jpqlTab = new MWF.widget.Tab(this.jpqlTabNode, {"style": "script"});
  115. this.jpqlTab.load();
  116. this.tabJpqlNode = Element("div");
  117. this.jpqlTabPageNode.inject(this.tabJpqlNode);
  118. this.tabCountJpqlNode = Element("div");
  119. this.countJpqlTabPageNode.inject(this.tabCountJpqlNode);
  120. this.jpqlPage = this.jpqlTab.addTab(this.tabJpqlNode, this.designer.lp.queryStatement);
  121. this.countJpqlPage = this.jpqlTab.addTab(this.tabCountJpqlNode, this.designer.lp.countStatement);
  122. this.jpqlPage.showTabIm();
  123. // this.jpqlPage.addEvent("postShow", function(){
  124. // if( this.view ){
  125. // this.view.setContentHeight();
  126. // this.view.selected();
  127. // }
  128. // }.bind(this));
  129. // this.countJpqlPage.addEvent("postShow", function(){
  130. // this.selected();
  131. // }.bind(this));
  132. },
  133. loadTab: function (callback) {
  134. var _self = this;
  135. MWF.require("MWF.widget.Tab", null, false);
  136. this.tab = new MWF.widget.Tab(this.tabNode, {"style": "script"});
  137. this.tab.load();
  138. this.tabRunNode = Element("div");
  139. this.pageRunNode = new Element("div", {
  140. "styles": {
  141. "overflow": "auto",
  142. "background-color": "#fff"
  143. }
  144. }).inject(this.tabRunNode);
  145. this.runArea.inject(this.pageRunNode);
  146. this.tabViewNode = Element("div", {"styles": {"height": "100%"}});
  147. this.pageViewNode = new Element("div.pageViewNode").inject(this.tabViewNode);
  148. this.viewArea.inject(this.pageViewNode);
  149. this.runPage = this.tab.addTab(this.tabRunNode, this.designer.lp.runTest);
  150. this.viewPage = this.tab.addTab(this.tabViewNode, this.designer.lp.view);
  151. this.runPage.showTabIm();
  152. this.viewPage.addEvent("postShow", function () {
  153. if (this.view) {
  154. this.view.setContentHeight();
  155. this.view.selected();
  156. }
  157. }.bind(this));
  158. this.runPage.addEvent("postShow", function () {
  159. this.selected();
  160. }.bind(this));
  161. },
  162. loadStatement: function () {
  163. //this.statementDesignerNode = new Element("div", {"styles": this.css.statementDesignerNode}).inject(this.areaNode);
  164. this.loadStatementHtml(function () {
  165. this.designerArea = this.areaNode.getElement(".o2_statement_statementDesignerNode");
  166. this.jpqlTabPageNode = this.areaNode.getElement(".o2_statement_statementJpqlTabPageNode");
  167. this.jpqlArea = this.areaNode.getElement(".o2_statement_statementDesignerJpql");
  168. this.scriptArea = this.areaNode.getElement(".o2_statement_statementDesignerScript");
  169. this.formatTypeArea = this.areaNode.getElement(".o2_statement_statementDesignerFormatContent");
  170. this.entityCategorySelect = this.areaNode.getElement(".o2_statement_statementDesignerCategoryContent").getElement("select");
  171. this.dynamicTableArea = this.areaNode.getElement(".o2_statement_statementDesignerTableArea_dynamic");
  172. this.officialTableArea = this.areaNode.getElement(".o2_statement_statementDesignerTableArea_official");
  173. this.customTableArea = this.areaNode.getElement(".o2_statement_statementDesignerTableArea_custom");
  174. this.dynamicTableSelect = this.areaNode.getElement(".o2_statement_statementDesignerSelectTable");
  175. this.officialTableSelect = this.officialTableArea.getElement("select");
  176. this.dynamicTableContent = this.areaNode.getElement(".o2_statement_statementDesignerTableContent");
  177. this.jpqlTabNode = this.areaNode.getElement(".o2_statement_statementJpqlTabNode");
  178. this.jpqlTypeSelect = this.areaNode.getElement(".o2_statement_statementDesignerTypeContent").getElement("select");
  179. // this.jpqlSelectEditor = this.areaNode.getElement(".o2_statement_statementDesignerJpql_select");
  180. // this.jpqlUpdateEditor = this.areaNode.getElement(".o2_statement_statementDesignerJpql_update");
  181. // this.jpqlDeleteEditor = this.areaNode.getElement(".o2_statement_statementDesignerJpql_sdelete");
  182. // this.jpqlSelectEditor_selectContent= this.jpqlSelectEditor.getElement(".o2_statement_statementDesignerJpql_jpql_selectContent");
  183. // this.jpqlSelectEditor_fromContent= this.jpqlSelectEditor.getElement(".o2_statement_statementDesignerJpql_jpql_fromContent");
  184. // this.jpqlSelectEditor_whereContent= this.jpqlSelectEditor.getElement(".o2_statement_statementDesignerJpql_jpql_whereContent");
  185. this.jpqlEditorNode = this.areaNode.getElement(".o2_statement_statementDesignerJpqlLine");
  186. this.countJpqlTabPageNode = this.areaNode.getElement(".o2_statement_statementCountJpqlTabPageNode");
  187. this.countJpqlArea = this.areaNode.getElement(".o2_statement_statementDesignerCountJpql");
  188. this.countScriptArea = this.areaNode.getElement(".o2_statement_statementDesignerCountScript");
  189. this.countJpqlEditorNode = this.areaNode.getElement(".o2_statement_statementDesignerCountJpqlLine");
  190. this.loadJpqlTab();
  191. this.resizeNode = this.areaNode.getElement(".o2_statement_resizeNode");
  192. this.tabNode = this.areaNode.getElement(".o2_statement_tabNode");
  193. this.runArea = this.areaNode.getElement(".o2_statement_statementRunNode");
  194. // this.runTitleNode = this.areaNode.getElement(".o2_statement_statementRunTitleNode");
  195. this.runContentNode = this.areaNode.getElement(".o2_statement_statementRunContentNode");
  196. this.runJsonNode = this.runContentNode.getFirst();
  197. this.runActionNode = this.runJsonNode.getNext();
  198. this.runResultNode = this.runContentNode.getLast();
  199. this.setRunnerSize();
  200. this.designer.addEvent("resize", this.setRunnerSize.bind(this));
  201. if (this.json.format == "script") {
  202. this.loadStatementScriptEditor();
  203. this.loadStatementCountScriptEditor();
  204. } else {
  205. this.loadStatementEditor();
  206. this.loadStatementCountEditor();
  207. }
  208. this.loadStatementRunner();
  209. this.viewArea = this.areaNode.getElement(".o2_statement_viewNode");
  210. this.loadView();
  211. this.loadTab();
  212. this.setEvent();
  213. this.loadVerticalResize();
  214. }.bind(this));
  215. },
  216. loadVerticalResize: function(){
  217. this.verticalResize = new Drag(this.resizeNode, {
  218. "snap": 10,
  219. "onStart": function(el, e){
  220. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  221. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  222. el.store("position", {"x": x, "y": y});
  223. var size = this.designerArea.getSize(); //designerArea
  224. el.store("initialHeight", size.y);
  225. var allSize = this.areaNode.getSize();
  226. el.store("initialAllHeight", allSize.y);
  227. }.bind(this),
  228. "onDrag": function(el, e){
  229. var allHeight = el.retrieve("initialAllHeight").toFloat(); //this.areaNode.getSize();
  230. // var x = e.event.x;
  231. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  232. var position = el.retrieve("position");
  233. var dy = y.toFloat()-position.y.toFloat();
  234. var initialHeight = el.retrieve("initialHeight").toFloat();
  235. var height = initialHeight+dy;
  236. if (height < 180) height = 180;
  237. if (height > allHeight-180) height = allHeight-180;
  238. this.designerAreaPercent = height/allHeight;
  239. this.setVerticalResize();
  240. }.bind(this)
  241. });
  242. },
  243. setVerticalResize: function(){
  244. var size = this.areaNode.getSize();
  245. var height = size.y;
  246. var designAreaHeight = this.designerAreaPercent*height - 52;
  247. // var runAreaHeight = height-designAreaHeight;
  248. this.designerArea.setStyle("height", ""+designAreaHeight+"px");
  249. debugger;
  250. var editorHeight = designAreaHeight - 98;
  251. if(this.jpqlEditorNode)this.jpqlEditorNode.setStyle( "height", ""+editorHeight+"px" );
  252. if(this.countJpqlEditorNode)this.countJpqlEditorNode.setStyle( "height", ""+editorHeight+"px" );
  253. if(this.scriptArea)this.scriptArea.setStyle( "height", ""+editorHeight+"px" );
  254. if(this.countScriptArea)this.countScriptArea.setStyle( "height", ""+editorHeight+"px" );
  255. if( this.editor )this.editor.resize();
  256. if( this.countEditor )this.countEditor.resize();
  257. if( this.scriptEditor ){
  258. this.scriptEditor.container.setStyle("height", ""+editorHeight+"px");
  259. this.scriptEditor.resizeContentNodeSize();
  260. }
  261. if( this.countScriptEditor ){
  262. this.countScriptEditor.container.setStyle("height", ""+editorHeight+"px");
  263. this.countScriptEditor.resizeContentNodeSize();
  264. }
  265. // this.tabNode.setStyle("height", ""+runAreaHeight+"px");
  266. this.setRunnerSize();
  267. if( this.view ){
  268. this.setViewSize();
  269. this.view.setContentHeight()
  270. }
  271. },
  272. loadStatementScriptEditor: function () {
  273. if (!this.scriptEditor) {
  274. debugger;
  275. o2.require("o2.widget.ScriptArea", function () {
  276. this.scriptEditor = new o2.widget.ScriptArea(this.scriptArea, {
  277. "isbind": false,
  278. "maxObj": this.designer.designNode,
  279. "title": this.designer.lp.scriptTitle,
  280. "onChange": function () {
  281. this.json.scriptText = this.scriptEditor.toJson().code;
  282. }.bind(this)
  283. });
  284. this.scriptEditor.load({"code": this.json.scriptText})
  285. }.bind(this), false);
  286. }
  287. },
  288. loadStatementCountScriptEditor: function () {
  289. if (!this.countScriptEditor) {
  290. debugger;
  291. o2.require("o2.widget.ScriptArea", function () {
  292. this.countScriptEditor = new o2.widget.ScriptArea(this.countScriptArea, {
  293. "isbind": false,
  294. "maxObj": this.designer.designNode,
  295. "title": this.designer.lp.scriptTitle,
  296. "onChange": function () {
  297. this.json.countScriptText = this.countScriptEditor.toJson().code;
  298. }.bind(this)
  299. });
  300. this.countScriptEditor.load({"code": this.json.countScriptText})
  301. }.bind(this), false);
  302. }
  303. },
  304. setRunnerSize: function () {
  305. debugger;
  306. var size = this.areaNode.getSize();
  307. var designerSize = this.designerArea.getComputedSize();
  308. var reizeNodeSize = this.resizeNode.getComputedSize();
  309. var y = size.y - designerSize.totalHeight - reizeNodeSize.totalHeight;
  310. var mTop = this.runArea.getStyle("margin-top").toInt();
  311. var mBottom = this.runArea.getStyle("margin-bottom").toInt();
  312. var pTop = this.runArea.getStyle("padding-top").toInt();
  313. var pBottom = this.runArea.getStyle("padding-bottom").toInt();
  314. y = y - mTop - mBottom - pTop - pBottom - 5;
  315. var tabSize = this.tabNode.getComputedSize();
  316. y = y - tabSize.totalHeight;
  317. this.runArea.setStyle("height", "" + y + "px");
  318. // var titleSize = this.runTitleNode.getComputedSize();
  319. // y = y - titleSize.totalHeight;
  320. this.runContentNode.setStyle("height", "" + y + "px");
  321. },
  322. loadStatementEditor: function () {
  323. if (!this.editor) {
  324. o2.require("o2.widget.JavascriptEditor", function () {
  325. this.editor = new o2.widget.JavascriptEditor(this.jpqlEditorNode, {
  326. "title": "JPQL",
  327. "option": {"mode": "sql"}
  328. });
  329. this.editor.load(function () {
  330. if (this.json.data) {
  331. this.editor.editor.setValue(this.json.data);
  332. } else {
  333. var table = "table";
  334. switch (this.json.type) {
  335. case "update":
  336. this.editor.editor.setValue("UPDATE " + table + " o SET ");
  337. break;
  338. case "delete":
  339. this.editor.editor.setValue("DELETE " + table + " o WHERE ");
  340. break;
  341. default:
  342. this.editor.editor.setValue("SELECT o FROM " + table + " o");
  343. }
  344. }
  345. this.json.data = this.editor.editor.getValue();
  346. this.editor.addEditorEvent("change", function () {
  347. debugger;
  348. this.data.data = this.editor.getValue();
  349. this.checkJpqlType();
  350. }.bind(this));
  351. // this.editor.editor.on("change", function(){
  352. // this.data.data = this.editor.getValue();
  353. // this.checkJpqlType();
  354. // }.bind(this));
  355. }.bind(this));
  356. }.bind(this), false);
  357. }
  358. },
  359. loadStatementCountEditor: function () {
  360. if (!this.countEditor) {
  361. o2.require("o2.widget.JavascriptEditor", function () {
  362. this.countEditor = new o2.widget.JavascriptEditor(this.countJpqlEditorNode, {
  363. "title": "JPQL",
  364. "option": {"mode": "sql"}
  365. });
  366. this.countEditor.load(function () {
  367. if (this.json.countData) {
  368. this.countEditor.editor.setValue(this.json.countData);
  369. } else {
  370. var table = "table";
  371. this.countEditor.editor.setValue("SELECT count(o.id) FROM " + table + " o");
  372. }
  373. this.json.countData = this.countEditor.editor.getValue();
  374. this.countEditor.addEditorEvent("change", function () {
  375. debugger;
  376. this.data.countData = this.countEditor.getValue();
  377. }.bind(this));
  378. // this.editor.editor.on("change", function(){
  379. // this.data.data = this.editor.getValue();
  380. // this.checkJpqlType();
  381. // }.bind(this));
  382. }.bind(this));
  383. }.bind(this), false);
  384. }
  385. },
  386. setSatementTable: function () {
  387. if (!this.json.type) this.json.type = "select";
  388. this.changeType(this.json.type, true);
  389. if (this.json.data) {
  390. this.editor.editor.setValue(this.json.data);
  391. } else {
  392. var table = (this.json.tableObj) ? this.json.tableObj.name : "table";
  393. switch (this.json.type) {
  394. case "update":
  395. this.editor.editor.setValue("UPDATE " + table + " o SET ");
  396. break;
  397. case "delete":
  398. this.editor.editor.setValue("DELETE " + table + " o WHERE ");
  399. break;
  400. default:
  401. this.editor.editor.setValue("SELECT o FROM " + table + " o");
  402. }
  403. }
  404. },
  405. checkJpqlType: function () {
  406. var str = this.json.data;
  407. this.json.data = str;
  408. var jpql_select = /^select/i;
  409. var jpql_update = /^update/i;
  410. var jpql_delete = /^delete/i;
  411. if (jpql_select.test(str)) return this.changeType("select");
  412. if (jpql_update.test(str)) return this.changeType("update");
  413. if (jpql_delete.test(str)) return this.changeType("delete");
  414. },
  415. changeType: function (type, force) {
  416. if (this.json.type != type) this.json.type = type;
  417. if (type != this.jpqlTypeSelect.options[this.jpqlTypeSelect.selectedIndex].value || force) {
  418. for (var i = 0; i < this.jpqlTypeSelect.options.length; i++) {
  419. if (this.jpqlTypeSelect.options[i].value == type) {
  420. this.jpqlTypeSelect.options[i].set("selected", true);
  421. break;
  422. }
  423. }
  424. }
  425. },
  426. loadStatementHtml: function (callback) {
  427. this.areaNode.loadAll({
  428. "css": this.path + this.options.style + "/statement.css",
  429. "html": this.path + "statementDesigner.html"
  430. }, {
  431. "bind": {"lp": this.designer.lp, "data": this.data}
  432. }, function () {
  433. if (callback) callback();
  434. }.bind(this));
  435. },
  436. loadStatementRunner: function () {
  437. o2.require("o2.widget.JavascriptEditor", function () {
  438. this.jsonEditor = new o2.widget.JavascriptEditor(this.runJsonNode, {
  439. "title": "JPQL",
  440. "option": {"mode": "json"}
  441. });
  442. this.jsonEditor.load(function () {
  443. this.jsonEditor.editor.setValue(this.data.testParameters || "{}");
  444. }.bind(this));
  445. }.bind(this), false);
  446. },
  447. setEvent: function () {
  448. this.designerArea.addEvent("click", function (e) {
  449. this.selected();
  450. e.stopPropagation();
  451. }.bind(this));
  452. this.formatTypeArea.getElements("input").addEvent("click", function (e) {
  453. if (e.target.checked) {
  454. var v = e.target.get("value");
  455. if (v === "script") {
  456. this.scriptArea.show();
  457. this.jpqlArea.hide();
  458. this.loadStatementScriptEditor();
  459. this.countScriptArea.show();
  460. this.countJpqlArea.hide();
  461. this.loadStatementCountScriptEditor();
  462. } else {
  463. this.scriptArea.hide();
  464. this.jpqlArea.show();
  465. this.loadStatementEditor();
  466. this.countScriptArea.hide();
  467. this.countJpqlArea.show();
  468. this.loadStatementCountEditor();
  469. }
  470. this.json.format = v;
  471. }
  472. }.bind(this));
  473. this.entityCategorySelect.addEvent("change", function (e) {
  474. var entityCategory = e.target.options[e.target.selectedIndex].value;
  475. switch (entityCategory) {
  476. case "dynamic":
  477. this.officialTableArea.hide();
  478. this.dynamicTableArea.show();
  479. this.customTableArea.hide();
  480. break;
  481. case "custom":
  482. this.officialTableArea.hide();
  483. this.dynamicTableArea.hide();
  484. this.customTableArea.show();
  485. break;
  486. default:
  487. this.officialTableArea.show();
  488. this.dynamicTableArea.hide();
  489. this.customTableArea.hide();
  490. break;
  491. }
  492. this.json.entityCategory = entityCategory
  493. }.bind(this));
  494. //@todo change table
  495. this.officialTableSelect.addEvent("change", function (e) {
  496. debugger;
  497. var entityClassName = e.target.options[e.target.selectedIndex].value;
  498. this.json.entityClassName = entityClassName;
  499. if (this.json.format == "jpql") {
  500. if (this.editor) {
  501. var re = /(.*from\s*)/ig;
  502. if (this.json.type == "update") re = /(.*update\s*)/ig;
  503. //if (this.json.type=="select" && this.editor){
  504. var v = this.json.data;
  505. var re2 = /(\s+)/ig;
  506. var arr = re.exec(v);
  507. if (arr && arr[0]) {
  508. var left = arr[0]
  509. v = v.substring(left.length, v.length);
  510. //var ar = re2.exec(v);
  511. var right = v.substring(v.indexOf(" "), v.length);
  512. this.json.data = left + entityClassName + right;
  513. this.editor.editor.setValue(this.json.data);
  514. }
  515. //}
  516. }
  517. }
  518. // var className = e.target.options[e.target.selectedIndex].value;
  519. // if (this.json.type=="select"){
  520. // this.json.data
  521. // /(select)*(where|)/g
  522. // }
  523. // }.bind(this));
  524. // this.jpqlTypeSelect.addEvent("change", function(){
  525. // var type = e.target.options[e.target.selectedIndex].value;
  526. // switch (entityCategory) {
  527. // case "update":
  528. // this.jpqlSelectEditor.hide();
  529. // this.jpqlUpdateEditor.show();
  530. // this.jpqlDeleteEditor.hide();
  531. // this.loadJpqlUpdateEditor();
  532. // break;
  533. // case "delete":
  534. // this.jpqlSelectEditor.hide();
  535. // this.jpqlUpdateEditor.hide();
  536. // this.jpqlDeleteEditor.show();
  537. // break;
  538. // default:
  539. // this.jpqlSelectEditor.show();
  540. // this.jpqlUpdateEditor.hide();
  541. // this.jpqlDeleteEditor.hide();
  542. // break;
  543. // }
  544. }.bind(this));
  545. this.runActionNode.getFirst().addEvent("click", this.runStatement.bind(this));
  546. this.dynamicTableSelect.addEvent("click", this.selectTable.bind(this));
  547. this.jpqlTypeSelect.addEvent("change", function () {
  548. var t = this.jpqlTypeSelect.options[this.jpqlTypeSelect.selectedIndex].value;
  549. if (t != this.json.type) {
  550. this.json.type = t;
  551. }
  552. if (t != "select") {
  553. this.jpqlPage.showTabIm();
  554. this.countJpqlPage.disableTab();
  555. this.runPage.showTabIm();
  556. this.viewPage.disableTab();
  557. } else {
  558. this.countJpqlPage.enableTab(true);
  559. this.viewPage.enableTab(true);
  560. }
  561. }.bind(this));
  562. },
  563. selectTable: function () {
  564. new MWF.O2Selector(this.designer.content, {
  565. "type": "queryTable",
  566. "count": 1,
  567. "values": (this.json.table) ? [this.json.table] : [],
  568. "title": this.designer.lp.selectTable,
  569. "onComplete": function (items) {
  570. if (items.length) {
  571. var id = items[0].data.id;
  572. var name = items[0].data.name;
  573. this.dynamicTableContent.set("text", name);
  574. this.json.table = name;
  575. this.json.tableObj = items[0].data;
  576. } else {
  577. this.dynamicTableContent.set("text", "");
  578. this.json.table = "";
  579. }
  580. }.bind(this)
  581. });
  582. },
  583. runStatement: function () {
  584. debugger;
  585. // if (!this.json.data){
  586. // this.designer.notice(this.designer.lp.inputStatementData, "error");
  587. // return false;
  588. // }
  589. o2.require("o2.widget.Mask", null, false);
  590. this.runMask = new o2.widget.Mask();
  591. this.runMask.loadNode(this.node);
  592. this.saveSilence(function () {
  593. debugger;
  594. this.execute(function (json) {
  595. this.executeData = json;
  596. o2.require("o2.widget.JsonParse", function () {
  597. this.runResultNode.empty();
  598. var jsonResult = new o2.widget.JsonParse(json, this.runResultNode);
  599. jsonResult.load();
  600. }.bind(this));
  601. if (this.view) {
  602. var flag = true;
  603. if (this.data.type !== "select") flag = false;
  604. if (this.data.format === "script" && !this.data.scriptText) flag = false;
  605. if (this.data.format !== "script" && !this.data.data) flag = false;
  606. if (flag) this.view.loadViewData();
  607. }
  608. this.setColumnDataPath(json);
  609. this.runMask.hide();
  610. }.bind(this), function () {
  611. if (this.runMask) this.runMask.hide();
  612. }.bind(this))
  613. // var json = this.jsonEditor.editor.getValue();
  614. // var o = JSON.parse(json);
  615. //
  616. // var mode = "data";
  617. // if( this.data.type === "select" ){
  618. // if( this.data.format === "script" ){
  619. // if( this.data.scriptText && this.data.countScriptText ){
  620. // mode = "all"
  621. // }else if( this.data.scriptText && !this.data.countScriptText ){
  622. // mode = "data"
  623. // }else if( !this.data.scriptText && this.data.countScriptText ){
  624. // mode = "count"
  625. // }else{
  626. // this.designer.notice(this.designer.lp.inputStatementData, "error");
  627. // return false;
  628. // }
  629. // }else{
  630. // if( this.data.data && this.data.countData ){
  631. // mode = "all"
  632. // }else if( this.data.data && !this.data.countData ){
  633. // mode = "data"
  634. // }else if( !this.data.data && this.data.countData ){
  635. // mode = "count"
  636. // }else{
  637. // this.designer.notice(this.designer.lp.inputStatementData, "error");
  638. // return false;
  639. // }
  640. // }
  641. // }
  642. // o2.Actions.load("x_query_assemble_designer").StatementAction.executeV2(this.json.id, mode, 1, 50 , o, function(json){
  643. // o2.require("o2.widget.JsonParse", function(){
  644. // this.runResultNode.empty();
  645. // var jsonResult = new o2.widget.JsonParse(json, this.runResultNode);
  646. // jsonResult.load();
  647. // }.bind(this));
  648. // this.runMask.hide();
  649. // }.bind(this), function(xhr, text, error){
  650. // debugger;
  651. // if (this.runMask) this.runMask.hide();
  652. // var errorText = error;
  653. // if (xhr){
  654. // var json = JSON.decode(xhr.responseText);
  655. // if (json){
  656. // errorText = json.message.trim() || "request json error";
  657. // }else{
  658. // errorText = "request json error: "+xhr.responseText;
  659. // }
  660. // }
  661. // errorText = errorText.replace(/\</g, "&lt;");
  662. // errorText = errorText.replace(/\</g, "&gt;");
  663. // MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  664. // }.bind(this))
  665. }.bind(this));
  666. },
  667. setColumnDataPath: function (json) {
  668. if (this.data.type !== "select") return;
  669. if (this.data.format === "script" && !this.data.scriptText) return;
  670. if (this.data.format !== "script" && !this.data.data) return;
  671. this.columnDataPathList = [];
  672. debugger;
  673. var addPath = function (value, key) {
  674. if (typeOf(value) === "array") {
  675. Array.each(value, function (v, idx) {
  676. var path = (key || typeOf(key) === "number") ? (key + "." + idx) : idx.toString();
  677. if (!this.columnDataPathList.contains(path)) this.columnDataPathList.push(path);
  678. if (typeOf(v) === "array" || typeOf(v) === "object") addPath(v, path);
  679. }.bind(this))
  680. } else if (typeOf(value) === "object") {
  681. Object.each(value, function (v, k) {
  682. var path = (key || typeOf(key) === "number") ? (key + "." + k) : k;
  683. if (!this.columnDataPathList.contains(path)) this.columnDataPathList.push(path);
  684. if (typeOf(v) === "array" || typeOf(v) === "object") addPath(v, path);
  685. addPath(v, path);
  686. }.bind(this))
  687. } else {
  688. // if( key && !this.columnDataPathList.indexOf(key) )this.columnDataPathList.push(key);
  689. }
  690. }.bind(this);
  691. for (var i = 0; i < json.data.length && i < 10; i++) {
  692. var d = json.data[i];
  693. addPath(d);
  694. }
  695. this.columnDataPathList.sort();
  696. if (this.view && this.view.items) {
  697. this.view.items.each(function (column) {
  698. column.refreshColumnPathData()
  699. })
  700. }
  701. },
  702. getColumnDataPath: function () {
  703. return this.columnDataPathList || [];
  704. },
  705. execute: function (success, failure) {
  706. var json = this.jsonEditor.editor.getValue();
  707. var o = JSON.parse(json);
  708. var mode = "data";
  709. if (this.data.type === "select") {
  710. if (this.data.format === "script") {
  711. if (this.data.scriptText && this.data.countScriptText) {
  712. mode = "all"
  713. } else if (this.data.scriptText && !this.data.countScriptText) {
  714. mode = "data"
  715. } else if (!this.data.scriptText && this.data.countScriptText) {
  716. mode = "count"
  717. } else {
  718. this.designer.notice(this.designer.lp.inputStatementData, "error");
  719. return false;
  720. }
  721. } else {
  722. if (this.data.data && this.data.countData) {
  723. mode = "all"
  724. } else if (this.data.data && !this.data.countData) {
  725. mode = "data"
  726. } else if (!this.data.data && this.data.countData) {
  727. mode = "count"
  728. } else {
  729. this.designer.notice(this.designer.lp.inputStatementData, "error");
  730. return false;
  731. }
  732. }
  733. }
  734. o2.Actions.load("x_query_assemble_designer").StatementAction.executeV2(this.json.id, mode, 1, 50, o, function (json) {
  735. if (success) success(json)
  736. }.bind(this), function (xhr, text, error) {
  737. debugger;
  738. if (failure) failure();
  739. var errorText = error;
  740. if (xhr) {
  741. var json = JSON.decode(xhr.responseText);
  742. if (json) {
  743. errorText = json.message.trim() || "request json error";
  744. } else {
  745. errorText = "request json error: " + xhr.responseText;
  746. }
  747. }
  748. errorText = errorText.replace(/\</g, "&lt;");
  749. errorText = errorText.replace(/\</g, "&gt;");
  750. MWF.xDesktop.notice("error", {x: "right", y: "top"}, errorText);
  751. }.bind(this))
  752. },
  753. save: function (callback) {
  754. debugger;
  755. if (!this.data.name) {
  756. this.designer.notice(this.designer.lp.inputStatementName, "error");
  757. return false;
  758. }
  759. if (typeOf(this.viewJson) === "object") {
  760. this.data.view = JSON.stringify(this.viewJson);
  761. if(!this.data.view.group)this.data.view.group = {};
  762. }
  763. //if( !this.data.tableType ){
  764. // this.data.tableType = "dynamic";
  765. //}
  766. if (this.editor) this.data.data = this.editor.editor.getValue();
  767. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  768. if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue();
  769. this.designer.actions.saveStatement(this.data, function (json) {
  770. this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  771. this.data.id = json.data.id;
  772. if (this.lisNode) {
  773. this.lisNode.getLast().set("text", this.data.name + "(" + this.data.alias + ")");
  774. }
  775. if (callback) callback();
  776. }.bind(this));
  777. },
  778. _setEditStyle: function () {
  779. },
  780. saveSilence: function (callback) {
  781. if (!this.data.name) {
  782. this.designer.notice(this.designer.lp.inputStatementName, "error");
  783. return false;
  784. }
  785. if (typeOf(this.viewJson) === "object") {
  786. this.data.view = JSON.stringify(this.viewJson);
  787. }
  788. if (this.editor) this.data.data = this.editor.editor.getValue();
  789. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  790. if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue();
  791. this.designer.actions.saveStatement(this.data, function (json) {
  792. //this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  793. this.data.id = json.data.id;
  794. if (this.lisNode) {
  795. this.lisNode.getLast().set("text", this.data.name + "(" + this.data.alias + ")");
  796. }
  797. if (callback) callback();
  798. }.bind(this));
  799. },
  800. loadView: function (callback) {
  801. this.setViewSize();
  802. this.designer.addEvent("resize", this.setViewSize.bind(this));
  803. if (!this.data.view) {
  804. this.viewJson = {};
  805. } else {
  806. this.viewJson = JSON.parse(this.data.view)
  807. }
  808. this.view = new MWF.xApplication.query.StatementDesigner.View(this.designer, this, this.viewJson, {});
  809. this.view.load(function () {
  810. this.view.setContentHeight();
  811. }.bind(this));
  812. },
  813. setViewSize: function () {
  814. debugger;
  815. var size = this.areaNode.getSize();
  816. var designerSize = this.designerArea.getComputedSize();
  817. var reizeNodeSize = this.resizeNode.getComputedSize();
  818. var y = size.y - designerSize.totalHeight - reizeNodeSize.totalHeight;
  819. var mTop = this.viewArea.getStyle("margin-top").toInt();
  820. var mBottom = this.viewArea.getStyle("margin-bottom").toInt();
  821. var pTop = this.viewArea.getStyle("padding-top").toInt();
  822. var pBottom = this.viewArea.getStyle("padding-bottom").toInt();
  823. y = y - mTop - mBottom - pTop - pBottom - 1;
  824. var tabSize = this.tabNode.getComputedSize();
  825. y = y - tabSize.totalHeight;
  826. this.viewArea.setStyle("height", "" + y + "px");
  827. // var titleSize = this.runTitleNode.getComputedSize();
  828. // y = y - titleSize.totalHeight;
  829. // this.runContentNode.setStyle("height", ""+y+"px");
  830. },
  831. preview: function () {
  832. if (this.isNewStatement) {
  833. this.designer.notice(this.designer.lp.saveStatementNotice, "error");
  834. return;
  835. }
  836. if (this.data.type !== "select") {
  837. this.designer.notice(this.designer.lp.previewNotSelectStatementNotice, "error");
  838. return;
  839. }
  840. if (!this.data.view) {
  841. this.designer.notice(this.designer.lp.noViewNotice, "error");
  842. }
  843. this.saveSilence(function () {
  844. var url = "../x_desktop/app.html?app=query.Query&status=";
  845. url += JSON.stringify({
  846. id: this.data.application,
  847. statementId: this.data.id
  848. });
  849. window.open(o2.filterUrl(url), "_blank");
  850. }.bind(this));
  851. }
  852. });
  853. MWF.xApplication.query.StatementDesigner.View = new Class({
  854. Extends: MWF.xApplication.query.ViewDesigner.View,
  855. Implements: [Options, Events],
  856. options: {
  857. "style": "default",
  858. "isView": false,
  859. "showTab": true,
  860. "propertyPath": "../x_component_query_StatementDesigner/$Statement/view.html"
  861. },
  862. initialize: function (designer, statement, data, options) {
  863. this.setOptions(options);
  864. this.path = "../x_component_query_ViewDesigner/$View/";
  865. this.cssPath = "../x_component_query_ViewDesigner/$View/" + this.options.style + "/css.wcss";
  866. this._loadCss();
  867. this.statement = statement;
  868. this.designer = designer;
  869. this.data = data;
  870. // if (!this.data.data) this.data.data = {};
  871. this.parseData();
  872. this.node = this.statement.viewArea;
  873. //this.tab = this.designer.tab;
  874. this.areaNode = new Element("div", {"styles": {"height": "calc(100% - 2px)", "overflow": "auto"}});
  875. this.areaNode.setStyles(this.css.areaNode);
  876. //MWF.require("MWF.widget.ScrollBar", function(){
  877. // new MWF.widget.ScrollBar(this.areaNode, {"distance": 100});
  878. //}.bind(this));
  879. // this.propertyListNode = this.designer.propertyDomArea;
  880. //this.propertyNode = this.designer.propertyContentArea;
  881. // if(this.designer.application) this.data.applicationName = this.designer.application.name;
  882. // if(this.designer.application) this.data.application = this.designer.application.id;
  883. // this.isNewView = (this.data.name) ? false : true;
  884. this.items = [];
  885. this.view = this;
  886. // this.autoSave();
  887. // this.designer.addEvent("queryClose", function(){
  888. // if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  889. // }.bind(this));
  890. },
  891. load: function (callback) {
  892. this.setAreaNodeSize();
  893. this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  894. this.areaNode.inject(this.node);
  895. this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
  896. this.loadTemplateStyle(function () {
  897. this.loadActionbar();
  898. this.loadView();
  899. this.loadPaging();
  900. // this.selected();
  901. this.setEvent();
  902. //if (this.options.showTab) this.page.showTabIm();
  903. this.setViewWidth();
  904. this.designer.addEvent("resize", this.setViewWidth.bind(this));
  905. if (callback) callback();
  906. }.bind(this))
  907. },
  908. parseData: function () {
  909. this.json = this.data;
  910. if (!this.json.id) {
  911. this.json.id = (new o2.widget.UUID).id;
  912. }
  913. if (!this.json.data || !this.json.data.events) {
  914. var url = "../x_component_query_StatementDesigner/$Statement/view.json";
  915. MWF.getJSON(url, {
  916. "onSuccess": function (obj) {
  917. if (!this.json.data) this.json.data = obj.data;
  918. if (!this.json.data.events) this.json.data.events = obj.data.events;
  919. }.bind(this),
  920. "onerror": function (text) {
  921. this.notice(text, "error");
  922. }.bind(this),
  923. "onRequestFailure": function (xhr) {
  924. this.notice(xhr.responseText, "error");
  925. }.bind(this)
  926. }, false);
  927. }
  928. },
  929. setEvent: function () {
  930. this.areaNode.addEvents({
  931. "click": function (e) {
  932. this.selected();
  933. e.stopPropagation();
  934. }.bind(this),
  935. "mouseover": function () {
  936. if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode_over)
  937. }.bind(this),
  938. "mouseout": function () {
  939. if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode)
  940. }.bind(this)
  941. });
  942. this.refreshNode.addEvent("click", function (e) {
  943. this.statement.runStatement();
  944. e.stopPropagation();
  945. }.bind(this));
  946. this.addColumnNode.addEvent("click", function (e) {
  947. this.addColumn();
  948. e.stopPropagation();
  949. }.bind(this));
  950. },
  951. selected: function () {
  952. debugger;
  953. if (this.statement.currentSelectedModule) {
  954. if (this.statement.currentSelectedModule == this) {
  955. return true;
  956. } else {
  957. this.statement.currentSelectedModule.unSelected();
  958. }
  959. }
  960. this.areaNode.setStyles(this.css.areaNode_selected);
  961. this.statement.currentSelectedModule = this;
  962. this.domListNode.show();
  963. this.isSelected = true;
  964. this.showProperty();
  965. },
  966. unSelected: function () {
  967. this.statement.currentSelectedModule = null;
  968. this.isSelected = false;
  969. this.areaNode.setStyles(this.css.areaNode);
  970. this.hideProperty();
  971. },
  972. showProperty: function () {
  973. if (!this.property) {
  974. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  975. "path": this.options.propertyPath,
  976. "onPostLoad": function () {
  977. this.property.show();
  978. }.bind(this)
  979. });
  980. this.property.load();
  981. } else {
  982. this.property.show();
  983. }
  984. },
  985. hideProperty: function () {
  986. if (this.property) this.property.hide();
  987. },
  988. loadViewData: function () {
  989. debugger;
  990. if (this.data.id) {
  991. // this.statement.saveSilence(function () {
  992. this.viewContentBodyNode.empty();
  993. this.viewContentTableNode = new Element("table", {
  994. "styles": this.css.viewContentTableNode,
  995. "border": "0px",
  996. "cellPadding": "0",
  997. "cellSpacing": "0"
  998. }).inject(this.viewContentBodyNode);
  999. // this.statement.execute( function (json) {
  1000. // this.statement.setColumnDataPath( json );
  1001. var entries = {};
  1002. this.json.data.selectList.each(function (entry) {
  1003. entries[entry.column] = entry;
  1004. }.bind(this));
  1005. if (this.statement.executeData && this.statement.executeData.data && this.statement.executeData.data.length) {
  1006. this.statement.executeData.data.each(function (line, idx) {
  1007. var tr = new Element("tr", {
  1008. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode
  1009. }).inject(this.viewContentTableNode);
  1010. //this.createViewCheckboxTd( tr );
  1011. Object.each(entries, function (c, k) {
  1012. debugger;
  1013. var path = c.path, code = c.code, obj = line;
  1014. if( path ){
  1015. var pathList = path.split(".");
  1016. for( var i=0; i<pathList.length; i++ ){
  1017. var p = pathList[i];
  1018. if( (/(^[1-9]\d*$)/.test(p)) )p = p.toInt();
  1019. if( obj[ p ] ){
  1020. obj = obj[ p ];
  1021. }else{
  1022. obj = "";
  1023. break;
  1024. }
  1025. }
  1026. }
  1027. if( code && code.trim())obj = MWF.Macro.exec( code, { "target" : {"value": obj, "data": line, "entry": c} });
  1028. var toName = function (value) {
  1029. if(typeOf(value) === "array"){
  1030. Array.each( value, function (v, idx) {
  1031. value[idx] = toName(v)
  1032. })
  1033. }else if( typeOf(value) === "object" ){
  1034. Object.each( value, function (v, key) {
  1035. value[key] = toName(v);
  1036. })
  1037. }else if( typeOf( value ) === "string" ){
  1038. value = o2.name.cn( value )
  1039. }
  1040. return value;
  1041. };
  1042. var d;
  1043. if( obj!= undefined && obj!= null ){
  1044. if( typeOf(obj) === "array" ) {
  1045. d = c.isName ? JSON.stringify(toName(Array.clone(obj))) : JSON.stringify(obj);
  1046. }else if( typeOf(obj) === "object" ){
  1047. d = c.isName ? JSON.stringify(toName(Object.clone(obj))) : JSON.stringify(obj);
  1048. }else{
  1049. d = c.isName ? o2.name.cn( obj.toString() ) : obj;
  1050. }
  1051. }
  1052. if (d != undefined && d != null ) {
  1053. var td = new Element("td", {
  1054. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
  1055. }).inject(tr);
  1056. if (c.isHtml) {
  1057. td.set("html", d);
  1058. } else {
  1059. td.set("text", d);
  1060. }
  1061. }
  1062. }.bind(this));
  1063. }.bind(this));
  1064. this.setContentColumnWidth();
  1065. this.setContentHeight();
  1066. } else if (this.json.data.noDataText) {
  1067. var noDataTextNodeStyle = this.css.noDataTextNode;
  1068. if (this.json.data.viewStyles) {
  1069. if (this.json.data.viewStyles["noDataTextNode"]) {
  1070. noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
  1071. } else {
  1072. this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
  1073. }
  1074. }
  1075. this.noDataTextNode = new Element("div", {
  1076. "styles": noDataTextNodeStyle,
  1077. "text": this.json.data.noDataText
  1078. }).inject(this.viewContentBodyNode);
  1079. }
  1080. // }.bind(this));
  1081. // }.bind(this));
  1082. }
  1083. },
  1084. addColumn: function () {
  1085. debugger;
  1086. MWF.require("MWF.widget.UUID", function () {
  1087. var id = (new MWF.widget.UUID).id;
  1088. var json = {
  1089. "id": id,
  1090. "column": id,
  1091. "displayName": this.designer.lp.unnamed,
  1092. "orderType": "original"
  1093. };
  1094. if (!this.json.data.selectList) this.json.data.selectList = [];
  1095. this.json.data.selectList.push(json);
  1096. var column = new MWF.xApplication.query.StatementDesigner.View.Column(json, this);
  1097. this.items.push(column);
  1098. column.selected();
  1099. if (this.viewContentTableNode) {
  1100. var trs = this.viewContentTableNode.getElements("tr");
  1101. trs.each(function (tr) {
  1102. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  1103. }.bind(this));
  1104. //this.setContentColumnWidth();
  1105. }
  1106. this.setViewWidth();
  1107. this.addColumnNode.scrollIntoView(true);
  1108. }.bind(this));
  1109. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  1110. },
  1111. setContentHeight: function () {
  1112. var size = this.areaNode.getSize();
  1113. var titleSize = this.viewTitleNode.getSize();
  1114. var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x: 0, y: 0};
  1115. var pagingSize = this.pagingNode ? this.pagingNode.getSize() : {x: 0, y: 0};
  1116. var height = size.y - titleSize.y - actionbarSize.y - pagingSize.y - 4;
  1117. this.viewContentScrollNode.setStyle("height", height);
  1118. var contentSize = this.viewContentBodyNode.getSize();
  1119. if (height < contentSize.y) height = contentSize.y + 10;
  1120. this.viewContentNode.setStyle("height", height);
  1121. this.contentLeftNode.setStyle("height", height);
  1122. this.contentRightNode.setStyle("height", height);
  1123. //this.viewContentBodyNode.setStyle("min-height", height);
  1124. },
  1125. loadViewColumns: function () {
  1126. // for (var i=0; i<10; i++){
  1127. if (this.json.data.selectList) {
  1128. this.json.data.selectList.each(function (json) {
  1129. this.items.push(new MWF.xApplication.query.StatementDesigner.View.Column(json, this));
  1130. }.bind(this));
  1131. }
  1132. // }
  1133. },
  1134. showActionbar: function (noSetHeight) {
  1135. this.actionbarNode.show();
  1136. if (!this.json.data.actionbarList) this.json.data.actionbarList = [];
  1137. if (!this.actionbarList || this.actionbarList.length == 0) {
  1138. if (this.json.data.actionbarList.length) {
  1139. this.json.data.actionbarList.each(function (json) {
  1140. this.actionbarList.push(new MWF.xApplication.query.StatementDesigner.View.Actionbar(json, this.json.data.actionbarList, this))
  1141. }.bind(this));
  1142. } else {
  1143. this.actionbarList.push(new MWF.xApplication.query.StatementDesigner.View.Actionbar(null, this.json.data.actionbarList, this))
  1144. }
  1145. }
  1146. if (!noSetHeight) this.setContentHeight();
  1147. },
  1148. loadPaging: function (noSetHeight) {
  1149. this.pagingNode = new Element("div#pagingNode", {"styles": this.css.pagingNode}).inject(this.areaNode);
  1150. this.pagingList = [];
  1151. if (!this.json.data.pagingList) this.json.data.pagingList = [];
  1152. if (!this.pagingList || this.pagingList.length == 0) {
  1153. if (this.json.data.pagingList.length) {
  1154. this.json.data.pagingList.each(function (json) {
  1155. this.pagingList.push(new MWF.xApplication.query.StatementDesigner.View.Paging(json, this.json.data.pagingList, this))
  1156. }.bind(this));
  1157. } else {
  1158. this.pagingList.push(new MWF.xApplication.query.StatementDesigner.View.Paging(null, this.json.data.pagingList, this))
  1159. }
  1160. }
  1161. // if( !noSetHeight )this.setContentHeight();
  1162. },
  1163. setViewWidth: function () {
  1164. if (!this.viewAreaNode) return;
  1165. this.viewAreaNode.setStyle("width", "auto");
  1166. this.viewTitleNode.setStyle("width", "auto");
  1167. var s1 = this.viewTitleTableNode.getSize();
  1168. var s2 = this.refreshNode.getSize();
  1169. var s3 = this.addColumnNode.getSize();
  1170. var width = s1.x + s2.x + s2.x;
  1171. var size = this.areaNode.getSize();
  1172. if (width > size.x) {
  1173. this.viewTitleNode.setStyle("width", "" + (width - 2) + "px");
  1174. this.viewAreaNode.setStyle("width", "" + (width - 2) + "px");
  1175. } else {
  1176. this.viewTitleNode.setStyle("width", "" + (size.x - 2) + "px");
  1177. this.viewAreaNode.setStyle("width", "" + (size.x - 2) + "px");
  1178. }
  1179. this.setContentColumnWidth();
  1180. this.setContentHeight();
  1181. },
  1182. _setEditStyle: function (name, input, oldValue) {
  1183. if (name == "data.actionbarHidden") {
  1184. if (this.json.data.actionbarHidden) {
  1185. this.hideActionbar()
  1186. } else {
  1187. this.showActionbar()
  1188. }
  1189. }
  1190. if (name == "data.selectAllEnable") {
  1191. if (this.json.data.selectAllEnable) {
  1192. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display", "table-cell");
  1193. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display", "table-cell");
  1194. } else {
  1195. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display", "none");
  1196. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display", "none");
  1197. }
  1198. }
  1199. if (name == "data.viewStyleType") {
  1200. var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
  1201. var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
  1202. this.loadTemplateStyles(file, extendFile, function (templateStyles) {
  1203. this.templateStyles = templateStyles;
  1204. var oldFile, oldExtendFile;
  1205. if (oldValue && this.stylesList[oldValue]) {
  1206. oldFile = this.stylesList[oldValue].file;
  1207. oldExtendFile = this.stylesList[oldValue].extendFile;
  1208. }
  1209. this.loadTemplateStyles(oldFile, oldExtendFile, function (oldTemplateStyles) {
  1210. this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
  1211. if (oldTemplateStyles["view"]) this.clearTemplateStyles(oldTemplateStyles["view"]);
  1212. if (this.templateStyles["view"]) this.setTemplateStyles(this.templateStyles["view"]);
  1213. this.setAllStyles();
  1214. this.actionbarList.each(function (module) {
  1215. if (oldTemplateStyles["actionbar"]) {
  1216. module.clearTemplateStyles(oldTemplateStyles["actionbar"]);
  1217. }
  1218. module.setStyleTemplate();
  1219. module.setAllStyles();
  1220. })
  1221. this.pagingList.each(function (module) {
  1222. if (oldTemplateStyles["paging"]) {
  1223. module.clearTemplateStyles(oldTemplateStyles["paging"]);
  1224. }
  1225. module.setStyleTemplate();
  1226. module.setAllStyles();
  1227. });
  1228. // this.moduleList.each(function(module){
  1229. // if (oldTemplateStyles[module.moduleName]){
  1230. // module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  1231. // }
  1232. // module.setStyleTemplate();
  1233. // module.setAllStyles();
  1234. // }.bind(this));
  1235. }.bind(this))
  1236. }.bind(this))
  1237. }
  1238. if (name == "data.viewStyles") {
  1239. this.setCustomStyles();
  1240. }
  1241. },
  1242. loadTemplateStyle: function (callback) {
  1243. this.loadStylesList(function () {
  1244. var oldStyleValue = "";
  1245. if ((!this.json.data.viewStyleType) || !this.stylesList[this.json.data.viewStyleType]) this.json.data.viewStyleType = "default";
  1246. this.loadTemplateStyles(this.stylesList[this.json.data.viewStyleType].file, this.stylesList[this.json.data.viewStyleType].extendFile,
  1247. function (templateStyles) {
  1248. this.templateStyles = templateStyles;
  1249. if (!this.json.data.viewStyleType) this.json.data.viewStyleType = "default";
  1250. if (this.templateStyles && this.templateStyles["view"]) {
  1251. var viewStyles = Object.clone(this.templateStyles["view"]);
  1252. if (viewStyles.contentGroupTd) delete viewStyles.contentGroupTd;
  1253. if (viewStyles.groupCollapseNode) delete viewStyles.groupCollapseNode;
  1254. if (viewStyles.groupExpandNode) delete viewStyles.groupExpandNode;
  1255. if (!this.json.data.viewStyles) {
  1256. this.json.data.viewStyles = viewStyles;
  1257. } else {
  1258. this.setTemplateStyles(viewStyles);
  1259. }
  1260. }
  1261. this.setCustomStyles();
  1262. if (callback) callback();
  1263. }.bind(this)
  1264. );
  1265. }.bind(this));
  1266. },
  1267. clearTemplateStyles: function (styles) {
  1268. if (styles) {
  1269. if (styles.container) this.removeStyles(styles.container, "container");
  1270. if (styles.table) this.removeStyles(styles.table, "table");
  1271. if (styles.titleTr) this.removeStyles(styles.titleTr, "titleTr");
  1272. if (styles.titleTd) this.removeStyles(styles.titleTd, "titleTd");
  1273. if (styles.contentTr) this.removeStyles(styles.contentTr, "contentTr");
  1274. if (styles.contentSelectedTr) this.removeStyles(styles.contentSelectedTr, "contentSelectedTr");
  1275. if (styles.contentTd) this.removeStyles(styles.contentTd, "contentTd");
  1276. // if (styles.contentGroupTd) this.removeStyles(styles.contentGroupTd, "contentGroupTd");
  1277. // if (styles.groupCollapseNode) this.removeStyles(styles.groupCollapseNode, "groupCollapseNode");
  1278. // if (styles.groupExpandNode) this.removeStyles(styles.groupExpandNode, "groupExpandNode");
  1279. if (styles.checkboxNode) this.removeStyles(styles.checkboxNode, "checkboxNode");
  1280. if (styles.checkedCheckboxNode) this.removeStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  1281. if (styles.radioNode) this.removeStyles(styles.radioNode, "radioNode");
  1282. if (styles.checkedRadioNode) this.removeStyles(styles.checkedRadioNode, "checkedRadioNode");
  1283. if (styles.tableProperties) this.removeStyles(styles.tableProperties, "tableProperties");
  1284. }
  1285. },
  1286. setTemplateStyles: function (styles) {
  1287. if (styles.container) this.copyStyles(styles.container, "container");
  1288. if (styles.table) this.copyStyles(styles.table, "table");
  1289. if (styles.titleTr) this.copyStyles(styles.titleTr, "titleTr");
  1290. if (styles.titleTd) this.copyStyles(styles.titleTd, "titleTd");
  1291. if (styles.contentTr) this.copyStyles(styles.contentTr, "contentTr");
  1292. if (styles.contentSelectedTr) this.copyStyles(styles.contentSelectedTr, "contentSelectedTr");
  1293. if (styles.contentTd) this.copyStyles(styles.contentTd, "contentTd");
  1294. // if (styles.contentGroupTd) this.copyStyles(styles.contentGroupTd, "contentGroupTd");
  1295. // if (styles.groupCollapseNode) this.copyStyles(styles.groupCollapseNode, "groupCollapseNode");
  1296. // if (styles.groupExpandNode) this.copyStyles(styles.groupExpandNode, "groupExpandNode");
  1297. if (styles.checkboxNode) this.copyStyles(styles.checkboxNode, "checkboxNode");
  1298. if (styles.checkedCheckboxNode) this.copyStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  1299. if (styles.radioNode) this.copyStyles(styles.radioNode, "radioNode");
  1300. if (styles.checkedRadioNode) this.copyStyles(styles.checkedRadioNode, "checkedRadioNode");
  1301. if (styles.tableProperties) this.copyStyles(styles.tableProperties, "tableProperties");
  1302. },
  1303. removeStyles: function (from, to) {
  1304. if (this.json.data.viewStyles[to]) {
  1305. Object.each(from, function (style, key) {
  1306. if (this.json.data.viewStyles[to][key] && this.json.data.viewStyles[to][key] == style) {
  1307. delete this.json.data.viewStyles[to][key];
  1308. }
  1309. }.bind(this));
  1310. }
  1311. },
  1312. copyStyles: function (from, to) {
  1313. if (!this.json.data.viewStyles[to]) this.json.data.viewStyles[to] = {};
  1314. Object.each(from, function (style, key) {
  1315. if (!this.json.data.viewStyles[to][key]) this.json.data.viewStyles[to][key] = style;
  1316. }.bind(this));
  1317. }
  1318. // preview: function(){
  1319. // if( this.isNewView ){
  1320. // this.designer.notice( this.designer.lp.saveViewNotice, "error" );
  1321. // return;
  1322. // }
  1323. // this.saveSilence( function () {
  1324. // var url = "../x_desktop/app.html?app=query.Query&status=";
  1325. // url += JSON.stringify({
  1326. // id : this.data.application,
  1327. // viewId : this.data.id
  1328. // });
  1329. // window.open(o2.filterUrl(url),"_blank");
  1330. // }.bind(this));
  1331. // },
  1332. // saveSilence: function(callback){
  1333. // if (!this.data.name){
  1334. // this.designer.notice(this.designer.lp.notice.inputName, "error");
  1335. // return false;
  1336. // }
  1337. //
  1338. // this.designer.actions.saveView(this.data, function(json){
  1339. // this.data.id = json.data.id;
  1340. // this.isNewView = false;
  1341. // //this.page.textNode.set("text", this.data.name);
  1342. // if (this.lisNode) {
  1343. // this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  1344. // }
  1345. // if (callback) callback();
  1346. // }.bind(this));
  1347. // },
  1348. // save: function(callback){
  1349. // //if (this.designer.tab.showPage==this.page){
  1350. // if (!this.data.name){
  1351. // this.designer.notice(this.designer.lp.notice.inputName, "error");
  1352. // return false;
  1353. // }
  1354. // //}
  1355. // this.designer.actions.saveView(this.data, function(json){
  1356. // this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  1357. // this.isNewView = false;
  1358. // this.data.id = json.data.id;
  1359. // //this.page.textNode.set("text", this.data.name);
  1360. // if (this.lisNode) {
  1361. // this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  1362. // }
  1363. // if (callback) callback();
  1364. // }.bind(this));
  1365. // },
  1366. // saveAs: function(){
  1367. // var form = new MWF.xApplication.query.StatementDesigner.View.NewNameForm(this, {
  1368. // name : this.data.name + "_" + MWF.xApplication.query.StatementDesigner.LP.copy,
  1369. // query : this.data.query || this.data.application,
  1370. // queryName : this.data.queryName || this.data.applicationName
  1371. // }, {
  1372. // onSave : function( data, callback ){
  1373. // this._saveAs( data, callback );
  1374. // }.bind(this)
  1375. // }, {
  1376. // app: this.designer
  1377. // });
  1378. // form.edit()
  1379. // },
  1380. // _saveAs : function( data , callback){
  1381. // var _self = this;
  1382. //
  1383. // var d = this.cloneObject( this.data );
  1384. //
  1385. // d.isNewView = true;
  1386. // d.id = this.designer.actions.getUUID();
  1387. // d.name = data.name;
  1388. // d.alias = "";
  1389. // d.query = data.query;
  1390. // d.queryName = data.queryName;
  1391. // d.application = data.query;
  1392. // d.applicationName = data.queryName;
  1393. // d.pid = d.id + d.id;
  1394. //
  1395. // delete d[this.data.id+"viewFilterType"];
  1396. // d[d.id+"viewFilterType"]="custom";
  1397. //
  1398. // d.data.selectList.each( function( entry ){
  1399. // entry.id = (new MWF.widget.UUID).id;
  1400. // }.bind(this));
  1401. //
  1402. // this.designer.actions.saveView(d, function(json){
  1403. // this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  1404. // if (callback) callback();
  1405. // }.bind(this));
  1406. // }
  1407. });
  1408. MWF.xApplication.query.StatementDesigner.View.Column = new Class({
  1409. Extends: MWF.xApplication.query.ViewDesigner.View.Column,
  1410. initialize: function (json, view, next) {
  1411. this.propertyPath = "../x_component_query_StatementDesigner/$Statement/column.html";
  1412. this.view = view;
  1413. this.json = json;
  1414. this.next = next;
  1415. this.css = this.view.css;
  1416. this.content = this.view.viewTitleTrNode;
  1417. this.domListNode = this.view.domListNode;
  1418. this.load();
  1419. },
  1420. refreshColumnPathData: function () {
  1421. if (this.property) {
  1422. this.property.loadDataPathSelect();
  1423. }
  1424. },
  1425. getColumnDataPath: function () {
  1426. return this.view.statement.getColumnDataPath();
  1427. },
  1428. showProperty: function () {
  1429. if (!this.property) {
  1430. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1431. "path": this.propertyPath,
  1432. "onPostLoad": function () {
  1433. this.property.show();
  1434. var processDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedProcessArea");
  1435. var cmsDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedCMSArea");
  1436. if (this.view.json.type == "cms") {
  1437. processDiv.setStyle("display", "none");
  1438. cmsDiv.setStyle("display", "block");
  1439. } else {
  1440. processDiv.setStyle("display", "block");
  1441. cmsDiv.setStyle("display", "none");
  1442. }
  1443. }.bind(this)
  1444. });
  1445. this.property.load();
  1446. } else {
  1447. this.property.show();
  1448. }
  1449. },
  1450. selected: function () {
  1451. if (this.view.statement.currentSelectedModule) {
  1452. if (this.view.statement.currentSelectedModule == this) {
  1453. return true;
  1454. } else {
  1455. this.view.statement.currentSelectedModule.unSelected();
  1456. }
  1457. }
  1458. this.view.domListNode.show();
  1459. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  1460. this.listNode.setStyles(this.css.cloumnListNode_selected);
  1461. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1462. new Fx.Scroll(this.view.designer.propertyDomArea, {
  1463. "wheelStops": false,
  1464. "duration": 100
  1465. }).toElement(this.listNode);
  1466. this.view.statement.currentSelectedModule = this;
  1467. this.isSelected = true;
  1468. this._showActions();
  1469. this.showProperty();
  1470. },
  1471. unSelected: function () {
  1472. this.view.statement.currentSelectedModule = null;
  1473. //this.node.setStyles(this.css.viewTitleColumnNode);
  1474. if (this.isError) {
  1475. this.node.setStyles(this.css.viewTitleColumnNode_error)
  1476. } else {
  1477. this.node.setStyles(this.css.viewTitleColumnNode)
  1478. }
  1479. this.listNode.setStyles(this.css.cloumnListNode);
  1480. this.isSelected = false;
  1481. this._hideActions();
  1482. this.hideProperty();
  1483. }
  1484. });
  1485. MWF.xApplication.query.StatementDesigner.View.Actionbar = new Class({
  1486. Extends: MWF.xApplication.query.ViewDesigner.View.Actionbar,
  1487. initialize: function (json, jsonList, view, options) {
  1488. this.setOptions(options);
  1489. this.propertyPath = "../x_component_query_StatementDesigner/$Statement/actionbar.html";
  1490. this.path = "../x_component_query_ViewDesigner/$View/";
  1491. this.imagePath_default = "../x_component_query_ViewDesigner/$View/";
  1492. this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";
  1493. this.cssPath = "../x_component_query_ViewDesigner/$View/" + this.options.style + "/actionbar.wcss";
  1494. this.view = view;
  1495. this.json = json;
  1496. this.jsonList = jsonList;
  1497. this.css = this.view.css;
  1498. this.container = this.view.actionbarNode;
  1499. this.moduleName = "actionbar";
  1500. this.load();
  1501. },
  1502. getJsonPath: function () {
  1503. return "../x_component_query_StatementDesigner/$Statement/toolbars.json";
  1504. },
  1505. selected: function () {
  1506. if (this.view.statement.currentSelectedModule) {
  1507. if (this.view.statement.currentSelectedModule == this) {
  1508. return true;
  1509. } else {
  1510. this.view.statement.currentSelectedModule.unSelected();
  1511. }
  1512. }
  1513. this.view.domListNode.show();
  1514. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1515. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1516. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1517. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1518. this.view.statement.currentSelectedModule = this;
  1519. this.isSelected = true;
  1520. //this._showActions();
  1521. this.showProperty();
  1522. },
  1523. unSelected: function () {
  1524. this.view.statement.currentSelectedModule = null;
  1525. this.node.setStyles(this.css.toolbarWarpNode);
  1526. //this.listNode.setStyles(this.css.cloumnListNode);
  1527. this.isSelected = false;
  1528. //this._hideActions();
  1529. this.hideProperty();
  1530. },
  1531. });
  1532. MWF.xApplication.query.StatementDesigner.View.Paging = new Class({
  1533. Extends: MWF.xApplication.query.ViewDesigner.View.Paging,
  1534. selected: function () {
  1535. if (this.view.statement.currentSelectedModule) {
  1536. if (this.view.statement.currentSelectedModule == this) {
  1537. return true;
  1538. } else {
  1539. this.view.statement.currentSelectedModule.unSelected();
  1540. }
  1541. }
  1542. this.view.domListNode.show();
  1543. this.node.setStyles(this.css.pagingWarpNode_selected);
  1544. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1545. this.view.statement.currentSelectedModule = this;
  1546. this.isSelected = true;
  1547. this.showProperty();
  1548. },
  1549. unSelected: function () {
  1550. this.view.statement.currentSelectedModule = null;
  1551. this.node.setStyles(this.css.pagingWarpNode);
  1552. this.isSelected = false;
  1553. this.hideProperty();
  1554. }
  1555. });