Start.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. draw2d.Start=function(){
  2. var _url="plug-in/designer/icons/startevent.png";
  3. draw2d.ResizeImage.call(this,_url);
  4. this.rightOutputPort=null;
  5. this.leftOutputPort=null;
  6. this.topOutputPort=null;
  7. this.resizeable=false;//不让改变大小
  8. this.bottomOutputPort=null;
  9. this.eventId='start1';
  10. this.eventName='开始节点';
  11. this.expression='applyUserId';
  12. this.setDimension(30,30);
  13. };
  14. draw2d.Start.prototype=new draw2d.Node();
  15. draw2d.Start.prototype.type="draw2d.Start";
  16. draw2d.Start.prototype.generateId=function(){
  17. this.id="start1";
  18. this.eventId=this.id;
  19. };
  20. draw2d.Start.prototype.createHTMLElement=function(){
  21. var item = draw2d.ResizeImage.prototype.createHTMLElement.call(this);
  22. return item;
  23. };
  24. draw2d.Start.prototype.setDimension=function(w, h){
  25. draw2d.ResizeImage.prototype.setDimension.call(this, w, h);
  26. };
  27. draw2d.Start.prototype.setWorkflow=function(_4fe5){
  28. draw2d.ResizeImage.prototype.setWorkflow.call(this,_4fe5);
  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.Start.prototype.figureDoubleClick=function(){
  63. var data = {event:this};
  64. var event = data.event;
  65. nodeid= event.getId();
  66. openProperties(nodeid,'eventProperties');
  67. };
  68. draw2d.Start.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-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,'eventProperties');
  79. }
  80. }));
  81. return menu;
  82. };
  83. draw2d.Start.prototype.toXML=function(){
  84. var xml='<startEvent id="'+this.eventId+'" name="'+this.eventName+'" activiti:initiator="'+this.expression+'"></startEvent>\n';
  85. return xml;
  86. };
  87. draw2d.Start.prototype.toBpmnDI=function(){
  88. var w=this.getWidth();
  89. var h=this.getHeight();
  90. var x=this.getAbsoluteX();
  91. var y=this.getAbsoluteY();
  92. var xml='<bpmndi:BPMNShape bpmnElement="'+this.eventId+'" id="BPMNShape_'+this.eventId+'">\n';
  93. xml=xml+'<omgdc:Bounds height="'+h+'" width="'+w+'" x="'+x+'" y="'+y+'"/>\n';
  94. xml=xml+'</bpmndi:BPMNShape>\n';
  95. return xml;
  96. };