TimerBoundary.js 4.1 KB

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