summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratischenko2014-07-23 10:48:41 (EDT)
committeratischenko2014-07-23 10:48:41 (EDT)
commit73aacfa23c2048b2a9533ba39895c4be42674171 (patch)
tree34901214fac9081517927985af1803ef4b6c6790
parentf457a87fb491c58b677d66d4e5022a954bd57299 (diff)
downloadorg.eclipse.papyrus-73aacfa23c2048b2a9533ba39895c4be42674171.zip
org.eclipse.papyrus-73aacfa23c2048b2a9533ba39895c4be42674171.tar.gz
org.eclipse.papyrus-73aacfa23c2048b2a9533ba39895c4be42674171.tar.bz2
374619 : [ActivityDiagram] Deletion of an activity node should alsorefs/changes/39/30339/1
deletes its edges Signed-off-by: atischenko <ticher777@gmail.com>
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ActivityNodeHelperAdvice.java113
1 files changed, 51 insertions, 62 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ActivityNodeHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ActivityNodeHelperAdvice.java
index 2f0f45a..2da0155 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ActivityNodeHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ActivityNodeHelperAdvice.java
@@ -16,27 +16,16 @@ package org.eclipse.papyrus.uml.service.types.helper.advice;
import java.util.HashSet;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.papyrus.commands.DestroyElementPapyrusCommand;
-import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.ActivityEdge;
import org.eclipse.uml2.uml.ActivityNode;
-import org.eclipse.uml2.uml.UMLPackage;
-
import com.google.common.collect.Sets;
/**
@@ -49,21 +38,21 @@ import com.google.common.collect.Sets;
*/
public class ActivityNodeHelperAdvice extends AbstractEditHelperAdvice {
-// @Override
-// protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
-// CompositeCommand cc = new CompositeCommand("Before Command for an Activity Node");////$NON-NLS-1$
-// /*
-// * Destroy edge
-// */
-// ICommand destroyEdgeCommand = getDestroyActivityEdgeCommand(request);
-// if(destroyEdgeCommand != null) {
-// cc.compose(destroyEdgeCommand);
-// }
-// if(cc != null && !cc.isEmpty()) {
-// return cc;
-// }
-// return super.getBeforeDestroyDependentsCommand(request);
-// }
+ @Override
+ protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
+ CompositeCommand cc = new CompositeCommand("Before Command for an Activity Node");////$NON-NLS-1$
+ /*
+ * Destroy edge
+ */
+ ICommand destroyEdgeCommand = getDestroyActivityEdgeCommand(request);
+ if(destroyEdgeCommand != null) {
+ cc.compose(destroyEdgeCommand);
+ }
+ if(cc != null && !cc.isEmpty()) {
+ return cc;
+ }
+ return super.getBeforeDestroyDependentsCommand(request);
+ }
//
// @Override
// protected ICommand getAfterDestroyDependentsCommand(DestroyDependentsRequest request) {
@@ -118,40 +107,40 @@ public class ActivityNodeHelperAdvice extends AbstractEditHelperAdvice {
// return null;
// }
//
-// /**
-// * When an activity node is deleted than all activity edge starting/ending from/to it should be deleted
-// *
-// * @param request
-// * @return
-// */
-// protected ICommand getDestroyActivityEdgeCommand(DestroyDependentsRequest request) {
-// EObject eObject = request.getElementToDestroy();
-// if(eObject instanceof ActivityNode) {
-// /*
-// * Destroy Activity Edge
-// */
-// ActivityNode activityNode = (ActivityNode)eObject;
-// EList<ActivityEdge> incomings = activityNode.getIncomings();
-// EList<ActivityEdge> outgoings = activityNode.getOutgoings();
-// HashSet<ActivityEdge> edges = Sets.newHashSet();
-// if(incomings != null && !incomings.isEmpty()) {
-// edges.addAll(incomings);
-// }
-// if(outgoings != null && !outgoings.isEmpty()) {
-// edges.addAll(outgoings);
-// }
-// if(!edges.isEmpty()) {
-// CompositeCommand cc = new CompositeCommand("Detele Incomings and outgoings edges from activity node");////$NON-NLS-1$
-// for(ActivityEdge e : edges) {
-// DestroyElementRequest destroyRequest = new DestroyElementRequest(e, false);
-// DestroyElementPapyrusCommand destroyCommand = new DestroyElementPapyrusCommand(destroyRequest);
-// if(destroyCommand != null && destroyCommand.canExecute()) {
-// cc.compose(destroyCommand);
-// }
-// }
-// return cc;
-// }
-// }
-// return null;
-// }
+ /**
+ * When an activity node is deleted than all activity edge starting/ending from/to it should be deleted
+ *
+ * @param request
+ * @return
+ */
+ protected ICommand getDestroyActivityEdgeCommand(DestroyDependentsRequest request) {
+ EObject eObject = request.getElementToDestroy();
+ if(eObject instanceof ActivityNode) {
+ /*
+ * Destroy Activity Edge
+ */
+ ActivityNode activityNode = (ActivityNode)eObject;
+ EList<ActivityEdge> incomings = activityNode.getIncomings();
+ EList<ActivityEdge> outgoings = activityNode.getOutgoings();
+ HashSet<ActivityEdge> edges = Sets.newHashSet();
+ if(incomings != null && !incomings.isEmpty()) {
+ edges.addAll(incomings);
+ }
+ if(outgoings != null && !outgoings.isEmpty()) {
+ edges.addAll(outgoings);
+ }
+ if(!edges.isEmpty()) {
+ CompositeCommand cc = new CompositeCommand("Detele Incomings and outgoings edges from activity node");////$NON-NLS-1$
+ for(ActivityEdge e : edges) {
+ DestroyElementRequest destroyRequest = new DestroyElementRequest(e, false);
+ DestroyElementPapyrusCommand destroyCommand = new DestroyElementPapyrusCommand(destroyRequest);
+ if(destroyCommand != null && destroyCommand.canExecute()) {
+ cc.compose(destroyCommand);
+ }
+ }
+ return cc;
+ }
+ }
+ return null;
+ }
}