Ldc
2024-04-07 0652600959e5e3b5796fb6e8da129704ca95347a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
draw2d.DecoratedConnection=function(){
    draw2d.Connection.call(this);
    var decorator = new draw2d.ArrowConnectionDecorator();
    var black = new draw2d.Color(0,0,0);
    decorator.setBackgroundColor(black);
    this.setTargetDecorator(decorator);
    this.setRouter(new draw2d.ManhattanConnectionRouter());
    this.setLineWidth(1);
    this.setColor(black);
    this.lineId=null;
    this.lineName=null;
    this.condition=null;
    this.listeners=new draw2d.ArrayList();
    this.label=null;
};
draw2d.DecoratedConnection.prototype=new draw2d.Connection();
draw2d.DecoratedConnection.prototype.type="DecoratedConnection";
draw2d.DecoratedConnection.prototype.getConditionXML=function(){
    var xml = '';
    if(this.condition != null&&this.condition!=''){
        xml = '<conditionExpression xsi:type="tFormalExpression"><![CDATA['+this.condition+']]></conditionExpression>\n';
    }
    return xml;
}
draw2d.DecoratedConnection.prototype.toXML=function(){
    var sourceId = null;
    var type=this.getSource().getParent().type;
    if(type=='draw2d.Start'){
        sourceId = this.getSource().getParent().eventId;
    }    
    else if(type=='draw2d.ExclusiveGateway'){
        sourceId = this.getSource().getParent().gatewayId;
    }else if(type=='draw2d.ParallelGateway'){
        sourceId = this.getSource().getParent().gatewayId;
    }else{
        sourceId = this.getSource().getParent().taskId;
    }
    var targetId = null;
    type=this.getTarget().getParent().type;
    if(type=='draw2d.End'){
        targetId = this.getTarget().getParent().eventId;
    }else if(type=='draw2d.ExclusiveGateway'){
        targetId = this.getTarget().getParent().gatewayId;
    }else if(type=='draw2d.ParallelGateway'){
        targetId = this.getTarget().getParent().gatewayId;
    }else{
        targetId = this.getTarget().getParent().taskId;
    }
    var name = this.lineId;
    var lineName = trim(this.lineName);
    if(lineName != null && lineName != "")
        name = lineName;
    var xml = '<sequenceFlow id="'+this.lineId+'" name="'+name+'" sourceRef="'+sourceId+'" targetRef="'+targetId+'">\n';
    xml = xml+this.getConditionXML();
    xml = xml+'</sequenceFlow>\n';
    return xml;
};
draw2d.DecoratedConnection.prototype.setLabel=function(text){
    if(this.label == null){
        this.label=new draw2d.Label(text);
        this.label.setFontSize(10);
        this.label.setAlign("left");
        //label.setBackgroundColor(new draw2d.Color(230,230,250));
        //label.setBorder(new draw2d.LineBorder(1));
        this.addFigure(this.label,new draw2d.ManhattanMidpointLocator(this));
    }else{
        this.label.setText(text);
    }
};
draw2d.DecoratedConnection.prototype.toBpmnDI=function(){
    var xml='<bpmndi:BPMNEdge bpmnElement="'+this.lineId+'" id="BPMNEdge_'+this.lineId+'">\n';
//    var startX = this.getSource().getAbsoluteX();
//    var startY = this.getSource().getAbsoluteY();
//    var endX = this.getTarget().getAbsoluteX();
//    var endY = this.getTarget().getAbsoluteY();
    var points=this.getPoints();
    for(var i=0;i<points.size;i++){
        xml=xml+'<omgdi:waypoint x="'+points.get(i).x+'" y="'+points.get(i).y+'" />\n';
    }
    xml=xml+'</bpmndi:BPMNEdge>\n';
    return xml;
};
draw2d.DecoratedConnection.prototype.onDoubleClick=function(){
    var id = this.getId();
    openFlowProperties(id);
};
draw2d.DecoratedConnection.prototype.getContextMenu=function(){
    if(this.workflow.disabled)return null;
    var menu =new draw2d.ContextMenu(100, 50);
    var data = {line:this};
    menu.appendMenuItem(new draw2d.ContextMenuItem("Properties", "properties-icon",data,function(x,y)
    {
        var data = this.getData();
        var line = data.line;
        var lid = line.getId();
        if(typeof openFlowProperties != "undefined"){
            openFlowProperties(lid);
        }
    }));
    menu.appendMenuItem(new draw2d.ContextMenuItem("Delete", "icon-remove",data,function(x,y)
    {
        var data = this.getData();
        var line = data.line;
        var lid = line.getId();
        var wf = line.getWorkflow();
        wf.getCommandStack().execute(new draw2d.CommandDelete(line));
        //wf.removeFigure(line);
    }));
    
    return menu;
};
draw2d.DecoratedConnection.prototype.getListener=function(id){
    for(var i=0;i<this.listeners.getSize();i++){
        var listener = this.listeners.get(i);
        if(listener.getId()=== id){
            return listener;
        }
    }
};
draw2d.DecoratedConnection.prototype.deleteListener=function(id){
    var listener = this.getListener(id);
    this.listeners.remove(listener);
};
draw2d.DecoratedConnection.prototype.setListener=function(listener){
    this.listeners.add(listener);
};