Main.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. MWF.APPPD = MWF.xApplication.process.ProcessDesigner;
  2. MWF.APPPD.options = {
  3. "multitask": true,
  4. "executable": false
  5. };
  6. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", null, false);
  7. MWF.require("MWF.widget.MWFRaphael", null, false);
  8. MWF.xApplication.process.ProcessDesigner.Main = new Class({
  9. Extends: MWF.xApplication.Common.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "template": "process.json",
  14. "name": "process.ProcessDesigner",
  15. "icon": "icon.png",
  16. "title": MWF.APPPD.LP.title,
  17. "appTitle": MWF.APPPD.LP.title,
  18. "id": "",
  19. "tooltip": {
  20. "unCategory": MWF.APPPD.LP.unCategory
  21. },
  22. "actions": null,
  23. "category": null,
  24. "processData": null
  25. },
  26. onQueryLoad: function(){
  27. this.shortcut = true;
  28. if (this.status){
  29. if(this.status.id)this.options.id = this.status.id;
  30. }
  31. if (!this.options.id){
  32. this.options.desktopReload = false;
  33. this.options.title = this.options.title + "-"+MWF.APPPD.LP.newProcess;
  34. }
  35. this.actions = MWF.Actions.get("x_processplatform_assemble_designer");
  36. //this.actions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  37. this.lp = MWF.xApplication.process.ProcessDesigner.LP;
  38. // this.processData = this.options.processData;
  39. if( !this.application && this.options.application ){
  40. this.application = this.options.application;
  41. }
  42. },
  43. loadApplication: function(callback){
  44. this.gadgets = [];
  45. this.gadgetMode="all";
  46. this.gadgetDecrease = 0;
  47. this.createNode();
  48. if (!this.options.isRefresh){
  49. this.maxSize(function(){
  50. this.openProcess();
  51. }.bind(this));
  52. }else{
  53. this.openProcess();
  54. }
  55. this.addKeyboardEvents();
  56. if (callback) callback();
  57. },
  58. addKeyboardEvents: function(){
  59. this.addEvent("copy", function(){
  60. this.copyModule();
  61. }.bind(this));
  62. this.addEvent("paste", function(){
  63. this.pasteModule();
  64. }.bind(this));
  65. this.addEvent("keySave", function(e){
  66. this.keySave(e);
  67. }.bind(this));
  68. this.addEvent("keyDelete", function(e){
  69. this.keyDelete(e);
  70. }.bind(this));
  71. //this.addEvent("cut", function(){
  72. // this.cutModule();
  73. //}.bind(this));
  74. },
  75. keySave: function(e){
  76. if (this.shortcut) {
  77. if (this.process) this.saveProcess();
  78. e.preventDefault();
  79. }
  80. },
  81. keyDelete: function(e){
  82. if (this.shortcut) {
  83. if (this.process) {
  84. if (this.process.selectedActivitys.length) {
  85. } else if (this.process.currentSelected) {
  86. var p = this.content.getPosition();
  87. if (this.process.currentSelected.type) {
  88. var a = this.process.currentSelected;
  89. var e = {"event": {"x": a.center.x + p.x, "y": a.center.y + p.y}};
  90. this.process.deleteActivity(e, this.process.currentSelected);
  91. } else {
  92. var r = this.process.currentSelected;
  93. var e = {"event": {"x": r.beginPoint.x + p.x, "y": r.beginPoint.y + p.y}};
  94. this.process.deleteRoute(e, this.process.currentSelected);
  95. }
  96. }
  97. }
  98. }
  99. },
  100. copyModule: function(){
  101. if (this.shortcut) {
  102. if (this.process) {
  103. // if (this.process.isFocus){
  104. //if (!this.paperInNode.contains(document.activeElement)) return false;
  105. if (this.process.selectedActivitys.length) {
  106. var activitys = [];
  107. var routes = [];
  108. this.process.selectedActivitys.each(function (activity) {
  109. //if (activity.data.type.toLowerCase()!=="begin"){
  110. activitys.push(Object.clone(activity.data));
  111. activity.routes.each(function (route) {
  112. if (route.toActivity) {
  113. //if (this.process.selectedActivitys.indexOf(route.toActivity) != -1){
  114. routes.push(Object.clone(route.data));
  115. //}else{
  116. // activity.routes = null;
  117. //}
  118. } else {
  119. routes.push(Object.clone(route.data));
  120. }
  121. }.bind(this));
  122. //}
  123. //activity.routes = activity.routes.clean();
  124. }.bind(this));
  125. MWF.clipboard.data = {
  126. "type": "process",
  127. "data": {
  128. "activitys": activitys,
  129. "routes": routes
  130. }
  131. };
  132. } else if (this.process.currentSelected) {
  133. if (this.process.currentSelected.type) {
  134. //if (this.process.currentSelected.data.type.toLowerCase()!=="begin"){
  135. var data = Object.clone(this.process.currentSelected.data);
  136. MWF.clipboard.data = {
  137. "type": "process",
  138. "data": {
  139. "activitys": [data],
  140. "routes": []
  141. }
  142. };
  143. //}
  144. } else {
  145. MWF.clipboard.data = null;
  146. }
  147. }
  148. // }
  149. }
  150. }
  151. },
  152. pasteModuleError: function(bakData){
  153. this.notice(this.lp.notice.processCopyError, "error");
  154. this.process.reload(bakData);
  155. MWF.clipboard.data = null;
  156. },
  157. pasteModule: function(){
  158. if (this.process){
  159. // if (this.process.isFocus){
  160. //if (!this.paperInNode.contains(document.activeElement)) return false;
  161. if (MWF.clipboard.data){
  162. if (MWF.clipboard.data.type=="process"){
  163. var bakData = Object.clone(this.process.process);
  164. this.process.unSelectedAll();
  165. var activitys = MWF.clipboard.data.data.activitys;
  166. var routes = MWF.clipboard.data.data.routes;
  167. var checkUUIDs;
  168. this.actions.getId(activitys.length+routes.length, function(ids) {
  169. try {
  170. checkUUIDs = ids.data;
  171. var idReplace = {};
  172. var processId = this.process.process.id;
  173. activitys.each(function(d){
  174. var id = checkUUIDs.pop().id;
  175. idReplace[d.id] = id;
  176. d.id = id;
  177. d.process = processId;
  178. });
  179. routes.each(function(d){
  180. var id = checkUUIDs.pop().id;
  181. idReplace[d.id] = id;
  182. d.id = id;
  183. d.process = processId;
  184. d.activity = idReplace[d.activity];
  185. });
  186. activitys.each(function(d){
  187. if (d.route){
  188. d.route = idReplace[d.route];
  189. }
  190. if (d.routeList){
  191. d.routeList.each(function(r, i){
  192. d.routeList[i] = idReplace[r]
  193. });
  194. }
  195. });
  196. var loadRoutes = function(){
  197. try{
  198. routes.each(function(item){
  199. this.process.process.routeList.push(Object.clone(item));
  200. this.process.routes[item.id] = new MWF.APPPD.Route(item, this.process);
  201. this.process.routeDatas[item.id] = item;
  202. // this.routes[item.id].load();
  203. }.bind(this));
  204. activitys.each(function(d){
  205. //this.process[d.type+"s"][d.id].loadRoutes();
  206. (this.process[d.type] || this.process[d.type+"s"][d.id]).loadRoutes();
  207. if (activitys.length>1){
  208. (this.process[d.type] || this.process[d.type+"s"][d.id]).selectedMulti();
  209. }else{
  210. this.process[d.type+"s"][d.id].selected();
  211. }
  212. }.bind(this));
  213. routes.each(function(item){
  214. var route = this.process.routes[item.id];
  215. if (!route.loaded) route.load();
  216. }.bind(this));
  217. MWF.clipboard.data = null;
  218. }catch(e){
  219. this.pasteModuleError(bakData);
  220. }
  221. };
  222. var loadedCount = 0;
  223. activitys.each(function(activity){
  224. //if (activity.type.toLowerCase()!=="begin"){
  225. var data = Object.clone(activity);
  226. var type = data.type;
  227. if (type.toLowerCase()=="begin"){
  228. if (!this.process.begin){
  229. this.process.process.begin = data;
  230. this.process.loadBegin(function(){
  231. loadedCount++;
  232. if (loadedCount==activitys.length) loadRoutes.apply(this);
  233. }.bind(this));
  234. }else{
  235. //loadedCount++;
  236. activitys.erase(activity);
  237. if (loadedCount==activitys.length) loadRoutes.apply(this);
  238. }
  239. }else{
  240. if (!this.process.process[type+"List"]) this.process.process[type+"List"] = [];
  241. this.process.process[type+"List"].push(data);
  242. var c = type.capitalize();
  243. // if (type==="begin") {
  244. // if (!this.process.begin){
  245. // this.process.loadActivity(c, data, this.process.begin, function(){
  246. // loadedCount++;
  247. // if (loadedCount==activitys.length) loadRoutes.apply(this);
  248. // }.bind(this));
  249. // }
  250. // }else{
  251. this.process.loadActivity(c, data, this.process[type+"s"], function(){
  252. loadedCount++;
  253. if (loadedCount==activitys.length) loadRoutes.apply(this);
  254. }.bind(this));
  255. // }
  256. }
  257. // }
  258. }.bind(this));
  259. }catch(e){
  260. this.pasteModuleError(bakData)
  261. }
  262. }.bind(this));
  263. }
  264. }
  265. // }
  266. }
  267. },
  268. createNode: function(){
  269. this.content.setStyle("overflow", "hidden");
  270. this.node = new Element("div", {
  271. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  272. }).inject(this.content);
  273. },
  274. openProcess: function(){
  275. this.loadNodes();
  276. this.loadGadgets();
  277. this.loadToolbar(function(){
  278. this.resizePaper();
  279. this.addEvent("resize", function(){this.resizePaper();}.bind(this));
  280. this.getProcessData(function(){
  281. this.loadPaper();
  282. }.bind(this));
  283. }.bind(this));
  284. this.resizeNode();
  285. this.addEvent("resize", this.resizeNode.bind(this));
  286. },
  287. resizeNode: function(){
  288. var nodeSize = this.node.getSize();
  289. var titleSize = this.gadgetTitleNode.getSize();
  290. var titleMarginTop = this.gadgetTitleNode.getStyle("margin-top").toFloat();
  291. var titleMarginBottom = this.gadgetTitleNode.getStyle("margin-bottom").toFloat();
  292. var titlePaddingTop = this.gadgetTitleNode.getStyle("padding-top").toFloat();
  293. var titlePaddingBottom = this.gadgetTitleNode.getStyle("padding-bottom").toFloat();
  294. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;
  295. y = nodeSize.y-y;
  296. this.gadgetContentNode.setStyle("height", ""+y+"px");
  297. },
  298. getProcessData: function(callback){
  299. if (!this.options.id){
  300. this.loadNewProcessData(callback);
  301. }else{
  302. this.loadProcessData(callback);
  303. }
  304. },
  305. loadNewProcessData: function(callback){
  306. //MWF.getJSON(this.path+"process.json", {
  307. var url = "../x_component_process_ProcessDesigner/$Process/template/"+this.options.template;
  308. MWF.getJSON(url, {
  309. "onSuccess": function(obj){
  310. obj.id="";
  311. obj.isNewProcess = true;
  312. this.processData = obj;
  313. if (callback) callback();
  314. }.bind(this),
  315. "onerror": function(text){
  316. this.notice(text, "error");
  317. }.bind(this),
  318. "onRequestFailure": function(xhr){
  319. this.notice(xhr.responseText, "error");
  320. }.bind(this)
  321. });
  322. },
  323. loadProcessData: function(callback){
  324. this.actions.getProcess(this.options.id, function(process){
  325. if (process){
  326. this.processData = process.data;
  327. this.processData.isNewProcess = false;
  328. this.setTitle(this.options.appTitle + "-"+this.processData.name);
  329. if (!this.application){
  330. this.actions.getApplication(process.data.application, function(json){
  331. this.application = {"name": json.data.name, "id": json.data.id};
  332. if (callback) callback();
  333. }.bind(this));
  334. }else{
  335. if (callback) callback();
  336. }
  337. }
  338. }.bind(this));
  339. },
  340. loadGadgets: function(){
  341. this.gadgetTitleNode = new Element("div", {
  342. "styles": this.css.gadgetTitleNode,
  343. "text": MWF.APPPD.LP.tools
  344. }).inject(this.gadgetAreaNode);
  345. this.gadgetTitleActionNode = new Element("div", {
  346. "styles": this.css.gadgetTitleActionNode,
  347. "events": {"click": function(e){this.switchGadgetAreaMode();}.bind(this)}
  348. }).inject(this.gadgetAreaNode);
  349. this.gadgetContentNode = new Element("div", {
  350. "styles": this.css.gadgetContentNode,
  351. "events": {"selectstart": function(e){e.preventDefault(); e.stopPropagation();}}
  352. }).inject(this.gadgetAreaNode);
  353. MWF.getJSON(this.path+"gadget.json", function(json){
  354. Object.each(json, function(value, key){
  355. this.createGadgetNode(value, key);
  356. }.bind(this));
  357. }.bind(this));
  358. this.setScrollBar(this.gadgetContentNode, null, {
  359. "V": {"x": 0, "y": 0},
  360. "H": {"x": 0, "y": 0}
  361. });
  362. },
  363. switchGadgetAreaMode: function(){
  364. if (this.gadgetMode=="all"){
  365. var size = this.gadgetAreaNode.getSize();
  366. this.gadgetDecrease = (size.x.toFloat())-60;
  367. this.gadgets.each(function(node){
  368. node.getLast().setStyle("display", "none");
  369. });
  370. this.gadgetTitleNode.set("text", "");
  371. this.gadgetAreaNode.setStyle("width", "60px");
  372. var rightMargin = this.rightContentNode.getStyle("margin-left").toFloat();
  373. rightMargin = rightMargin - this.gadgetDecrease;
  374. this.rightContentNode.setStyle("margin-left", ""+rightMargin+"px");
  375. this.gadgetTitleActionNode.setStyles(this.css.gadgetTitleActionNodeRight);
  376. this.gadgetMode="simple";
  377. }else{
  378. sizeX = 60 + this.gadgetDecrease;
  379. var rightMargin = this.rightContentNode.getStyle("margin-left").toFloat();
  380. rightMargin = rightMargin + this.gadgetDecrease;
  381. this.gadgetAreaNode.setStyle("width", ""+sizeX+"px");
  382. this.rightContentNode.setStyle("margin-left", ""+rightMargin+"px");
  383. this.gadgets.each(function(node){
  384. node.getLast().setStyle("display", "block");
  385. });
  386. this.gadgetTitleNode.set("text", MWF.APPPD.LP.tools);
  387. this.gadgetTitleActionNode.setStyles(this.css.gadgetTitleActionNode);
  388. this.gadgetMode="all";
  389. }
  390. },
  391. createGadgetNode: function(data, key){
  392. var _self = this;
  393. var gadgetNode = new Element("div", {
  394. "styles": this.css.gadgetToolNode,
  395. "title": data.text,
  396. "events": {
  397. "mouseover": function(e){
  398. try {
  399. this.setStyles(_self.css.gadgetToolNodeOver);
  400. }catch(e){
  401. this.setStyles(_self.css.gadgetToolNodeOverCSS2);
  402. };
  403. },
  404. "mouseout": function(e){
  405. try {
  406. this.setStyles(_self.css.gadgetToolNode);
  407. }catch(e){};
  408. },
  409. "mousedown": function(e){
  410. try {
  411. this.setStyles(_self.css.gadgetToolNodeDown);
  412. }catch(e){
  413. this.setStyles(_self.css.gadgetToolNodeDownCSS2);
  414. };
  415. },
  416. "mouseup": function(e){
  417. try {
  418. this.setStyles(_self.css.gadgetToolNodeUp);
  419. }catch(e){
  420. this.setStyles(_self.css.gadgetToolNodeUpCSS2);
  421. };
  422. }
  423. }
  424. }).inject(this.gadgetContentNode);
  425. gadgetNode.store("gadgetClass", data.className);
  426. gadgetNode.store("gadgetType", key);
  427. gadgetNode.store("gadgetIcon", data.icon);
  428. var iconNode = new Element("div", {
  429. "styles": this.css.gadgetToolIconNode
  430. }).inject(gadgetNode);
  431. iconNode.setStyle("background-image", "url("+this.path+this.options.style+"/gadget/"+data.icon+")");
  432. var textNode = new Element("div", {
  433. "styles": this.css.gadgetToolTextNode,
  434. "text": data.text
  435. });
  436. textNode.inject(gadgetNode);
  437. // var designer = this;
  438. gadgetNode.addEvent("mousedown", function(e){
  439. var className = this.retrieve("gadgetClass");
  440. var gadgetType = this.retrieve("gadgetType");
  441. var gadgetIcon = this.retrieve("gadgetIcon");
  442. _self.gadgetCreateActivity(this, gadgetType, gadgetIcon, className, e);
  443. });
  444. this.gadgets.push(gadgetNode);
  445. },
  446. gadgetCreateActivity: function(node, gadgetType, gadgetIcon, className, e){
  447. var activity = null;
  448. // if (activity){
  449. var moveNode = new Element("div", {
  450. "styles": {
  451. "width": "30px",
  452. "height": "30px",
  453. "opacity": "1",
  454. "background": "url("+this.path+this.options.style+"/gadget/"+gadgetIcon+") top left no-repeat",
  455. "postion": "absolute"
  456. }
  457. }).inject(this.paperNode);
  458. var moveNodeSize = moveNode.getSize();
  459. //moveNode.position({"relativeTo": node, "position": "upperLeft", "edge": "upperLeft"});
  460. var x = e.page.x;
  461. var y = e.page.y;
  462. moveNode.positionTo(x, y);
  463. var droppables = [this.paperNode];
  464. var nodeDrag = new Drag.Move(moveNode, {
  465. "droppables": droppables,
  466. "onEnter": function(dragging, inObj){
  467. moveNode.setStyles({
  468. "opacity":"1",
  469. "background": "url("+this.path+this.options.style+"/gadget/"+gadgetIcon+") top left no-repeat"
  470. });
  471. //moveNode.setStyle("opacity","0");
  472. //activity = this.process.createActivity(gadgetType, className);
  473. //if (activity){
  474. // activity.selected();
  475. // activity.activityMoveStart();
  476. //
  477. // moveNode.dragMove = true;
  478. //
  479. // var p = moveNode.getPosition(this.paperNode);
  480. // var dx = p.x - activity.point.x;
  481. // var dy = p.y - activity.point.y;
  482. // activity.activityMove(dx, dy, 0, 0, e);
  483. //
  484. // moveNode.dx = activity.point.x;
  485. // moveNode.dy = activity.point.y;
  486. // activity.activityMoveStart();
  487. //}else{
  488. // moveNode.setStyles({
  489. // "opacity":"1",
  490. // "background": "url("+this.path+this.options.style+"/gadget/stop.png) top left no-repeat",
  491. // });
  492. //}
  493. }.bind(this),
  494. "onLeave": function(dragging, inObj){
  495. moveNode.setStyles({
  496. "opacity":"1",
  497. "background": "url("+this.path+this.options.style+"/gadget/stop.png) top left no-repeat"
  498. });
  499. if (activity) activity.destroy();
  500. moveNode.dragMove = false;
  501. }.bind(this),
  502. "onDrag": function(e){
  503. if (moveNode.dragMove){
  504. var p = moveNode.getPosition(this.paperNode);
  505. var dx = p.x-moveNode.dx;
  506. var dy = p.y-moveNode.dy;
  507. activity.activityMove(dx, dy, 0, 0, e);
  508. }
  509. }.bind(this),
  510. "onDrop": function(dragging, inObj){
  511. //if (moveNode.dragMove){
  512. // activity.activityMoveEnd();
  513. //}
  514. }.bind(this),
  515. "onComplete": function(e){
  516. var p = moveNode.getPosition(this.paperNode);
  517. //var dx = p.x - activity.point.x;
  518. //var dy = p.y - activity.point.y;
  519. var px = Raphael.snapTo(10, p.x, 10);
  520. var py = Raphael.snapTo(10, p.y, 10);
  521. activity = this.process.createActivity(gadgetType, className, {"x": px, "y": py});
  522. if (activity) activity.selected();
  523. // activity.activityMoveStart();
  524. //moveNode.dragMove = true;
  525. // activity.activityMove(dx, dy, 0, 0, e);
  526. //moveNode.dx = activity.point.x;
  527. //moveNode.dy = activity.point.y;
  528. //activity.activityMoveStart();
  529. // activity.activityMoveEnd();
  530. moveNode.destroy();
  531. }.bind(this),
  532. "onCancel": function(dragging){
  533. if (activity) activity.destroy();
  534. moveNode.destroy();
  535. }.bind(this)
  536. });
  537. nodeDrag.start(e);
  538. // }
  539. },
  540. loadNodes: function(){
  541. this.gadgetAreaNode = new Element("div", {
  542. "styles": this.css.gadgetAreaNode
  543. }).inject(this.node);
  544. this.rightContentNode = new Element("div", {
  545. "styles": this.css.rightContentNode
  546. }).inject(this.node);
  547. this.toolbarNode = new Element("div", {
  548. "styles": this.css.toolbarNode
  549. }).inject(this.rightContentNode);
  550. this.paperAreaNode = new Element("div", {
  551. "styles": this.css.paperAreaNode
  552. }).inject(this.rightContentNode);
  553. this.paperNode = new Element("div", {
  554. "styles": this.css.paperNode
  555. }).inject(this.paperAreaNode);
  556. },
  557. loadToolbar: function(callback){
  558. this.getProcessToolbarHTML(function(toolbarNode){
  559. var spans = toolbarNode.getElements("span");
  560. spans.each(function(item, idx){
  561. var img = item.get("MWFButtonImage");
  562. if (img){
  563. item.set("MWFButtonImage", this.path+""+this.options.style+"/toolbarIcon/"+img);
  564. }
  565. }.bind(this));
  566. $(toolbarNode).inject(this.toolbarNode);
  567. MWF.require("MWF.widget.Toolbar", function(){
  568. this.processToolbar = new MWF.widget.Toolbar(toolbarNode, {"style": "Process"}, this);
  569. this.processToolbar.load();
  570. if (callback) callback();
  571. }.bind(this));
  572. var select = toolbarNode.getElement("select");
  573. if (select){
  574. select.addEvent("change", function(){
  575. this.process.setStyle(select.options[select.selectedIndex].value);
  576. }.bind(this));
  577. }
  578. this.processEditionNode = toolbarNode.getElement(".processEdition");
  579. this.processEditionInforNode = toolbarNode.getElement(".processEditionInfor");
  580. }.bind(this));
  581. },
  582. getProcessToolbarHTML: function(callback){
  583. var toolbarUrl = this.path+"processToolbars.html";
  584. var r = new Request.HTML({
  585. url: toolbarUrl,
  586. method: "get",
  587. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  588. var toolbarNode = responseTree[0];
  589. if (callback) callback(toolbarNode);
  590. }.bind(this),
  591. onFailure: function(xhr){
  592. this.notice("request processToolbars error: "+xhr.responseText, "error");
  593. }.bind(this)
  594. });
  595. r.send();
  596. },
  597. resizePaper: function(){
  598. var nodeSize = this.node.getSize();
  599. var toolbarSize = this.processToolbar.node.getSize();
  600. var y = nodeSize.y - toolbarSize.y;
  601. var marginTop = this.paperNode.getStyle("margin-top").toFloat();
  602. var marginBottom = this.paperNode.getStyle("margin-bottom").toFloat();
  603. y = y - marginTop - marginBottom;
  604. //this.paperAreaNode.setStyle("height", ""+y+"px");
  605. this.paperNode.setStyle("height", ""+y+"px");
  606. if (this.paper) this.paper.setSize("100%", "100%");
  607. if (this.process){
  608. if (this.process.panel){
  609. this.process.panel.modulePanel.container.position({
  610. relativeTo: this.paperNode,
  611. position: 'upperRight',
  612. edge: 'upperRight'
  613. });
  614. var size = this.process.panel.modulePanel.container.getSize();
  615. var pSize = this.paperNode.getSize();
  616. if (pSize.y<size.y){
  617. var height = (this.paperNode.getSize().y.toFloat())-6;
  618. this.process.panel.modulePanel.container.setStyle("height", ""+height+"px");
  619. this.process.panel.modulePanel.content.setStyle("height", this.process.panel.modulePanel.getContentHeight());
  620. this.process.panel.setPanelSize();
  621. }
  622. if (pSize.x<size.x){
  623. this.process.panel.modulePanel.container.setStyle("width", ""+pSize.x+"px");
  624. }
  625. if (this.process.panel.propertyPanel){
  626. this.process.panel.propertyPanel.container.position({
  627. relativeTo: this.paperNode,
  628. position: 'bottomRight',
  629. edge: 'bottomRight'
  630. });
  631. var size = this.process.panel.propertyPanel.container.getSize();
  632. var pSize = this.paperNode.getSize();
  633. if (pSize.y<size.y){
  634. var height = (this.paperNode.getSize().y.toFloat())-6;
  635. this.process.panel.propertyPanel.container.setStyle("height", ""+height+"px");
  636. this.process.panel.propertyPanel.content.setStyle("height", this.process.panel.propertyPanel.getContentHeight());
  637. this.process.panel.setPropertyPanelSize();
  638. }
  639. if (pSize.x<size.x){
  640. this.process.panel.propertyPanel.container.setStyle("width", ""+pSize.x+"px");
  641. }
  642. }
  643. }
  644. }
  645. },
  646. loadPaper: function(){
  647. MWFRaphael.load(function(){
  648. this.paperInNode = new Element("div", {"styles": this.css.paperInNode}).inject(this.paperNode);
  649. this.paper = Raphael(this.paperInNode, "100%", "99%");
  650. this.paper.container = this.paperNode;
  651. MWF.xDesktop.requireApp("process.ProcessDesigner", "Process", function(){
  652. this.process = new MWF.APPPD.Process(this.paper, this.processData, this, {
  653. "style":"flat",
  654. "onPostLoad": function(){
  655. this.fireEvent("postProcessLoad");
  656. }.bind(this)
  657. });
  658. this.process.load();
  659. }.bind(this));
  660. }.bind(this));
  661. },
  662. setToolBardisabled: function(type){
  663. switch (type){
  664. case "default":
  665. break;
  666. case "createRoute":
  667. break;
  668. case "decision":
  669. break;
  670. default:
  671. }
  672. },
  673. recordStatus: function(){
  674. debugger;
  675. return {"id": this.options.id};
  676. },
  677. saveProcess: function(){
  678. if (!this.process.process.name){
  679. this.notice(this.lp.notice.no_name, "error");
  680. return false;
  681. }
  682. this.process.save(function(){
  683. var name = this.process.process.name;
  684. this.setTitle(this.options.appTitle + "-"+name);
  685. this.options.desktopReload = true;
  686. this.options.id = this.process.process.id;
  687. }.bind(this));
  688. },
  689. saveNewProcess: function(b, e){
  690. //this.process.saveNew(e);
  691. },
  692. createManualActivity: function(){
  693. this.process.createManualActivity();
  694. },
  695. createConditionActivity: function(){
  696. this.process.createConditionActivity();
  697. },
  698. createAutoActivity: function(){
  699. this.process.createAutoActivity();
  700. },
  701. createSplitActivity: function(){
  702. this.process.createSplitActivity();
  703. },
  704. createMergeActivity: function(){
  705. this.process.createMergeActivity();
  706. },
  707. createEmbedActivity: function(){
  708. this.process.createEmbedActivity();
  709. },
  710. createPublishActivity: function(){
  711. this.process.createPublishActivity();
  712. },
  713. createInvokesActivity: function(){
  714. this.process.createInvokesActivity();
  715. },
  716. createBeginActivity: function(){
  717. this.process.createBeginActivity();
  718. },
  719. createEndActivity: function(){
  720. this.process.createEndActivity();
  721. },
  722. createRoute: function(){
  723. this.process.createRoute();
  724. },
  725. processExplode: function(){
  726. this.process.explode();
  727. },
  728. saveNewEdition: function(el, e){
  729. this.process.saveNewEdition(e);
  730. },
  731. listEdition: function(el, e){
  732. this.process.listEdition(e);
  733. },
  734. onPostClose: function() {
  735. if (this.process) {
  736. this.process.activitys.each(function (activity) {
  737. activity.routes.each(function (route) {
  738. MWF.release(route);
  739. });
  740. MWF.release(activity);
  741. });
  742. MWF.release(this.process);
  743. }
  744. }
  745. });