summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-07-18 09:00:19 (EDT)
committer Manik Kishore2012-07-19 02:20:43 (EDT)
commitda2a2da44b80a1e1b2ceeb902266cac288443f2c (patch)
tree38e91e5caf3ddb6788094074e4af18321490fb52
parent4ee3d4e57eeb7dd7ea4a6582d9f865ba01af5525 (diff)
downloadorg.eclipse.stardust.ui.web-da2a2da44b80a1e1b2ceeb902266cac288443f2c.zip
org.eclipse.stardust.ui.web-da2a2da44b80a1e1b2ceeb902266cac288443f2c.tar.gz
org.eclipse.stardust.ui.web-da2a2da44b80a1e1b2ceeb902266cac288443f2c.tar.bz2
Jira-ID: CRNT-25511
1)Added code to deleteEvent() in EventCommandHandler.java. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@57748 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/EventCommandHandler.java73
1 files changed, 57 insertions, 16 deletions
diff --git a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/EventCommandHandler.java b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/EventCommandHandler.java
index 928e11f..184bf3a 100644
--- a/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/EventCommandHandler.java
+++ b/web-modeler/src/main/java/org/eclipse/stardust/ui/web/modeler/edit/diagram/node/EventCommandHandler.java
@@ -12,6 +12,7 @@
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.extractLong;
import static org.eclipse.stardust.ui.web.modeler.marshaling.GsonUtils.extractString;
import static org.eclipse.stardust.ui.web.modeler.service.ModelService.EVENT_TYPE_PROPERTY;
import static org.eclipse.stardust.ui.web.modeler.service.ModelService.HEIGHT_PROPERTY;
@@ -21,7 +22,11 @@ import static org.eclipse.stardust.ui.web.modeler.service.ModelService.X_PROPERT
import static org.eclipse.stardust.ui.web.modeler.service.ModelService.Y_PROPERTY;
import org.eclipse.emf.ecore.EObject;
+
+import com.google.gson.JsonObject;
+
import org.eclipse.stardust.model.xpdl.builder.common.AbstractElementBuilder;
+import org.eclipse.stardust.model.xpdl.builder.utils.MBFacade;
import org.eclipse.stardust.model.xpdl.builder.utils.ModelerConstants;
import org.eclipse.stardust.model.xpdl.builder.utils.XpdlModelUtils;
import org.eclipse.stardust.model.xpdl.carnot.EndEventSymbol;
@@ -32,18 +37,16 @@ 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.ICommandHandler;
-import com.google.gson.JsonObject;
-
/**
*
* @author Sidharth.Singh
- *
+ *
*/
public class EventCommandHandler implements ICommandHandler
{
@Override
- public boolean isValidTarget(Class< ? > type)
+ public boolean isValidTarget(Class<? > type)
{
return LaneSymbol.class.isAssignableFrom(type);
}
@@ -51,36 +54,45 @@ public class EventCommandHandler implements ICommandHandler
@Override
public void handleCommand(String commandId, EObject targetElement, JsonObject request)
{
+ LaneSymbol parentLaneSymbol = (LaneSymbol) targetElement;
+ ModelType model = ModelUtils.findContainingModel(parentLaneSymbol);
+ ProcessDefinitionType processDefinition = ModelUtils.findContainingProcess(parentLaneSymbol);
+
if ("eventSymbol.create".equals(commandId))
{
- createEvent(targetElement, request);
+ createEvent(parentLaneSymbol, model, processDefinition, request);
}
else if ("eventSymbol.delete".equals(commandId))
{
- //TODO : add impl code
+ deleteEvent(parentLaneSymbol, model, processDefinition, request);
}
}
- private void createEvent(EObject targetElement, JsonObject request)
+ private void createEvent(LaneSymbol parentLaneSymbol, ModelType model,
+ ProcessDefinitionType processDefinition, JsonObject request)
{
- LaneSymbol parentLaneSymbol = (LaneSymbol) targetElement;
- ModelType model = ModelUtils.findContainingModel(parentLaneSymbol);
- ProcessDefinitionType processDefinition = ModelUtils.findContainingProcess(parentLaneSymbol);
+
long maxOid = XpdlModelUtils.getMaxUsedOid(model);
- if (START_EVENT.equals(extractString(request, ModelerConstants.MODEL_ELEMENT_PROPERTY, EVENT_TYPE_PROPERTY)))
+ if (START_EVENT.equals(extractString(request,
+ ModelerConstants.MODEL_ELEMENT_PROPERTY, EVENT_TYPE_PROPERTY)))
{
StartEventSymbol startEventSymbol = AbstractElementBuilder.F_CWM.createStartEventSymbol();
startEventSymbol.setElementOid(++maxOid);
- startEventSymbol.setXPos(extractInt(request, X_PROPERTY) - parentLaneSymbol.getXPos());
- startEventSymbol.setYPos(extractInt(request, Y_PROPERTY) - parentLaneSymbol.getYPos());
+ startEventSymbol.setXPos(extractInt(request, X_PROPERTY)
+ - parentLaneSymbol.getXPos());
+ startEventSymbol.setYPos(extractInt(request, Y_PROPERTY)
+ - parentLaneSymbol.getYPos());
startEventSymbol.setWidth(extractInt(request, WIDTH_PROPERTY));
startEventSymbol.setHeight(extractInt(request, HEIGHT_PROPERTY));
// TODO evaluate other properties
- processDefinition.getDiagram().get(0).getStartEventSymbols().add(startEventSymbol);
+ processDefinition.getDiagram()
+ .get(0)
+ .getStartEventSymbols()
+ .add(startEventSymbol);
parentLaneSymbol.getStartEventSymbols().add(startEventSymbol);
}
else
@@ -88,8 +100,10 @@ public class EventCommandHandler implements ICommandHandler
EndEventSymbol endEventSymbol = AbstractElementBuilder.F_CWM.createEndEventSymbol();
endEventSymbol.setElementOid(++maxOid);
- endEventSymbol.setXPos(extractInt(request, X_PROPERTY) - parentLaneSymbol.getXPos());
- endEventSymbol.setYPos(extractInt(request, Y_PROPERTY) - parentLaneSymbol.getYPos());
+ endEventSymbol.setXPos(extractInt(request, X_PROPERTY)
+ - parentLaneSymbol.getXPos());
+ endEventSymbol.setYPos(extractInt(request, Y_PROPERTY)
+ - parentLaneSymbol.getYPos());
endEventSymbol.setWidth(extractInt(request, WIDTH_PROPERTY));
endEventSymbol.setHeight(extractInt(request, HEIGHT_PROPERTY));
@@ -99,4 +113,31 @@ public class EventCommandHandler implements ICommandHandler
}
}
+ private void deleteEvent(LaneSymbol parentLaneSymbol, ModelType model,
+ ProcessDefinitionType processDefinition, JsonObject request)
+ {
+ Long eventOId = extractLong(request, ModelerConstants.OID_PROPERTY);
+ if (START_EVENT.equals(extractString(request,
+ ModelerConstants.MODEL_ELEMENT_PROPERTY, EVENT_TYPE_PROPERTY)))
+ {
+ StartEventSymbol startEventSymbol = MBFacade.findStartEventSymbol(
+ parentLaneSymbol, eventOId);
+ processDefinition.getDiagram()
+ .get(0)
+ .getStartEventSymbols()
+ .remove(startEventSymbol);
+ parentLaneSymbol.getStartEventSymbols().remove(startEventSymbol);
+ }
+ else
+ {
+ EndEventSymbol endEventSymbol = MBFacade.findEndEventSymbol(parentLaneSymbol,
+ eventOId);
+ processDefinition.getDiagram()
+ .get(0)
+ .getEndEventSymbols()
+ .remove(endEventSymbol);
+ parentLaneSymbol.getEndEventSymbols().remove(endEventSymbol);
+ }
+ }
+
}