Main.js 29 KB

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