ExclusiveGateway.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. draw2d.ExclusiveGateway=function(){
  2. var _url="plug-in/designer/icons/gateway.exclusive.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.gatewayId=null;
  9. this.gatewayName=null;
  10. this.setDimension(40,40);
  11. };
  12. draw2d.ExclusiveGateway.prototype=new draw2d.Node();
  13. draw2d.ExclusiveGateway.prototype.type="draw2d.ExclusiveGateway";
  14. draw2d.ExclusiveGateway.prototype.generateId=function(){
  15. this.id="exclusiveGateway"+Sequence.create();
  16. this.gatewayId=this.id;
  17. this.gatewayName=this.id;
  18. };
  19. draw2d.ExclusiveGateway.prototype.createHTMLElement=function(){
  20. var item = draw2d.ResizeImage.prototype.createHTMLElement.call(this);
  21. return item;
  22. };
  23. draw2d.ExclusiveGateway.prototype.setDimension=function(w, h){
  24. draw2d.ResizeImage.prototype.setDimension.call(this, w, h);
  25. };
  26. draw2d.ExclusiveGateway.prototype.setWorkflow=function(_4fe5){
  27. draw2d.ResizeImage.prototype.setWorkflow.call(this,_4fe5);
  28. this.resizeable=false;//不让改变大小
  29. if(_4fe5!==null&&this.rightOutputPort===null){
  30. this.rightOutputPort=new draw2d.MyOutputPort();
  31. this.rightOutputPort.setMaxFanOut(1);
  32. this.rightOutputPort.setWorkflow(_4fe5);
  33. this.rightOutputPort.setName("rightOutputPort");
  34. //this.rightOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  35. this.addPort(this.rightOutputPort,this.width,this.height/2);
  36. }
  37. if(_4fe5!==null&&this.leftOutputPort===null){
  38. this.leftOutputPort=new draw2d.MyOutputPort();
  39. this.leftOutputPort.setMaxFanOut(1);
  40. this.leftOutputPort.setWorkflow(_4fe5);
  41. this.leftOutputPort.setName("leftOutputPort");
  42. //this.leftOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  43. this.addPort(this.leftOutputPort,0,this.height/2);
  44. }
  45. if(_4fe5!==null&&this.topOutputPort===null){
  46. this.topOutputPort=new draw2d.MyOutputPort();
  47. this.topOutputPort.setMaxFanOut(1);
  48. this.topOutputPort.setWorkflow(_4fe5);
  49. this.topOutputPort.setName("topOutputPort");
  50. //this.topOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  51. this.addPort(this.topOutputPort,this.width/2,0);
  52. }
  53. if(_4fe5!==null&&this.bottomOutputPort===null){
  54. this.bottomOutputPort=new draw2d.MyOutputPort();
  55. this.bottomOutputPort.setMaxFanOut(1);
  56. this.bottomOutputPort.setWorkflow(_4fe5);
  57. this.bottomOutputPort.setName("bottomOutputPort");
  58. //this.bottomOutputPort.setBackgroundColor(new draw2d.Color(245,115,115));
  59. this.addPort(this.bottomOutputPort,this.width/2,this.height);
  60. }
  61. };
  62. draw2d.ExclusiveGateway.prototype.figureDoubleClick=function(){
  63. var data = {event:this};
  64. var event = data.event;
  65. nodeid = event.getId();
  66. openProperties(nodeid,'gatewayProperties');
  67. };
  68. draw2d.ExclusiveGateway.prototype.getContextMenu=function(){
  69. if(this.workflow.disabled)return null;
  70. var menu =new draw2d.ContextMenu(100, 50);
  71. var data = {event:this};
  72. menu.appendMenuItem(new draw2d.ContextMenuItem("Properties", "properties-icon",data,function(x,y)
  73. {
  74. var data = this.getData();
  75. var event = data.event;
  76. nodeid= event.getId();
  77. if(typeof openProperties != "undefined"){
  78. openProperties(nodeid,'gatewayProperties');
  79. }
  80. }));
  81. return menu;
  82. };
  83. draw2d.ExclusiveGateway.prototype.toXML=function(){
  84. var name = this.gatewayId;
  85. var newName = trim(this.gatewayName);
  86. if(newName != null && newName != "")
  87. name = newName;
  88. var xml='<exclusiveGateway id="'+this.gatewayId+'" name="'+name+'"></exclusiveGateway>\n';
  89. return xml;
  90. };
  91. draw2d.ExclusiveGateway.prototype.toBpmnDI=function(){
  92. var w=this.getWidth();
  93. var h=this.getHeight();
  94. var x=this.getAbsoluteX();
  95. var y=this.getAbsoluteY();
  96. var xml='<bpmndi:BPMNShape bpmnElement="'+this.gatewayId+'" id="BPMNShape_'+this.gatewayId+'">\n';
  97. xml=xml+'<omgdc:Bounds height="'+h+'" width="'+w+'" x="'+x+'" y="'+y+'"/>\n';
  98. xml=xml+'</bpmndi:BPMNShape>\n';
  99. return xml;
  100. };