End.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. draw2d.End=function(){
  2. _url="plug-in/designer/icons/endevent.png";
  3. draw2d.ResizeImage.call(this,_url);
  4. this.rightInputPort=null;
  5. this.leftInputPort=null;
  6. this.topInputPort=null;
  7. this.bottomInputPort=null;
  8. this.resizeable=false;//不让改变大小
  9. this.eventId='end';
  10. this.eventName='结束节点';
  11. this.setDimension(30,30);
  12. };
  13. draw2d.End.prototype=new draw2d.Node();
  14. draw2d.End.prototype.type="draw2d.End";
  15. draw2d.End.prototype.generateId=function(){
  16. this.id="end";
  17. this.taskId=this.id;
  18. };
  19. draw2d.End.prototype.createHTMLElement=function(){
  20. var item = draw2d.ResizeImage.prototype.createHTMLElement.call(this);
  21. return item;
  22. };
  23. draw2d.End.prototype.setDimension=function(w, h){
  24. draw2d.ResizeImage.prototype.setDimension.call(this, w, h);
  25. };
  26. draw2d.End.prototype.setWorkflow=function(_505d){
  27. draw2d.ResizeImage.prototype.setWorkflow.call(this,_505d);
  28. if(_505d!==null&&this.rightInputPort===null){
  29. this.rightInputPort=new draw2d.MyInputPort();
  30. this.rightInputPort.setName("RightInputPort");
  31. this.rightInputPort.setWorkflow(_505d);
  32. this.rightInputPort.setBackgroundColor(new draw2d.Color(115,115,245));
  33. this.addPort(this.rightInputPort,this.width,this.height/2);
  34. }
  35. if(_505d!==null&&this.leftInputPort===null){
  36. this.leftInputPort=new draw2d.MyInputPort();
  37. this.leftInputPort.setName("leftInputPort");
  38. this.leftInputPort.setWorkflow(_505d);
  39. this.leftInputPort.setBackgroundColor(new draw2d.Color(115,115,245));
  40. this.addPort(this.leftInputPort,0,this.height/2);
  41. }
  42. if(_505d!==null&&this.topInputPort===null){
  43. this.topInputPort=new draw2d.MyInputPort();
  44. this.topInputPort.setName("RightInputPort");
  45. this.topInputPort.setWorkflow(_505d);
  46. this.topInputPort.setBackgroundColor(new draw2d.Color(115,115,245));
  47. this.addPort(this.topInputPort,this.width/2,0);
  48. }
  49. if(_505d!==null&&this.bottomInputPort===null){
  50. this.bottomInputPort=new draw2d.MyInputPort();
  51. this.bottomInputPort.setName("RightInputPort");
  52. this.bottomInputPort.setWorkflow(_505d);
  53. this.bottomInputPort.setBackgroundColor(new draw2d.Color(115,115,245));
  54. this.addPort(this.bottomInputPort,this.width/2,this.height);
  55. }
  56. };
  57. draw2d.End.prototype.figureDoubleClick=function(){
  58. var data = {event:this};
  59. var event = data.event;
  60. nodeid= event.getId();
  61. openProperties(nodeid,'eventProperties');
  62. };
  63. draw2d.End.prototype.getContextMenu=function(){
  64. if(this.workflow.disabled)return null;
  65. var menu =new draw2d.ContextMenu(100, 50);
  66. var data = {event:this};
  67. menu.appendMenuItem(new draw2d.ContextMenuItem("属性", "properties-icon",data,function(x,y)
  68. {
  69. var data = this.getData();
  70. var event = data.event;
  71. nodeid = event.getId();
  72. if(typeof openProperties != "undefined"){
  73. openProperties(nodeid,'eventProperties');
  74. }
  75. }));
  76. return menu;
  77. };
  78. draw2d.End.prototype.toXML=function(){
  79. var xml='<endEvent id="'+this.eventId+'" name="'+this.eventName+'"></endEvent>\n';
  80. return xml;
  81. };
  82. draw2d.End.prototype.toBpmnDI=function(){
  83. var w=this.getWidth();
  84. var h=this.getHeight();
  85. var x=this.getAbsoluteX();
  86. var y=this.getAbsoluteY();
  87. var xml='<bpmndi:BPMNShape bpmnElement="'+this.eventId+'" id="BPMNShape_'+this.eventId+'">\n';
  88. xml=xml+'<omgdc:Bounds height="'+h+'" width="'+w+'" x="'+x+'" y="'+y+'"/>\n';
  89. xml=xml+'</bpmndi:BPMNShape>\n';
  90. return xml;
  91. };