ScriptTask.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. draw2d.ScriptTask=function(){
  2. draw2d.Task.call(this);
  3. this.setTitle("脚本任务");
  4. this.setIcon();
  5. };
  6. draw2d.ScriptTask.prototype=new draw2d.Task();
  7. draw2d.ScriptTask.prototype.type="draw2d.ScriptTask";
  8. draw2d.ScriptTask.newInstance=function(scriptTaskXMLNode){
  9. var task = new draw2d.ScriptTask();
  10. task.id=scriptTaskXMLNode.attr('id');
  11. task.taskId=scriptTaskXMLNode.attr('id');
  12. task.taskName=scriptTaskXMLNode.attr('name');
  13. task.setContent(scriptTaskXMLNode.attr('name'));
  14. return task;
  15. };
  16. draw2d.ScriptTask.prototype.setWorkflow=function(_5019){
  17. draw2d.Task.prototype.setWorkflow.call(this,_5019);
  18. };
  19. draw2d.ScriptTask.prototype.getContextMenu=function(){
  20. var menu = draw2d.Task.prototype.getContextMenu.call(this);
  21. return menu;
  22. };
  23. draw2d.ScriptTask.prototype.setIcon = function(){
  24. var icon=draw2d.Task.prototype.setIcon.call(this);
  25. icon.className="script-task-icon";
  26. };
  27. draw2d.ScriptTask.prototype.getStartElementXML=function(){
  28. var name = this.taskId;
  29. var taskName = trim(this.taskName);
  30. if(taskName != null && taskName != "")
  31. name = taskName;
  32. var format=this.scriptFormat;
  33. if(format==null||format==''){
  34. format='Groovy';
  35. }
  36. var xml='<scriptTask id="'+this.taskId+'" name="'+name+'" scriptFormat="'+format+'" ';
  37. if(this.resultVariable!=null&&this.resultVariable!=''){
  38. xml=xml+'activiti:resultVariable="'+this.resultVariable+'" ';
  39. }
  40. if(this.formKey != null && this.formKey != ""){
  41. xml=xml+'activiti:formKey="'+this.formKey+'" ';
  42. }
  43. xml=xml+'>\n';
  44. return xml;
  45. };
  46. draw2d.ScriptTask.prototype.getEndElementXML=function(){
  47. var xml = '</scriptTask>\n';
  48. return xml;
  49. };
  50. draw2d.ScriptTask.prototype.getDocumentationXML=function(){
  51. if(this.documentation==null||this.documentation=='')return '';
  52. var xml='<documentation>';
  53. xml=xml+this.documentation;
  54. xml=xml+'</documentation>';
  55. return xml;
  56. };
  57. draw2d.ScriptTask.prototype.getScriptXML=function(){
  58. var xml='<script>';
  59. xml=xml+this.expression;
  60. xml=xml+'</script>';
  61. return xml;
  62. };
  63. draw2d.ScriptTask.prototype.figureDoubleClick=function(){
  64. var data = {event:this};
  65. var event = data.event;
  66. var tid = event.getId();
  67. openProperties(tid,'scriptTaskProperties');
  68. };
  69. draw2d.ScriptTask.prototype.getContextMenu=function(){
  70. if(this.workflow.disabled)return null;
  71. var menu =new draw2d.ContextMenu(100, 50);
  72. var data = {task:this};
  73. menu.appendMenuItem(new draw2d.ContextMenuItem("属性", "properties-icon",data,function(x,y)
  74. {
  75. var data = this.getData();
  76. var task = data.task;
  77. var tid = task.getId();
  78. if(typeof openProperties != "undefined"){
  79. openProperties(tid,'scriptTaskProperties');
  80. }
  81. }));
  82. menu.appendMenuItem(new draw2d.ContextMenuItem("删除", "icon-remove",data,function(x,y)
  83. {
  84. var data = this.getData();
  85. var task = data.task;
  86. var tid = task.getId();
  87. var wf = task.getWorkflow();
  88. wf.getCommandStack().execute(new draw2d.CommandDelete(task));
  89. }));
  90. return menu;
  91. };
  92. draw2d.ScriptTask.prototype.toXML=function(){
  93. var xml=this.getStartElementXML();
  94. xml=xml+this.getDocumentationXML();
  95. xml=xml+this.getScriptXML();
  96. xml=xml+this.getEndElementXML();
  97. return xml;
  98. };
  99. draw2d.ScriptTask.prototype.toBpmnDI=function(){
  100. var w=this.getWidth();
  101. var h=this.getHeight();
  102. var x=this.getAbsoluteX();
  103. var y=this.getAbsoluteY();
  104. var xml='<bpmndi:BPMNShape bpmnElement="'+this.taskId+'" id="BPMNShape_'+this.taskId+'">\n';
  105. xml=xml+'<omgdc:Bounds height="'+h+'" width="'+w+'" x="'+x+'" y="'+y+'"/>\n';
  106. xml=xml+'</bpmndi:BPMNShape>\n';
  107. return xml;
  108. };