var PMConnectionDropBehavior=function(a){PMUI.behavior.ConnectionDropBehavior.call(this,a)};PMConnectionDropBehavior.prototype=new PMUI.behavior.ConnectionDropBehavior;PMConnectionDropBehavior.prototype.type="PMConnectionDropBehavior"; PMConnectionDropBehavior.prototype.basicRules={PMEvent:{PMEvent:{connection:"regular",type:"SEQUENCE"},PMActivity:{connection:"regular",type:"SEQUENCE"}},PMActivity:{PMActivity:{connection:"regular",type:"SEQUENCE"},PMArtifact:{connection:"dotted",destDecorator:"con_none",type:"ASSOCIATION"},PMIntermediateEvent:{connection:"regular",type:"SEQUENCE"},PMEndEvent:{connection:"regular",type:"SEQUENCE"},PMGateway:{connection:"regular",type:"SEQUENCE"}},PMStartEvent:{PMActivity:{connection:"regular",type:"SEQUENCE"}, PMIntermediateEvent:{connection:"regular",type:"SEQUENCE"},PMEndEvent:{connection:"regular",type:"SEQUENCE"},PMGateway:{connection:"regular",type:"SEQUENCE"}},PMIntermediateEvent:{PMActivity:{connection:"regular",type:"SEQUENCE"},PMIntermediateEvent:{connection:"regular",type:"SEQUENCE"},PMEndEvent:{connection:"regular",type:"SEQUENCE"},PMGateway:{connection:"regular",type:"SEQUENCE"}},PMBoundaryEvent:{PMActivity:{connection:"regular",type:"SEQUENCE"},PMIntermediateEvent:{connection:"regular",type:"SEQUENCE"}, PMEndEvent:{connection:"regular",type:"SEQUENCE"},PMGateway:{connection:"regular",type:"SEQUENCE"}},PMGateway:{PMActivity:{connection:"regular",type:"SEQUENCE"},PMIntermediateEvent:{connection:"regular",type:"SEQUENCE"},PMEndEvent:{connection:"regular",type:"SEQUENCE"},PMGateway:{connection:"regular",type:"SEQUENCE"}},PMArtifact:{PMActivity:{connection:"dotted",destDecorator:"con_none",type:"ASSOCIATION"}}}; PMConnectionDropBehavior.prototype.initRules={PMCanvas:{PMCanvas:{name:"PMCanvas to PMCanvas",rules:PMConnectionDropBehavior.prototype.basicRules}},PMActivity:{PMCanvas:{name:"PMActivity to PMCanvas",rules:PMConnectionDropBehavior.prototype.basicRules}}}; PMConnectionDropBehavior.prototype.dropStartHook=function(a,b,c){a.srcDecorator=null;a.destDecorator=null;b=c.draggable.attr("id");b=a.canvas.customShapes.find("id",b);var d;if(b)if(d=this.validate(b,a))a.setConnectionType({type:d.type,segmentStyle:d.connection,srcDecorator:d.srcDecorator,destDecorator:d.destDecorator});else if("undefined"!==typeof b){if(!(c.helper&&"drag-helper"===c.helper.attr("id")))return!1;a.setConnectionType("none")}return!0}; PMConnectionDropBehavior.prototype.validate=function(a,b){var c,d,e,g,h;e={PMEvent:{START:"PMStartEvent",END:"PMEndEvent",INTERMEDIATE:"PMIntermediateEvent",BOUNDARY:"PMBoundaryEvent"},bpmnArtifact:{TEXTANNOTATION:"bpmnAnnotation"}};if(a&&b){if(a.getID()===b.getID())return!1;if(this.initRules[a.getParent().getType()]&&this.initRules[a.getParent().getType()][b.getParent().getType()])if(g=this.initRules[a.getParent().getType()][b.getParent().getType()].rules,h=this.initRules[a.getParent().getType()][b.getParent().getType()].name, c=a.getType(),d=b.getType(),"PMEvent"===c&&e[c]&&e[c][a.getEventType()]&&(c=e[c][a.getEventType()]),"PMEvent"===d&&e[d]&&e[d][b.getEventType()]&&(d=e[d][b.getEventType()]),e=g[c]&&g[c][d]?g[c][d]:!1,g)switch(h){case "bpmnPool to bpmnPool":a.getParent().getID()!==b.getParent().getID()&&(e=!1);break;case "bpmnLane to bpmnLane":a.getFirstPool(a.parent).getID()!==b.getFirstPool(b.parent).getID()&&(e=this.extraRules[c]&&this.extraRules[c][d]?this.extraRules[c][d]:!1);break;case "bpmnActivity to bpmnLane":e= this.basicRules[c]&&this.basicRules[c][d]?this.basicRules[c][d]:!1}else e=!1;else c=a.getType(),d=b.getType(),"PMEvent"===c&&e[c]&&e[c][a.getEventType()]&&(c=e[c][a.getEventType()]),"PMEvent"===d&&e[d]&&e[d][b.getEventType()]&&(d=e[d][b.getEventType()]),e=this.advancedRules[c]&&this.advancedRules[c][d]?this.advancedRules[c][d]:!1;return e}}; PMConnectionDropBehavior.prototype.onDrop=function(a){return function(b,c){var d=a.getCanvas(),e=c.draggable.attr("id"),g,h,f,k,n;g=d.currentConnection;a.entered=!1;if(!a.drop.dropStartHook(a,b,c))return!1;if("none"===a.getConnectionType())return!0;g&&(f=g.srcPort,g=g.destPort,f=f.id===e?f:g.id===e?g:null);if(c.helper&&"drag-helper"===c.helper.attr("id")){e=a.canvas.connectionSegment.startPoint;h=a.canvas.connectionSegment.pointsTo;if(h.parent&&h.parent.id===a.id)return!0;h.setPosition(h.oldX,h.oldY); e.x=e.portX;e.y=e.portY;f=new PMUI.draw.Port({width:10,height:10});g=new PMUI.draw.Port({width:10,height:10});k=c.offset.left-a.canvas.getX()-a.getAbsoluteX()+a.canvas.getLeftScroll();n=c.offset.top-a.canvas.getY()-a.getAbsoluteY()+a.canvas.getTopScroll();h.addPort(f,e.x,e.y);a.addPort(g,k,n,!1,f);e=new PMFlow({srcPort:f,destPort:g,canvas:a.canvas,segmentStyle:a.connectionType.segmentStyle,flo_type:a.connectionType.type});e.setSrcDecorator(new PMUI.draw.ConnectionDecorator({width:11,height:11,canvas:d, decoratorPrefix:"undefined"!==typeof a.connectionType.srcDecorator&&null!==a.connectionType.srcDecorator?a.connectionType.srcDecorator:"PM-decorator",decoratorType:"source",parent:e}));e.setDestDecorator(new PMUI.draw.ConnectionDecorator({width:11,height:11,canvas:d,decoratorPrefix:"undefined"!==typeof a.connectionType.destDecorator&&null!==a.connectionType.destDecorator?a.connectionType.destDecorator:"PM-decorator",decoratorType:"target",parent:e}));e.canvas.commandStack.add(new PMUI.command.CommandConnect(e)); e.connect();e.setSegmentMoveHandlers();d.addConnection(e);e.setTargetShape(g.parent);e.setOriginShape(f.parent);e.savePoints();e.checkAndCreateIntersectionsWithAll();f.attachListeners(f);g.attachListeners(g);d.triggerCreateEvent(e,[])}else if(f&&(e=f.getConnection(),prop=e.srcPort.getID()===f.getID()?PMConnectionDropBehavior.prototype.validate(a,e.destPort.getParent()):PMConnectionDropBehavior.prototype.validate(e.srcPort.getParent(),a)))f.setOldParent(f.getParent()),f.setOldX(f.getX()),f.setOldY(f.getY()), g=c.position.left,h=c.position.top,f.setPosition(g,h),a.dragging=!1,a.getID()!==f.parent.getID()?(f.parent.removePort(f),g=c.offset.left-d.getX()-a.absoluteX+a.canvas.getLeftScroll(),h=c.offset.top-d.getY()-a.absoluteY+a.canvas.getTopScroll(),a.addPort(f,g,h,!0),d.regularShapes.insert(f)):a.definePortPosition(f,f.getPoint(!0)),g={before:{condition:e.flo_condition,type:e.flo_type,segmentStyle:e.segmentStyle,srcDecorator:e.srcDecorator.getDecoratorPrefix(),destDecorator:e.destDecorator.getDecoratorPrefix()}, after:{type:prop.type,segmentStyle:prop.connection,srcDecorator:prop.srcDecorator,destDecorator:prop.destDecorator}},e.connect(),d.triggerPortChangeEvent(f),e=new PMCommandReconnect(f,g),d.commandStack.add(e);return!1}};var ToolbarPanel=function(a){ToolbarPanel.prototype.init.call(this,a)};ToolbarPanel.prototype=new PMUI.core.Panel;ToolbarPanel.prototype.type="ToolbarPanel"; ToolbarPanel.prototype.init=function(a){var b={buttons:[]};jQuery.extend(!0,b,a);PMUI.core.Panel.call(this,a);this.buttons=[];this.setButtons(b.buttons)};ToolbarPanel.prototype.setButtons=function(a){var b=this;jQuery.each(a,function(a,d){b.buttons.push(d)});return this}; ToolbarPanel.prototype.createHTMLButton=function(a){var b,c=PMUI.createHTMLElement("li"),d=PMUI.createHTMLElement("span");text=PMUI.createHTMLElement("span");c.title=a.tooltip;c.className="pm-toolbarpanel-btn";c.id=a.selector;for(b=0;bthis.getSegmentHeight(0)?this.getSegmentWidth(0):this.getSegmentHeight(0);for(d=1;de+1?(e=a,b=d):c>e+1&&(e=c,b=d);a=(this.lineSegments.get(b).endPoint.x-this.lineSegments.get(b).startPoint.x)/2;c=(this.lineSegments.get(b).endPoint.y-this.lineSegments.get(b).startPoint.y)/2;a=this.lineSegments.get(b).startPoint.x+a; b=this.lineSegments.get(b).startPoint.y+c;return new PMUI.util.Point(a,b)};PMFlow.prototype.connect=function(a){PMUI.draw.Connection.prototype.connect.call(this,a);a=this.getLabelCoordinates();this.label=new PMUI.draw.Label({message:this.getName(),canvas:this.canvas,parent:this,position:{location:"center",diffX:a.getX()/this.canvas.zoomFactor,diffY:a.getY()/this.canvas.zoomFactor}});this.html.appendChild(this.label.getHTML());return this}; PMFlow.prototype.changeFlowType=function(a){var b,c,d={"default":{srcPrefix:"PM-decorator_default",destPrefix:"PM-decorator"},conditional:{srcPrefix:"PM-decorator_conditional",destPrefix:"PM-decorator"},sequence:{srcPrefix:"PM-decorator",destPrefix:"PM-decorator"}};"association"===a?(b="dotted",c="con-none"):b="regular";this.setSegmentStyle(b);this.originalSegmentStyle=b;if("association"===a)this.srcDecorator.setDecoratorPrefix("PM-decorator"),this.srcDecorator.paint();else return this.srcDecorator.setDecoratorPrefix(d[a].srcPrefix).setDecoratorType("source").paint(), this.destDecorator.setDecoratorPrefix(d[a].destPrefix).setDecoratorType("target").paint(),this.disconnect().connect().setSegmentMoveHandlers().checkAndCreateIntersectionsWithAll(),this;c&&this.srcDecorator?this.destDecorator.setDecoratorPrefix(c):this.destDecorator.setDecoratorPrefix("PM-decorator");this.srcDecorator.paint();this.disconnect();this.connect();return this}; PMFlow.prototype.saveAndDestroy=function(){PMUI.draw.Connection.prototype.saveAndDestroy.call(this);"DEFAULT"===this.getFlowType()&&this.getSrcPort().getParent().updateDefaultFlow("")}; var PMCommandReconnect=function(a,b){var c=function(a){PMUI.command.CommandReconnect.call(this,a);c.prototype.init.call(this,a,b)};c.prototype=new PMUI.command.CommandReconnect(a);c.prototype.init=function(a,b){this.prefix={PMActivity:"act",PMGateway:"gat"};this.srcShape=a.connection.getSrcPort().parent;this.before.type=this.receiver.connection.getFlowType?this.receiver.connection.getFlowType():"connection";this.before.condition=this.receiver.connection.getFlowCondition?this.receiver.connection.getFlowCondition(): "flowCondition";this.before.defaultFlow="PMGateway"===this.srcShape.type||"PMActivity"===this.srcShape.type?this.srcShape[this.prefix[this.srcShape.type]+"_default_flow"]:"";this.condition=this.after.type=null;this.after.defaultFlow=""};c.prototype.fireTrigger=function(a){var b=[],c=this.receiver.connection,h,f,k;if("DEFAULT"===this.after.type||"DEFAULT"===this.before.type)b.push({id:this.srcShape.getID(),relatedObject:this.srcShape,type:this.srcShape.type,fields:[{field:"default_flow",newVal:this.srcShape[this.prefix[this.srcShape.type]+ "_default_flow"],oldVal:a?this.after.defaultFlow:this.before.defaultFlow}]});f={id:c.getID(),relatedObject:c,type:c.type,fields:[]};h=a?this.after.type:this.before.type;k=c.getFlowType();h!==k&&f.fields.push({field:"type",newVal:k,oldVal:h});h=a?this.after.condition:this.before.condition;k=c.getFlowCondition();h!==k&&f.fields.push({field:"condition",newVal:k,oldVal:h});0