From c58930bcc5a0be0176df2ce296e338ec991ced26 Mon Sep 17 00:00:00 2001 From: Mickael ADAM Date: Mon, 6 Jun 2016 09:44:57 +0200 Subject: Bug 495411 - [Test] JUnit regression in org.eclipse.papyrus.uml.diagram.statemachine.tests.canonical.TestStateMachineContextLink.testToManageContextLink - move to the nearest Package of the constraint in case of deletion of context link. Change-Id: I9666f4718cb45ce6d9d6a7a775b386b5a3763761 Signed-off-by: Mickael ADAM --- .../types/command/ConstraintContextDestroyCommand.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConstraintContextDestroyCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConstraintContextDestroyCommand.java index f5900a0c9a0..df41b096c82 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConstraintContextDestroyCommand.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConstraintContextDestroyCommand.java @@ -21,9 +21,9 @@ import org.eclipse.gmf.runtime.common.core.command.CommandResult; import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest; import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.Namespace; import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Type; /** * Context link destroy command @@ -42,7 +42,7 @@ public class ConstraintContextDestroyCommand extends EditElementCommand { if (target == null || getElementToEdit() == null) { return false; } - return getElementToEdit() instanceof Constraint && (target instanceof Type || target instanceof Package); + return getElementToEdit() instanceof Constraint && (target instanceof Element); } @Override @@ -51,10 +51,11 @@ public class ConstraintContextDestroyCommand extends EditElementCommand { return CommandResult.newCancelledCommandResult(); } ((Constraint) getElementToEdit()).setContext((Namespace) null); - if (target instanceof Package) { - ((Package) target).getPackagedElements().add((Constraint) getElementToEdit()); - } else if (target instanceof Type) { - ((Type) target).getPackage().getPackagedElements().add((Constraint) getElementToEdit()); + if (target instanceof Element) { + Package nearest = ((Element) target).getNearestPackage(); + if (nearest != null) { + nearest.getPackagedElements().add((Constraint) getElementToEdit()); + } } return CommandResult.newOKCommandResult(); } -- cgit v1.2.3