summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-09-04 02:17:34 (EDT)
committerStephan Born2012-09-04 02:17:34 (EDT)
commita74e2efde5c2c0d510d8d99106d4de552f458828 (patch)
tree8fb6db1ef6c3f12b85b3cd95b812b7eacff794f6
parenta618a983eb36e2a1a3380e8cdee0227d81cb0737 (diff)
downloadorg.eclipse.stardust.ui.web-a74e2efde5c2c0d510d8d99106d4de552f458828.zip
org.eclipse.stardust.ui.web-a74e2efde5c2c0d510d8d99106d4de552f458828.tar.gz
org.eclipse.stardust.ui.web-a74e2efde5c2c0d510d8d99106d4de552f458828.tar.bz2
CRNT-25999, CRNT-26000
1)Added validateAnchorPoint method in m_connection.js to validate anchorPoints based on connection rules. 2)Made changes in m_diagram.js setAnchorPoint() to validateAnchorPoint before createConnection 3)Added NPE check in removeFlyOutMenu and removePrimitives git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@58885 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_connection.js65
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_diagram.js25
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_drawable.js76
3 files changed, 116 insertions, 50 deletions
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 ede55e5..5cff4e6 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
@@ -7,21 +7,26 @@ define(
"m_propertiesPanel", "m_dataFlowPropertiesPanel",
"m_controlFlowPropertiesPanel", "m_activitySymbol",
"m_gatewaySymbol", "m_eventSymbol", "m_controlFlow",
- "m_dataFlow", "m_modelerUtils" ],
+ "m_dataFlow", "m_modelerUtils", "m_messageDisplay" ],
function(m_utils, m_constants, m_canvasManager, m_drawable,
m_commandsController, m_command, m_controlFlow,
m_propertiesPanel, m_dataFlowPropertiesPanel,
m_controlFlowPropertiesPanel, m_activitySymbol,
m_gatewaySymbol, m_eventSymbol, m_controlFlow, m_dataFlow,
- m_modelerUtils) {
+ m_modelerUtils, m_messageDisplay) {
return {
createConnection : function(diagram, fromAnchorPoint) {
var connection = new Connection();
connection.bind(diagram);
-
- connection.setFirstAnchorPoint(fromAnchorPoint);
+ // Validate the connection rules for anchor Point
+ if(connection.validateAnchorPoint(fromAnchorPoint)){
+ connection.setFirstAnchorPoint(fromAnchorPoint);
+ }else{
+ // reset the connection
+ connection = null;
+ }
return connection;
},
@@ -309,7 +314,10 @@ define(
this.prepare();
}
- if (this.toAnchorPoint.symbol != null) {
+ if (this.toAnchorPoint.symbol != null && this.validateAnchorPoint(this.fromAnchorPoint, this.toAnchorPoint)) {
+ // On Mouse move , the same connection is added again,
+ // so remove if present then add(update)
+ this.toAnchorPoint.symbol.connections.pop(this);
this.toAnchorPoint.symbol.connections.push(this);
if (this.isDataFlow()) {
@@ -1274,9 +1282,11 @@ define(
// Remove this connection from FROM and TO Symbol's
// connection array
m_utils.removeItemFromArray(
- this.toAnchorPoint.symbol.connections, this);
- m_utils.removeItemFromArray(
this.fromAnchorPoint.symbol.connections, this);
+ if(this.toAnchorPoint.symbol){
+ m_utils.removeItemFromArray(
+ this.toAnchorPoint.symbol.connections, this);
+ }
};
/**
@@ -1333,6 +1343,47 @@ define(
}
/**
+ * Validate connection rules for symbols
+ */
+ Connection.prototype.validateAnchorPoint = function(
+ fromAnchorPoint, toAnchorPoint) {
+ m_messageDisplay.clear();
+ if (fromAnchorPoint.symbol.type == m_constants.EVENT_SYMBOL) {
+ // Check for OUT connections on End Event
+ if (fromAnchorPoint.symbol.modelElement.eventType == m_constants.STOP_EVENT_TYPE) {
+ m_messageDisplay
+ .showErrorMessage("Only in sequence flow connections are allowed on End Events.");
+ return false;
+ } else if (fromAnchorPoint.symbol.connections.length > 1) {
+ // Start Event can have only one OUT connection
+ m_messageDisplay
+ .showErrorMessage("No further connection allowed for this Event.");
+ return false;
+ }
+ } else if ((toAnchorPoint != null && toAnchorPoint.symbol.type == m_constants.EVENT_SYMBOL)) {
+ // Check for IN connections on Start Event
+ if (toAnchorPoint.symbol.modelElement.eventType == m_constants.START_EVENT_TYPE) {
+ m_messageDisplay
+ .showErrorMessage("Only out sequence flow connections are allowed on Start Events.");
+ return false;
+ } else if (toAnchorPoint.symbol.connections.length > 1) {
+ // End Event can have only one IN connection
+ m_messageDisplay
+ .showErrorMessage("No further connection allowed for this Event.");
+ return false;
+ }
+ }
+ // If Start and End symbol are same, show error
+ if (toAnchorPoint != null
+ && fromAnchorPoint.symbol.oid == toAnchorPoint.symbol.oid) {
+ m_messageDisplay
+ .showErrorMessage("A connection must connect two different symbols.");
+ return false;
+ }
+ return true;
+ }
+
+ /**
*
*/
Connection.prototype.flipFlowOrientation = function(
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 22a9ef5..7df7f45 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
@@ -1406,19 +1406,30 @@ define(
*/
Diagram.prototype.setAnchorPoint = function(anchorPoint) {
if (this.currentConnection == null) {
+ // createConnection returns null, if anchorPoint is not
+ // valid.Ex. trying to create a connection from End
+ // Event
this.currentConnection = this
.createConnection(anchorPoint);
// Set dummy anchor point
-
- this.currentConnection.setDummySecondAnchorPoint();
+ if (this.currentConnection) {
+ this.currentConnection.setDummySecondAnchorPoint();
+ }
} else {
- this.currentConnection
- .setSecondAnchorPoint(anchorPoint);
- this.currentConnection.select();
+ // Validate if connection is allowed on current anchor
+ // point
+ if (this.currentConnection.validateAnchorPoint(
+ this.currentConnection.fromAnchorPoint,
+ anchorPoint)) {
+ this.currentConnection
+ .setSecondAnchorPoint(anchorPoint);
+ this.currentConnection.select();
+ this.currentConnection = null;
+ this.mode = this.NORMAL_MODE;
+ }
+
- this.currentConnection = null;
- this.mode = this.NORMAL_MODE;
}
};
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_drawable.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_drawable.js
index 96ad3a8..495a08d 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_drawable.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_drawable.js
@@ -17,7 +17,7 @@ define(
/**
* Does not have a position and a bounding box.
- *
+ *
* Supports Flyout Menu layout.
*/
function Drawable() {
@@ -41,7 +41,7 @@ define(
this.bottomFlyOutMenuItems = [];
/**
- *
+ *
*/
Drawable.prototype.applyChanges = function(changedObject) {
m_utils.inheritFields(this, changedObject);
@@ -64,53 +64,53 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.onCreate = function(transferObject) {
this.oid = transferObject.oid;
-
+
this.register();
-
+
m_messageDisplay.markModified();
};
/**
- *
+ *
*/
Drawable.prototype.onUpdate = function(transferObject) {
m_messageDisplay.markModified();
};
/**
- *
+ *
*/
Drawable.prototype.onDelete = function(transferObject) {
m_messageDisplay.markModified();
};
/**
- *
+ *
*/
Drawable.prototype.addToPrimitives = function(element) {
this.primitives.push(element);
};
/**
- *
+ *
*/
Drawable.prototype.hoverIn = function() {
this.showPointerCursor();
};
/**
- *
+ *
*/
Drawable.prototype.hoverOut = function() {
this.showDefaultCursor();
};
/**
- *
+ *
*/
Drawable.prototype.showPointerCursor = function() {
for ( var n in this.primitives) {
@@ -119,7 +119,7 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.showDefaultCursor = function() {
for ( var n in this.primitives) {
@@ -128,7 +128,7 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.showMoveCursor = function() {
for ( var n in this.primitives) {
@@ -137,7 +137,7 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.addToEditableTextPrimitives = function(
element) {
@@ -180,7 +180,7 @@ define(
/**
* Refreshes all graphics elements e.g. text, icons against the
* model element properties e.g. names, types.
- *
+ *
* To be overloaded for subclasses.
*/
Drawable.prototype.refreshFromModelElement = function() {
@@ -197,21 +197,21 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.showProximitySensor = function() {
this.proximitySensor.show();
};
/**
- *
+ *
*/
Drawable.prototype.hideProximitySensor = function() {
this.proximitySensor.hide();
};
/**
- *
+ *
*/
Drawable.prototype.adjustFlyOutMenu = function(x, y, width,
height) {
@@ -227,7 +227,7 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.adjustFlyOutMenuItems = function(x, y,
width, height) {
@@ -275,7 +275,7 @@ define(
}
/**
- *
+ *
*/
Drawable.prototype.showFlyOutMenu = function() {
this.flyOutMenuBackground.show();
@@ -321,7 +321,7 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.hideFlyOutMenu = function() {
this.flyOutMenuBackground.animate({
@@ -364,7 +364,7 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.addFlyOutMenuItems = function(left, right,
bottom) {
@@ -435,31 +435,35 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.proximityHoverIn = function(event) {
this.showFlyOutMenu();
};
/**
- *
+ *
*/
Drawable.prototype.proximityHoverOut = function(event) {
this.hideFlyOutMenu();
};
/**
- *
+ *
*/
Drawable.prototype.removeProximitySensor = function() {
- this.proximitySensor.remove();
+ if (this.proximitySensor) {
+ this.proximitySensor.remove();
+ }
};
/**
- *
+ *
*/
Drawable.prototype.removeFlyOutMenu = function() {
- this.flyOutMenuBackground.remove();
+ if (this.flyOutMenuBackground) {
+ this.flyOutMenuBackground.remove();
+ }
var n = 0;
@@ -487,14 +491,14 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.deselect = function() {
this.selected = false;
};
/**
- *
+ *
*/
Drawable.prototype.doubleClickEditableTextPrimitive = function(
element) {
@@ -503,7 +507,7 @@ define(
};
/**
- *
+ *
*/
Drawable.prototype.showDashboard = function(dashboardContent) {
m_canvasManager.drawRectangle(
@@ -580,7 +584,7 @@ define(
// Draw axis
var pathString = "";
-
+
pathString += "M" + (this.getDashboardX() + 10) + " " + (this.getDashboardY() + yOffset);
pathString += "L" + (this.getDashboardX() + 10) + " " + (this.getDashboardY() + yOffset - 80);
@@ -591,7 +595,7 @@ define(
}).show();
pathString = "";
-
+
pathString += "M" + (this.getDashboardX() + 10) + " " + (this.getDashboardY() + yOffset);
pathString += "L" + (this.getDashboardX() + 210) + " " + (this.getDashboardY() + yOffset);
@@ -602,7 +606,7 @@ define(
}).show();
var data = dashboardContent[contentItem].data;
-
+
pathString = "";
for ( var n in data) {
@@ -612,7 +616,7 @@ define(
pathString += ("L" + (this.getDashboardX() + 10 + data[n][0]) + " " + (this.getDashboardY() + yOffset - data[n][1]));
}
}
-
+
m_canvasManager.drawPath(pathString, {
"stroke" : "red",
"stroke-width" : 1.5
@@ -648,7 +652,7 @@ define(
}
/**
- *
+ *
*/
function Drawable_doubleClickEditableTextPrimitiveClosure() {
this.auxiliaryProperties.callbackScope