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