summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-09-21 08:01:53 (EDT)
committer Stephan Born2012-09-21 08:01:53 (EDT)
commite760cf0caaf6f22327650310864a7f87cea23fbc (patch)
treeb228a9e194ff6ee1cea251af545d10a7f2cf389d
parent5fdea9147444094f3c6c53f88145baa476bf7a05 (diff)
downloadorg.eclipse.stardust.ui.web-e760cf0caaf6f22327650310864a7f87cea23fbc.zip
org.eclipse.stardust.ui.web-e760cf0caaf6f22327650310864a7f87cea23fbc.tar.gz
org.eclipse.stardust.ui.web-e760cf0caaf6f22327650310864a7f87cea23fbc.tar.bz2
CRNT-26281
1)Added code in m_symbol.js dragStop() of AnchorPoint for reverting the drag if validation fails for connection. 2)Made changes to existing validation method of ActivitySymbol and EventSymbol to handle rerouting connections. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@59421 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js42
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js13
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js2
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_eventSymbol.js4
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js102
5 files changed, 113 insertions, 50 deletions
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js
index 0ba7aa0..259fff6 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_activitySymbol.js
@@ -549,24 +549,25 @@ define(
/**
*
*/
- ActivitySymbol.prototype.validateCreateConnection = function() {
+ ActivitySymbol.prototype.validateCreateConnection = function(
+ conn) {
var outMappingActivity = new Array();
var inMappingActivity = new Array();
for ( var n in this.connections) {
var connection = this.connections[n];
if (connection.fromAnchorPoint.symbol.type == m_constants.ACTIVITY_SYMBOL
&& connection.fromAnchorPoint.symbol.oid == this.oid) {
- if ((null != connection.toAnchorPoint
- && null != connection.toAnchorPoint.symbol)
+ if ((null != connection.toAnchorPoint && null != connection.toAnchorPoint.symbol)
&& connection.toAnchorPoint.symbol.type == m_constants.DATA_SYMBOL) {
- //do nothing
- }else{
+ // do nothing
+ } else {
if (-1 != jQuery.inArray(
connection.fromAnchorPoint.symbol.oid,
outMappingActivity)) {
return false;
- }else
- outMappingActivity.push(connection.fromAnchorPoint.symbol.oid);
+ } else
+ outMappingActivity
+ .push(connection.fromAnchorPoint.symbol.oid);
}
} else if (null != connection.toAnchorPoint
&& null != connection.toAnchorPoint.symbol) {
@@ -579,12 +580,33 @@ define(
connection.toAnchorPoint.symbol.oid,
inMappingActivity)) {
return false;
- }else
- inMappingActivity.push(connection.toAnchorPoint.symbol.oid);
+ } else
+ inMappingActivity
+ .push(connection.toAnchorPoint.symbol.oid);
+ }
+ }
+ }
+ // When rerouting happens, connection is not present in
+ // this.connections, check the validation rules with symbol connections list
+ if (conn != null && conn.oid > 0) {
+ if (-1 == jQuery.inArray(conn, this.connections)) {
+ if (conn.fromAnchorPoint
+ && conn.fromAnchorPoint.symbol) {
+ if (this.oid == conn.fromAnchorPoint.symbol.oid) {
+ return (-1 == jQuery.inArray(
+ conn.fromAnchorPoint.symbol.oid,
+ outMappingActivity))
+ }
+ }
+ if (conn.toAnchorPoint && conn.toAnchorPoint.symbol) {
+ if (this.oid == conn.toAnchorPoint.symbol.oid) {
+ return (-1 == jQuery.inArray(
+ conn.toAnchorPoint.symbol.oid,
+ inMappingActivity))
+ }
}
}
}
-
return true;
};
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js
index 64da1b5..1dc4dd7 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js
@@ -390,7 +390,9 @@ define(
this.setSecondAnchorPointNoComplete(anchorPoint);
var updateConnection = null;
+
if (this.toAnchorPoint.symbol != null) {
+
// When IN mapping present and OUT mapping is added,
// same connection is modified viceversa
if (this.isDataFlow()) {
@@ -423,6 +425,7 @@ define(
}
}
}
+
// If update is not called, new connection is created
if (updateConnection == null) {
this.complete(sync);
@@ -1457,7 +1460,7 @@ define(
.showErrorMessage("Events can be connected only to activities and gateways.");
return false;
} else if (!fromAnchorPoint.symbol
- .validateCreateConnection()) {
+ .validateCreateConnection(this)) {
// Start Event can have only one OUT connection
m_messageDisplay
.showErrorMessage("No further connection allowed for this Event.");
@@ -1483,13 +1486,15 @@ define(
// Data symbol validation called
if (null != toAnchorPoint
&& (toAnchorPoint.symbol.type == m_constants.DATA_SYMBOL)) {
+ // Validation handled on Data Symbol for data
+ // connections.
if (!toAnchorPoint.symbol
.validateCreateConnection()) {
m_messageDisplay
.showErrorMessage("No further OUT Connection allowed from this activity.");
}
} else if (!fromAnchorPoint.symbol
- .validateCreateConnection()) {
+ .validateCreateConnection(this)) {
m_messageDisplay
.showErrorMessage("No more connection allowed from this activity.");
return false;
@@ -1513,7 +1518,7 @@ define(
.showErrorMessage("Only out sequence flow connections are allowed on Start Events.");
return false;
} else if (!toAnchorPoint.symbol
- .validateCreateConnection()) {
+ .validateCreateConnection(this)) {
// End Event can have only one IN connection
m_messageDisplay
.showErrorMessage("No more connection allowed to this Event.");
@@ -1529,7 +1534,7 @@ define(
}else if (toAnchorPoint.symbol.type == m_constants.ACTIVITY_SYMBOL) {
if ((fromAnchorPoint.symbol.type != m_constants.DATA_SYMBOL && fromAnchorPoint.symbol.type != m_constants.EVENT_SYMBOL)
&& !toAnchorPoint.symbol
- .validateCreateConnection()) {
+ .validateCreateConnection(this)) {
m_messageDisplay
.showErrorMessage("No more connections allowed to this activity.");
return false;
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
index dbfcaf3..f15b65c 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js
@@ -74,6 +74,7 @@ define(
this.process = null;
this.mode = this.NORMAL_MODE;
this.symbols = [];
+ this.dragEnabled = null;
// Activity symbols by OIDs
@@ -1521,7 +1522,6 @@ define(
Diagram.prototype.clearCurrentSelection = function() {
this.deselectCurrentSelection();
this.currentSelection = [];
- this.currentFlyOutSymbol = null;
this.showProcessPropertiesPanel();
};
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_eventSymbol.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_eventSymbol.js
index da2ec4c..0d2dd08 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_eventSymbol.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_eventSymbol.js
@@ -295,9 +295,9 @@ define(
/**
*
*/
- EventSymbol.prototype.validateCreateConnection = function() {
+ EventSymbol.prototype.validateCreateConnection = function(conn) {
if (this.connections.length > 0
- && this.connections[0].oid > 0) {
+ && this.connections[0].oid > 0 && (this.connections[0].oid != conn.oid)) {
m_messageDisplay
.showMessage("No further connection allowed for this Event.");
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js
index 87e65b1..e3e5b72 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js
@@ -881,6 +881,7 @@ define(
this.dragStartX = this.x;
this.dragStartY = this.y;
+ this.diagram.dragEnabled = true;
}
};
@@ -974,6 +975,7 @@ define(
}
}
}
+ this.diagram.dragEnabled = false;
}
};
@@ -1013,8 +1015,10 @@ define(
Symbol.prototype.validateProximity = function(event) {
try {
// while in connection mode/or symbol is Pool/swimlane ,
- // flyout menu can disappear
- if ((this.diagram.mode == this.diagram.CONNECTION_MODE || this.diagram.currentConnection != null || this.diagram.currentSelection.length > 0)
+ // or in Drag and Drop mode flyout menu should disappear
+ if ((this.diagram.mode == this.diagram.CONNECTION_MODE
+ || this.diagram.currentConnection != null || this.diagram.currentSelection.length > 0 || this.diagram.newSymbol)
+ || this.diagram.dragEnabled
|| this.type == null
|| (this.type && (this.type.toLowerCase()
.indexOf(
@@ -1905,6 +1909,12 @@ define(
this.direction = m_constants.TO_ANCHOR_POINT;
}
+ // Remember drag start position
+ this.dragStartX = this.x;
+ this.dragStartY = this.y;
+ // Flag required to hide flyout menu's in Drag and Drop
+ this.symbol.diagram.dragEnabled = true;
+
// Replace and anchor point and keep reference
for ( var n in this.symbol.anchorPoints) {
@@ -1939,6 +1949,7 @@ define(
if (symbol != null) {
var anchorPoint = symbol.getClosestAnchorPoint(this.x,
this.y, true);
+ var updateConnection = true;
if (symbol == this.symbol) {
if (this.direction == m_constants.FROM_ANCHOR_POINT) {
@@ -1948,36 +1959,56 @@ define(
}
} else {
var newConnection = null;
+ // Store the new Anchor Points to create new
+ // connection
+ var fromAnchorPoint = this.dragConnection.fromAnchorPoint;
+ var toAnchorPoint = this.dragConnection.toAnchorPoint;
+ // Validate the new connection
+ if (this.dragConnection.validateCreateConnection(
+ fromAnchorPoint, toAnchorPoint)) {
+
+ // Reset the original Anchor Point in dragConnection
+ // for deletion
+ if (this.dragConnection.originalFromAnchorPoint) {
+ this.dragConnection.fromAnchorPoint = this.dragConnection.originalFromAnchorPoint;
+ this.dragConnection.originalFromAnchorPoint = null;
+ } else if (this.dragConnection.originalToAnchorPoint) {
+ this.dragConnection.toAnchorPoint = this.dragConnection.originalToAnchorPoint;
+ this.dragConnection.originalToAnchorPoint = null;
+ }
+ this.dragConnection.createDeleteCommand(true);
+
+ if (this.direction == m_constants.TO_ANCHOR_POINT) {
+ newConnection = this.symbol.diagram
+ .createConnection(fromAnchorPoint);
+ // Create the connection
+ newConnection.setSecondAnchorPoint(
+ anchorPoint, true);
+ } else {
+ newConnection = this.symbol.diagram
+ .createConnection(anchorPoint);
+ // Create the connection
+ newConnection.setSecondAnchorPoint(
+ toAnchorPoint, true);
+ }
- var fromAnchorPoint =this.dragConnection.fromAnchorPoint;
- var toAnchorPoint =this.dragConnection.toAnchorPoint;
- // Reset the original Anchor Point in dragConnection
- // for deletion
- if (this.dragConnection.originalFromAnchorPoint) {
- this.dragConnection.fromAnchorPoint = this.dragConnection.originalFromAnchorPoint;
- this.dragConnection.originalFromAnchorPoint = null;
- } else if (this.dragConnection.originalToAnchorPoint) {
- this.dragConnection.toAnchorPoint = this.dragConnection.originalToAnchorPoint;
- this.dragConnection.originalToAnchorPoint = null;
- }
-
- this.dragConnection.createDeleteCommand(true);
-
- if (this.direction == m_constants.TO_ANCHOR_POINT) {
- newConnection = this.symbol.diagram
- .createConnection(fromAnchorPoint);
- newConnection.setSecondAnchorPoint(anchorPoint,
- true);
- } else {
- newConnection = this.symbol.diagram
- .createConnection(anchorPoint);
- newConnection
- .setSecondAnchorPoint(
- toAnchorPoint,
- true);
+ this.dragConnection = newConnection;
+
+ }else{
+ // Reset the original Anchor Point in
+ // dragConnection to revert
+ if (this.dragConnection.originalFromAnchorPoint) {
+ this.dragConnection.fromAnchorPoint = this.dragConnection.originalFromAnchorPoint;
+ this.dragConnection.originalFromAnchorPoint = null;
+ } else if (this.dragConnection.originalToAnchorPoint) {
+ this.dragConnection.toAnchorPoint = this.dragConnection.originalToAnchorPoint;
+ this.dragConnection.originalToAnchorPoint = null;
+ }
+ this.dragConnection.toAnchorPointOrientation = this.dragConnection.toAnchorPoint.orientation;
+ this.dragConnection.fromAnchorPointOrientation = this.dragConnection.fromAnchorPoint.orientation;
+ this.moveTo(this.dragStartX,this.dragStartY);
+ updateConnection = false;
}
-
- this.dragConnection = newConnection;
}
} else {
if (this.direction == m_constants.FROM_ANCHOR_POINT) {
@@ -1988,12 +2019,17 @@ define(
}
this.dragConnection.reroute();
-
- this.dragConnection.createUpdateCommand();
+ // if reroute validation fails no update is required
+ if(updateConnection){
+ this.dragConnection.createUpdateCommand();
+ m_messageDisplay.showMessage("Connection updated");
+ this.remove();
+ }
this.dragConnection.select();
this.dragConnection.toAnchorPoint.deselect();
- this.remove();
+ // dragEnabled flag is used to hide flyout menu in Drag mode
+ this.symbol.diagram.dragEnabled = false;
}
/**