CallActivity.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. draw2d.CallActivity=function(_url){
  2. _url="plug-in/designer/icons/callactivity.png";
  3. draw2d.ResizeImage.call(this,_url);
  4. this.rightOutputPort=null;
  5. this.leftOutputPort=null;
  6. this.topOutputPort=null;
  7. this.bottomOutputPort=null;
  8. this.subProcessId=null;
  9. this.name=null;
  10. this.insource=null;
  11. this.intarget=null;
  12. this.outsource=null;
  13. this.outtarget=null;
  14. this.callSubProcess=null;
  15. this.setDimension(30,30);
  16. };
  17. draw2d.CallActivity.prototype=new draw2d.Node();
  18. draw2d.CallActivity.prototype.type="draw2d.CallActivity";
  19. draw2d.CallActivity.prototype.generateId=function(){
  20. this.id="callSubProcess"+Sequence.create();
  21. this.subProcessId=this.id;
  22. this.name=this.id
  23. };
  24. draw2d.CallActivity.prototype.createHTMLElement=function(){
  25. var item = draw2d.ResizeImage.prototype.createHTMLElement.call(this);
  26. return item;
  27. };
  28. draw2d.CallActivity.prototype.setDimension=function(w, h){
  29. draw2d.ResizeImage.prototype.setDimension.call(this, w, h);
  30. };
  31. draw2d.CallActivity.prototype.setWorkflow=function(_4fe5){
  32. draw2d.ResizeImage.prototype.setWorkflow.call(this,_4fe5);
  33. this.resizeable=false;//不让改变大小
  34. if(_4fe5!==null&&this.rightOutputPort===null){
  35. this.rightOutputPort=new draw2d.MyOutputPort();
  36. this.rightOutputPort.setMaxFanOut(1);
  37. this.rightOutputPort.setWorkflow(_4fe5);
  38. this.rightOutputPort.setName("rightOutputPort");
  39. //this.rightOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  40. this.addPort(this.rightOutputPort,this.width,this.height/2);
  41. }
  42. if(_4fe5!==null&&this.leftOutputPort===null){
  43. this.leftOutputPort=new draw2d.MyOutputPort();
  44. this.leftOutputPort.setMaxFanOut(1);
  45. this.leftOutputPort.setWorkflow(_4fe5);
  46. this.leftOutputPort.setName("leftOutputPort");
  47. //this.leftOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  48. this.addPort(this.leftOutputPort,0,this.height/2);
  49. }
  50. if(_4fe5!==null&&this.topOutputPort===null){
  51. this.topOutputPort=new draw2d.MyOutputPort();
  52. this.topOutputPort.setMaxFanOut(1);
  53. this.topOutputPort.setWorkflow(_4fe5);
  54. this.topOutputPort.setName("topOutputPort");
  55. //this.topOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  56. this.addPort(this.topOutputPort,this.width/2,0);
  57. }
  58. if(_4fe5!==null&&this.bottomOutputPort===null){
  59. this.bottomOutputPort=new draw2d.MyOutputPort();
  60. this.bottomOutputPort.setMaxFanOut(1);
  61. this.bottomOutputPort.setWorkflow(_4fe5);
  62. this.bottomOutputPort.setName("bottomOutputPort");
  63. //this.bottomOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  64. this.addPort(this.bottomOutputPort,this.width/2,this.height);
  65. }
  66. };
  67. draw2d.CallActivity.prototype.figureDoubleClick=function(){
  68. var data = {event:this};
  69. var event = data.event;
  70. nodeid= event.getId();
  71. openProperties(nodeid,'subProcessProperties');
  72. };
  73. draw2d.CallActivity.prototype.getContextMenu=function(){
  74. if(this.workflow.disabled)return null;
  75. var menu =new draw2d.ContextMenu(100, 50);
  76. var data = {event:this};
  77. menu.appendMenuItem(new draw2d.ContextMenuItem("Properties", "properties-icon",data,function(x,y)
  78. {
  79. var data = this.getData();
  80. var event = data.event;
  81. nodeid = event.getId();
  82. if(typeof openProperties != "undefined"){
  83. openProperties(nodeid,'subProcessProperties');
  84. }
  85. }));
  86. return menu;
  87. };
  88. draw2d.CallActivity.prototype.toXML=function(){
  89. var xml='<callActivity id="'+this.subProcessId+'" name="'+this.name+'" calledElement="'+this.callSubProcess+'" >\n';
  90. if((this.insource!=null&&this.intarget!=null&&this.insource!=''&&this.intarget!='')||(this.outsource!=null&&this.outtarget!=null&&this.outsource!=''&&this.outtarget!='')){
  91. xml=xml+'<extensionElements>\n';
  92. }
  93. if(this.insource!=null&&this.intarget!=null&&this.insource!=''&&this.intarget!=''){
  94. xml=xml+'<activiti:in source="'+this.insource+'" target="'+this.intarget+'"/>\n';
  95. //update-begin---author:scott------------date:20160308-----------------for:默认传递变量给子流程-------
  96. //子流程默认传递固定变量
  97. if(this.insource != 'applyUserId'){
  98. xml = xml+'<activiti:in source="applyUserId" target="applyUserId"/>\n';
  99. }
  100. xml = xml+'<activiti:in source="JG_LOCAL_PROCESS_ID" target="JG_SUB_MAIN_PROCESS_ID"/>\n';
  101. //update-end---author:scott------------date:20160308-----------------for:默认传递变量给子流程-------
  102. }
  103. if(this.outsource!=null&&this.outtarget!=null&&this.outsource!=''&&this.outtarget!=''){
  104. xml=xml+'<activiti:out source="'+this.outsource+'" target="'+this.outtarget+'"/>\n';
  105. }
  106. if((this.insource!=null&&this.intarget!=null&&this.insource!=''&&this.intarget!='')||(this.outsource!=null&&this.outtarget!=null&&this.outsource!=''&&this.outtarget!='')){
  107. xml=xml+'</extensionElements>\n';
  108. }
  109. xml=xml+'</callActivity>\n';
  110. return xml;
  111. };
  112. draw2d.CallActivity.prototype.toBpmnDI=function(){
  113. var w=this.getWidth();
  114. var h=this.getHeight();
  115. var x=this.getAbsoluteX();
  116. var y=this.getAbsoluteY();
  117. var xml='<bpmndi:BPMNShape bpmnElement="'+this.subProcessId+'" id="BPMNShape_'+this.subProcessId+'">\n';
  118. xml=xml+'<omgdc:Bounds height="'+h+'" width="'+w+'" x="'+x+'" y="'+y+'"/>\n';
  119. xml=xml+'</bpmndi:BPMNShape>\n';
  120. return xml;
  121. };