Statement.js 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764
  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. this.changeEditorEntityClassName( entityClassName.split(".").getLast() );
  500. // var className = e.target.options[e.target.selectedIndex].value;
  501. // if (this.json.type=="select"){
  502. // this.json.data
  503. // /(select)*(where|)/g
  504. // }
  505. // }.bind(this));
  506. // this.jpqlTypeSelect.addEvent("change", function(){
  507. // var type = e.target.options[e.target.selectedIndex].value;
  508. // switch (entityCategory) {
  509. // case "update":
  510. // this.jpqlSelectEditor.hide();
  511. // this.jpqlUpdateEditor.show();
  512. // this.jpqlDeleteEditor.hide();
  513. // this.loadJpqlUpdateEditor();
  514. // break;
  515. // case "delete":
  516. // this.jpqlSelectEditor.hide();
  517. // this.jpqlUpdateEditor.hide();
  518. // this.jpqlDeleteEditor.show();
  519. // break;
  520. // default:
  521. // this.jpqlSelectEditor.show();
  522. // this.jpqlUpdateEditor.hide();
  523. // this.jpqlDeleteEditor.hide();
  524. // break;
  525. // }
  526. }.bind(this));
  527. this.runActionNode.getFirst().addEvent("click", this.runStatement.bind(this));
  528. this.dynamicTableSelect.addEvent("click", this.selectTable.bind(this));
  529. this.jpqlTypeSelect.addEvent("change", function () {
  530. var t = this.jpqlTypeSelect.options[this.jpqlTypeSelect.selectedIndex].value;
  531. if (t != this.json.type) {
  532. this.json.type = t;
  533. }
  534. if (t != "select") {
  535. this.jpqlPage.showTabIm();
  536. this.countJpqlPage.disableTab();
  537. this.runPage.showTabIm();
  538. this.viewPage.disableTab();
  539. } else {
  540. this.countJpqlPage.enableTab(true);
  541. this.viewPage.enableTab(true);
  542. }
  543. }.bind(this));
  544. },
  545. changeEditorEntityClassName : function( entityClassName ){
  546. if (this.json.format == "jpql") {
  547. if (this.editor) {
  548. var re = /(.*from\s*)/ig;
  549. if (this.json.type == "update") re = /(.*update\s*)/ig;
  550. //if (this.json.type=="select" && this.editor){
  551. var v = this.json.data;
  552. var re2 = /(\s+)/ig;
  553. var arr = re.exec(v);
  554. if (arr && arr[0]) {
  555. var left = arr[0]
  556. v = v.substring(left.length, v.length);
  557. //var ar = re2.exec(v);
  558. var right = v.substring(v.indexOf(" "), v.length);
  559. this.json.data = left + entityClassName + right;
  560. this.editor.editor.setValue(this.json.data);
  561. }
  562. //}
  563. }
  564. if( this.countEditor ){
  565. var re = /(.*from\s*)/ig;
  566. var v = this.json.countData;
  567. var re2 = /(\s+)/ig;
  568. var arr = re.exec(v);
  569. if (arr && arr[0]) {
  570. var left = arr[0]
  571. v = v.substring(left.length, v.length);
  572. //var ar = re2.exec(v);
  573. var right = v.substring(v.indexOf(" "), v.length);
  574. this.json.countData = left + entityClassName + right;
  575. this.countEditor.editor.setValue(this.json.countData);
  576. }
  577. }
  578. }
  579. },
  580. selectTable: function () {
  581. new MWF.O2Selector(this.designer.content, {
  582. "type": "queryTable",
  583. "count": 1,
  584. "values": (this.json.table) ? [this.json.table] : [],
  585. "title": this.designer.lp.selectTable,
  586. "onComplete": function (items) {
  587. if (items.length) {
  588. var id = items[0].data.id;
  589. var name = items[0].data.name;
  590. this.dynamicTableContent.set("text", name);
  591. this.json.table = name;
  592. this.json.tableObj = items[0].data;
  593. this.changeEditorEntityClassName( name );
  594. if(this.view && this.view.property && this.view.property.viewFilter)this.view.property.viewFilter.setPathInputSelectOptions();
  595. } else {
  596. this.dynamicTableContent.set("text", "");
  597. this.json.table = "";
  598. if(this.view && this.view.property && this.view.property.viewFilter)this.view.property.viewFilter.setPathInputSelectOptions();
  599. }
  600. }.bind(this)
  601. });
  602. },
  603. runStatement: function () {
  604. debugger;
  605. // if (!this.json.data){
  606. // this.designer.notice(this.designer.lp.inputStatementData, "error");
  607. // return false;
  608. // }
  609. o2.require("o2.widget.Mask", null, false);
  610. this.runMask = new o2.widget.Mask();
  611. this.runMask.loadNode(this.node);
  612. this.saveSilence(function () {
  613. debugger;
  614. this.execute(function (json) {
  615. this.executeData = json;
  616. o2.require("o2.widget.JsonParse", function () {
  617. this.runResultNode.empty();
  618. var jsonResult = new o2.widget.JsonParse(json, this.runResultNode);
  619. jsonResult.load();
  620. }.bind(this));
  621. if (this.view) {
  622. var flag = true;
  623. if (this.data.type !== "select") flag = false;
  624. if (this.data.format === "script" && !this.data.scriptText) flag = false;
  625. if (this.data.format !== "script" && !this.data.data) flag = false;
  626. if (flag) this.view.loadViewData();
  627. }
  628. this.setColumnDataPath(json);
  629. this.runMask.hide();
  630. }.bind(this), function () {
  631. if (this.runMask) this.runMask.hide();
  632. }.bind(this))
  633. // var json = this.jsonEditor.editor.getValue();
  634. // var o = JSON.parse(json);
  635. //
  636. // var mode = "data";
  637. // if( this.data.type === "select" ){
  638. // if( this.data.format === "script" ){
  639. // if( this.data.scriptText && this.data.countScriptText ){
  640. // mode = "all"
  641. // }else if( this.data.scriptText && !this.data.countScriptText ){
  642. // mode = "data"
  643. // }else if( !this.data.scriptText && this.data.countScriptText ){
  644. // mode = "count"
  645. // }else{
  646. // this.designer.notice(this.designer.lp.inputStatementData, "error");
  647. // return false;
  648. // }
  649. // }else{
  650. // if( this.data.data && this.data.countData ){
  651. // mode = "all"
  652. // }else if( this.data.data && !this.data.countData ){
  653. // mode = "data"
  654. // }else if( !this.data.data && this.data.countData ){
  655. // mode = "count"
  656. // }else{
  657. // this.designer.notice(this.designer.lp.inputStatementData, "error");
  658. // return false;
  659. // }
  660. // }
  661. // }
  662. // o2.Actions.load("x_query_assemble_designer").StatementAction.executeV2(this.json.id, mode, 1, 50 , o, function(json){
  663. // o2.require("o2.widget.JsonParse", function(){
  664. // this.runResultNode.empty();
  665. // var jsonResult = new o2.widget.JsonParse(json, this.runResultNode);
  666. // jsonResult.load();
  667. // }.bind(this));
  668. // this.runMask.hide();
  669. // }.bind(this), function(xhr, text, error){
  670. // debugger;
  671. // if (this.runMask) this.runMask.hide();
  672. // var errorText = error;
  673. // if (xhr){
  674. // var json = JSON.decode(xhr.responseText);
  675. // if (json){
  676. // errorText = json.message.trim() || "request json error";
  677. // }else{
  678. // errorText = "request json error: "+xhr.responseText;
  679. // }
  680. // }
  681. // errorText = errorText.replace(/\</g, "&lt;");
  682. // errorText = errorText.replace(/\</g, "&gt;");
  683. // MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  684. // }.bind(this))
  685. }.bind(this));
  686. },
  687. setColumnDataPath: function (json) {
  688. if (this.data.type !== "select") return;
  689. if (this.data.format === "script" && !this.data.scriptText) return;
  690. if (this.data.format !== "script" && !this.data.data) return;
  691. this.columnDataPathList = [];
  692. debugger;
  693. var addPath = function (value, key) {
  694. if (typeOf(value) === "array") {
  695. Array.each(value, function (v, idx) {
  696. var path = (key || typeOf(key) === "number") ? (key + "." + idx) : idx.toString();
  697. if (!this.columnDataPathList.contains(path)) this.columnDataPathList.push(path);
  698. if (typeOf(v) === "array" || typeOf(v) === "object") addPath(v, path);
  699. }.bind(this))
  700. } else if (typeOf(value) === "object") {
  701. Object.each(value, function (v, k) {
  702. var path = (key || typeOf(key) === "number") ? (key + "." + k) : k;
  703. if (!this.columnDataPathList.contains(path)) this.columnDataPathList.push(path);
  704. if (typeOf(v) === "array" || typeOf(v) === "object") addPath(v, path);
  705. addPath(v, path);
  706. }.bind(this))
  707. } else {
  708. // if( key && !this.columnDataPathList.indexOf(key) )this.columnDataPathList.push(key);
  709. }
  710. }.bind(this);
  711. for (var i = 0; i < json.data.length && i < 10; i++) {
  712. var d = json.data[i];
  713. addPath(d);
  714. }
  715. this.columnDataPathList.sort();
  716. if (this.view && this.view.items) {
  717. this.view.items.each(function (column) {
  718. column.refreshColumnPathData()
  719. })
  720. }
  721. },
  722. getColumnDataPath: function () {
  723. return this.columnDataPathList || [];
  724. },
  725. execute: function (success, failure) {
  726. var json = this.jsonEditor.editor.getValue();
  727. var o = JSON.parse(json);
  728. var mode = "data";
  729. if (this.data.type === "select") {
  730. if (this.data.format === "script") {
  731. if (this.data.scriptText && this.data.countScriptText) {
  732. mode = "all"
  733. } else if (this.data.scriptText && !this.data.countScriptText) {
  734. mode = "data"
  735. } else if (!this.data.scriptText && this.data.countScriptText) {
  736. mode = "count"
  737. } else {
  738. this.designer.notice(this.designer.lp.inputStatementData, "error");
  739. return false;
  740. }
  741. } else {
  742. if (this.data.data && this.data.countData) {
  743. mode = "all"
  744. } else if (this.data.data && !this.data.countData) {
  745. mode = "data"
  746. } else if (!this.data.data && this.data.countData) {
  747. mode = "count"
  748. } else {
  749. this.designer.notice(this.designer.lp.inputStatementData, "error");
  750. return false;
  751. }
  752. }
  753. }
  754. o2.Actions.load("x_query_assemble_designer").StatementAction.executeV2(this.json.id, mode, 1, 50, o, function (json) {
  755. if (success) success(json)
  756. }.bind(this), function (xhr, text, error) {
  757. debugger;
  758. if (failure) failure();
  759. var errorText = error;
  760. if (xhr) {
  761. var json = JSON.decode(xhr.responseText);
  762. if (json) {
  763. errorText = json.message.trim() || "request json error";
  764. } else {
  765. errorText = "request json error: " + xhr.responseText;
  766. }
  767. }
  768. errorText = errorText.replace(/\</g, "&lt;");
  769. errorText = errorText.replace(/\</g, "&gt;");
  770. MWF.xDesktop.notice("error", {x: "right", y: "top"}, errorText);
  771. }.bind(this))
  772. },
  773. save: function (callback) {
  774. debugger;
  775. if (!this.data.name) {
  776. this.designer.notice(this.designer.lp.inputStatementName, "error");
  777. return false;
  778. }
  779. if (typeOf(this.viewJson) === "object") {
  780. this.data.view = JSON.stringify(this.viewJson);
  781. if(!this.data.view.group)this.data.view.group = {};
  782. }
  783. //if( !this.data.tableType ){
  784. // this.data.tableType = "dynamic";
  785. //}
  786. if (this.editor) this.data.data = this.editor.editor.getValue();
  787. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  788. if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue();
  789. this.designer.actions.saveStatement(this.data, function (json) {
  790. this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  791. this.data.id = json.data.id;
  792. if (this.lisNode) {
  793. this.lisNode.getLast().set("text", this.data.name + "(" + this.data.alias + ")");
  794. }
  795. if (callback) callback();
  796. }.bind(this));
  797. },
  798. _setEditStyle: function () {
  799. },
  800. saveSilence: function (callback) {
  801. if (!this.data.name) {
  802. this.designer.notice(this.designer.lp.inputStatementName, "error");
  803. return false;
  804. }
  805. if (typeOf(this.viewJson) === "object") {
  806. this.data.view = JSON.stringify(this.viewJson);
  807. }
  808. if (this.editor) this.data.data = this.editor.editor.getValue();
  809. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  810. if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue();
  811. this.designer.actions.saveStatement(this.data, function (json) {
  812. //this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  813. this.data.id = json.data.id;
  814. if (this.lisNode) {
  815. this.lisNode.getLast().set("text", this.data.name + "(" + this.data.alias + ")");
  816. }
  817. if (callback) callback();
  818. }.bind(this));
  819. },
  820. loadView: function (callback) {
  821. this.setViewSize();
  822. this.designer.addEvent("resize", this.setViewSize.bind(this));
  823. if (!this.data.view) {
  824. this.viewJson = {};
  825. } else {
  826. this.viewJson = JSON.parse(this.data.view)
  827. }
  828. this.view = new MWF.xApplication.query.StatementDesigner.View(this.designer, this, this.viewJson, {});
  829. this.view.load(function () {
  830. this.view.setContentHeight();
  831. }.bind(this));
  832. },
  833. setViewSize: function () {
  834. debugger;
  835. var size = this.areaNode.getSize();
  836. var designerSize = this.designerArea.getComputedSize();
  837. var reizeNodeSize = this.resizeNode.getComputedSize();
  838. var y = size.y - designerSize.totalHeight - reizeNodeSize.totalHeight;
  839. var mTop = this.viewArea.getStyle("margin-top").toInt();
  840. var mBottom = this.viewArea.getStyle("margin-bottom").toInt();
  841. var pTop = this.viewArea.getStyle("padding-top").toInt();
  842. var pBottom = this.viewArea.getStyle("padding-bottom").toInt();
  843. y = y - mTop - mBottom - pTop - pBottom - 1;
  844. var tabSize = this.tabNode.getComputedSize();
  845. y = y - tabSize.totalHeight;
  846. this.viewArea.setStyle("height", "" + y + "px");
  847. // var titleSize = this.runTitleNode.getComputedSize();
  848. // y = y - titleSize.totalHeight;
  849. // this.runContentNode.setStyle("height", ""+y+"px");
  850. },
  851. preview: function () {
  852. if (this.isNewStatement) {
  853. this.designer.notice(this.designer.lp.saveStatementNotice, "error");
  854. return;
  855. }
  856. if (this.data.type !== "select") {
  857. this.designer.notice(this.designer.lp.previewNotSelectStatementNotice, "error");
  858. return;
  859. }
  860. if (!this.data.view) {
  861. this.designer.notice(this.designer.lp.noViewNotice, "error");
  862. }
  863. this.saveSilence(function () {
  864. var url = "../x_desktop/app.html?app=query.Query&status=";
  865. url += JSON.stringify({
  866. id: this.data.application,
  867. statementId: this.data.id
  868. });
  869. window.open(o2.filterUrl(url), "_blank");
  870. }.bind(this));
  871. }
  872. });
  873. MWF.xApplication.query.StatementDesigner.View = new Class({
  874. Extends: MWF.xApplication.query.ViewDesigner.View,
  875. Implements: [Options, Events],
  876. options: {
  877. "style": "default",
  878. "isView": false,
  879. "showTab": true,
  880. "propertyPath": "../x_component_query_StatementDesigner/$Statement/view.html"
  881. },
  882. initialize: function (designer, statement, data, options) {
  883. this.setOptions(options);
  884. this.path = "../x_component_query_ViewDesigner/$View/";
  885. this.cssPath = "../x_component_query_ViewDesigner/$View/" + this.options.style + "/css.wcss";
  886. this._loadCss();
  887. this.statement = statement;
  888. this.designer = designer;
  889. this.data = data;
  890. // if (!this.data.data) this.data.data = {};
  891. this.parseData();
  892. this.node = this.statement.viewArea;
  893. //this.tab = this.designer.tab;
  894. this.areaNode = new Element("div", {"styles": {"height": "calc(100% - 2px)", "overflow": "auto"}});
  895. this.areaNode.setStyles(this.css.areaNode);
  896. //MWF.require("MWF.widget.ScrollBar", function(){
  897. // new MWF.widget.ScrollBar(this.areaNode, {"distance": 100});
  898. //}.bind(this));
  899. // this.propertyListNode = this.designer.propertyDomArea;
  900. //this.propertyNode = this.designer.propertyContentArea;
  901. // if(this.designer.application) this.data.applicationName = this.designer.application.name;
  902. // if(this.designer.application) this.data.application = this.designer.application.id;
  903. // this.isNewView = (this.data.name) ? false : true;
  904. this.items = [];
  905. this.view = this;
  906. // this.autoSave();
  907. // this.designer.addEvent("queryClose", function(){
  908. // if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  909. // }.bind(this));
  910. },
  911. load: function (callback) {
  912. this.setAreaNodeSize();
  913. this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  914. this.areaNode.inject(this.node);
  915. this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
  916. this.loadTemplateStyle(function () {
  917. this.loadActionbar();
  918. this.loadView();
  919. this.loadPaging();
  920. // this.selected();
  921. this.setEvent();
  922. //if (this.options.showTab) this.page.showTabIm();
  923. this.setViewWidth();
  924. this.designer.addEvent("resize", this.setViewWidth.bind(this));
  925. if (callback) callback();
  926. }.bind(this))
  927. },
  928. parseData: function () {
  929. this.json = this.data;
  930. if (!this.json.id) {
  931. this.json.id = (new o2.widget.UUID).id;
  932. }
  933. if (!this.json.data || !this.json.data.events) {
  934. var url = "../x_component_query_StatementDesigner/$Statement/view.json";
  935. MWF.getJSON(url, {
  936. "onSuccess": function (obj) {
  937. if (!this.json.data) this.json.data = obj.data;
  938. if (!this.json.data.events) this.json.data.events = obj.data.events;
  939. }.bind(this),
  940. "onerror": function (text) {
  941. this.notice(text, "error");
  942. }.bind(this),
  943. "onRequestFailure": function (xhr) {
  944. this.notice(xhr.responseText, "error");
  945. }.bind(this)
  946. }, false);
  947. }
  948. },
  949. setEvent: function () {
  950. this.areaNode.addEvents({
  951. "click": function (e) {
  952. this.selected();
  953. e.stopPropagation();
  954. }.bind(this),
  955. "mouseover": function () {
  956. if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode_over)
  957. }.bind(this),
  958. "mouseout": function () {
  959. if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode)
  960. }.bind(this)
  961. });
  962. this.refreshNode.addEvent("click", function (e) {
  963. this.statement.runStatement();
  964. e.stopPropagation();
  965. }.bind(this));
  966. this.addColumnNode.addEvent("click", function (e) {
  967. this.addColumn();
  968. e.stopPropagation();
  969. }.bind(this));
  970. },
  971. selected: function () {
  972. debugger;
  973. if (this.statement.currentSelectedModule) {
  974. if (this.statement.currentSelectedModule == this) {
  975. return true;
  976. } else {
  977. this.statement.currentSelectedModule.unSelected();
  978. }
  979. }
  980. this.areaNode.setStyles(this.css.areaNode_selected);
  981. this.statement.currentSelectedModule = this;
  982. this.domListNode.show();
  983. this.isSelected = true;
  984. this.showProperty();
  985. },
  986. unSelected: function () {
  987. this.statement.currentSelectedModule = null;
  988. this.isSelected = false;
  989. this.areaNode.setStyles(this.css.areaNode);
  990. this.hideProperty();
  991. },
  992. showProperty: function () {
  993. if (!this.property) {
  994. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  995. "path": this.options.propertyPath,
  996. "onPostLoad": function () {
  997. this.property.show();
  998. }.bind(this)
  999. });
  1000. this.property.load();
  1001. } else {
  1002. this.property.show();
  1003. }
  1004. },
  1005. hideProperty: function () {
  1006. if (this.property) this.property.hide();
  1007. },
  1008. loadViewData: function () {
  1009. debugger;
  1010. if (this.data.id) {
  1011. // this.statement.saveSilence(function () {
  1012. this.viewContentBodyNode.empty();
  1013. this.viewContentTableNode = new Element("table", {
  1014. "styles": this.css.viewContentTableNode,
  1015. "border": "0px",
  1016. "cellPadding": "0",
  1017. "cellSpacing": "0"
  1018. }).inject(this.viewContentBodyNode);
  1019. // this.statement.execute( function (json) {
  1020. // this.statement.setColumnDataPath( json );
  1021. var entries = {};
  1022. this.json.data.selectList.each(function (entry) {
  1023. entries[entry.column] = entry;
  1024. }.bind(this));
  1025. if (this.statement.executeData && this.statement.executeData.data && this.statement.executeData.data.length) {
  1026. this.statement.executeData.data.each(function (line, idx) {
  1027. var tr = new Element("tr", {
  1028. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode
  1029. }).inject(this.viewContentTableNode);
  1030. //this.createViewCheckboxTd( tr );
  1031. Object.each(entries, function (c, k) {
  1032. debugger;
  1033. var path = c.path, code = c.code, obj = line;
  1034. if( path ){
  1035. var pathList = path.split(".");
  1036. for( var i=0; i<pathList.length; i++ ){
  1037. var p = pathList[i];
  1038. if( (/(^[1-9]\d*$)/.test(p)) )p = p.toInt();
  1039. if( obj[ p ] ){
  1040. obj = obj[ p ];
  1041. }else{
  1042. obj = "";
  1043. break;
  1044. }
  1045. }
  1046. }
  1047. if( code && code.trim())obj = MWF.Macro.exec( code, { "target" : {"value": obj, "data": line, "entry": c} });
  1048. var toName = function (value) {
  1049. if(typeOf(value) === "array"){
  1050. Array.each( value, function (v, idx) {
  1051. value[idx] = toName(v)
  1052. })
  1053. }else if( typeOf(value) === "object" ){
  1054. Object.each( value, function (v, key) {
  1055. value[key] = toName(v);
  1056. })
  1057. }else if( typeOf( value ) === "string" ){
  1058. value = o2.name.cn( value )
  1059. }
  1060. return value;
  1061. };
  1062. var d;
  1063. if( obj!= undefined && obj!= null ){
  1064. if( typeOf(obj) === "array" ) {
  1065. d = c.isName ? JSON.stringify(toName(Array.clone(obj))) : JSON.stringify(obj);
  1066. }else if( typeOf(obj) === "object" ){
  1067. d = c.isName ? JSON.stringify(toName(Object.clone(obj))) : JSON.stringify(obj);
  1068. }else{
  1069. d = c.isName ? o2.name.cn( obj.toString() ) : obj;
  1070. }
  1071. }
  1072. if (d != undefined && d != null ) {
  1073. var td = new Element("td", {
  1074. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
  1075. }).inject(tr);
  1076. if (c.isHtml) {
  1077. td.set("html", d);
  1078. } else {
  1079. td.set("text", d);
  1080. }
  1081. }
  1082. }.bind(this));
  1083. }.bind(this));
  1084. this.setContentColumnWidth();
  1085. this.setContentHeight();
  1086. } else if (this.json.data.noDataText) {
  1087. var noDataTextNodeStyle = this.css.noDataTextNode;
  1088. if (this.json.data.viewStyles) {
  1089. if (this.json.data.viewStyles["noDataTextNode"]) {
  1090. noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
  1091. } else {
  1092. this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
  1093. }
  1094. }
  1095. this.noDataTextNode = new Element("div", {
  1096. "styles": noDataTextNodeStyle,
  1097. "text": this.json.data.noDataText
  1098. }).inject(this.viewContentBodyNode);
  1099. }
  1100. // }.bind(this));
  1101. // }.bind(this));
  1102. }
  1103. },
  1104. addColumn: function () {
  1105. debugger;
  1106. MWF.require("MWF.widget.UUID", function () {
  1107. var id = (new MWF.widget.UUID).id;
  1108. var json = {
  1109. "id": id,
  1110. "column": id,
  1111. "displayName": this.designer.lp.unnamed,
  1112. "orderType": "original"
  1113. };
  1114. if (!this.json.data.selectList) this.json.data.selectList = [];
  1115. this.json.data.selectList.push(json);
  1116. var column = new MWF.xApplication.query.StatementDesigner.View.Column(json, this);
  1117. this.items.push(column);
  1118. column.selected();
  1119. if (this.viewContentTableNode) {
  1120. var trs = this.viewContentTableNode.getElements("tr");
  1121. trs.each(function (tr) {
  1122. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  1123. }.bind(this));
  1124. //this.setContentColumnWidth();
  1125. }
  1126. this.setViewWidth();
  1127. this.addColumnNode.scrollIntoView(true);
  1128. }.bind(this));
  1129. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  1130. },
  1131. setContentHeight: function () {
  1132. var size = this.areaNode.getSize();
  1133. var titleSize = this.viewTitleNode.getSize();
  1134. var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x: 0, y: 0};
  1135. var pagingSize = this.pagingNode ? this.pagingNode.getSize() : {x: 0, y: 0};
  1136. var height = size.y - titleSize.y - actionbarSize.y - pagingSize.y - 4;
  1137. this.viewContentScrollNode.setStyle("height", height);
  1138. var contentSize = this.viewContentBodyNode.getSize();
  1139. if (height < contentSize.y) height = contentSize.y + 10;
  1140. this.viewContentNode.setStyle("height", height);
  1141. this.contentLeftNode.setStyle("height", height);
  1142. this.contentRightNode.setStyle("height", height);
  1143. //this.viewContentBodyNode.setStyle("min-height", height);
  1144. },
  1145. loadViewColumns: function () {
  1146. // for (var i=0; i<10; i++){
  1147. if (this.json.data.selectList) {
  1148. this.json.data.selectList.each(function (json) {
  1149. this.items.push(new MWF.xApplication.query.StatementDesigner.View.Column(json, this));
  1150. }.bind(this));
  1151. }
  1152. // }
  1153. },
  1154. showActionbar: function (noSetHeight) {
  1155. this.actionbarNode.show();
  1156. if (!this.json.data.actionbarList) this.json.data.actionbarList = [];
  1157. if (!this.actionbarList || this.actionbarList.length == 0) {
  1158. if (this.json.data.actionbarList.length) {
  1159. this.json.data.actionbarList.each(function (json) {
  1160. this.actionbarList.push(new MWF.xApplication.query.StatementDesigner.View.Actionbar(json, this.json.data.actionbarList, this))
  1161. }.bind(this));
  1162. } else {
  1163. this.actionbarList.push(new MWF.xApplication.query.StatementDesigner.View.Actionbar(null, this.json.data.actionbarList, this))
  1164. }
  1165. }
  1166. if (!noSetHeight) this.setContentHeight();
  1167. },
  1168. loadPaging: function (noSetHeight) {
  1169. this.pagingNode = new Element("div#pagingNode", {"styles": this.css.pagingNode}).inject(this.areaNode);
  1170. this.pagingList = [];
  1171. if (!this.json.data.pagingList) this.json.data.pagingList = [];
  1172. if (!this.pagingList || this.pagingList.length == 0) {
  1173. if (this.json.data.pagingList.length) {
  1174. this.json.data.pagingList.each(function (json) {
  1175. this.pagingList.push(new MWF.xApplication.query.StatementDesigner.View.Paging(json, this.json.data.pagingList, this))
  1176. }.bind(this));
  1177. } else {
  1178. this.pagingList.push(new MWF.xApplication.query.StatementDesigner.View.Paging(null, this.json.data.pagingList, this))
  1179. }
  1180. }
  1181. // if( !noSetHeight )this.setContentHeight();
  1182. },
  1183. setViewWidth: function () {
  1184. if (!this.viewAreaNode) return;
  1185. this.viewAreaNode.setStyle("width", "auto");
  1186. this.viewTitleNode.setStyle("width", "auto");
  1187. var s1 = this.viewTitleTableNode.getSize();
  1188. var s2 = this.refreshNode.getSize();
  1189. var s3 = this.addColumnNode.getSize();
  1190. var width = s1.x + s2.x + s2.x;
  1191. var size = this.areaNode.getSize();
  1192. if (width > size.x) {
  1193. this.viewTitleNode.setStyle("width", "" + (width - 2) + "px");
  1194. this.viewAreaNode.setStyle("width", "" + (width - 2) + "px");
  1195. } else {
  1196. this.viewTitleNode.setStyle("width", "" + (size.x - 2) + "px");
  1197. this.viewAreaNode.setStyle("width", "" + (size.x - 2) + "px");
  1198. }
  1199. this.setContentColumnWidth();
  1200. this.setContentHeight();
  1201. },
  1202. _setEditStyle: function (name, input, oldValue) {
  1203. if (name == "data.actionbarHidden") {
  1204. if (this.json.data.actionbarHidden) {
  1205. this.hideActionbar()
  1206. } else {
  1207. this.showActionbar()
  1208. }
  1209. }
  1210. if (name == "data.selectAllEnable") {
  1211. if (this.json.data.selectAllEnable) {
  1212. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display", "table-cell");
  1213. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display", "table-cell");
  1214. } else {
  1215. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display", "none");
  1216. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display", "none");
  1217. }
  1218. }
  1219. if (name == "data.viewStyleType") {
  1220. var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
  1221. var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
  1222. this.loadTemplateStyles(file, extendFile, function (templateStyles) {
  1223. this.templateStyles = templateStyles;
  1224. var oldFile, oldExtendFile;
  1225. if (oldValue && this.stylesList[oldValue]) {
  1226. oldFile = this.stylesList[oldValue].file;
  1227. oldExtendFile = this.stylesList[oldValue].extendFile;
  1228. }
  1229. this.loadTemplateStyles(oldFile, oldExtendFile, function (oldTemplateStyles) {
  1230. this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
  1231. if (oldTemplateStyles["view"]) this.clearTemplateStyles(oldTemplateStyles["view"]);
  1232. if (this.templateStyles["view"]) this.setTemplateStyles(this.templateStyles["view"]);
  1233. this.setAllStyles();
  1234. this.actionbarList.each(function (module) {
  1235. if (oldTemplateStyles["actionbar"]) {
  1236. module.clearTemplateStyles(oldTemplateStyles["actionbar"]);
  1237. }
  1238. module.setStyleTemplate();
  1239. module.setAllStyles();
  1240. })
  1241. this.pagingList.each(function (module) {
  1242. if (oldTemplateStyles["paging"]) {
  1243. module.clearTemplateStyles(oldTemplateStyles["paging"]);
  1244. }
  1245. module.setStyleTemplate();
  1246. module.setAllStyles();
  1247. });
  1248. // this.moduleList.each(function(module){
  1249. // if (oldTemplateStyles[module.moduleName]){
  1250. // module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  1251. // }
  1252. // module.setStyleTemplate();
  1253. // module.setAllStyles();
  1254. // }.bind(this));
  1255. }.bind(this))
  1256. }.bind(this))
  1257. }
  1258. if (name == "data.viewStyles") {
  1259. this.setCustomStyles();
  1260. }
  1261. },
  1262. loadTemplateStyle: function (callback) {
  1263. this.loadStylesList(function () {
  1264. var oldStyleValue = "";
  1265. if ((!this.json.data.viewStyleType) || !this.stylesList[this.json.data.viewStyleType]) this.json.data.viewStyleType = "default";
  1266. this.loadTemplateStyles(this.stylesList[this.json.data.viewStyleType].file, this.stylesList[this.json.data.viewStyleType].extendFile,
  1267. function (templateStyles) {
  1268. this.templateStyles = templateStyles;
  1269. if (!this.json.data.viewStyleType) this.json.data.viewStyleType = "default";
  1270. if (this.templateStyles && this.templateStyles["view"]) {
  1271. var viewStyles = Object.clone(this.templateStyles["view"]);
  1272. if (viewStyles.contentGroupTd) delete viewStyles.contentGroupTd;
  1273. if (viewStyles.groupCollapseNode) delete viewStyles.groupCollapseNode;
  1274. if (viewStyles.groupExpandNode) delete viewStyles.groupExpandNode;
  1275. if (!this.json.data.viewStyles) {
  1276. this.json.data.viewStyles = viewStyles;
  1277. } else {
  1278. this.setTemplateStyles(viewStyles);
  1279. }
  1280. }
  1281. this.setCustomStyles();
  1282. if (callback) callback();
  1283. }.bind(this)
  1284. );
  1285. }.bind(this));
  1286. },
  1287. clearTemplateStyles: function (styles) {
  1288. if (styles) {
  1289. if (styles.container) this.removeStyles(styles.container, "container");
  1290. if (styles.table) this.removeStyles(styles.table, "table");
  1291. if (styles.titleTr) this.removeStyles(styles.titleTr, "titleTr");
  1292. if (styles.titleTd) this.removeStyles(styles.titleTd, "titleTd");
  1293. if (styles.contentTr) this.removeStyles(styles.contentTr, "contentTr");
  1294. if (styles.contentSelectedTr) this.removeStyles(styles.contentSelectedTr, "contentSelectedTr");
  1295. if (styles.contentTd) this.removeStyles(styles.contentTd, "contentTd");
  1296. // if (styles.contentGroupTd) this.removeStyles(styles.contentGroupTd, "contentGroupTd");
  1297. // if (styles.groupCollapseNode) this.removeStyles(styles.groupCollapseNode, "groupCollapseNode");
  1298. // if (styles.groupExpandNode) this.removeStyles(styles.groupExpandNode, "groupExpandNode");
  1299. if (styles.checkboxNode) this.removeStyles(styles.checkboxNode, "checkboxNode");
  1300. if (styles.checkedCheckboxNode) this.removeStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  1301. if (styles.radioNode) this.removeStyles(styles.radioNode, "radioNode");
  1302. if (styles.checkedRadioNode) this.removeStyles(styles.checkedRadioNode, "checkedRadioNode");
  1303. if (styles.tableProperties) this.removeStyles(styles.tableProperties, "tableProperties");
  1304. }
  1305. },
  1306. setTemplateStyles: function (styles) {
  1307. if (styles.container) this.copyStyles(styles.container, "container");
  1308. if (styles.table) this.copyStyles(styles.table, "table");
  1309. if (styles.titleTr) this.copyStyles(styles.titleTr, "titleTr");
  1310. if (styles.titleTd) this.copyStyles(styles.titleTd, "titleTd");
  1311. if (styles.contentTr) this.copyStyles(styles.contentTr, "contentTr");
  1312. if (styles.contentSelectedTr) this.copyStyles(styles.contentSelectedTr, "contentSelectedTr");
  1313. if (styles.contentTd) this.copyStyles(styles.contentTd, "contentTd");
  1314. // if (styles.contentGroupTd) this.copyStyles(styles.contentGroupTd, "contentGroupTd");
  1315. // if (styles.groupCollapseNode) this.copyStyles(styles.groupCollapseNode, "groupCollapseNode");
  1316. // if (styles.groupExpandNode) this.copyStyles(styles.groupExpandNode, "groupExpandNode");
  1317. if (styles.checkboxNode) this.copyStyles(styles.checkboxNode, "checkboxNode");
  1318. if (styles.checkedCheckboxNode) this.copyStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  1319. if (styles.radioNode) this.copyStyles(styles.radioNode, "radioNode");
  1320. if (styles.checkedRadioNode) this.copyStyles(styles.checkedRadioNode, "checkedRadioNode");
  1321. if (styles.tableProperties) this.copyStyles(styles.tableProperties, "tableProperties");
  1322. },
  1323. removeStyles: function (from, to) {
  1324. if (this.json.data.viewStyles[to]) {
  1325. Object.each(from, function (style, key) {
  1326. if (this.json.data.viewStyles[to][key] && this.json.data.viewStyles[to][key] == style) {
  1327. delete this.json.data.viewStyles[to][key];
  1328. }
  1329. }.bind(this));
  1330. }
  1331. },
  1332. copyStyles: function (from, to) {
  1333. if (!this.json.data.viewStyles[to]) this.json.data.viewStyles[to] = {};
  1334. Object.each(from, function (style, key) {
  1335. if (!this.json.data.viewStyles[to][key]) this.json.data.viewStyles[to][key] = style;
  1336. }.bind(this));
  1337. }
  1338. // preview: function(){
  1339. // if( this.isNewView ){
  1340. // this.designer.notice( this.designer.lp.saveViewNotice, "error" );
  1341. // return;
  1342. // }
  1343. // this.saveSilence( function () {
  1344. // var url = "../x_desktop/app.html?app=query.Query&status=";
  1345. // url += JSON.stringify({
  1346. // id : this.data.application,
  1347. // viewId : this.data.id
  1348. // });
  1349. // window.open(o2.filterUrl(url),"_blank");
  1350. // }.bind(this));
  1351. // },
  1352. // saveSilence: function(callback){
  1353. // if (!this.data.name){
  1354. // this.designer.notice(this.designer.lp.notice.inputName, "error");
  1355. // return false;
  1356. // }
  1357. //
  1358. // this.designer.actions.saveView(this.data, function(json){
  1359. // this.data.id = json.data.id;
  1360. // this.isNewView = false;
  1361. // //this.page.textNode.set("text", this.data.name);
  1362. // if (this.lisNode) {
  1363. // this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  1364. // }
  1365. // if (callback) callback();
  1366. // }.bind(this));
  1367. // },
  1368. // save: function(callback){
  1369. // //if (this.designer.tab.showPage==this.page){
  1370. // if (!this.data.name){
  1371. // this.designer.notice(this.designer.lp.notice.inputName, "error");
  1372. // return false;
  1373. // }
  1374. // //}
  1375. // this.designer.actions.saveView(this.data, function(json){
  1376. // this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  1377. // this.isNewView = false;
  1378. // this.data.id = json.data.id;
  1379. // //this.page.textNode.set("text", this.data.name);
  1380. // if (this.lisNode) {
  1381. // this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  1382. // }
  1383. // if (callback) callback();
  1384. // }.bind(this));
  1385. // },
  1386. // saveAs: function(){
  1387. // var form = new MWF.xApplication.query.StatementDesigner.View.NewNameForm(this, {
  1388. // name : this.data.name + "_" + MWF.xApplication.query.StatementDesigner.LP.copy,
  1389. // query : this.data.query || this.data.application,
  1390. // queryName : this.data.queryName || this.data.applicationName
  1391. // }, {
  1392. // onSave : function( data, callback ){
  1393. // this._saveAs( data, callback );
  1394. // }.bind(this)
  1395. // }, {
  1396. // app: this.designer
  1397. // });
  1398. // form.edit()
  1399. // },
  1400. // _saveAs : function( data , callback){
  1401. // var _self = this;
  1402. //
  1403. // var d = this.cloneObject( this.data );
  1404. //
  1405. // d.isNewView = true;
  1406. // d.id = this.designer.actions.getUUID();
  1407. // d.name = data.name;
  1408. // d.alias = "";
  1409. // d.query = data.query;
  1410. // d.queryName = data.queryName;
  1411. // d.application = data.query;
  1412. // d.applicationName = data.queryName;
  1413. // d.pid = d.id + d.id;
  1414. //
  1415. // delete d[this.data.id+"viewFilterType"];
  1416. // d[d.id+"viewFilterType"]="custom";
  1417. //
  1418. // d.data.selectList.each( function( entry ){
  1419. // entry.id = (new MWF.widget.UUID).id;
  1420. // }.bind(this));
  1421. //
  1422. // this.designer.actions.saveView(d, function(json){
  1423. // this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  1424. // if (callback) callback();
  1425. // }.bind(this));
  1426. // }
  1427. });
  1428. MWF.xApplication.query.StatementDesigner.View.Column = new Class({
  1429. Extends: MWF.xApplication.query.ViewDesigner.View.Column,
  1430. initialize: function (json, view, next) {
  1431. this.propertyPath = "../x_component_query_StatementDesigner/$Statement/column.html";
  1432. this.view = view;
  1433. this.json = json;
  1434. this.next = next;
  1435. this.css = this.view.css;
  1436. this.content = this.view.viewTitleTrNode;
  1437. this.domListNode = this.view.domListNode;
  1438. this.load();
  1439. },
  1440. refreshColumnPathData: function () {
  1441. if (this.property) {
  1442. this.property.loadDataPathSelect();
  1443. }
  1444. },
  1445. getColumnDataPath: function () {
  1446. return this.view.statement.getColumnDataPath();
  1447. },
  1448. showProperty: function () {
  1449. if (!this.property) {
  1450. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1451. "path": this.propertyPath,
  1452. "onPostLoad": function () {
  1453. this.property.show();
  1454. var processDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedProcessArea");
  1455. var cmsDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedCMSArea");
  1456. if (this.view.json.type == "cms") {
  1457. processDiv.setStyle("display", "none");
  1458. cmsDiv.setStyle("display", "block");
  1459. } else {
  1460. processDiv.setStyle("display", "block");
  1461. cmsDiv.setStyle("display", "none");
  1462. }
  1463. }.bind(this)
  1464. });
  1465. this.property.load();
  1466. } else {
  1467. this.property.show();
  1468. }
  1469. },
  1470. selected: function () {
  1471. if (this.view.statement.currentSelectedModule) {
  1472. if (this.view.statement.currentSelectedModule == this) {
  1473. return true;
  1474. } else {
  1475. this.view.statement.currentSelectedModule.unSelected();
  1476. }
  1477. }
  1478. this.view.domListNode.show();
  1479. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  1480. this.listNode.setStyles(this.css.cloumnListNode_selected);
  1481. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1482. new Fx.Scroll(this.view.designer.propertyDomArea, {
  1483. "wheelStops": false,
  1484. "duration": 100
  1485. }).toElement(this.listNode);
  1486. this.view.statement.currentSelectedModule = this;
  1487. this.isSelected = true;
  1488. this._showActions();
  1489. this.showProperty();
  1490. },
  1491. unSelected: function () {
  1492. this.view.statement.currentSelectedModule = null;
  1493. //this.node.setStyles(this.css.viewTitleColumnNode);
  1494. if (this.isError) {
  1495. this.node.setStyles(this.css.viewTitleColumnNode_error)
  1496. } else {
  1497. this.node.setStyles(this.css.viewTitleColumnNode)
  1498. }
  1499. this.listNode.setStyles(this.css.cloumnListNode);
  1500. this.isSelected = false;
  1501. this._hideActions();
  1502. this.hideProperty();
  1503. }
  1504. });
  1505. MWF.xApplication.query.StatementDesigner.View.Actionbar = new Class({
  1506. Extends: MWF.xApplication.query.ViewDesigner.View.Actionbar,
  1507. initialize: function (json, jsonList, view, options) {
  1508. this.setOptions(options);
  1509. this.propertyPath = "../x_component_query_StatementDesigner/$Statement/actionbar.html";
  1510. this.path = "../x_component_query_ViewDesigner/$View/";
  1511. this.imagePath_default = "../x_component_query_ViewDesigner/$View/";
  1512. this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";
  1513. this.cssPath = "../x_component_query_ViewDesigner/$View/" + this.options.style + "/actionbar.wcss";
  1514. this.view = view;
  1515. this.json = json;
  1516. this.jsonList = jsonList;
  1517. this.css = this.view.css;
  1518. this.container = this.view.actionbarNode;
  1519. this.moduleName = "actionbar";
  1520. this.load();
  1521. },
  1522. getJsonPath: function () {
  1523. return "../x_component_query_StatementDesigner/$Statement/toolbars.json";
  1524. },
  1525. selected: function () {
  1526. if (this.view.statement.currentSelectedModule) {
  1527. if (this.view.statement.currentSelectedModule == this) {
  1528. return true;
  1529. } else {
  1530. this.view.statement.currentSelectedModule.unSelected();
  1531. }
  1532. }
  1533. this.view.domListNode.show();
  1534. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1535. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1536. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1537. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1538. this.view.statement.currentSelectedModule = this;
  1539. this.isSelected = true;
  1540. //this._showActions();
  1541. this.showProperty();
  1542. },
  1543. unSelected: function () {
  1544. this.view.statement.currentSelectedModule = null;
  1545. this.node.setStyles(this.css.toolbarWarpNode);
  1546. //this.listNode.setStyles(this.css.cloumnListNode);
  1547. this.isSelected = false;
  1548. //this._hideActions();
  1549. this.hideProperty();
  1550. },
  1551. });
  1552. MWF.xApplication.query.StatementDesigner.View.Paging = new Class({
  1553. Extends: MWF.xApplication.query.ViewDesigner.View.Paging,
  1554. selected: function () {
  1555. if (this.view.statement.currentSelectedModule) {
  1556. if (this.view.statement.currentSelectedModule == this) {
  1557. return true;
  1558. } else {
  1559. this.view.statement.currentSelectedModule.unSelected();
  1560. }
  1561. }
  1562. this.view.domListNode.show();
  1563. this.node.setStyles(this.css.pagingWarpNode_selected);
  1564. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1565. this.view.statement.currentSelectedModule = this;
  1566. this.isSelected = true;
  1567. this.showProperty();
  1568. },
  1569. unSelected: function () {
  1570. this.view.statement.currentSelectedModule = null;
  1571. this.node.setStyles(this.css.pagingWarpNode);
  1572. this.isSelected = false;
  1573. this.hideProperty();
  1574. }
  1575. });