ErrorBoundary.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. draw2d.ErrorBoundary=function(_url){
  2. _url="plug-in/designer/icons/error.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.expression=null;
  11. this.setDimension(40,40);
  12. };
  13. draw2d.ErrorBoundary.prototype=new draw2d.Node();
  14. draw2d.ErrorBoundary.prototype.type="draw2d.ErrorBoundary";
  15. draw2d.ErrorBoundary.prototype.generateId=function(){
  16. this.id="catchError"+Sequence.create();
  17. this.boundaryId=this.id;
  18. };
  19. draw2d.ErrorBoundary.prototype.createHTMLElement=function(){
  20. var item = draw2d.ResizeImage.prototype.createHTMLElement.call(this);
  21. return item;
  22. };
  23. draw2d.ErrorBoundary.prototype.setDimension=function(w, h){
  24. draw2d.ResizeImage.prototype.setDimension.call(this, w, h);
  25. };
  26. draw2d.ErrorBoundary.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.ErrorBoundary.prototype.figureDoubleClick=function(){
  63. var data = {event:this};
  64. var event = data.event;
  65. var tid = event.getId();
  66. openProperties(tid,'errorBoundaryEventProperties');
  67. };
  68. draw2d.ErrorBoundary.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. var tid = event.getId();
  77. if(typeof openProperties != "undefined"){
  78. openProperties(tid,'errorBoundaryEventProperties');
  79. }
  80. }));
  81. return menu;
  82. };
  83. draw2d.ErrorBoundary.prototype.toXML=function(){
  84. var attached = trim(this.attached);
  85. if(attached != null && attached != "")
  86. attached = attached;
  87. var xml='<boundaryEvent id="'+this.boundaryId+'" attachedToRef="'+attached+'">\n';
  88. var errorref=trim(this.expression);
  89. if(errorref!=null&&errorref!=''){
  90. xml=xml+'<errorEventDefinition errorRef="'+errorref+'"/>\n';
  91. }
  92. xml=xml+'</boundaryEvent>\n';
  93. return xml;
  94. };
  95. draw2d.ErrorBoundary.prototype.toBpmnDI=function(){
  96. var w=this.getWidth();
  97. var h=this.getHeight();
  98. var x=this.getAbsoluteX();
  99. var y=this.getAbsoluteY();
  100. var xml='<bpmndi:BPMNShape bpmnElement="'+this.boundaryId+'" id="BPMNShape_'+this.boundaryId+'">\n';
  101. xml=xml+'<omgdc:Bounds height="'+h+'" width="'+w+'" x="'+x+'" y="'+y+'"/>\n';
  102. xml=xml+'</bpmndi:BPMNShape>\n';
  103. return xml;
  104. };