Statement.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  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. MWF.xApplication.query.StatementDesigner.Statement = new Class({
  10. Extends: MWF.widget.Common,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "isView": false,
  15. "showTab": true,
  16. "propertyPath": "../x_component_query_StatementDesigner/$Statement/statement.html"
  17. },
  18. initialize: function(designer, data, options){
  19. this.setOptions(options);
  20. this.path = "../x_component_query_StatementDesigner/$Statement/";
  21. this.cssPath = "../x_component_query_StatementDesigner/$Statement/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.designer = designer;
  24. this.data = data;
  25. this.parseData();
  26. this.node = this.designer.designNode;
  27. this.areaNode = new Element("div", {"styles": {"height": "100%", "overflow": "auto"}});
  28. //this.statementRunNode = this.designer.designerStatementArea;
  29. if(this.designer.application) this.data.applicationName = this.designer.application.name;
  30. if(this.designer.application) this.data.application = this.designer.application.id;
  31. this.isNewStatement = (this.data.id) ? false : true;
  32. this.view = this;
  33. this.autoSave();
  34. this.designer.addEvent("queryClose", function(){
  35. if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  36. }.bind(this));
  37. },
  38. parseData: function(){
  39. this.json = this.data;
  40. if (!this.json.type) this.json.type = "select";
  41. if (!this.json.format) this.json.format = "jpql";
  42. if (!this.json.entityCategory) this.json.entityCategory = "official";
  43. if (!this.json.entityClassName) this.json.entityClassName = "com.x.processplatform.core.entity.content.Task";
  44. },
  45. autoSave: function(){
  46. this.autoSaveTimerID = window.setInterval(function(){
  47. if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFAutoSaveCheck");
  48. if (this.autoSaveCheckNode){
  49. if (this.autoSaveCheckNode.get("checked")){
  50. this.save();
  51. }
  52. }
  53. }.bind(this), 60000);
  54. },
  55. load : function(){
  56. // this.setAreaNodeSize();
  57. // this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  58. this.areaNode.inject(this.node);
  59. this.designer.statementListAreaNode.getChildren().each(function(node){
  60. var statement = node.retrieve("statement");
  61. if (statement.id==this.data.id){
  62. if (this.designer.currentListStatementItem){
  63. this.designer.currentListStatementItem.setStyles(this.designer.css.listStatementItem);
  64. }
  65. node.setStyles(this.designer.css.listStatementItem_current);
  66. this.designer.currentListStatementItem = node;
  67. this.lisNode = node;
  68. }
  69. }.bind(this));
  70. this.loadStatement();
  71. // this.showProperty();
  72. this.selected();
  73. },
  74. selected: function(){
  75. if (this.currentSelectedModule){
  76. if (this.currentSelectedModule==this){
  77. return true;
  78. }else{
  79. this.currentSelectedModule.unSelected();
  80. }
  81. }
  82. this.currentSelectedModule = this;
  83. this.isSelected = true;
  84. this.showProperty();
  85. },
  86. unSelected: function(){
  87. this.currentSelectedModule = null;
  88. this.isSelected = false;
  89. this.hideProperty();
  90. },
  91. showProperty: function(){
  92. if (!this.property){
  93. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.designer.designerContentArea, this.designer, {
  94. "path": this.options.propertyPath,
  95. "onPostLoad": function(){
  96. this.property.show();
  97. }.bind(this)
  98. });
  99. this.property.load();
  100. }else{
  101. this.property.show();
  102. }
  103. },
  104. hideProperty: function(){
  105. if (this.property) this.property.hide();
  106. },
  107. loadStatement: function(){
  108. //this.statementDesignerNode = new Element("div", {"styles": this.css.statementDesignerNode}).inject(this.areaNode);
  109. this.loadStatementHtml(function(){
  110. this.designerArea = this.areaNode.getElement(".o2_statement_statementDesignerNode");
  111. this.jpqlArea = this.areaNode.getElement(".o2_statement_statementDesignerJpql");
  112. this.scriptArea = this.areaNode.getElement(".o2_statement_statementDesignerScript");
  113. this.formatTypeArea = this.areaNode.getElement(".o2_statement_statementDesignerFormatContent");
  114. this.entityCategorySelect = this.areaNode.getElement(".o2_statement_statementDesignerCategoryContent").getElement("select");
  115. this.dynamicTableArea = this.areaNode.getElement(".o2_statement_statementDesignerTableArea_dynamic");
  116. this.officialTableArea = this.areaNode.getElement(".o2_statement_statementDesignerTableArea_official");
  117. this.customTableArea = this.areaNode.getElement(".o2_statement_statementDesignerTableArea_custom");
  118. this.dynamicTableSelect = this.areaNode.getElement(".o2_statement_statementDesignerSelectTable");
  119. this.officialTableSelect = this.officialTableArea.getElement("select");
  120. this.dynamicTableContent = this.areaNode.getElement(".o2_statement_statementDesignerTableContent");
  121. this.jpqlTypeSelect = this.areaNode.getElement(".o2_statement_statementDesignerTypeContent").getElement("select");
  122. // this.jpqlSelectEditor = this.areaNode.getElement(".o2_statement_statementDesignerJpql_select");
  123. // this.jpqlUpdateEditor = this.areaNode.getElement(".o2_statement_statementDesignerJpql_update");
  124. // this.jpqlDeleteEditor = this.areaNode.getElement(".o2_statement_statementDesignerJpql_sdelete");
  125. // this.jpqlSelectEditor_selectContent= this.jpqlSelectEditor.getElement(".o2_statement_statementDesignerJpql_jpql_selectContent");
  126. // this.jpqlSelectEditor_fromContent= this.jpqlSelectEditor.getElement(".o2_statement_statementDesignerJpql_jpql_fromContent");
  127. // this.jpqlSelectEditor_whereContent= this.jpqlSelectEditor.getElement(".o2_statement_statementDesignerJpql_jpql_whereContent");
  128. this.jpqlEditorNode = this.areaNode.getElement(".o2_statement_statementDesignerJpqlLine");
  129. // this.runArea = this.areaNode.getElement(".o2_statement_statementRunNode");
  130. // this.runTitleNode = this.areaNode.getElement(".o2_statement_statementRunTitleNode");
  131. // this.runContentNode = this.areaNode.getElement(".o2_statement_statementRunContentNode");
  132. // this.runJsonNode = this.runContentNode.getFirst();
  133. // this.runActionNode = this.runJsonNode.getNext();
  134. // this.runResultNode = this.runContentNode.getLast();
  135. //
  136. // this.setRunnerSize();
  137. // this.designer.addEvent("resize", this.setRunnerSize.bind(this));
  138. this.viewArea = this.areaNode.getElement(".o2_statement_viewNode");
  139. this.setViewSize();
  140. this.designer.addEvent("resize", this.setViewSize.bind(this));
  141. if (this.json.format=="script"){
  142. this.loadStatementScriptEditor();
  143. }else{
  144. this.loadStatementEditor();
  145. }
  146. // this.loadStatementRunner();
  147. this.loadView();
  148. this.setEvent();
  149. }.bind(this));
  150. },
  151. loadStatementScriptEditor: function(){
  152. if (! this.scriptEditor){
  153. debugger;
  154. o2.require("o2.widget.ScriptArea", function(){
  155. this.scriptEditor = new o2.widget.ScriptArea(this.scriptArea, {
  156. "isbind": false,
  157. "maxObj": this.designer.designNode,
  158. "title": this.designer.lp.scriptTitle,
  159. "onChange": function(){
  160. this.json.scriptText = this.scriptEditor.toJson().code;
  161. }.bind(this)
  162. });
  163. this.scriptEditor.load({"code": this.json.scriptText})
  164. }.bind(this), false);
  165. }
  166. },
  167. // setRunnerSize: function(){
  168. // debugger;
  169. // var size = this.areaNode.getSize();
  170. // var designerSize = this.designerArea.getComputedSize();
  171. // var y = size.y-designerSize.totalHeight;
  172. // var mTop = this.runArea.getStyle("margin-top").toInt();
  173. // var mBottom = this.runArea.getStyle("margin-bottom").toInt();
  174. // var pTop = this.runArea.getStyle("padding-top").toInt();
  175. // var pBottom = this.runArea.getStyle("padding-bottom").toInt();
  176. // y = y-mTop-mBottom-pTop-pBottom-1;
  177. //
  178. // this.runArea.setStyle("height", ""+y+"px");
  179. //
  180. // var titleSize = this.runTitleNode.getComputedSize();
  181. // y = y - titleSize.totalHeight;
  182. // this.runContentNode.setStyle("height", ""+y+"px");
  183. // },
  184. loadStatementEditor: function(){
  185. if (!this.editor){
  186. o2.require("o2.widget.JavascriptEditor", function(){
  187. this.editor = new o2.widget.JavascriptEditor(this.jpqlEditorNode, {"title": "JPQL", "option": {"mode": "sql"}});
  188. this.editor.load(function(){
  189. if (this.json.data){
  190. this.editor.editor.setValue(this.json.data);
  191. }else{
  192. var table = "table";
  193. switch (this.json.type) {
  194. case "update":
  195. this.editor.editor.setValue("UPDATE "+table+" o SET ");
  196. break;
  197. case "delete":
  198. this.editor.editor.setValue("DELETE "+table+" o WHERE ");
  199. break;
  200. default:
  201. this.editor.editor.setValue("SELECT * FROM "+table+" o");
  202. }
  203. }
  204. this.json.data = this.editor.editor.getValue();
  205. this.editor.addEditorEvent("change", function(){
  206. debugger;
  207. this.data.data = this.editor.getValue();
  208. this.checkJpqlType();
  209. }.bind(this));
  210. // this.editor.editor.on("change", function(){
  211. // this.data.data = this.editor.getValue();
  212. // this.checkJpqlType();
  213. // }.bind(this));
  214. }.bind(this));
  215. }.bind(this), false);
  216. }
  217. },
  218. setSatementTable: function(){
  219. if (!this.json.type) this.json.type = "select";
  220. this.changeType(this.json.type, true);
  221. if (this.json.data){
  222. this.editor.editor.setValue(this.json.data);
  223. }else{
  224. var table = (this.json.tableObj) ? this.json.tableObj.name : "table";
  225. switch (this.json.type) {
  226. case "update":
  227. this.editor.editor.setValue("UPDATE "+table+" o SET ");
  228. break;
  229. case "delete":
  230. this.editor.editor.setValue("DELETE "+table+" o WHERE ");
  231. break;
  232. default:
  233. this.editor.editor.setValue("SELECT * FROM "+table+" o");
  234. }
  235. }
  236. },
  237. checkJpqlType: function(){
  238. var str = this.json.data;
  239. this.json.data = str;
  240. var jpql_select = /^select/i;
  241. var jpql_update = /^update/i;
  242. var jpql_delete = /^delete/i;
  243. if (jpql_select.test(str)) return this.changeType("select");
  244. if (jpql_update.test(str)) return this.changeType("update");
  245. if (jpql_delete.test(str)) return this.changeType("delete");
  246. },
  247. changeType: function(type, force){
  248. if (this.json.type!=type) this.json.type=type;
  249. if (type != this.jpqlTypeSelect.options[this.jpqlTypeSelect.selectedIndex].value || force){
  250. for (var i=0; i<this.jpqlTypeSelect.options.length; i++){
  251. if (this.jpqlTypeSelect.options[i].value==type){
  252. this.jpqlTypeSelect.options[i].set("selected", true);
  253. break;
  254. }
  255. }
  256. }
  257. },
  258. loadStatementHtml: function(callback){
  259. this.areaNode.loadAll({
  260. "css": this.path+this.options.style+"/statement.css",
  261. "html": this.path+"statementDesigner.html"
  262. }, {
  263. "bind": {"lp": this.designer.lp, "data": this.data}
  264. },function(){
  265. if (callback) callback();
  266. }.bind(this));
  267. },
  268. // loadStatementRunner: function(){
  269. // o2.require("o2.widget.JavascriptEditor", function(){
  270. // this.jsonEditor = new o2.widget.JavascriptEditor(this.runJsonNode, {"title": "JPQL", "option": {"mode": "json"}});
  271. // this.jsonEditor.load(function(){
  272. // this.jsonEditor.editor.setValue("{}");
  273. // }.bind(this));
  274. // }.bind(this), false);
  275. // },
  276. setEvent: function(){
  277. this.designerArea.addEvent("click", function (e) {
  278. this.selected();
  279. e.stopPropagation();
  280. }.bind(this));
  281. this.formatTypeArea.getElements("input").addEvent("click", function(e){
  282. if (e.target.checked){
  283. var v = e.target.get("value");
  284. if (v==="script"){
  285. this.scriptArea.show();
  286. this.jpqlArea.hide();
  287. this.loadStatementScriptEditor();
  288. }else{
  289. this.scriptArea.hide();
  290. this.jpqlArea.show();
  291. this.loadStatementEditor();
  292. }
  293. this.json.format = v;
  294. }
  295. }.bind(this));
  296. this.entityCategorySelect.addEvent("change", function(e){
  297. var entityCategory = e.target.options[e.target.selectedIndex].value;
  298. switch (entityCategory) {
  299. case "dynamic":
  300. this.officialTableArea.hide();
  301. this.dynamicTableArea.show();
  302. this.customTableArea.hide();
  303. break;
  304. case "custom":
  305. this.officialTableArea.hide();
  306. this.dynamicTableArea.hide();
  307. this.customTableArea.show();
  308. break;
  309. default:
  310. this.officialTableArea.show();
  311. this.dynamicTableArea.hide();
  312. this.customTableArea.hide();
  313. break;
  314. }
  315. this.json.entityCategory = entityCategory
  316. }.bind(this));
  317. //@todo change table
  318. this.officialTableSelect.addEvent("change", function(e){
  319. debugger;
  320. var entityClassName = e.target.options[e.target.selectedIndex].value;
  321. this.json.entityClassName = entityClassName;
  322. if (this.json.format=="jpql"){
  323. if (this.editor){
  324. var re = /(.*from\s*)/ig;
  325. if (this.json.type=="update") re = /(.*update\s*)/ig;
  326. //if (this.json.type=="select" && this.editor){
  327. var v = this.json.data;
  328. var re2 = /(\s+)/ig;
  329. var arr = re.exec(v);
  330. if (arr && arr[0]){
  331. var left = arr[0]
  332. v = v.substring(left.length, v.length);
  333. //var ar = re2.exec(v);
  334. var right = v.substring(v.indexOf(" "),v.length);
  335. this.json.data = left+entityClassName+right;
  336. this.editor.editor.setValue(this.json.data);
  337. }
  338. //}
  339. }
  340. }
  341. // var className = e.target.options[e.target.selectedIndex].value;
  342. // if (this.json.type=="select"){
  343. // this.json.data
  344. // /(select)*(where|)/g
  345. // }
  346. // }.bind(this));
  347. // this.jpqlTypeSelect.addEvent("change", function(){
  348. // var type = e.target.options[e.target.selectedIndex].value;
  349. // switch (entityCategory) {
  350. // case "update":
  351. // this.jpqlSelectEditor.hide();
  352. // this.jpqlUpdateEditor.show();
  353. // this.jpqlDeleteEditor.hide();
  354. // this.loadJpqlUpdateEditor();
  355. // break;
  356. // case "delete":
  357. // this.jpqlSelectEditor.hide();
  358. // this.jpqlUpdateEditor.hide();
  359. // this.jpqlDeleteEditor.show();
  360. // break;
  361. // default:
  362. // this.jpqlSelectEditor.show();
  363. // this.jpqlUpdateEditor.hide();
  364. // this.jpqlDeleteEditor.hide();
  365. // break;
  366. // }
  367. }.bind(this));
  368. // this.runActionNode.getFirst().addEvent("click", this.runStatement.bind(this));
  369. this.dynamicTableSelect.addEvent("click", this.selectTable.bind(this));
  370. this.jpqlTypeSelect.addEvent("change", function(){
  371. var t = this.jpqlTypeSelect.options[this.jpqlTypeSelect.selectedIndex].value;
  372. if (t!=this.json.type) this.json.type=t;
  373. }.bind(this));
  374. },
  375. selectTable: function(){
  376. new MWF.O2Selector(this.designer.content, {
  377. "type": "queryTable",
  378. "count": 1,
  379. "values": (this.json.table) ? [this.json.table] : [],
  380. "title": this.designer.lp.selectTable,
  381. "onComplete": function(items){
  382. if (items.length){
  383. var id = items[0].data.id;
  384. var name = items[0].data.name;
  385. this.dynamicTableContent.set("text", name);
  386. this.json.table = name;
  387. this.json.tableObj = items[0].data;
  388. }else{
  389. this.dynamicTableContent.set("text", "");
  390. this.json.table = "";
  391. }
  392. }.bind(this)
  393. });
  394. },
  395. runStatement:function(){
  396. debugger;
  397. // if (!this.json.data){
  398. // this.designer.notice(this.designer.lp.inputStatementData, "error");
  399. // return false;
  400. // }
  401. o2.require("o2.widget.Mask", null, false);
  402. this.runMask = new o2.widget.Mask();
  403. this.runMask.loadNode(this.node);
  404. this.saveSilence(function(){
  405. var json = this.jsonEditor.editor.getValue();
  406. var o = JSON.parse(json);
  407. o2.Actions.get("x_query_assemble_designer").executeStatement(this.json.id, 1, 50 , o, function(json){
  408. o2.require("o2.widget.JsonParse", function(){
  409. // this.runResultNode.empty();
  410. // var jsonResult = new o2.widget.JsonParse(json.data, this.runResultNode);
  411. // jsonResult.load();
  412. }.bind(this));
  413. this.runMask.hide();
  414. }.bind(this), function(xhr, text, error){
  415. debugger;
  416. if (this.runMask) this.runMask.hide();
  417. var errorText = error;
  418. if (xhr){
  419. var json = JSON.decode(xhr.responseText);
  420. if (json){
  421. errorText = json.message.trim() || "request json error";
  422. }else{
  423. errorText = "request json error: "+xhr.responseText;
  424. }
  425. }
  426. errorText = errorText.replace(/\</g, "&lt;");
  427. errorText = errorText.replace(/\</g, "&gt;");
  428. MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  429. }.bind(this))
  430. }.bind(this));
  431. },
  432. save: function(callback){
  433. debugger;
  434. if (!this.data.name){
  435. this.designer.notice(this.designer.lp.inputStatementName, "error");
  436. return false;
  437. }
  438. //if( !this.data.tableType ){
  439. // this.data.tableType = "dynamic";
  440. //}
  441. if (this.editor) this.data.data = this.editor.editor.getValue();
  442. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  443. this.designer.actions.saveStatement(this.data, function(json){
  444. this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  445. this.data.id = json.data.id;
  446. if (this.lisNode) {
  447. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  448. }
  449. if (callback) callback();
  450. }.bind(this));
  451. },
  452. _setEditStyle: function(){},
  453. saveSilence: function(callback){
  454. if (!this.data.name){
  455. this.designer.notice(this.designer.lp.inputStatementName, "error");
  456. return false;
  457. }
  458. if (this.editor) this.data.data = this.editor.editor.getValue();
  459. if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code;
  460. this.designer.actions.saveStatement(this.data, function(json){
  461. //this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  462. this.data.id = json.data.id;
  463. if (this.lisNode) {
  464. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  465. }
  466. if (callback) callback();
  467. }.bind(this));
  468. },
  469. loadView : function(){
  470. if( !this.data.view )this.data.view = {};
  471. this.view = new MWF.xApplication.query.StatementDesigner.View(this.designer, this, this.data.view, {});
  472. this.view.load();
  473. },
  474. setViewSize: function(){
  475. debugger;
  476. var size = this.areaNode.getSize();
  477. var designerSize = this.designerArea.getComputedSize();
  478. var y = size.y-designerSize.totalHeight;
  479. var mTop = this.viewArea.getStyle("margin-top").toInt();
  480. var mBottom = this.viewArea.getStyle("margin-bottom").toInt();
  481. var pTop = this.viewArea.getStyle("padding-top").toInt();
  482. var pBottom = this.viewArea.getStyle("padding-bottom").toInt();
  483. y = y-mTop-mBottom-pTop-pBottom-1;
  484. this.viewArea.setStyle("height", ""+y+"px");
  485. // var titleSize = this.runTitleNode.getComputedSize();
  486. // y = y - titleSize.totalHeight;
  487. // this.runContentNode.setStyle("height", ""+y+"px");
  488. }
  489. });
  490. MWF.xApplication.query.StatementDesigner.View = new Class({
  491. Extends: MWF.xApplication.query.ViewDesigner.View,
  492. Implements: [Options, Events],
  493. options: {
  494. "style": "default",
  495. "isView": false,
  496. "showTab": true,
  497. "propertyPath": "../x_component_query_StatementDesigner/$Statement/view.html"
  498. },
  499. initialize: function(designer, statement, data, options){
  500. this.setOptions(options);
  501. this.path = "../x_component_query_ViewDesigner/$View/";
  502. this.cssPath = "../x_component_query_ViewDesigner/$View/"+this.options.style+"/css.wcss";
  503. this._loadCss();
  504. this.statement = statement;
  505. this.designer = designer;
  506. this.data = data;
  507. // if (!this.data.data) this.data.data = {};
  508. this.parseData();
  509. this.node = this.statement.viewArea;
  510. //this.tab = this.designer.tab;
  511. this.areaNode = new Element("div", {"styles": {"height": "calc(100% - 2px)", "overflow": "auto" }});
  512. this.areaNode.setStyles(this.css.areaNode);
  513. //MWF.require("MWF.widget.ScrollBar", function(){
  514. // new MWF.widget.ScrollBar(this.areaNode, {"distance": 100});
  515. //}.bind(this));
  516. // this.propertyListNode = this.designer.propertyDomArea;
  517. //this.propertyNode = this.designer.propertyContentArea;
  518. // if(this.designer.application) this.data.applicationName = this.designer.application.name;
  519. // if(this.designer.application) this.data.application = this.designer.application.id;
  520. // this.isNewView = (this.data.name) ? false : true;
  521. this.items = [];
  522. this.view = this;
  523. // this.autoSave();
  524. // this.designer.addEvent("queryClose", function(){
  525. // if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  526. // }.bind(this));
  527. },
  528. load : function(){
  529. this.setAreaNodeSize();
  530. this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  531. this.areaNode.inject(this.node);
  532. this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
  533. this.loadTemplateStyle( function () {
  534. this.loadActionbar();
  535. this.loadView();
  536. this.loadPaging();
  537. // this.selected();
  538. this.setEvent();
  539. //if (this.options.showTab) this.page.showTabIm();
  540. this.setViewWidth();
  541. this.designer.addEvent("resize", this.setViewWidth.bind(this));
  542. }.bind(this))
  543. },
  544. parseData: function(){
  545. this.json = this.data;
  546. if( !this.json.data || !this.json.data.events ){
  547. var url = "../x_component_query_StatementDesigner/$Statement/view.json";
  548. MWF.getJSON(url, {
  549. "onSuccess": function(obj){
  550. if(!this.json.data)this.json.data = obj.data;
  551. if(!this.json.data.events)this.json.data.events = obj.data.events;
  552. }.bind(this),
  553. "onerror": function(text){
  554. this.notice(text, "error");
  555. }.bind(this),
  556. "onRequestFailure": function(xhr){
  557. this.notice(xhr.responseText, "error");
  558. }.bind(this)
  559. },false);
  560. }
  561. },
  562. setEvent: function(){
  563. this.areaNode.addEvents({
  564. "click": function(e){ this.selected(); e.stopPropagation(); }.bind(this),
  565. "mouseover": function(){ if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode_over)}.bind(this),
  566. "mouseout": function(){if (!this.isSelected) this.areaNode.setStyles(this.css.areaNode)}.bind(this)
  567. });
  568. this.refreshNode.addEvent("click", function(e){
  569. this.loadViewData();
  570. e.stopPropagation();
  571. }.bind(this));
  572. this.addColumnNode.addEvent("click", function(e){
  573. this.addColumn();
  574. e.stopPropagation();
  575. }.bind(this));
  576. },
  577. selected: function(){
  578. debugger;
  579. if (this.statement.currentSelectedModule){
  580. if (this.statement.currentSelectedModule==this){
  581. return true;
  582. }else{
  583. this.statement.currentSelectedModule.unSelected();
  584. }
  585. }
  586. this.areaNode.setStyles(this.css.areaNode_selected);
  587. this.statement.currentSelectedModule = this;
  588. this.isSelected = true;
  589. this.showProperty();
  590. },
  591. unSelected: function(){
  592. this.statement.currentSelectedModule = null;
  593. this.isSelected = false;
  594. this.areaNode.setStyles(this.css.areaNode);
  595. this.hideProperty();
  596. },
  597. showProperty: function(){
  598. if (!this.property){
  599. this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  600. "path": this.options.propertyPath,
  601. "onPostLoad": function(){
  602. this.property.show();
  603. }.bind(this)
  604. });
  605. this.property.load();
  606. }else{
  607. this.property.show();
  608. }
  609. },
  610. hideProperty: function(){
  611. if (this.property) this.property.hide();
  612. },
  613. loadViewData: function(){
  614. if (this.data.id){
  615. this.saveSilence(function(){
  616. this.viewContentBodyNode.empty();
  617. this.viewContentTableNode = new Element("table", {
  618. "styles": this.css.viewContentTableNode,
  619. "border": "0px",
  620. "cellPadding": "0",
  621. "cellSpacing": "0"
  622. }).inject(this.viewContentBodyNode);
  623. this.designer.actions.loadView(this.data.id, null,function(json){
  624. var entries = {};
  625. json.data.selectList.each(function(entry){entries[entry.column] = entry;}.bind(this));
  626. if (this.json.data.group.column){
  627. if (json.data.groupGrid.length){
  628. var groupColumn = null;
  629. for (var c = 0; c<json.data.selectList.length; c++){
  630. if (json.data.selectList[c].column === json.data.group.column){
  631. groupColumn = json.data.selectList[c];
  632. break;
  633. }
  634. }
  635. json.data.groupGrid.each(function(line, idx){
  636. var groupTr = new Element("tr", {
  637. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode,
  638. "data-is-group" : "yes"
  639. }).inject(this.viewContentTableNode);
  640. var colSpan = this.items.length ;
  641. var td = new Element("td", {
  642. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentGroupTd"] : this.css.viewContentGroupTdNode,
  643. "colSpan": colSpan
  644. }).inject(groupTr);
  645. var groupAreaNode;
  646. if( this.json.data.viewStyles ){
  647. groupAreaNode = new Element("div", {"styles": this.json.data.viewStyles["groupCollapseNode"]}).inject(td);
  648. groupAreaNode.set("text", line.group);
  649. }else{
  650. groupAreaNode = new Element("div", {"styles": this.css.viewContentTdGroupNode}).inject(td);
  651. var groupIconNode = new Element("div", {"styles": this.css.viewContentTdGroupIconNode}).inject(groupAreaNode);
  652. var groupTextNode = new Element("div", {"styles": this.css.viewContentTdGroupTextNode}).inject(groupAreaNode);
  653. if (groupColumn){
  654. //groupTextNode.set("text", (groupColumn.code) ? MWF.Macro.exec(groupColumn.code, {"value": line.group, "gridData": json.data.groupGrid, "data": json.data, "entry": line}) : line.group);
  655. groupTextNode.set("text", line.group);
  656. }else{
  657. groupTextNode.set("text", line.group);
  658. }
  659. }
  660. var subtrs = [];
  661. line.list.each(function(entry){
  662. var tr = new Element("tr", {
  663. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode
  664. }).inject(this.viewContentTableNode);
  665. tr.setStyle("display", "none");
  666. //this.createViewCheckboxTd( tr );
  667. var td = new Element("td", {
  668. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
  669. }).inject(tr);
  670. Object.each(entries, function(c, k){
  671. var d = entry.data[k];
  672. if (d!=undefined){
  673. if (k!=this.json.data.group.column){
  674. var td = new Element("td", {
  675. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
  676. }).inject(tr);
  677. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  678. if (c.isHtml){
  679. td.set("html", d);
  680. }else{
  681. td.set("text", d);
  682. }
  683. }
  684. }
  685. }.bind(this));
  686. // Object.each(entry.data, function(d, k){
  687. // if (k!=this.json.data.group.column){
  688. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  689. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  690. // }
  691. // }.bind(this));
  692. subtrs.push(tr)
  693. }.bind(this));
  694. groupAreaNode.store("subtrs", subtrs);
  695. var _self = this;
  696. groupAreaNode.addEvent("click", function(){
  697. var subtrs = this.retrieve("subtrs");
  698. var iconNode = groupAreaNode.getFirst("div");
  699. if (subtrs[0]){
  700. if (subtrs[0].getStyle("display")=="none"){
  701. subtrs.each(function(subtr){ subtr.setStyle("display", "table-row"); });
  702. if( iconNode ) {
  703. iconNode.setStyle("background", "url(" + "../x_component_process_StatementDesigner/$View/default/icon/down.png) center center no-repeat");
  704. }else{
  705. this.setStyles( _self.json.data.viewStyles["groupExpandNode"] )
  706. }
  707. }else{
  708. subtrs.each(function(subtr){ subtr.setStyle("display", "none"); });
  709. if( iconNode ) {
  710. iconNode.setStyle("background", "url(" + "../x_component_process_StatementDesigner/$View/default/icon/right.png) center center no-repeat");
  711. }else{
  712. this.setStyles( _self.json.data.viewStyles["groupCollapseNode"] )
  713. }
  714. }
  715. }
  716. _self.setContentHeight();
  717. });
  718. }.bind(this));
  719. this.setContentColumnWidth();
  720. this.setContentHeight();
  721. }else if(this.json.data.noDataText){
  722. var noDataTextNodeStyle = this.css.noDataTextNode;
  723. if( this.json.data.viewStyles ){
  724. if( this.json.data.viewStyles["noDataTextNode"] ){
  725. noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
  726. }else{
  727. this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
  728. }
  729. }
  730. this.noDataTextNode = new Element( "div", {
  731. "styles": noDataTextNodeStyle,
  732. "text" : this.json.data.noDataText
  733. }).inject( this.viewContentBodyNode );
  734. }
  735. }else{
  736. if (json.data.grid.length){
  737. json.data.grid.each(function(line, idx){
  738. var tr = new Element("tr", {
  739. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode
  740. }).inject(this.viewContentTableNode);
  741. //this.createViewCheckboxTd( tr );
  742. Object.each(entries, function(c, k){
  743. var d = line.data[k];
  744. if (d!=undefined){
  745. var td = new Element("td", {
  746. "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
  747. }).inject(tr);
  748. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  749. if (c.isHtml){
  750. td.set("html", d);
  751. }else{
  752. td.set("text", d);
  753. }
  754. //td.set("text", d);
  755. }
  756. }.bind(this));
  757. // Object.each(line.data, function(d, k){
  758. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  759. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  760. // }.bind(this));
  761. }.bind(this));
  762. this.setContentColumnWidth();
  763. this.setContentHeight();
  764. }else if(this.json.data.noDataText){
  765. var noDataTextNodeStyle = this.css.noDataTextNode;
  766. if( this.json.data.viewStyles ){
  767. if( this.json.data.viewStyles["noDataTextNode"] ){
  768. noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
  769. }else{
  770. this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
  771. }
  772. }
  773. this.noDataTextNode = new Element( "div", {
  774. "styles": noDataTextNodeStyle,
  775. "text" : this.json.data.noDataText
  776. }).inject( this.viewContentBodyNode );
  777. }
  778. }
  779. }.bind(this));
  780. }.bind(this));
  781. }
  782. },
  783. addColumn: function(){
  784. debugger;
  785. MWF.require("MWF.widget.UUID", function(){
  786. var id = (new MWF.widget.UUID).id;
  787. var json = {
  788. "id": id,
  789. "column": id,
  790. "displayName": this.designer.lp.unnamed,
  791. "orderType": "original"
  792. };
  793. if (!this.json.data.selectList) this.json.data.selectList = [];
  794. this.json.data.selectList.push(json);
  795. var column = new MWF.xApplication.query.StatementDesigner.View.Column(json, this);
  796. this.items.push(column);
  797. column.selected();
  798. if (this.viewContentTableNode){
  799. var trs = this.viewContentTableNode.getElements("tr");
  800. trs.each(function(tr){
  801. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  802. }.bind(this));
  803. //this.setContentColumnWidth();
  804. }
  805. this.setViewWidth();
  806. this.addColumnNode.scrollIntoView(true);
  807. }.bind(this));
  808. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  809. },
  810. loadViewColumns: function(){
  811. // for (var i=0; i<10; i++){
  812. if (this.json.data.selectList) {
  813. this.json.data.selectList.each(function (json) {
  814. this.items.push(new MWF.xApplication.query.StatementDesigner.View.Column(json, this));
  815. }.bind(this));
  816. }
  817. // }
  818. },
  819. showActionbar : function( noSetHeight ){
  820. this.actionbarNode.show();
  821. if( !this.json.data.actionbarList )this.json.data.actionbarList = [];
  822. if( !this.actionbarList || this.actionbarList.length == 0 ){
  823. if( this.json.data.actionbarList.length ){
  824. this.json.data.actionbarList.each( function(json){
  825. this.actionbarList.push( new MWF.xApplication.query.StatementDesigner.View.Actionbar( json, this.json.data.actionbarList, this) )
  826. }.bind(this));
  827. }else{
  828. this.actionbarList.push( new MWF.xApplication.query.StatementDesigner.View.Actionbar( null, this.json.data.actionbarList, this) )
  829. }
  830. }
  831. if( !noSetHeight )this.setContentHeight();
  832. },
  833. loadPaging: function( noSetHeight ){
  834. this.pagingNode = new Element("div#pagingNode", {"styles": this.css.pagingNode}).inject(this.areaNode);
  835. this.pagingList = [];
  836. if( !this.json.data.pagingList )this.json.data.pagingList = [];
  837. if( !this.pagingList || this.pagingList.length == 0 ){
  838. if( this.json.data.pagingList.length ){
  839. this.json.data.pagingList.each( function(json){
  840. this.pagingList.push( new MWF.xApplication.query.StatementDesigner.View.Paging( json, this.json.data.pagingList, this) )
  841. }.bind(this));
  842. }else{
  843. this.pagingList.push( new MWF.xApplication.query.StatementDesigner.View.Paging( null, this.json.data.pagingList, this) )
  844. }
  845. }
  846. // if( !noSetHeight )this.setContentHeight();
  847. },
  848. setViewWidth: function(){
  849. if( !this.viewAreaNode )return;
  850. this.viewAreaNode.setStyle("width", "auto");
  851. this.viewTitleNode.setStyle("width", "auto");
  852. var s1 = this.viewTitleTableNode.getSize();
  853. var s2 = this.refreshNode.getSize();
  854. var s3 = this.addColumnNode.getSize();
  855. var width = s1.x+s2.x+s2.x;
  856. var size = this.areaNode.getSize();
  857. if (width>size.x){
  858. this.viewTitleNode.setStyle("width", ""+(width-2)+"px");
  859. this.viewAreaNode.setStyle("width", ""+(width-2)+"px");
  860. }else{
  861. this.viewTitleNode.setStyle("width", ""+(size.x-2)+"px");
  862. this.viewAreaNode.setStyle("width", ""+(size.x-2)+"px");
  863. }
  864. this.setContentColumnWidth();
  865. this.setContentHeight();
  866. },
  867. preview: function(){
  868. if( this.isNewView ){
  869. this.designer.notice( this.designer.lp.saveViewNotice, "error" );
  870. return;
  871. }
  872. this.saveSilence( function () {
  873. var url = "../x_desktop/app.html?app=query.Query&status=";
  874. url += JSON.stringify({
  875. id : this.data.application,
  876. viewId : this.data.id
  877. });
  878. window.open(o2.filterUrl(url),"_blank");
  879. }.bind(this));
  880. },
  881. saveSilence: function(callback){
  882. if (!this.data.name){
  883. this.designer.notice(this.designer.lp.notice.inputName, "error");
  884. return false;
  885. }
  886. this.designer.actions.saveView(this.data, function(json){
  887. this.data.id = json.data.id;
  888. this.isNewView = false;
  889. //this.page.textNode.set("text", this.data.name);
  890. if (this.lisNode) {
  891. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  892. }
  893. if (callback) callback();
  894. }.bind(this));
  895. },
  896. save: function(callback){
  897. //if (this.designer.tab.showPage==this.page){
  898. if (!this.data.name){
  899. this.designer.notice(this.designer.lp.notice.inputName, "error");
  900. return false;
  901. }
  902. //}
  903. this.designer.actions.saveView(this.data, function(json){
  904. this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  905. this.isNewView = false;
  906. this.data.id = json.data.id;
  907. //this.page.textNode.set("text", this.data.name);
  908. if (this.lisNode) {
  909. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  910. }
  911. if (callback) callback();
  912. }.bind(this));
  913. },
  914. _setEditStyle: function(name, input, oldValue){
  915. if( name=="data.actionbarHidden" ){
  916. if( this.json.data.actionbarHidden ){
  917. this.hideActionbar()
  918. }else{
  919. this.showActionbar()
  920. }
  921. }
  922. if( name=="data.selectAllEnable" ){
  923. if( this.json.data.selectAllEnable ){
  924. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","table-cell");
  925. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","table-cell");
  926. }else{
  927. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","none");
  928. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","none");
  929. }
  930. }
  931. if (name=="data.viewStyleType"){
  932. var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
  933. var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
  934. this.loadTemplateStyles( file, extendFile, function( templateStyles ){
  935. this.templateStyles = templateStyles;
  936. var oldFile, oldExtendFile;
  937. if( oldValue && this.stylesList[oldValue] ){
  938. oldFile = this.stylesList[oldValue].file;
  939. oldExtendFile = this.stylesList[oldValue].extendFile;
  940. }
  941. this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){
  942. this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
  943. if (oldTemplateStyles["view"]) this.clearTemplateStyles(oldTemplateStyles["view"]);
  944. if (this.templateStyles["view"]) this.setTemplateStyles(this.templateStyles["view"]);
  945. this.setAllStyles();
  946. this.actionbarList.each( function (module) {
  947. if (oldTemplateStyles["actionbar"]){
  948. module.clearTemplateStyles(oldTemplateStyles["actionbar"]);
  949. }
  950. module.setStyleTemplate();
  951. module.setAllStyles();
  952. })
  953. this.pagingList.each( function (module) {
  954. if (oldTemplateStyles["paging"]){
  955. module.clearTemplateStyles(oldTemplateStyles["paging"]);
  956. }
  957. module.setStyleTemplate();
  958. module.setAllStyles();
  959. });
  960. // this.moduleList.each(function(module){
  961. // if (oldTemplateStyles[module.moduleName]){
  962. // module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  963. // }
  964. // module.setStyleTemplate();
  965. // module.setAllStyles();
  966. // }.bind(this));
  967. }.bind(this))
  968. }.bind(this))
  969. }
  970. if (name=="data.viewStyles"){
  971. this.setCustomStyles();
  972. }
  973. },
  974. removeStyles: function(from, to){
  975. if (this.json.data.viewStyles[to]){
  976. Object.each(from, function(style, key){
  977. if (this.json.data.viewStyles[to][key] && this.json.data.viewStyles[to][key]==style){
  978. delete this.json.data.viewStyles[to][key];
  979. }
  980. }.bind(this));
  981. }
  982. },
  983. copyStyles: function(from, to){
  984. if (!this.json.data.viewStyles[to]) this.json.data.viewStyles[to] = {};
  985. Object.each(from, function(style, key){
  986. if (!this.json.data.viewStyles[to][key]) this.json.data.viewStyles[to][key] = style;
  987. }.bind(this));
  988. },
  989. saveAs: function(){
  990. var form = new MWF.xApplication.query.StatementDesigner.View.NewNameForm(this, {
  991. name : this.data.name + "_" + MWF.xApplication.query.StatementDesigner.LP.copy,
  992. query : this.data.query || this.data.application,
  993. queryName : this.data.queryName || this.data.applicationName
  994. }, {
  995. onSave : function( data, callback ){
  996. this._saveAs( data, callback );
  997. }.bind(this)
  998. }, {
  999. app: this.designer
  1000. });
  1001. form.edit()
  1002. },
  1003. _saveAs : function( data , callback){
  1004. var _self = this;
  1005. var d = this.cloneObject( this.data );
  1006. d.isNewView = true;
  1007. d.id = this.designer.actions.getUUID();
  1008. d.name = data.name;
  1009. d.alias = "";
  1010. d.query = data.query;
  1011. d.queryName = data.queryName;
  1012. d.application = data.query;
  1013. d.applicationName = data.queryName;
  1014. d.pid = d.id + d.id;
  1015. delete d[this.data.id+"viewFilterType"];
  1016. d[d.id+"viewFilterType"]="custom";
  1017. d.data.selectList.each( function( entry ){
  1018. entry.id = (new MWF.widget.UUID).id;
  1019. }.bind(this));
  1020. this.designer.actions.saveView(d, function(json){
  1021. this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  1022. if (callback) callback();
  1023. }.bind(this));
  1024. }
  1025. });
  1026. MWF.xApplication.query.StatementDesigner.View.Column = new Class({
  1027. Extends: MWF.xApplication.query.ViewDesigner.View.Column,
  1028. selected: function(){
  1029. if (this.view.statement.currentSelectedModule){
  1030. if (this.view.statement.currentSelectedModule==this){
  1031. return true;
  1032. }else{
  1033. this.view.statement.currentSelectedModule.unSelected();
  1034. }
  1035. }
  1036. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  1037. this.listNode.setStyles(this.css.cloumnListNode_selected);
  1038. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1039. new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1040. this.view.statement.currentSelectedModule = this;
  1041. this.isSelected = true;
  1042. this._showActions();
  1043. this.showProperty();
  1044. },
  1045. unSelected: function(){
  1046. this.view.statement.currentSelectedModule = null;
  1047. //this.node.setStyles(this.css.viewTitleColumnNode);
  1048. if (this.isError){
  1049. this.node.setStyles(this.css.viewTitleColumnNode_error)
  1050. }else{
  1051. this.node.setStyles(this.css.viewTitleColumnNode)
  1052. }
  1053. this.listNode.setStyles(this.css.cloumnListNode);
  1054. this.isSelected = false;
  1055. this._hideActions();
  1056. this.hideProperty();
  1057. }
  1058. });
  1059. MWF.xApplication.query.StatementDesigner.View.Actionbar = new Class({
  1060. Extends: MWF.xApplication.query.ViewDesigner.View.Actionbar,
  1061. initialize: function(json, jsonList, view, options){
  1062. this.setOptions( options );
  1063. this.propertyPath = "../x_component_query_StatementDesigner/$Statement/actionbar.html";
  1064. this.path = "../x_component_query_ViewDesigner/$View/";
  1065. this.imagePath_default = "../x_component_query_ViewDesigner/$View/";
  1066. this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";
  1067. this.cssPath = "../x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
  1068. this.view = view;
  1069. this.json = json;
  1070. this.jsonList = jsonList;
  1071. this.css = this.view.css;
  1072. this.container = this.view.actionbarNode;
  1073. this.moduleName = "actionbar";
  1074. this.load();
  1075. },
  1076. getJsonPath : function(){
  1077. return "../x_component_query_StatementDesigner/$Statement/toolbars.json";
  1078. },
  1079. selected: function(){
  1080. if (this.view.statement.currentSelectedModule){
  1081. if (this.view.statement.currentSelectedModule==this){
  1082. return true;
  1083. }else{
  1084. this.view.statement.currentSelectedModule.unSelected();
  1085. }
  1086. }
  1087. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1088. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1089. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1090. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1091. this.view.statement.currentSelectedModule = this;
  1092. this.isSelected = true;
  1093. //this._showActions();
  1094. this.showProperty();
  1095. },
  1096. unSelected: function(){
  1097. this.view.statement.currentSelectedModule = null;
  1098. this.node.setStyles(this.css.toolbarWarpNode)
  1099. //this.listNode.setStyles(this.css.cloumnListNode);
  1100. this.isSelected = false;
  1101. //this._hideActions();
  1102. this.hideProperty();
  1103. },
  1104. });
  1105. MWF.xApplication.query.StatementDesigner.View.Paging = new Class({
  1106. Extends: MWF.xApplication.query.ViewDesigner.View.Paging,
  1107. selected: function(){
  1108. if (this.view.statement.currentSelectedModule){
  1109. if (this.view.statement.currentSelectedModule==this){
  1110. return true;
  1111. }else{
  1112. this.view.statement.currentSelectedModule.unSelected();
  1113. }
  1114. }
  1115. this.node.setStyles(this.css.pagingWarpNode_selected);
  1116. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1117. this.view.statement.currentSelectedModule = this;
  1118. this.isSelected = true;
  1119. this.showProperty();
  1120. },
  1121. unSelected: function(){
  1122. this.view.statement.currentSelectedModule = null;
  1123. this.node.setStyles(this.css.pagingWarpNode);
  1124. this.isSelected = false;
  1125. this.hideProperty();
  1126. }
  1127. });