Statement.js 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740
  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;
  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 * 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 * 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. }
  762. //if( !this.data.tableType ){
  763. // this.data.tableType = "dynamic";
  764. //}
  765. if (this.editor) this.data.data = this.editor.editor.getValue();
  766. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  767. if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue();
  768. this.designer.actions.saveStatement(this.data, function (json) {
  769. this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  770. this.data.id = json.data.id;
  771. if (this.lisNode) {
  772. this.lisNode.getLast().set("text", this.data.name + "(" + this.data.alias + ")");
  773. }
  774. if (callback) callback();
  775. }.bind(this));
  776. },
  777. _setEditStyle: function () {
  778. },
  779. saveSilence: function (callback) {
  780. if (!this.data.name) {
  781. this.designer.notice(this.designer.lp.inputStatementName, "error");
  782. return false;
  783. }
  784. if (typeOf(this.viewJson) === "object") {
  785. this.data.view = JSON.stringify(this.viewJson);
  786. }
  787. if (this.editor) this.data.data = this.editor.editor.getValue();
  788. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  789. if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue();
  790. this.designer.actions.saveStatement(this.data, function (json) {
  791. //this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  792. this.data.id = json.data.id;
  793. if (this.lisNode) {
  794. this.lisNode.getLast().set("text", this.data.name + "(" + this.data.alias + ")");
  795. }
  796. if (callback) callback();
  797. }.bind(this));
  798. },
  799. loadView: function (callback) {
  800. this.setViewSize();
  801. this.designer.addEvent("resize", this.setViewSize.bind(this));
  802. if (!this.data.view) {
  803. this.viewJson = {};
  804. } else {
  805. this.viewJson = JSON.parse(this.data.view)
  806. }
  807. this.view = new MWF.xApplication.query.StatementDesigner.View(this.designer, this, this.viewJson, {});
  808. this.view.load(function () {
  809. this.view.setContentHeight();
  810. }.bind(this));
  811. },
  812. setViewSize: function () {
  813. debugger;
  814. var size = this.areaNode.getSize();
  815. var designerSize = this.designerArea.getComputedSize();
  816. var reizeNodeSize = this.resizeNode.getComputedSize();
  817. var y = size.y - designerSize.totalHeight - reizeNodeSize.totalHeight;
  818. var mTop = this.viewArea.getStyle("margin-top").toInt();
  819. var mBottom = this.viewArea.getStyle("margin-bottom").toInt();
  820. var pTop = this.viewArea.getStyle("padding-top").toInt();
  821. var pBottom = this.viewArea.getStyle("padding-bottom").toInt();
  822. y = y - mTop - mBottom - pTop - pBottom - 1;
  823. var tabSize = this.tabNode.getComputedSize();
  824. y = y - tabSize.totalHeight;
  825. this.viewArea.setStyle("height", "" + y + "px");
  826. // var titleSize = this.runTitleNode.getComputedSize();
  827. // y = y - titleSize.totalHeight;
  828. // this.runContentNode.setStyle("height", ""+y+"px");
  829. },
  830. preview: function () {
  831. if (this.isNewStatement) {
  832. this.designer.notice(this.designer.lp.saveStatementNotice, "error");
  833. return;
  834. }
  835. if (this.data.type !== "select") {
  836. this.designer.notice(this.designer.lp.previewNotSelectStatementNotice, "error");
  837. return;
  838. }
  839. if (!this.data.view) {
  840. this.designer.notice(this.designer.lp.noViewNotice, "error");
  841. }
  842. this.saveSilence(function () {
  843. var url = "../x_desktop/app.html?app=query.Query&status=";
  844. url += JSON.stringify({
  845. id: this.data.application,
  846. statementId: this.data.id
  847. });
  848. window.open(o2.filterUrl(url), "_blank");
  849. }.bind(this));
  850. }
  851. });
  852. MWF.xApplication.query.StatementDesigner.View = new Class({
  853. Extends: MWF.xApplication.query.ViewDesigner.View,
  854. Implements: [Options, Events],
  855. options: {
  856. "style": "default",
  857. "isView": false,
  858. "showTab": true,
  859. "propertyPath": "../x_component_query_StatementDesigner/$Statement/view.html"
  860. },
  861. initialize: function (designer, statement, data, options) {
  862. this.setOptions(options);
  863. this.path = "../x_component_query_ViewDesigner/$View/";
  864. this.cssPath = "../x_component_query_ViewDesigner/$View/" + this.options.style + "/css.wcss";
  865. this._loadCss();
  866. this.statement = statement;
  867. this.designer = designer;
  868. this.data = data;
  869. // if (!this.data.data) this.data.data = {};
  870. this.parseData();
  871. this.node = this.statement.viewArea;
  872. //this.tab = this.designer.tab;
  873. this.areaNode = new Element("div", {"styles": {"height": "calc(100% - 2px)", "overflow": "auto"}});
  874. this.areaNode.setStyles(this.css.areaNode);
  875. //MWF.require("MWF.widget.ScrollBar", function(){
  876. // new MWF.widget.ScrollBar(this.areaNode, {"distance": 100});
  877. //}.bind(this));
  878. // this.propertyListNode = this.designer.propertyDomArea;
  879. //this.propertyNode = this.designer.propertyContentArea;
  880. // if(this.designer.application) this.data.applicationName = this.designer.application.name;
  881. // if(this.designer.application) this.data.application = this.designer.application.id;
  882. // this.isNewView = (this.data.name) ? false : true;
  883. this.items = [];
  884. this.view = this;
  885. // this.autoSave();
  886. // this.designer.addEvent("queryClose", function(){
  887. // if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  888. // }.bind(this));
  889. },
  890. load: function (callback) {
  891. this.setAreaNodeSize();
  892. this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  893. this.areaNode.inject(this.node);
  894. this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
  895. this.loadTemplateStyle(function () {
  896. this.loadActionbar();
  897. this.loadView();
  898. this.loadPaging();
  899. // this.selected();
  900. this.setEvent();
  901. //if (this.options.showTab) this.page.showTabIm();
  902. this.setViewWidth();
  903. this.designer.addEvent("resize", this.setViewWidth.bind(this));
  904. if (callback) callback();
  905. }.bind(this))
  906. },
  907. parseData: function () {
  908. this.json = this.data;
  909. if (!this.json.id) {
  910. this.json.id = (new o2.widget.UUID).id;
  911. }
  912. if (!this.json.data || !this.json.data.events) {
  913. var url = "../x_component_query_StatementDesigner/$Statement/view.json";
  914. MWF.getJSON(url, {
  915. "onSuccess": function (obj) {
  916. if (!this.json.data) this.json.data = obj.data;
  917. if (!this.json.data.events) this.json.data.events = obj.data.events;
  918. }.bind(this),
  919. "onerror": function (text) {
  920. this.notice(text, "error");
  921. }.bind(this),
  922. "onRequestFailure": function (xhr) {
  923. this.notice(xhr.responseText, "error");
  924. }.bind(this)
  925. }, false);
  926. }
  927. },
  928. setEvent: function () {
  929. this.areaNode.addEvents({
  930. "click": function (e) {
  931. this.selected();
  932. e.stopPropagation();
  933. }.bind(this),
  934. "mouseover": function () {
  935. if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode_over)
  936. }.bind(this),
  937. "mouseout": function () {
  938. if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode)
  939. }.bind(this)
  940. });
  941. this.refreshNode.addEvent("click", function (e) {
  942. this.statement.runStatement();
  943. e.stopPropagation();
  944. }.bind(this));
  945. this.addColumnNode.addEvent("click", function (e) {
  946. this.addColumn();
  947. e.stopPropagation();
  948. }.bind(this));
  949. },
  950. selected: function () {
  951. debugger;
  952. if (this.statement.currentSelectedModule) {
  953. if (this.statement.currentSelectedModule == this) {
  954. return true;
  955. } else {
  956. this.statement.currentSelectedModule.unSelected();
  957. }
  958. }
  959. this.areaNode.setStyles(this.css.areaNode_selected);
  960. this.statement.currentSelectedModule = this;
  961. this.domListNode.show();
  962. this.isSelected = true;
  963. this.showProperty();
  964. },
  965. unSelected: function () {
  966. this.statement.currentSelectedModule = null;
  967. this.isSelected = false;
  968. this.areaNode.setStyles(this.css.areaNode);
  969. this.hideProperty();
  970. },
  971. showProperty: function () {
  972. if (!this.property) {
  973. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  974. "path": this.options.propertyPath,
  975. "onPostLoad": function () {
  976. this.property.show();
  977. }.bind(this)
  978. });
  979. this.property.load();
  980. } else {
  981. this.property.show();
  982. }
  983. },
  984. hideProperty: function () {
  985. if (this.property) this.property.hide();
  986. },
  987. loadViewData: function () {
  988. debugger;
  989. if (this.data.id) {
  990. // this.statement.saveSilence(function () {
  991. this.viewContentBodyNode.empty();
  992. this.viewContentTableNode = new Element("table", {
  993. "styles": this.css.viewContentTableNode,
  994. "border": "0px",
  995. "cellPadding": "0",
  996. "cellSpacing": "0"
  997. }).inject(this.viewContentBodyNode);
  998. // this.statement.execute( function (json) {
  999. // this.statement.setColumnDataPath( json );
  1000. var entries = {};
  1001. this.json.data.selectList.each(function (entry) {
  1002. entries[entry.column] = entry;
  1003. }.bind(this));
  1004. if (this.statement.executeData && this.statement.executeData.data && this.statement.executeData.data.length) {
  1005. this.statement.executeData.data.each(function (line, idx) {
  1006. var tr = new Element("tr", {
  1007. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode
  1008. }).inject(this.viewContentTableNode);
  1009. //this.createViewCheckboxTd( tr );
  1010. Object.each(entries, function (c, k) {
  1011. debugger;
  1012. var path = c.path, code = c.code, obj = line;
  1013. if( path ){
  1014. var pathList = path.split(".");
  1015. for( var i=0; i<pathList.length; i++ ){
  1016. var p = pathList[i];
  1017. if( (/(^[1-9]\d*$)/.test(p)) )p = p.toInt();
  1018. if( obj[ p ] ){
  1019. obj = obj[ p ];
  1020. }else{
  1021. obj = "";
  1022. break;
  1023. }
  1024. }
  1025. }
  1026. if( code && code.trim())obj = MWF.Macro.exec( code, {"value": obj, "data": line, "entry": c});
  1027. var toName = function (value) {
  1028. if(typeOf(value) === "array"){
  1029. Array.each( value, function (v, idx) {
  1030. value[idx] = toName(v)
  1031. })
  1032. }else if( typeOf(value) === "object" ){
  1033. Object.each( value, function (v, key) {
  1034. value[key] = toName(v);
  1035. })
  1036. }else if( typeOf( value ) === "string" ){
  1037. value = o2.name.cn( value )
  1038. }
  1039. return value;
  1040. };
  1041. var d;
  1042. if( obj!= undefined && obj!= null ){
  1043. if( typeOf(obj) === "array" ) {
  1044. d = c.isName ? JSON.stringify(toName(Array.clone(obj))) : JSON.stringify(obj);
  1045. }else if( typeOf(obj) === "object" ){
  1046. d = c.isName ? JSON.stringify(toName(Object.clone(obj))) : JSON.stringify(obj);
  1047. }else{
  1048. d = c.isName ? o2.name.cn( obj.toString() ) : obj;
  1049. }
  1050. }
  1051. if (d != undefined && d != null ) {
  1052. var td = new Element("td", {
  1053. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
  1054. }).inject(tr);
  1055. if (c.isHtml) {
  1056. td.set("html", d);
  1057. } else {
  1058. td.set("text", d);
  1059. }
  1060. }
  1061. }.bind(this));
  1062. }.bind(this));
  1063. this.setContentColumnWidth();
  1064. this.setContentHeight();
  1065. } else if (this.json.data.noDataText) {
  1066. var noDataTextNodeStyle = this.css.noDataTextNode;
  1067. if (this.json.data.viewStyles) {
  1068. if (this.json.data.viewStyles["noDataTextNode"]) {
  1069. noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
  1070. } else {
  1071. this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
  1072. }
  1073. }
  1074. this.noDataTextNode = new Element("div", {
  1075. "styles": noDataTextNodeStyle,
  1076. "text": this.json.data.noDataText
  1077. }).inject(this.viewContentBodyNode);
  1078. }
  1079. // }.bind(this));
  1080. // }.bind(this));
  1081. }
  1082. },
  1083. addColumn: function () {
  1084. debugger;
  1085. MWF.require("MWF.widget.UUID", function () {
  1086. var id = (new MWF.widget.UUID).id;
  1087. var json = {
  1088. "id": id,
  1089. "column": id,
  1090. "displayName": this.designer.lp.unnamed,
  1091. "orderType": "original"
  1092. };
  1093. if (!this.json.data.selectList) this.json.data.selectList = [];
  1094. this.json.data.selectList.push(json);
  1095. var column = new MWF.xApplication.query.StatementDesigner.View.Column(json, this);
  1096. this.items.push(column);
  1097. column.selected();
  1098. if (this.viewContentTableNode) {
  1099. var trs = this.viewContentTableNode.getElements("tr");
  1100. trs.each(function (tr) {
  1101. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  1102. }.bind(this));
  1103. //this.setContentColumnWidth();
  1104. }
  1105. this.setViewWidth();
  1106. this.addColumnNode.scrollIntoView(true);
  1107. }.bind(this));
  1108. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  1109. },
  1110. setContentHeight: function () {
  1111. var size = this.areaNode.getSize();
  1112. var titleSize = this.viewTitleNode.getSize();
  1113. var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x: 0, y: 0};
  1114. var pagingSize = this.pagingNode ? this.pagingNode.getSize() : {x: 0, y: 0};
  1115. var height = size.y - titleSize.y - actionbarSize.y - pagingSize.y - 4;
  1116. this.viewContentScrollNode.setStyle("height", height);
  1117. var contentSize = this.viewContentBodyNode.getSize();
  1118. if (height < contentSize.y) height = contentSize.y + 10;
  1119. this.viewContentNode.setStyle("height", height);
  1120. this.contentLeftNode.setStyle("height", height);
  1121. this.contentRightNode.setStyle("height", height);
  1122. //this.viewContentBodyNode.setStyle("min-height", height);
  1123. },
  1124. loadViewColumns: function () {
  1125. // for (var i=0; i<10; i++){
  1126. if (this.json.data.selectList) {
  1127. this.json.data.selectList.each(function (json) {
  1128. this.items.push(new MWF.xApplication.query.StatementDesigner.View.Column(json, this));
  1129. }.bind(this));
  1130. }
  1131. // }
  1132. },
  1133. showActionbar: function (noSetHeight) {
  1134. this.actionbarNode.show();
  1135. if (!this.json.data.actionbarList) this.json.data.actionbarList = [];
  1136. if (!this.actionbarList || this.actionbarList.length == 0) {
  1137. if (this.json.data.actionbarList.length) {
  1138. this.json.data.actionbarList.each(function (json) {
  1139. this.actionbarList.push(new MWF.xApplication.query.StatementDesigner.View.Actionbar(json, this.json.data.actionbarList, this))
  1140. }.bind(this));
  1141. } else {
  1142. this.actionbarList.push(new MWF.xApplication.query.StatementDesigner.View.Actionbar(null, this.json.data.actionbarList, this))
  1143. }
  1144. }
  1145. if (!noSetHeight) this.setContentHeight();
  1146. },
  1147. loadPaging: function (noSetHeight) {
  1148. this.pagingNode = new Element("div#pagingNode", {"styles": this.css.pagingNode}).inject(this.areaNode);
  1149. this.pagingList = [];
  1150. if (!this.json.data.pagingList) this.json.data.pagingList = [];
  1151. if (!this.pagingList || this.pagingList.length == 0) {
  1152. if (this.json.data.pagingList.length) {
  1153. this.json.data.pagingList.each(function (json) {
  1154. this.pagingList.push(new MWF.xApplication.query.StatementDesigner.View.Paging(json, this.json.data.pagingList, this))
  1155. }.bind(this));
  1156. } else {
  1157. this.pagingList.push(new MWF.xApplication.query.StatementDesigner.View.Paging(null, this.json.data.pagingList, this))
  1158. }
  1159. }
  1160. // if( !noSetHeight )this.setContentHeight();
  1161. },
  1162. setViewWidth: function () {
  1163. if (!this.viewAreaNode) return;
  1164. this.viewAreaNode.setStyle("width", "auto");
  1165. this.viewTitleNode.setStyle("width", "auto");
  1166. var s1 = this.viewTitleTableNode.getSize();
  1167. var s2 = this.refreshNode.getSize();
  1168. var s3 = this.addColumnNode.getSize();
  1169. var width = s1.x + s2.x + s2.x;
  1170. var size = this.areaNode.getSize();
  1171. if (width > size.x) {
  1172. this.viewTitleNode.setStyle("width", "" + (width - 2) + "px");
  1173. this.viewAreaNode.setStyle("width", "" + (width - 2) + "px");
  1174. } else {
  1175. this.viewTitleNode.setStyle("width", "" + (size.x - 2) + "px");
  1176. this.viewAreaNode.setStyle("width", "" + (size.x - 2) + "px");
  1177. }
  1178. this.setContentColumnWidth();
  1179. this.setContentHeight();
  1180. },
  1181. _setEditStyle: function (name, input, oldValue) {
  1182. if (name == "data.actionbarHidden") {
  1183. if (this.json.data.actionbarHidden) {
  1184. this.hideActionbar()
  1185. } else {
  1186. this.showActionbar()
  1187. }
  1188. }
  1189. if (name == "data.selectAllEnable") {
  1190. if (this.json.data.selectAllEnable) {
  1191. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display", "table-cell");
  1192. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display", "table-cell");
  1193. } else {
  1194. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display", "none");
  1195. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display", "none");
  1196. }
  1197. }
  1198. if (name == "data.viewStyleType") {
  1199. var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
  1200. var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
  1201. this.loadTemplateStyles(file, extendFile, function (templateStyles) {
  1202. this.templateStyles = templateStyles;
  1203. var oldFile, oldExtendFile;
  1204. if (oldValue && this.stylesList[oldValue]) {
  1205. oldFile = this.stylesList[oldValue].file;
  1206. oldExtendFile = this.stylesList[oldValue].extendFile;
  1207. }
  1208. this.loadTemplateStyles(oldFile, oldExtendFile, function (oldTemplateStyles) {
  1209. this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
  1210. if (oldTemplateStyles["view"]) this.clearTemplateStyles(oldTemplateStyles["view"]);
  1211. if (this.templateStyles["view"]) this.setTemplateStyles(this.templateStyles["view"]);
  1212. this.setAllStyles();
  1213. this.actionbarList.each(function (module) {
  1214. if (oldTemplateStyles["actionbar"]) {
  1215. module.clearTemplateStyles(oldTemplateStyles["actionbar"]);
  1216. }
  1217. module.setStyleTemplate();
  1218. module.setAllStyles();
  1219. })
  1220. this.pagingList.each(function (module) {
  1221. if (oldTemplateStyles["paging"]) {
  1222. module.clearTemplateStyles(oldTemplateStyles["paging"]);
  1223. }
  1224. module.setStyleTemplate();
  1225. module.setAllStyles();
  1226. });
  1227. // this.moduleList.each(function(module){
  1228. // if (oldTemplateStyles[module.moduleName]){
  1229. // module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  1230. // }
  1231. // module.setStyleTemplate();
  1232. // module.setAllStyles();
  1233. // }.bind(this));
  1234. }.bind(this))
  1235. }.bind(this))
  1236. }
  1237. if (name == "data.viewStyles") {
  1238. this.setCustomStyles();
  1239. }
  1240. },
  1241. loadTemplateStyle: function (callback) {
  1242. this.loadStylesList(function () {
  1243. var oldStyleValue = "";
  1244. if ((!this.json.data.viewStyleType) || !this.stylesList[this.json.data.viewStyleType]) this.json.data.viewStyleType = "default";
  1245. this.loadTemplateStyles(this.stylesList[this.json.data.viewStyleType].file, this.stylesList[this.json.data.viewStyleType].extendFile,
  1246. function (templateStyles) {
  1247. this.templateStyles = templateStyles;
  1248. if (!this.json.data.viewStyleType) this.json.data.viewStyleType = "default";
  1249. if (this.templateStyles && this.templateStyles["view"]) {
  1250. var viewStyles = Object.clone(this.templateStyles["view"]);
  1251. if (viewStyles.contentGroupTd) delete viewStyles.contentGroupTd;
  1252. if (viewStyles.groupCollapseNode) delete viewStyles.groupCollapseNode;
  1253. if (viewStyles.groupExpandNode) delete viewStyles.groupExpandNode;
  1254. if (!this.json.data.viewStyles) {
  1255. this.json.data.viewStyles = viewStyles;
  1256. } else {
  1257. this.setTemplateStyles(viewStyles);
  1258. }
  1259. }
  1260. this.setCustomStyles();
  1261. if (callback) callback();
  1262. }.bind(this)
  1263. );
  1264. }.bind(this));
  1265. },
  1266. clearTemplateStyles: function (styles) {
  1267. if (styles) {
  1268. if (styles.container) this.removeStyles(styles.container, "container");
  1269. if (styles.table) this.removeStyles(styles.table, "table");
  1270. if (styles.titleTr) this.removeStyles(styles.titleTr, "titleTr");
  1271. if (styles.titleTd) this.removeStyles(styles.titleTd, "titleTd");
  1272. if (styles.contentTr) this.removeStyles(styles.contentTr, "contentTr");
  1273. if (styles.contentSelectedTr) this.removeStyles(styles.contentSelectedTr, "contentSelectedTr");
  1274. if (styles.contentTd) this.removeStyles(styles.contentTd, "contentTd");
  1275. // if (styles.contentGroupTd) this.removeStyles(styles.contentGroupTd, "contentGroupTd");
  1276. // if (styles.groupCollapseNode) this.removeStyles(styles.groupCollapseNode, "groupCollapseNode");
  1277. // if (styles.groupExpandNode) this.removeStyles(styles.groupExpandNode, "groupExpandNode");
  1278. if (styles.checkboxNode) this.removeStyles(styles.checkboxNode, "checkboxNode");
  1279. if (styles.checkedCheckboxNode) this.removeStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  1280. if (styles.radioNode) this.removeStyles(styles.radioNode, "radioNode");
  1281. if (styles.checkedRadioNode) this.removeStyles(styles.checkedRadioNode, "checkedRadioNode");
  1282. if (styles.tableProperties) this.removeStyles(styles.tableProperties, "tableProperties");
  1283. }
  1284. },
  1285. setTemplateStyles: function (styles) {
  1286. if (styles.container) this.copyStyles(styles.container, "container");
  1287. if (styles.table) this.copyStyles(styles.table, "table");
  1288. if (styles.titleTr) this.copyStyles(styles.titleTr, "titleTr");
  1289. if (styles.titleTd) this.copyStyles(styles.titleTd, "titleTd");
  1290. if (styles.contentTr) this.copyStyles(styles.contentTr, "contentTr");
  1291. if (styles.contentSelectedTr) this.copyStyles(styles.contentSelectedTr, "contentSelectedTr");
  1292. if (styles.contentTd) this.copyStyles(styles.contentTd, "contentTd");
  1293. // if (styles.contentGroupTd) this.copyStyles(styles.contentGroupTd, "contentGroupTd");
  1294. // if (styles.groupCollapseNode) this.copyStyles(styles.groupCollapseNode, "groupCollapseNode");
  1295. // if (styles.groupExpandNode) this.copyStyles(styles.groupExpandNode, "groupExpandNode");
  1296. if (styles.checkboxNode) this.copyStyles(styles.checkboxNode, "checkboxNode");
  1297. if (styles.checkedCheckboxNode) this.copyStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  1298. if (styles.radioNode) this.copyStyles(styles.radioNode, "radioNode");
  1299. if (styles.checkedRadioNode) this.copyStyles(styles.checkedRadioNode, "checkedRadioNode");
  1300. if (styles.tableProperties) this.copyStyles(styles.tableProperties, "tableProperties");
  1301. },
  1302. removeStyles: function (from, to) {
  1303. if (this.json.data.viewStyles[to]) {
  1304. Object.each(from, function (style, key) {
  1305. if (this.json.data.viewStyles[to][key] && this.json.data.viewStyles[to][key] == style) {
  1306. delete this.json.data.viewStyles[to][key];
  1307. }
  1308. }.bind(this));
  1309. }
  1310. },
  1311. copyStyles: function (from, to) {
  1312. if (!this.json.data.viewStyles[to]) this.json.data.viewStyles[to] = {};
  1313. Object.each(from, function (style, key) {
  1314. if (!this.json.data.viewStyles[to][key]) this.json.data.viewStyles[to][key] = style;
  1315. }.bind(this));
  1316. }
  1317. // preview: function(){
  1318. // if( this.isNewView ){
  1319. // this.designer.notice( this.designer.lp.saveViewNotice, "error" );
  1320. // return;
  1321. // }
  1322. // this.saveSilence( function () {
  1323. // var url = "../x_desktop/app.html?app=query.Query&status=";
  1324. // url += JSON.stringify({
  1325. // id : this.data.application,
  1326. // viewId : this.data.id
  1327. // });
  1328. // window.open(o2.filterUrl(url),"_blank");
  1329. // }.bind(this));
  1330. // },
  1331. // saveSilence: function(callback){
  1332. // if (!this.data.name){
  1333. // this.designer.notice(this.designer.lp.notice.inputName, "error");
  1334. // return false;
  1335. // }
  1336. //
  1337. // this.designer.actions.saveView(this.data, function(json){
  1338. // this.data.id = json.data.id;
  1339. // this.isNewView = false;
  1340. // //this.page.textNode.set("text", this.data.name);
  1341. // if (this.lisNode) {
  1342. // this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  1343. // }
  1344. // if (callback) callback();
  1345. // }.bind(this));
  1346. // },
  1347. // save: function(callback){
  1348. // //if (this.designer.tab.showPage==this.page){
  1349. // if (!this.data.name){
  1350. // this.designer.notice(this.designer.lp.notice.inputName, "error");
  1351. // return false;
  1352. // }
  1353. // //}
  1354. // this.designer.actions.saveView(this.data, function(json){
  1355. // this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  1356. // this.isNewView = false;
  1357. // this.data.id = json.data.id;
  1358. // //this.page.textNode.set("text", this.data.name);
  1359. // if (this.lisNode) {
  1360. // this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  1361. // }
  1362. // if (callback) callback();
  1363. // }.bind(this));
  1364. // },
  1365. // saveAs: function(){
  1366. // var form = new MWF.xApplication.query.StatementDesigner.View.NewNameForm(this, {
  1367. // name : this.data.name + "_" + MWF.xApplication.query.StatementDesigner.LP.copy,
  1368. // query : this.data.query || this.data.application,
  1369. // queryName : this.data.queryName || this.data.applicationName
  1370. // }, {
  1371. // onSave : function( data, callback ){
  1372. // this._saveAs( data, callback );
  1373. // }.bind(this)
  1374. // }, {
  1375. // app: this.designer
  1376. // });
  1377. // form.edit()
  1378. // },
  1379. // _saveAs : function( data , callback){
  1380. // var _self = this;
  1381. //
  1382. // var d = this.cloneObject( this.data );
  1383. //
  1384. // d.isNewView = true;
  1385. // d.id = this.designer.actions.getUUID();
  1386. // d.name = data.name;
  1387. // d.alias = "";
  1388. // d.query = data.query;
  1389. // d.queryName = data.queryName;
  1390. // d.application = data.query;
  1391. // d.applicationName = data.queryName;
  1392. // d.pid = d.id + d.id;
  1393. //
  1394. // delete d[this.data.id+"viewFilterType"];
  1395. // d[d.id+"viewFilterType"]="custom";
  1396. //
  1397. // d.data.selectList.each( function( entry ){
  1398. // entry.id = (new MWF.widget.UUID).id;
  1399. // }.bind(this));
  1400. //
  1401. // this.designer.actions.saveView(d, function(json){
  1402. // this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  1403. // if (callback) callback();
  1404. // }.bind(this));
  1405. // }
  1406. });
  1407. MWF.xApplication.query.StatementDesigner.View.Column = new Class({
  1408. Extends: MWF.xApplication.query.ViewDesigner.View.Column,
  1409. initialize: function (json, view, next) {
  1410. this.propertyPath = "../x_component_query_StatementDesigner/$Statement/column.html";
  1411. this.view = view;
  1412. this.json = json;
  1413. this.next = next;
  1414. this.css = this.view.css;
  1415. this.content = this.view.viewTitleTrNode;
  1416. this.domListNode = this.view.domListNode;
  1417. this.load();
  1418. },
  1419. refreshColumnPathData: function () {
  1420. if (this.property) {
  1421. this.property.loadDataPathSelect();
  1422. }
  1423. },
  1424. getColumnDataPath: function () {
  1425. return this.view.statement.getColumnDataPath();
  1426. },
  1427. showProperty: function () {
  1428. if (!this.property) {
  1429. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1430. "path": this.propertyPath,
  1431. "onPostLoad": function () {
  1432. this.property.show();
  1433. var processDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedProcessArea");
  1434. var cmsDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedCMSArea");
  1435. if (this.view.json.type == "cms") {
  1436. processDiv.setStyle("display", "none");
  1437. cmsDiv.setStyle("display", "block");
  1438. } else {
  1439. processDiv.setStyle("display", "block");
  1440. cmsDiv.setStyle("display", "none");
  1441. }
  1442. }.bind(this)
  1443. });
  1444. this.property.load();
  1445. } else {
  1446. this.property.show();
  1447. }
  1448. },
  1449. selected: function () {
  1450. if (this.view.statement.currentSelectedModule) {
  1451. if (this.view.statement.currentSelectedModule == this) {
  1452. return true;
  1453. } else {
  1454. this.view.statement.currentSelectedModule.unSelected();
  1455. }
  1456. }
  1457. this.view.domListNode.show();
  1458. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  1459. this.listNode.setStyles(this.css.cloumnListNode_selected);
  1460. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1461. new Fx.Scroll(this.view.designer.propertyDomArea, {
  1462. "wheelStops": false,
  1463. "duration": 100
  1464. }).toElement(this.listNode);
  1465. this.view.statement.currentSelectedModule = this;
  1466. this.isSelected = true;
  1467. this._showActions();
  1468. this.showProperty();
  1469. },
  1470. unSelected: function () {
  1471. this.view.statement.currentSelectedModule = null;
  1472. //this.node.setStyles(this.css.viewTitleColumnNode);
  1473. if (this.isError) {
  1474. this.node.setStyles(this.css.viewTitleColumnNode_error)
  1475. } else {
  1476. this.node.setStyles(this.css.viewTitleColumnNode)
  1477. }
  1478. this.listNode.setStyles(this.css.cloumnListNode);
  1479. this.isSelected = false;
  1480. this._hideActions();
  1481. this.hideProperty();
  1482. }
  1483. });
  1484. MWF.xApplication.query.StatementDesigner.View.Actionbar = new Class({
  1485. Extends: MWF.xApplication.query.ViewDesigner.View.Actionbar,
  1486. initialize: function (json, jsonList, view, options) {
  1487. this.setOptions(options);
  1488. this.propertyPath = "../x_component_query_StatementDesigner/$Statement/actionbar.html";
  1489. this.path = "../x_component_query_ViewDesigner/$View/";
  1490. this.imagePath_default = "../x_component_query_ViewDesigner/$View/";
  1491. this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";
  1492. this.cssPath = "../x_component_query_ViewDesigner/$View/" + this.options.style + "/actionbar.wcss";
  1493. this.view = view;
  1494. this.json = json;
  1495. this.jsonList = jsonList;
  1496. this.css = this.view.css;
  1497. this.container = this.view.actionbarNode;
  1498. this.moduleName = "actionbar";
  1499. this.load();
  1500. },
  1501. getJsonPath: function () {
  1502. return "../x_component_query_StatementDesigner/$Statement/toolbars.json";
  1503. },
  1504. selected: function () {
  1505. if (this.view.statement.currentSelectedModule) {
  1506. if (this.view.statement.currentSelectedModule == this) {
  1507. return true;
  1508. } else {
  1509. this.view.statement.currentSelectedModule.unSelected();
  1510. }
  1511. }
  1512. this.view.domListNode.show();
  1513. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1514. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1515. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1516. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1517. this.view.statement.currentSelectedModule = this;
  1518. this.isSelected = true;
  1519. //this._showActions();
  1520. this.showProperty();
  1521. },
  1522. unSelected: function () {
  1523. this.view.statement.currentSelectedModule = null;
  1524. this.node.setStyles(this.css.toolbarWarpNode);
  1525. //this.listNode.setStyles(this.css.cloumnListNode);
  1526. this.isSelected = false;
  1527. //this._hideActions();
  1528. this.hideProperty();
  1529. },
  1530. });
  1531. MWF.xApplication.query.StatementDesigner.View.Paging = new Class({
  1532. Extends: MWF.xApplication.query.ViewDesigner.View.Paging,
  1533. selected: function () {
  1534. if (this.view.statement.currentSelectedModule) {
  1535. if (this.view.statement.currentSelectedModule == this) {
  1536. return true;
  1537. } else {
  1538. this.view.statement.currentSelectedModule.unSelected();
  1539. }
  1540. }
  1541. this.view.domListNode.show();
  1542. this.node.setStyles(this.css.pagingWarpNode_selected);
  1543. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1544. this.view.statement.currentSelectedModule = this;
  1545. this.isSelected = true;
  1546. this.showProperty();
  1547. },
  1548. unSelected: function () {
  1549. this.view.statement.currentSelectedModule = null;
  1550. this.node.setStyles(this.css.pagingWarpNode);
  1551. this.isSelected = false;
  1552. this.hideProperty();
  1553. }
  1554. });