|
@@ -1,8 +1,15 @@
|
|
|
package org.yakindu.sct.ui.editor.edithelper;
|
|
|
|
|
|
+import org.eclipse.emf.common.util.EList;
|
|
|
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
|
|
|
import org.eclipse.gmf.runtime.common.core.command.ICommand;
|
|
|
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
|
|
|
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
|
|
|
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
|
|
|
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
|
|
|
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
|
|
|
+import org.yakindu.sct.model.sgraph.Transition;
|
|
|
+import org.yakindu.sct.model.sgraph.Vertex;
|
|
|
import org.yakindu.sct.ui.editor.commands.CreateTransitionCommand;
|
|
|
|
|
|
/**
|
|
@@ -22,4 +29,22 @@ public class VertexEditHelper extends AbstractEditHelper {
|
|
|
CreateRelationshipRequest req) {
|
|
|
return new CreateTransitionCommand(req);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected ICommand getDestroyDependentsCommand(DestroyDependentsRequest req) {
|
|
|
+ Vertex elementToDestroy = (Vertex) req.getElementToDestroy();
|
|
|
+ EList<Transition> incomingTransitions = elementToDestroy
|
|
|
+ .getIncomingTransitions();
|
|
|
+ if (incomingTransitions.size() != 0) {
|
|
|
+ CompositeCommand compoundCommand = new CompositeCommand(
|
|
|
+ "Delete vertex");
|
|
|
+ for (Transition transition : incomingTransitions) {
|
|
|
+ DestroyElementCommand destroyCommand = new DestroyElementCommand(
|
|
|
+ new DestroyElementRequest(transition, false));
|
|
|
+ compoundCommand.add(destroyCommand);
|
|
|
+ }
|
|
|
+ return compoundCommand;
|
|
|
+ }
|
|
|
+ return super.getDestroyDependentsCommand(req);
|
|
|
+ }
|
|
|
}
|