Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-06-06 07:44:57 +0000
committerGerrit Code Review @ Eclipse.org2016-06-06 14:27:21 +0000
commitc58930bcc5a0be0176df2ce296e338ec991ced26 (patch)
tree2c8cbff7cbaa6b70c0b50c2f8dd63f648764d8b2 /plugins/uml
parent1b9f40a722dd90db9e3ea6d6cb5f2702aa93b483 (diff)
downloadorg.eclipse.papyrus-c58930bcc5a0be0176df2ce296e338ec991ced26.tar.gz
org.eclipse.papyrus-c58930bcc5a0be0176df2ce296e338ec991ced26.tar.xz
org.eclipse.papyrus-c58930bcc5a0be0176df2ce296e338ec991ced26.zip
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 <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConstraintContextDestroyCommand.java13
1 files changed, 7 insertions, 6 deletions
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();
}

Back to the top