summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-10-03 09:39:04 (EDT)
committer Manik Kishore2012-10-03 09:39:04 (EDT)
commite85e0351a8a853b5231f57c2cf29bf46a7958838 (patch)
tree9162212265b626b83fac9308f5feb9324ec23da4
parent50b65981d024baa58f9de39282f27c2a064c20c2 (diff)
downloadorg.eclipse.stardust.ui.web-e85e0351a8a853b5231f57c2cf29bf46a7958838.zip
org.eclipse.stardust.ui.web-e85e0351a8a853b5231f57c2cf29bf46a7958838.tar.gz
org.eclipse.stardust.ui.web-e85e0351a8a853b5231f57c2cf29bf46a7958838.tar.bz2
CRNT-26180
Added method isSymbolWithinStretchLimit() in m_symbol.js to validate stretch. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@59744 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_constants.js2
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js286
2 files changed, 172 insertions, 116 deletions
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_constants.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_constants.js
index 85e1baf..70d6b96 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_constants.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_constants.js
@@ -83,6 +83,8 @@ define(function() {
EAST : 1,
SOUTH : 2,
WEST : 3,
+ // Symbol should not be allowed to shrink below some size
+ SYMBOL_MIN_SIZE : 10,
// Activity Symbol
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 b09e127..249ee58 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
@@ -3,7 +3,7 @@
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors: SunGard CSA LLC - initial API and implementation and/or initial
* documentation
******************************************************************************/
@@ -26,7 +26,7 @@ define(
};
/**
- *
+ *
*/
function Symbol() {
var drawable = m_drawable.createDrawable();
@@ -50,14 +50,14 @@ define(
// Method initialization
/**
- *
+ *
*/
Symbol.prototype.toString = function() {
return "Lightdust.Symbol";
};
/**
- *
+ *
*/
Symbol.prototype.getProperties = function() {
this.properties.dimensions = {
@@ -71,7 +71,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.initialize = function(x, y) {
this.prepare(x, y);
@@ -100,21 +100,21 @@ define(
}
/**
- *
+ *
*/
Symbol.prototype.getXCenter = function() {
return this.x + 0.5 * this.width;
};
/**
- *
+ *
*/
Symbol.prototype.getYCenter = function() {
return this.y + 0.5 * this.height;
};
/**
- *
+ *
*/
Symbol.prototype.prepare = function(x, y) {
this.x = x;
@@ -124,7 +124,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.prepareNoPosition = function() {
this.createPrimitives();
@@ -145,21 +145,21 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.isContainerSymbol = function() {
return false;
};
/**
- *
+ *
*/
Symbol.prototype.requiresParentSymbol = function() {
return true;
};
/**
- *
+ *
*/
Symbol.prototype.completeNoTransfer = function() {
m_messageDisplay.clear();
@@ -253,11 +253,11 @@ define(
} else if (m_constants.ANNOTATION_SYMBOL.match(this.type)) {
commandType = "annotationSymbol." + str;
}
-
+
return commandType;
}
/**
- *
+ *
* Registers symbol in specific lists in the diagram.
*/
Symbol.prototype.register = function() {
@@ -265,21 +265,21 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.createPrimitives = function() {
// Nothing to be done
};
/**
- *
+ *
*/
Symbol.prototype.createChildSymbols = function() {
// Nothing to be done
};
/**
- *
+ *
*/
Symbol.prototype.createAnchorPoints = function() {
this.anchorPoints[0] = new AnchorPoint(this, 0);
@@ -289,7 +289,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.showAnchorPoints = function() {
for ( var n in this.anchorPoints) {
@@ -298,7 +298,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.hideAnchorPoints = function() {
for ( var n in this.anchorPoints) {
@@ -307,7 +307,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.getClosestAnchorPoint = function(x, y,
skipScrollAdjustment) {
@@ -336,7 +336,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.showPrimitives = function() {
for ( var n in this.primitives) {
@@ -346,7 +346,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.hidePrimitives = function() {
for ( var n in this.primitives) {
@@ -355,7 +355,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.hide = function() {
this.visible = false;
@@ -368,7 +368,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.show = function() {
this.visible = true;
@@ -379,7 +379,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.hideConnections = function() {
var n = 0;
@@ -441,7 +441,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.cacheAnchorPointAndAdjust = function(
currentAnchorPt, targetAnchorPt) {
@@ -470,7 +470,7 @@ define(
}
/**
- *
+ *
*/
Symbol.prototype.showConnections = function() {
var n = 0;
@@ -490,7 +490,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.primitivesToFront = function() {
for ( var n in this.primitives) {
@@ -499,7 +499,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.adjustAnchorPoints = function() {
this.anchorPoints[0].adjust();
@@ -519,7 +519,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.adjustAuxiliaryElements = function() {
if (this.visible) {
@@ -533,13 +533,13 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.adjustChildSymbols = function() {
};
/**
- *
+ *
*/
Symbol.prototype.adjustSelectFrame = function() {
this.leftSelectFrame.attr("path", this
@@ -553,7 +553,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.isInBoundingBox = function(xClick, yClick) {
return this.x <= xClick && this.x + this.width >= xClick
@@ -562,7 +562,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.isInRectangle = function(x, y, width, height) {
return x <= this.x && x + width >= this.x + this.width
@@ -571,7 +571,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.createProximitySensorPrimitive = function() {
return m_canvasManager.drawRectangle(this.x
@@ -589,7 +589,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.createSelectFrame = function() {
this.leftSelectFrame = m_canvasManager.drawPath(this
@@ -666,7 +666,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.getLeftSelectFramePath = function() {
return "M"
@@ -680,7 +680,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.getTopSelectFramePath = function() {
return "M"
@@ -693,7 +693,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.getRightSelectFramePath = function() {
return "M"
@@ -707,7 +707,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.getBottomSelectFramePath = function() {
return "M"
@@ -721,7 +721,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.createFlyOutMenuBackground = function(x, y,
height, width) {
@@ -751,7 +751,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.showSelectFrame = function() {
this.leftSelectFrame.show();
@@ -761,7 +761,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.hideSelectFrame = function() {
this.leftSelectFrame.hide();
@@ -771,7 +771,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.move = function(x, y) {
this.moveBy(x - (this.x + (this.width / 2)), y
@@ -779,7 +779,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.moveBy = function(dX, dY) {
this.x = this.x + dX;
@@ -842,7 +842,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.refresh = function() {
this.refreshFromModelElement();
@@ -865,13 +865,13 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.adjustPrimitives = function() {
};
/**
- *
+ *
*/
Symbol.prototype.dragStart = function() {
// TODO hide for all selected
@@ -895,7 +895,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.dragStop = function() {
if (this.diagram.mode == this.diagram.SYMBOL_MOVE_MODE) {
@@ -991,7 +991,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.proximityHoverIn = function(event) {
if (this.diagram.mode == this.diagram.NORMAL_MODE) {
@@ -1016,7 +1016,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.proximityHoverOut = function(event) {
if (this.diagram.mode == this.diagram.NORMAL_MODE) {
@@ -1080,7 +1080,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.addToPrimitives = function(element) {
this.primitives.push(element);
@@ -1106,7 +1106,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.initializeDefaultEventHandling = function(
element) {
@@ -1134,7 +1134,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.mouseMove = function(x, y) {
if (this.diagram.isInConnectionMode()) {
@@ -1160,7 +1160,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.hoverIn = function(x, y) {
if (this.diagram.isInConnectionMode()) {
@@ -1186,7 +1186,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.hoverOut = function() {
if (this.diagram.isInConnectionMode()) {
@@ -1204,7 +1204,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.click = function(x, y) {
// When symbol is Draged, the edit symbol operation should
@@ -1250,7 +1250,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.select = function() {
if (!this.isCompleted()) {
@@ -1267,7 +1267,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.showPropertiesPanel = function() {
if (this.propertiesPanel != null) {
@@ -1278,7 +1278,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.deselect = function() {
if (!this.isCompleted()) {
@@ -1295,19 +1295,19 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.highlight = function() {
};
/**
- *
+ *
*/
Symbol.prototype.dehighlight = function() {
};
/**
- *
+ *
*/
Symbol.prototype.deselectAnchorPoints = function() {
for ( var n in this.anchorPoints) {
@@ -1316,7 +1316,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.remove = function() {
this.removePrimitives();
@@ -1331,7 +1331,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.createAndSubmitDeleteCommand = function() {
var command = m_command.createRemoveNodeCommand(this
@@ -1361,7 +1361,7 @@ define(
}
/**
- *
+ *
*/
Symbol.prototype.removePrimitives = function() {
var n = 0;
@@ -1373,7 +1373,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.removeConnections = function() {
var n = 0;
@@ -1385,7 +1385,7 @@ define(
};
/**
- *
+ *
*/
Symbol.prototype.removeAnchorPoints = function() {
for ( var n in this.anchorPoints) {
@@ -1394,9 +1394,32 @@ define(
};
/**
- *
+ *
+ */
+ Symbol.prototype.stretchStart = function() {
+ this.preDragSymbolState = {
+ x : this.x,
+ y : this.y,
+ height : this.height,
+ width : this.width
+ };
+ };
+
+ /**
+ *
*/
Symbol.prototype.stretchStop = function() {
+ // Check if stretch is overlapping with other symbol boundry
+ // or ouside swimlane margin
+ if (!this.isSymbolWithinStretchLimit()) {
+ this.x = this.preDragSymbolState.x;
+ this.y = this.preDragSymbolState.y;
+ this.width = this.preDragSymbolState.width;
+ this.height = this.preDragSymbolState.height;
+ this.adjustGeometry();
+ return;
+ }
+
var newGeometry = {
"x" : this.x,
"y" : this.y,
@@ -1411,59 +1434,90 @@ define(
};
/**
- *
+ *
+ */
+ Symbol.prototype.isSymbolWithinStretchLimit = function() {
+ // If stretch is outside left/right margin of swimlane
+ if (this.x < this.parentSymbol.x
+ || (this.x + this.width) > (this.parentSymbol.x + this.parentSymbol.width)) {
+ return false;
+ }
+ // If stretch is outside top/bottom margin of swimlane
+ else if (this.y < this.parentSymbol.y
+ || (this.y + this.height) > (this.parentSymbol.y + this.parentSymbol.height)) {
+ return false;
+ } else {
+ // Check if symbol co-ordinate collides with some other
+ // symbol co-ordinates
+ for ( var n in this.parentSymbol.containedSymbols) {
+ if (this.parentSymbol.containedSymbols[n] != this
+ && this.parentSymbol.containedSymbols[n]
+ .isInBoundingBox(this.x, this.y)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ };
+
+ /**
+ *
*/
Symbol.prototype.stretchLeft = function(dX, dY, x, y) {
- this.width = x - this.diagram.X_OFFSET - this.x;
+ this.width += this.x - (x - this.diagram.X_OFFSET);
this.x = x - this.diagram.X_OFFSET;
-
+ if (this.width < m_constants.SYMBOL_MIN_SIZE)
+ this.width = m_constants.SYMBOL_MIN_SIZE;
this.adjustGeometry();
};
/**
- *
+ *
*/
Symbol.prototype.stretchTop = function(dX, dY, x, y) {
- this.height = y - this.diagram.Y_OFFSET - this.y;
+ this.height += this.y - (y - this.diagram.Y_OFFSET);
this.y = y - this.diagram.Y_OFFSET;
-
+ if (this.height < m_constants.SYMBOL_MIN_SIZE)
+ this.height = m_constants.SYMBOL_MIN_SIZE;
this.adjustGeometry();
};
/**
- *
+ *
*/
Symbol.prototype.stretchRight = function(dX, dY, x, y) {
this.width = x - this.diagram.X_OFFSET - this.x;
-
+ if (this.width < m_constants.SYMBOL_MIN_SIZE)
+ this.width = m_constants.SYMBOL_MIN_SIZE;
this.adjustGeometry();
};
/**
- *
+ *
*/
Symbol.prototype.stretchBottom = function(dX, dY, x, y) {
- this.height = y - this.diagram.Y_OFFSET - this.y;
-
+ this.height += ((y - this.diagram.Y_OFFSET) - (this.y + this.height));
+ if (this.height < m_constants.SYMBOL_MIN_SIZE)
+ this.height = m_constants.SYMBOL_MIN_SIZE;
this.adjustGeometry();
};
/**
- *
+ *
*/
Symbol.prototype.validateCreateConnection = function() {
return true;
};
/*
- *
+ *
*/
Symbol.prototype.onParentSymbolChange = function() {
// Do nothing
};
/*
- *
+ *
*/
Symbol.prototype.flipFlowOrientation = function(flowOrientation) {
var x = this.x;
@@ -1473,21 +1527,21 @@ define(
};
/*
- *
+ *
*/
Symbol.prototype.getDashboardX = function() {
return this.x + 30;
};
/*
- *
+ *
*/
Symbol.prototype.getDashboardY = function() {
return this.y + 30;
};
/*
- *
+ *
*/
Symbol.prototype.hideGlow = function() {
if (this.glow != null) {
@@ -1498,7 +1552,7 @@ define(
};
/*
- *
+ *
*/
Symbol.prototype.removeGlow = function() {
if (this.glow != null) {
@@ -1512,21 +1566,21 @@ define(
// Callback methods for closure trick
/**
- *
+ *
*/
function Symbol_hoverInClosure(event, x, y) {
this.auxiliaryProperties.callbackScope.hoverIn(x, y);
}
/**
- *
+ *
*/
function Symbol_hoverOutClosure() {
this.auxiliaryProperties.callbackScope.hoverOut();
}
/**
- *
+ *
*/
function Symbol_clickClosure(event, x, y) {
this.auxiliaryProperties.callbackScope.click(x, y);
@@ -1538,14 +1592,14 @@ define(
}
/**
- *
+ *
*/
function Symbol_hoverInFlyOutMenuClosure() {
this.auxiliaryProperties.callbackScope.showFlyOutMenu();
}
/**
- *
+ *
*/
function Symbol_hoverOutFlyOutMenuClosure(event) {
// Hover out(hide flyout menu) if mouse cursor is outside
@@ -1557,14 +1611,14 @@ define(
}
/**
- *
+ *
*/
function Symbol_mouseMoveClosure(event, x, y) {
this.auxiliaryProperties.callbackScope.mouseMove(x, y);
}
/**
- *
+ *
*/
function Symbol_dragClosure(dX, dY, x, y, event) {
this.auxiliaryProperties.callbackScope.diagram
@@ -1584,21 +1638,21 @@ define(
}
/**
- *
+ *
*/
function Symbol_dragStartClosure() {
this.auxiliaryProperties.callbackScope.dragStart();
}
/**
- *
+ *
*/
function Symbol_dragStopClosure() {
this.auxiliaryProperties.callbackScope.dragStop();
}
/**
- *
+ *
*/
function Symbol_stretchLeftClosure(dX, dY, x, y) {
this.auxiliaryProperties.callbackScope
@@ -1614,7 +1668,7 @@ define(
}
/**
- *
+ *
*/
function Symbol_stretchTopClosure(dX, dY, x, y) {
this.auxiliaryProperties.callbackScope
@@ -1630,7 +1684,7 @@ define(
}
/**
- *
+ *
*/
function Symbol_stretchRightClosure(dX, dY, x, y) {
this.auxiliaryProperties.callbackScope
@@ -1646,7 +1700,7 @@ define(
}
/**
- *
+ *
*/
function Symbol_stretchBottomClosure(dX, dY, x, y) {
this.auxiliaryProperties.callbackScope
@@ -1662,7 +1716,7 @@ define(
}
/**
- *
+ *
*/
function Symbol_stretchStartClosure() {
if (this.auxiliaryProperties.callbackScope.stretchStart) {
@@ -1671,7 +1725,7 @@ define(
}
/**
- *
+ *
*/
function Symbol_stretchStopClosure() {
this.auxiliaryProperties.callbackScope.stretchStop();
@@ -1680,7 +1734,7 @@ define(
}
/**
- *
+ *
*/
// TOD= Is this needed
function Symbol_createClosure(callbackScope, data) {
@@ -1728,14 +1782,14 @@ define(
AnchorPoint_dragStopClosure);
/**
- *
+ *
*/
AnchorPoint.prototype.toString = function() {
return "Lightdust.AnchorPoint";
};
/**
- *
+ *
*/
AnchorPoint.prototype.moveTo = function(x, y) {
this.x = x;
@@ -1748,7 +1802,7 @@ define(
}
/**
- *
+ *
*/
AnchorPoint.prototype.adjust = function() {
if (this.orientation == m_constants.NORTH) {
@@ -1767,7 +1821,7 @@ define(
};
/**
- *
+ *
*/
AnchorPoint.prototype.show = function() {
this.graphics.show();
@@ -1775,14 +1829,14 @@ define(
};
/**
- *
+ *
*/
AnchorPoint.prototype.hide = function() {
this.graphics.hide();
};
/**
- *
+ *
*/
AnchorPoint.prototype.select = function() {
this.graphics
@@ -1802,7 +1856,7 @@ define(
};
/**
- *
+ *
*/
AnchorPoint.prototype.deselect = function() {
this.graphics.animate({
@@ -1818,21 +1872,21 @@ define(
};
/**
- *
+ *
*/
AnchorPoint.prototype.hoverIn = function() {
this.select();
};
/**
- *
+ *
*/
AnchorPoint.prototype.hoverOut = function() {
this.deselect();
};
/**
- *
+ *
*/
AnchorPoint.prototype.drag = function(dX, dY, x, y) {
if (this.dragConnection == null) {
@@ -1905,7 +1959,7 @@ define(
}
/**
- *
+ *
*/
AnchorPoint.prototype.dragStart = function() {
this.symbol.diagram.mode = this.symbol.diagram.SYMBOL_MOVE_MODE;
@@ -1950,7 +2004,7 @@ define(
}
/**
- *
+ *
*/
AnchorPoint.prototype.dragStop = function() {
this.symbol.diagram.mode = this.symbol.diagram.NORMAL_MODE;
@@ -2065,7 +2119,7 @@ define(
}
/**
- *
+ *
*/
AnchorPoint.prototype.remove = function() {
this.graphics.remove();