Statement.js 74 KB

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