From 10f83d9a7206b126eedbb99e65f103ff3111e279 Mon Sep 17 00:00:00 2001 From: girish Date: Fri, 4 Feb 2011 09:06:25 +0000 Subject: [PATCH] Fixed Boundary Event on zoom --- workflow/engine/templates/bpmn/MyWorkflow.js | 169 ++++++++---------- .../templates/bpmn/ProcessMapContext.js | 2 - workflow/engine/templates/bpmn/bpmnShapes.js | 94 +++++----- 3 files changed, 124 insertions(+), 141 deletions(-) diff --git a/workflow/engine/templates/bpmn/MyWorkflow.js b/workflow/engine/templates/bpmn/MyWorkflow.js index 947976907..473006754 100755 --- a/workflow/engine/templates/bpmn/MyWorkflow.js +++ b/workflow/engine/templates/bpmn/MyWorkflow.js @@ -872,11 +872,11 @@ MyWorkflow.prototype.toggleShapes=function(item) if(item.type == 'bpmnEventBoundaryTimerInter') { - workflow.boundaryEvent = true; - workflow.taskName = oldWorkflow.taskName; - var newShape = eval("new bpmnTask(workflow)"); - //workflow.boundaryEvent = false; - + workflow.currentSelection.boundaryEvent = true; + workflow.taskName = oldWorkflow.taskName; + var newShape = workflow.currentSelection; + newShape.setDimension(newShape.getWidth(),newShape.getHeight()); + } else if(item.type == 'bpmnSubProcess') { @@ -885,33 +885,34 @@ MyWorkflow.prototype.toggleShapes=function(item) } else newShape = eval("new "+item.type+"(this.workflow)"); - - this.workflow.addFigure(newShape,x,y); //Add New Selected Gateway First - //Delete Old Shape - item.scope.workflow.getCommandStack().execute(new CommandDelete(oldWorkflow)); - ToolGeneric.prototype.execute.call(item.scope); + if(item.type != 'bpmnEventBoundaryTimerInter') + { + this.workflow.addFigure(newShape,x,y); //Add New Selected Shape First + //Delete Old Shape + item.scope.workflow.getCommandStack().execute(new CommandDelete(oldWorkflow)); + ToolGeneric.prototype.execute.call(item.scope); + //to create all the new connections again - var connObj; - for(i=0 ; i < countConn ; i++) - { - if(sourcePortId[i] == shapeId) //If shapeId is equal to sourceId the , replace the oldShape object by new shape Object - sourceNode[i] = newShape; - else - targetNode[i] = newShape; - - connObj = new DecoratedConnection(); - connObj.setTarget(eval('targetNode[i].getPort(targetPortName[i])')); - connObj.setSource(eval('sourceNode[i].getPort(sourcePortName[i])')); - newShape.workflow.addFigure(connObj); - } + var connObj; + for(i=0 ; i < countConn ; i++) + { + if(sourcePortId[i] == shapeId) //If shapeId is equal to sourceId the , replace the oldShape object by new shape Object + sourceNode[i] = newShape; + else + targetNode[i] = newShape; + connObj = new DecoratedConnection(); + connObj.setTarget(eval('targetNode[i].getPort(targetPortName[i])')); + connObj.setSource(eval('sourceNode[i].getPort(sourcePortName[i])')); + newShape.workflow.addFigure(connObj); + } + } + //Saving Asynchronously deleted shape and new created shape into DB if(item.type.match(/Boundary/)) { - newShape.id = oldWorkflow.id; - newShape.html.id = oldWorkflow.id; newShape.actiontype = 'updateTask'; workflow.saveShape(newShape); } @@ -1604,7 +1605,7 @@ MyWorkflow.prototype.saveShape= function(oNewShape) this.workflow.newTaskInfo = Ext.util.JSON.decode(response.responseText); oNewShape.html.id = this.workflow.newTaskInfo.uid; oNewShape.id = this.workflow.newTaskInfo.uid; - if(oNewShape.type == 'bpmnTask'){ + if(oNewShape.type == 'bpmnTask' && oNewShape.boundaryEvent != true){ oNewShape.taskName = this.workflow.newTaskInfo.label; workflow.redrawTaskText(oNewShape,''); //After Figure is added, Update Start Event connected to Task @@ -1620,17 +1621,16 @@ MyWorkflow.prototype.saveShape= function(oNewShape) if (preSelectedFigure.type.match(/Gateway/)) //preSelectedFigure.rou_type = 'SEQUENTIAL'; this.workflow.saveRoute(preSelectedFigure,oNewShape); - if (preSelectedFigure.type.match(/Inter/)) { //preSelectedFigure.rou_type = 'SEQUENTIAL'; this.workflow.saveEvents(preSelectedFigure,oNewShape); } } + } else if(oNewShape.type == 'bpmnSubProcess'){ oNewShape.subProcessName = this.workflow.newTaskInfo.label; - } - } + } } }, failure: function(){ @@ -2107,14 +2107,9 @@ MyWorkflow.prototype.saveRoute = function(preObj,newObj) } } -/** - * Deleting Route Silently - * @Param oConn Object - * @Param iVal Integer - * @Author Girish joshi - */ MyWorkflow.prototype.deleteRoute = function(oConn,iVal){ + workflow.oConn = oConn; var sourceObjType = oConn.sourcePort.parentNode.type; var targetObjType = oConn.targetPort.parentNode.type; var rou_uid = oConn.id; @@ -2122,27 +2117,42 @@ MyWorkflow.prototype.deleteRoute = function(oConn,iVal){ //Setting Condition for VALID ROUTE_UID present in Route Table //For start and gateway event, we dont have entry in ROUTE table if(rou_uid != '' && !sourceObjType.match(/Gateway/) && !sourceObjType.match(/Start/) && !targetObjType.match(/Gateway/)) - var urlparams = '?action=deleteRoute&data={"uid":"'+ rou_uid +'"}'; + { + workflow.urlDeleteparameter = '?action=deleteRoute&data={"uid":"'+ rou_uid +'"}'; + } - //Deleting route for Start event and also deleting start event - else if(sourceObjType.match(/Start/)){ - var targetObj = oConn.targetPort.parentNode; //Task - var tas_uid = targetObj.id; - var tas_start = 'FALSE'; - urlparams = '?action=saveStartEvent&data={"tas_uid":"'+tas_uid+'","tas_start":"'+tas_start+'"}'; - } - Ext.Ajax.request({ - url: "processes_Ajax.php"+ urlparams, + //Deleting route for Start event and also deleting start event + else if(sourceObjType.match(/Start/)){ + var targetObj = oConn.targetPort.parentNode; //Task + var tas_uid = targetObj.id; + var tas_start = 'FALSE'; + workflow.urlDeleteparameter = '?action=saveStartEvent&data={"tas_uid":"'+tas_uid+'","tas_start":"'+tas_start+'"}'; + } + Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete the Event',this.showEventResult); + +} + +MyWorkflow.prototype.showEventResult = function(btn){ + //this.workflow.confirm = btn; + if(typeof workflow.urlDeleteparameter != 'undefined') + { + var url = workflow.urlDeleteparameter; + if(btn == 'yes') + { + Ext.Ajax.request({ + url: "processes_Ajax.php"+ url, success: function(response) { if(iVal == 0) - oConn.workflow.getCommandStack().execute(new CommandDelete(oConn)); + workflow.getCommandStack().execute(new CommandDelete(workflow.oConn)); }, failure: function(){ Ext.Msg.alert ('Failure'); } }); -} + } + } + }; /** * Deleting Event * @Param eventObj Object @@ -2182,7 +2192,7 @@ MyWorkflow.prototype.getDeleteCriteria = function() workflow.currentSelection.actiontype = 'saveStartEvent'; break; case 'bpmnEventEmptyEnd': - workflow.currentSelection.actiontype = 'deleteEndEvent'; + //workflow.currentSelection.actiontype = 'deleteEndEvent'; var currentObj = workflow.currentSelection; var ports = currentObj.getPorts(); var len =ports.data.length; @@ -2210,18 +2220,18 @@ MyWorkflow.prototype.getDeleteCriteria = function() } } if(typeof route != 'undefined') - workflow.deleteRoute(route,1); + { + workflow.deleteRoute(route,1); + } break; - } - if(shape.match(/Gateway/)) - { + case shape.match(/Gateway/): workflow.currentSelection.actiontype = 'deleteGateway'; workflow.deleteShape(workflow.currentSelection); - } - else - workflow.deleteShape(workflow.currentSelection); + break; + } - + if(workflow.currentSelection.actiontype != '') + workflow.deleteShape(workflow.currentSelection); } @@ -2273,7 +2283,9 @@ MyWorkflow.prototype.zoom = function(sType) workflow.zoomTaskHeight = height; } ++workflow.limitFlag; - fig.setPosition(xPos + zoomFactor*xPos,yPos + zoomFactor*yPos); + xPos = xPos + zoomFactor*xPos; + yPos = yPos + zoomFactor*yPos + fig.setPosition(xPos,yPos); } else if(sType == 'out' && workflow.limitFlag > 0) { @@ -2298,55 +2310,30 @@ MyWorkflow.prototype.zoom = function(sType) workflow.zoomTaskHeight = height; } --workflow.limitFlag; - fig.setPosition(xPos - zoomFactor*xPos,yPos - zoomFactor*yPos); + xPos = xPos - zoomFactor*xPos; + yPos = yPos - zoomFactor*yPos + fig.setPosition(xPos,yPos); } fig.setDimension(width,height); if(fig.type == 'bpmnTask') - { workflow.redrawTaskText(fig,sType); - } else if(fig.type == 'bpmnAnnotation') - { workflow.redrawAnnotationText(fig,sType); - } } } MyWorkflow.prototype.redrawTaskText = function(fig,sType) { - fig.bpmnText.clear(); - //len = Math.ceil(this.input.value.length/16); - var len = fig.getWidth() / 18; - if (len >= 6) { - //len = 1.5; - var padleft = 0.12 * fig.getWidth(); - var padtop = 0.40 * fig.getHeight() -3; - fig.rectWidth = fig.getWidth() - 2 * padleft; - } - else { - padleft = 0.1 * fig.getWidth(); - padtop = 0.09 * fig.getHeight() -3; - fig.rectWidth = fig.getWidth() - 2 * padleft; - } - var rectheight = fig.getHeight() - padtop -7; - - if(typeof fig.size == 'undefined') - fig.size = fig.bpmnText.ftSz.substr(0,fig.bpmnText.ftSz.length-2); - else - fig.size = fig.size; - if(sType == 'in' && sType != '') - fig.size = parseInt(fig.size) + 4; + fig.fontSize = parseInt(fig.fontSize) + 4; else if(sType == 'out' && sType != '') - fig.size = parseInt(fig.size) - 4; + fig.fontSize = parseInt(fig.fontSize) - 4; - //Setting font minimum limit - if(fig.size < 11) - fig.size = 11; - eval("fig.bpmnText.setFont('verdana','"+fig.size+"px', Font.PLAIN)"); - fig.bpmnText.drawStringRect(fig.taskName, padleft, padtop, fig.rectWidth, rectheight, 'center'); - fig.bpmnText.paint(); + //Setting font minimum limit + if(this.fontSize < 11) + this.fontSize = 11; + fig.paint(); } MyWorkflow.prototype.redrawAnnotationText = function(fig,sType) diff --git a/workflow/engine/templates/bpmn/ProcessMapContext.js b/workflow/engine/templates/bpmn/ProcessMapContext.js index a6d6a922f..20d959bed 100755 --- a/workflow/engine/templates/bpmn/ProcessMapContext.js +++ b/workflow/engine/templates/bpmn/ProcessMapContext.js @@ -291,8 +291,6 @@ ProcessMapContext.prototype.exportProcess= function() ProcessMapContext.prototype.addTask= function() { - var count = ++workflow.taskNo; //Incrementing Task No and assigning it to a local variable - workflow.taskName = 'Task '+count; var newShape = eval("new bpmnTask(workflow)"); var xPos = workflow.contextX; var yPos = workflow.contextY; diff --git a/workflow/engine/templates/bpmn/bpmnShapes.js b/workflow/engine/templates/bpmn/bpmnShapes.js index 2408508ad..b6c82da46 100755 --- a/workflow/engine/templates/bpmn/bpmnShapes.js +++ b/workflow/engine/templates/bpmn/bpmnShapes.js @@ -77,78 +77,76 @@ bpmnTask.prototype.paint = function () { var len = this.getWidth() / 18; if (len >= 6) { //len = 1.5; - var padleft = 0.12 * this.getWidth(); - var padtop = 0.40 * this.getHeight() -3; - this.rectWidth = this.getWidth() - 2 * padleft; + this.padleft = 0.12 * this.getWidth(); + this.padtop = 0.40 * this.getHeight() -3; + this.rectWidth = this.getWidth() - 2 * this.padleft; } else { - padleft = 0.1 * this.getWidth(); - padtop = 0.09 * this.getHeight() -3; - this.rectWidth = this.getWidth() - 2 * padleft; + this.padleft = 0.1 * this.getWidth(); + this.padtop = 0.09 * this.getHeight() -3; + this.rectWidth = this.getWidth() - 2 * this.padleft; } - var rectheight = this.getHeight() - padtop -7; + this.rectheight = this.getHeight() - this.padtop -7; + + if(typeof this.fontSize == 'undefined' || this.fontSize == '') + this.fontSize = 11; + else if(this.fontSize < 11) + this.fontSize = 11; + - var fontSize = 11; - - this.bpmnText.setFont('verdana', +fontSize+'px', Font.PLAIN); + this.bpmnText.setFont('verdana', +this.fontSize+'px', Font.PLAIN); + if(typeof this.taskName == 'undefined') this.taskName = ''; - this.bpmnText.drawStringRect(this.taskName, padleft, padtop, this.rectWidth, rectheight, 'center'); + this.bpmnText.drawStringRect(this.taskName, this.padleft, this.padtop, this.rectWidth, this.rectheight, 'center'); // tempcoord = this.coord_converter(this.getWidth(), this.getHeight(), this.taskName.length); // bpmnText.drawTextString(this.taskName, this.getWidth(), this.getHeight(), tempcoord.temp_x, tempcoord.temp_y); /**************************** Drawing Timer Boundary event starts here *******************************/ - var boundaryTimer = new jsGraphics(this.id); + this.boundaryTimer = new jsGraphics(this.id); var x_cir1=5; var y_cir1=45; - boundaryTimer.setColor("#c0c0c0"); - boundaryTimer.fillEllipse(x[3]-x[3]/1.08,y[4]-12,30,30); + this.x3 = x[3]; + this.y4 = y[4]; + this.y5 = y[5]; - boundaryTimer.setStroke(this.stroke); - boundaryTimer.setColor( "#f9faf2" ); - boundaryTimer.fillEllipse(x[3]-x[3]/1.08,y[5]-12,30,30); - boundaryTimer.setColor("#adae5e"); - boundaryTimer.drawEllipse(x[3]-x[3]/1.08,y[5]-12,30,30); + this.boundaryTimer.setColor("#c0c0c0"); + this.boundaryTimer.fillEllipse(this.x3-this.x3/1.08,this.y4-12,30,30); + + this.boundaryTimer.setStroke(this.stroke); + this.boundaryTimer.setColor( "#f9faf2" ); + this.boundaryTimer.fillEllipse(this.x3-this.x3/1.08,this.y5-12,30,30); + this.boundaryTimer.setColor("#adae5e"); + this.boundaryTimer.drawEllipse(this.x3-this.x3/1.08,this.y5-12,30,30); var x_cir2=8; var y_cir2=48; - boundaryTimer.setColor( "#f9faf2" ); - boundaryTimer.fillEllipse(x[3]-x[3]/1.08+3,y[5]-9,30-6,30-6); - boundaryTimer.setColor("#adae5e"); - boundaryTimer.drawEllipse(x[3]-x[3]/1.08+3,y[5]-9,30-6,30-6); + this.boundaryTimer.setColor( "#f9faf2" ); + this.boundaryTimer.fillEllipse(this.x3-this.x3/1.08+3,this.y5-9,30-6,30-6); + this.boundaryTimer.setColor("#adae5e"); + this.boundaryTimer.drawEllipse(this.x3-this.x3/1.08+3,this.y5-9,30-6,30-6); - /* - //drawing clock's minutes lines - this.graphics.setColor("#adae5e"); + this.boundaryTimer.setColor("#adae5e"); //this.graphics.drawEllipse(x_cir3,y_cir3,30-20,30-20); - this.graphics.drawLine(30/2,30/2,30/1.3,30/2); - this.graphics.drawLine(30/2,30/2,30/2,30/4.5); - */ + this.boundaryTimer.drawLine(30/2.2+this.x3-this.x3/1.08,30/2+this.y5-10,30/1.6+this.x3-this.x3/1.08,30/2+this.y5-10); //horizontal line + this.boundaryTimer.drawLine(30/2.2+this.x3-this.x3/1.08,30/2+this.y5-10,30/2.2+this.x3-this.x3/1.08,30/3.7+this.y5-10); //vertical line - - //var x_cir3=10; - //var y_cir3=10; - //this.graphics.setColor( "#f9faf2" ); - //this.graphics.fillEllipse(x_cir3,y_cir3,30-20,30-20); - boundaryTimer.setColor("#adae5e"); - //this.graphics.drawEllipse(x_cir3,y_cir3,30-20,30-20); - boundaryTimer.drawLine(30/2.2+x[3]-x[3]/1.08,30/2+y[5]-10,30/1.6+x[3]-x[3]/1.08,30/2+y[5]-10); //horizontal line - boundaryTimer.drawLine(30/2.2+x[3]-x[3]/1.08,30/2+y[5]-10,30/2.2+x[3]-x[3]/1.08,30/3.7+y[5]-10); //vertical line - - boundaryTimer.drawLine(x[3]-x[3]/1.08+24,y[5]-3,x[3]-x[3]/1.08+20,y[5]); //10th min line 24,8,20,11 - boundaryTimer.drawLine(x[3]-x[3]/1.08+21,y[5]+4,x[3]-x[3]/1.08+25,y[5]+4); //15th min line - boundaryTimer.drawLine(x[3]-x[3]/1.08+24,y[5]+11,x[3]-x[3]/1.08+19,y[5]+9); //25th min line - boundaryTimer.drawLine(x[3]-x[3]/1.08+15,y[5]+11,x[3]-x[3]/1.08+15,y[5]+14); //30th min line - boundaryTimer.drawLine(x[3]-x[3]/1.08+8,y[5]+11,x[3]-x[3]/1.08+12,y[5]+8); //40th min line - boundaryTimer.drawLine(x[3]-x[3]/1.08+5,y[5]+4,x[3]-x[3]/1.08+8,y[5]+4); //45th min line - boundaryTimer.drawLine(x[3]-x[3]/1.08+8,y[5]-4,x[3]-x[3]/1.08+11,y[5]-1); //50th min line - boundaryTimer.drawLine(x[3]-x[3]/1.08+15,y[5]-7,x[3]-x[3]/1.08+15,y[5]-4); //60th min line + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+24,this.y5-3,this.x3-this.x3/1.08+20,this.y5); //10th min line 24,8,20,11 + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+21,this.y5+4,this.x3-this.x3/1.08+25,this.y5+4); //15th min line + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+24,this.y5+11,this.x3-this.x3/1.08+19,this.y5+9); //25th min line + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+15,this.y5+11,this.x3-this.x3/1.08+15,this.y5+14); //30th min line + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+8,this.y5+11,this.x3-this.x3/1.08+12,this.y5+8); //40th min line + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+5,this.y5+4,this.x3-this.x3/1.08+8,this.y5+4); //45th min line + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+8,this.y5-4,this.x3-this.x3/1.08+11,this.y5-1); //50th min line + this.boundaryTimer.drawLine(this.x3-this.x3/1.08+15,this.y5-7,this.x3-this.x3/1.08+15,this.y5-4); //60th min line if(this.boundaryEvent == true) - boundaryTimer.paint(); + { + this.boundaryTimer.paint(); + } /**************************** Drawing Timer Boundary event ends here *******************************/ this.bpmnText.paint();