summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-09-24 06:50:27 (EDT)
committerStephan Born2012-09-24 06:50:27 (EDT)
commitc57ad0b04401262791b431de6d3bdb17754fa505 (patch)
tree90b91e6eeb602ff8f2e70c7b1f69aa07409071f4
parent215247df8cda4d7f35781ac1ae09bce85ee3a532 (diff)
downloadorg.eclipse.stardust.ui.web-c57ad0b04401262791b431de6d3bdb17754fa505.zip
org.eclipse.stardust.ui.web-c57ad0b04401262791b431de6d3bdb17754fa505.tar.gz
org.eclipse.stardust.ui.web-c57ad0b04401262791b431de6d3bdb17754fa505.tar.bz2
CRNT-26097
Made changes to existing logic of MoveNodeSymbolHandler, a)Added code to remove from oldParent and add symbol to newParent on lane change b)Added a parameter parentSymbolId to createMoveNodeSymbolCommand newGeometry{} change object git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@59450 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/MoveNodeSymbolHandler.java114
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_swimlaneSymbol.js10
-rw-r--r--web-modeler/src/main/resources/META-INF/xhtml/js/m_symbol.js7
3 files changed, 112 insertions, 19 deletions
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/MoveNodeSymbolHandler.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/MoveNodeSymbolHandler.java
index b164b7f..5a06cad 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/MoveNodeSymbolHandler.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/MoveNodeSymbolHandler.java
@@ -1,38 +1,61 @@
package org.eclipse.stardust.ui.web.modeler.edit.diagram.node;
import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractInt;
+import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractString;
import static org.eclipse.stardust.ui.web.modeler.service.ModelService.HEIGHT_PROPERTY;
import static org.eclipse.stardust.ui.web.modeler.service.ModelService.WIDTH_PROPERTY;
import static org.eclipse.stardust.ui.web.modeler.service.ModelService.X_PROPERTY;
import static org.eclipse.stardust.ui.web.modeler.service.ModelService.Y_PROPERTY;
+import javax.annotation.Resource;
+
+import org.springframework.context.ApplicationContext;
+
import com.google.gson.JsonObject;
+import org.eclipse.stardust.engine.api.model.IModelParticipant;
+import org.eclipse.stardust.engine.core.model.gui.ActivitySymbol;
+import org.eclipse.stardust.model.xpdl.builder.utils.ModelBuilderFacade;
+import org.eclipse.stardust.model.xpdl.builder.utils.ModelerConstants;
+import org.eclipse.stardust.model.xpdl.carnot.ActivitySymbolType;
+import org.eclipse.stardust.model.xpdl.carnot.DataSymbolType;
+import org.eclipse.stardust.model.xpdl.carnot.EndEventSymbol;
import org.eclipse.stardust.model.xpdl.carnot.INodeSymbol;
-import org.eclipse.stardust.model.xpdl.carnot.ISwimlaneSymbol;
+import org.eclipse.stardust.model.xpdl.carnot.LaneSymbol;
+import org.eclipse.stardust.model.xpdl.carnot.ProcessDefinitionType;
+import org.eclipse.stardust.model.xpdl.carnot.StartEventSymbol;
+import org.eclipse.stardust.model.xpdl.carnot.util.ModelUtils;
import org.eclipse.stardust.ui.web.modeler.edit.spi.CommandHandler;
import org.eclipse.stardust.ui.web.modeler.edit.spi.OnCommand;
+import org.eclipse.stardust.ui.web.modeler.service.ModelService;
@CommandHandler
public class MoveNodeSymbolHandler
{
+ @Resource
+ private ApplicationContext springContext;
+
@OnCommand(commandId = "nodeSymbol.move")
public void handleMoveNode(INodeSymbol nodeSymbol, JsonObject request)
{
int laneOffsetX = 0;
int laneOffsetY = 0;
- ISwimlaneSymbol container = (nodeSymbol.eContainer() instanceof ISwimlaneSymbol)
- ? (ISwimlaneSymbol) nodeSymbol.eContainer()
- : null;
- while (null != container)
+ LaneSymbol newParentSymbol = null;
+ // New parent swimlane Id is passed to get Parent Lane to set
+ // laneOffsetX,laneOffsetY, also used when parent changes
+ String parentID = extractString(request, ModelerConstants.PARENT_SYMBOL_ID_PROPERTY);
+ ProcessDefinitionType processDefinition = ModelUtils.findContainingProcess(nodeSymbol);
+ if ( !(nodeSymbol instanceof LaneSymbol))
{
- laneOffsetX += container.getXPos();
- laneOffsetY += container.getYPos();
+ newParentSymbol = getModelBuilderFacade().findLaneSymbolById(processDefinition,
+ parentID);
+
+ if (null != newParentSymbol)
+ {
+ laneOffsetX = new Long(newParentSymbol.getXPos()).intValue();
+ laneOffsetY = new Long(newParentSymbol.getYPos()).intValue();
+ }
- // recurse
- container = (container.eContainer() instanceof ISwimlaneSymbol)
- ? (ISwimlaneSymbol) container.eContainer()
- : null;
}
nodeSymbol.setXPos(extractInt(request, X_PROPERTY) - laneOffsetX);
@@ -46,5 +69,74 @@ public class MoveNodeSymbolHandler
{
nodeSymbol.setHeight(extractInt(request, HEIGHT_PROPERTY));
}
+
+ // Type property is used to identify the symbol type, used while changing
+ // parentSymbol on move from one lane to another.
+ if (request.has(ModelerConstants.TYPE_PROPERTY))
+ {
+ String symbolType = request.get(ModelerConstants.TYPE_PROPERTY).getAsString();
+ if (null != symbolType)
+ {
+ LaneSymbol parentLane = (LaneSymbol) nodeSymbol.eContainer();
+ if (symbolType.equals(ModelerConstants.ACTIVITY_SYMBOL)
+ || symbolType.equals(ModelerConstants.GATEWAY_SYMBOL))
+ {
+ if (parentLane.getElementOid() != newParentSymbol.getElementOid())
+ {
+ // If the parent is changed, remove reference from old parent
+ parentLane.getActivitySymbol().remove(nodeSymbol);
+ ActivitySymbol activitySymbol = (ActivitySymbol) nodeSymbol;
+ // Set the Performer for Activity
+ if (null != activitySymbol.getActivity().getPerformer())
+ {
+ activitySymbol.getActivity().setPerformer(
+ (IModelParticipant) newParentSymbol.getParticipant());
+ }
+ newParentSymbol.getActivitySymbol()
+ .add((ActivitySymbolType) nodeSymbol);
+ }
+ }
+ else if (symbolType.equals(ModelerConstants.EVENT_SYMBOL))
+ {
+ StartEventSymbol startSymbol = getModelBuilderFacade().findStartEventSymbol(
+ parentLane, nodeSymbol.getElementOid());
+ if (null != startSymbol)
+ {
+ if (parentLane.getElementOid() != newParentSymbol.getElementOid())
+ {
+ parentLane.getStartEventSymbols().remove(nodeSymbol);
+
+ newParentSymbol.getStartEventSymbols().add(
+ (StartEventSymbol) nodeSymbol);
+ }
+ }
+ else
+ {
+ if (parentLane.getElementOid() != newParentSymbol.getElementOid())
+ {
+ parentLane.getEndEventSymbols().remove(nodeSymbol);
+
+ newParentSymbol.getEndEventSymbols()
+ .add((EndEventSymbol) nodeSymbol);
+ }
+ }
+ }
+ else if (symbolType.equals(ModelerConstants.DATA_SYMBOL))
+ {
+ if (parentLane.getElementOid() != newParentSymbol.getElementOid())
+ {
+ parentLane.getDataSymbol().remove(nodeSymbol);
+
+ newParentSymbol.getDataSymbol().add((DataSymbolType) nodeSymbol);
+ }
+ }
+ }
+ }
+ }
+
+ private ModelBuilderFacade getModelBuilderFacade()
+ {
+ return new ModelBuilderFacade(springContext.getBean(ModelService.class)
+ .getModelManagementStrategy());
}
}
diff --git a/web-modeler/src/main/resources/META-INF/xhtml/js/m_swimlaneSymbol.js b/web-modeler/src/main/resources/META-INF/xhtml/js/m_swimlaneSymbol.js
index f564fa6..3cd2b37 100644
--- a/web-modeler/src/main/resources/META-INF/xhtml/js/m_swimlaneSymbol.js
+++ b/web-modeler/src/main/resources/META-INF/xhtml/js/m_swimlaneSymbol.js
@@ -744,7 +744,7 @@ define(
* Temporarily commented out as left stretch is disabled
*/
SwimlaneSymbol.prototype.stretchLeft = function(dX, dY, x, y) {
- if (this.diagram.mode == this.diagram.NORMAL_MODE) {
+ if (!this.diagram.isInConnectionMode()) {
this.width = this.preDragState.width - dX;
this.x = this.preDragState.x + dX;
@@ -756,7 +756,7 @@ define(
* Temporarily commented out as top stretch is disabled
*/
SwimlaneSymbol.prototype.stretchTop = function(dX, dY, x, y) {
- if (this.diagram.mode == this.diagram.NORMAL_MODE) {
+ if (!this.diagram.isInConnectionMode()) {
this.height = this.preDragState.height - dY;
this.y = this.preDragState.y + dY;
@@ -768,7 +768,7 @@ define(
*
*/
SwimlaneSymbol.prototype.stretchRight = function(dX, dY, x, y) {
- if (this.diagram.mode == this.diagram.NORMAL_MODE) {
+ if (!this.diagram.isInConnectionMode()) {
this.width = this.preDragState.width + dX;
this.adjustGeometry();
@@ -779,7 +779,7 @@ define(
*
*/
SwimlaneSymbol.prototype.stretchBottom = function(dX, dY, x, y) {
- if (this.diagram.mode == this.diagram.NORMAL_MODE) {
+ if (!this.diagram.isInConnectionMode()) {
this.height = this.preDragState.height + dY;
this.adjustGeometry();
@@ -837,7 +837,7 @@ define(
this.parentSymbol.recalculateBoundingBox();
this.parentSymbol.adjustGeometry();
- var newGeometry = {"x": this.x, "y" : this.y, "oid" : this.oid, "width" : this.width , "height" :this.height};
+ var newGeometry = {"x": this.x, "y" : this.y, "parentSymbolId" : this.parentSymbol.id, "width" : this.width , "height" :this.height};
var command = m_command.createMoveNodeSymbolCommand(this.diagram.model.id, this.oid, newGeometry);
m_commandsController.submitCommand(command);
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 58aacdc..4d15a38 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
@@ -940,7 +940,8 @@ define(
var newGeometry = {
"x" : this.x,
"y" : this.y,
- "oid" : this.oid
+ "parentSymbolId" : this.parentSymbol.id,
+ "type" : this.type
};
var command = m_command
@@ -964,7 +965,7 @@ define(
var newGeometry = {
"x" : this.x,
"y" : this.y,
- "oid" : this.oid
+ "parentSymbolId" : this.parentSymbol.id
};
var command = m_command
@@ -1378,7 +1379,7 @@ define(
var newGeometry = {
"x" : this.x,
"y" : this.y,
- "oid" : this.oid,
+ "parentSymbolId" : this.parentSymbol.id,
"width" : this.width,
"height" : this.height
};