diff --git a/features/org.eclipse.papyrus.uml.domain.services.feature/feature.xml b/features/org.eclipse.papyrus.uml.domain.services.feature/feature.xml index 6cb1e22d9513877c964b10241b40e86d311f882f..7243ef5c0941b1de5376c9192fb2e49c309a2757 100644 --- a/features/org.eclipse.papyrus.uml.domain.services.feature/feature.xml +++ b/features/org.eclipse.papyrus.uml.domain.services.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.papyrus.uml.domain.services.feature" label="%featureName" - version="0.12.0.qualifier" + version="0.12.0" provider-name="%providerName" license-feature="org.eclipse.license" license-feature-version="2.0.2"> diff --git a/features/org.eclipse.papyrus.uml.domain.services.feature/pom.xml b/features/org.eclipse.papyrus.uml.domain.services.feature/pom.xml index 213a7bf72eff4176105cbfc5dc4f5a76e78f1fb5..3847c1ced46db94ba384f17f6cacd6a4bbe0a4a7 100644 --- a/features/org.eclipse.papyrus.uml.domain.services.feature/pom.xml +++ b/features/org.eclipse.papyrus.uml.domain.services.feature/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>papyrus-uml-domain-services</groupId> <artifactId>parent</artifactId> - <version>0.12.0-SNAPSHOT</version> + <version>0.12.0</version> <relativePath>../../parent</relativePath> </parent> <artifactId>org.eclipse.papyrus.uml.domain.services.feature</artifactId> diff --git a/parent/pom.xml b/parent/pom.xml index c36c30f0530f49ad5b0d8dfe64368753b0fa97d0..be3bc43565fadc043a996db917d1c428976ffec4 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -5,7 +5,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>papyrus-uml-domain-services</groupId> <artifactId>parent</artifactId> - <version>0.12.0-SNAPSHOT</version> + <version>0.12.0</version> <packaging>pom</packaging> <name>Papyrus-UML-services</name> diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.papyrus.uml.domain.services.test/META-INF/MANIFEST.MF index 3b495bee5635a13e6e2e7fbe6cf49643d95d37dd..910cde8ce6bc70d43f8e15b134dc47f303a97c95 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: UML Domain service Tests Bundle-SymbolicName: org.eclipse.papyrus.uml.domain.services.test -Bundle-Version: 0.12.0.qualifier +Bundle-Version: 0.12.0 Fragment-Host: org.eclipse.papyrus.uml.domain.services;bundle-version="0.1.0" Automatic-Module-Name: org.eclipse.papyrus.uml.domain.services.test Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/pom.xml b/plugins/org.eclipse.papyrus.uml.domain.services.test/pom.xml index a8c3b646212797aefde43bcb49904820e38a8d1a..037cafccae086235365f4e7dc7de5b606c57eeaf 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/pom.xml +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>papyrus-uml-domain-services</groupId> <artifactId>parent</artifactId> - <version>0.12.0-SNAPSHOT</version> + <version>0.12.0</version> <relativePath>../../parent</relativePath> </parent> diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurerTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurerTest.java index 024c52fee145ff8cb170d343afca0b4f36297f48..14bf2bbf3f28b67d2a3804dae6b133ad46578829 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurerTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurerTest.java @@ -24,7 +24,6 @@ import org.eclipse.papyrus.uml.domain.services.utils.AbstractUMLTest; import org.eclipse.uml2.uml.AcceptCallAction; import org.eclipse.uml2.uml.ActionExecutionSpecification; import org.eclipse.uml2.uml.Activity; -import org.eclipse.uml2.uml.ActivityPartition; import org.eclipse.uml2.uml.AddStructuralFeatureValueAction; import org.eclipse.uml2.uml.AddVariableValueAction; import org.eclipse.uml2.uml.AggregationKind; @@ -96,22 +95,6 @@ public class ElementConfigurerTest extends AbstractUMLTest { assertNull(new ElementConfigurer().configure(null, null)); } - @Test - public void testActivityPartition() { - Activity activity = create(Activity.class); - ActivityPartition activityPartition = create(ActivityPartition.class); - - activity.getOwnedGroups().add(activityPartition); - - assertTrue(activity.getPartitions().isEmpty()); - - ElementConfigurer elementConfigurer = new ElementConfigurer(); - elementConfigurer.configure(activityPartition, activity); - - assertFalse(activity.getPartitions().isEmpty()); - assertEquals(activityPartition, activity.getPartitions().get(0)); - } - @Test public void testNamedElement() { diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/destroy/DiagramElementDeletorTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/destroy/DiagramElementDeletorTest.java index 7cccc7c23a3079611122154e11023d7382e7c785..ba01bafcfd3ac6d4e647ae41b232230932013098 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/destroy/DiagramElementDeletorTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/destroy/DiagramElementDeletorTest.java @@ -19,21 +19,30 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.List; + import org.eclipse.papyrus.uml.domain.services.edges.ElementDomainBasedEdgeInitializer; import org.eclipse.papyrus.uml.domain.services.status.State; import org.eclipse.papyrus.uml.domain.services.utils.AbstractUMLTest; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.ActivityEdge; +import org.eclipse.uml2.uml.ActivityNode; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Collaboration; import org.eclipse.uml2.uml.CollaborationUse; import org.eclipse.uml2.uml.CombinedFragment; import org.eclipse.uml2.uml.Connector; import org.eclipse.uml2.uml.ConnectorEnd; +import org.eclipse.uml2.uml.ControlFlow; +import org.eclipse.uml2.uml.DecisionNode; import org.eclipse.uml2.uml.Extend; import org.eclipse.uml2.uml.Include; import org.eclipse.uml2.uml.Interaction; import org.eclipse.uml2.uml.InteractionOperand; +import org.eclipse.uml2.uml.JoinNode; import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.MessageOccurrenceSpecification; +import org.eclipse.uml2.uml.ObjectFlow; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.PackageImport; import org.eclipse.uml2.uml.PackageMerge; @@ -64,7 +73,34 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { @Override public void setUp() { super.setUp(); - destroyer = ElementDestroyer.buildDefault(getCrossRef(), getEditableChecker()); + this.destroyer = ElementDestroyer.buildDefault(getCrossRef(), getEditableChecker()); + } + + /** + * Check that the deletion of an {@link ActivityNode} also removes connected + * {@link ActivityEdge}. We will check with only two sub-types since the + * implementation is global to all {@link ActivityNode} kind. + */ + @Test + public void deleteActivityNodeTest() { + Activity activity = create(Activity.class); + DecisionNode decisionNode = createIn(DecisionNode.class, activity); + JoinNode joinNode = createIn(JoinNode.class, activity); + ObjectFlow objectFlow = createIn(ObjectFlow.class, activity); + ControlFlow controlFlow = createIn(ControlFlow.class, activity); + ControlFlow controlFlow2 = createIn(ControlFlow.class, activity); + objectFlow.setSource(joinNode); + objectFlow.setTarget(decisionNode); + controlFlow.setSource(decisionNode); + controlFlow.setTarget(joinNode); + assertTrue(activity.getEdges().containsAll(List.of(objectFlow, controlFlow, controlFlow2))); + assertTrue(activity.getOwnedNodes().containsAll(List.of(decisionNode, joinNode))); + this.destroyer.destroy(joinNode); + assertEquals(1, activity.getOwnedNodes().size()); + assertEquals(decisionNode, activity.getOwnedNodes().get(0)); + assertEquals(1, activity.getEdges().size()); + assertEquals(controlFlow2, activity.getEdges().get(0)); + } /** @@ -80,7 +116,7 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { assertEquals(clazz.getOwnedAttributes().size(), 1); assertNotNull(property.eContainer()); - destroyer.destroy(property); + this.destroyer.destroy(property); assertEquals(clazz.getOwnedAttributes().size(), 0); assertNull(property.eContainer()); @@ -97,7 +133,7 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { collaborationUse.setType(collab); createIn(Usage.class, collaborationUse, UMLPackage.eINSTANCE.getCollaborationUse_RoleBinding().getName()); - destroyer.destroy(collab); + this.destroyer.destroy(collab); assertTrue(collaborationUse.getRoleBindings().isEmpty()); assertNull(collaborationUse.getType()); @@ -119,7 +155,7 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { assertEquals(port1.getSourceDirectedRelationships().size(), 1); assertEquals(port2.getTargetDirectedRelationships().size(), 1); - destroyer.destroy(port1); + this.destroyer.destroy(port1); assertEquals(port1.getSourceDirectedRelationships().size(), 0); assertEquals(port2.getTargetDirectedRelationships().size(), 0); @@ -136,7 +172,7 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { ConnectorEnd connectorEnd1 = createIn(ConnectorEnd.class, connector, END); ConnectorEnd connectorEnd2 = createIn(ConnectorEnd.class, connector, END); - destroyer.destroy(connectorEnd1); + this.destroyer.destroy(connectorEnd1); assertEquals(connector.getEnds().size(), 0); assertNull(connectorEnd1.getOwner()); @@ -153,9 +189,9 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { ConnectorEnd connectorEnd1 = createIn(ConnectorEnd.class, connector, END); ConnectorEnd connectorEnd2 = createIn(ConnectorEnd.class, connector, END); - destroyer = ElementDestroyer.buildDefault(getCrossRef(), e -> e == connector); + this.destroyer = ElementDestroyer.buildDefault(getCrossRef(), e -> e == connector); - DestroyerStatus destroyStatus = destroyer.destroy(connectorEnd1); + DestroyerStatus destroyStatus = this.destroyer.destroy(connectorEnd1); assertFalse(isSuccessStatus(destroyStatus)); assertEquals(connector.getEnds().size(), 2); @@ -172,9 +208,9 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { ConnectorEnd connectorEnd1 = createIn(ConnectorEnd.class, connector, END); ConnectorEnd connectorEnd2 = createIn(ConnectorEnd.class, connector, END); - destroyer = ElementDestroyer.buildDefault(getCrossRef(), e -> e != connectorEnd1); + this.destroyer = ElementDestroyer.buildDefault(getCrossRef(), e -> e != connectorEnd1); - DestroyerStatus destroyStatus = destroyer.destroy(connectorEnd1); + DestroyerStatus destroyStatus = this.destroyer.destroy(connectorEnd1); assertFalse(isSuccessStatus(destroyStatus)); assertEquals(connector.getEnds().size(), 2); @@ -193,9 +229,9 @@ public class DiagramElementDeletorTest extends AbstractUMLTest { ConnectorEnd connectorEnd1 = createIn(ConnectorEnd.class, connector, END); ConnectorEnd connectorEnd2 = createIn(ConnectorEnd.class, connector, END); - destroyer = ElementDestroyer.buildDefault(getCrossRef(), e -> e != connector); + this.destroyer = ElementDestroyer.buildDefault(getCrossRef(), e -> e != connector); - DestroyerStatus destroyStatus = destroyer.destroy(connectorEnd1); + DestroyerStatus destroyStatus = this.destroyer.destroy(connectorEnd1); assertFalse(isSuccessStatus(destroyStatus)); assertEquals(connector.getEnds().size(), 2); diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropBehaviorProviderTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropBehaviorProviderTest.java index 63cbc3e647de836cf65f2f5668986f333ae89fb0..9371310b890736e36331a843529f2004d3e717d6 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropBehaviorProviderTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropBehaviorProviderTest.java @@ -49,7 +49,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte @BeforeEach public void setUp() { super.setUp(); - activityExternalSourceToRepresentationDropBehaviorProvider = new ActivityExternalSourceToRepresentationDropBehaviorProvider(); + this.activityExternalSourceToRepresentationDropBehaviorProvider = new ActivityExternalSourceToRepresentationDropBehaviorProvider(); } @Test @@ -58,7 +58,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity activityToDrop = createIn(Activity.class, root); Activity subActivity = createIn(Activity.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityToDrop, subActivity, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityToDrop, subActivity, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -71,7 +71,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity activityToDrop = createIn(Activity.class, root); ActivityPartition partition = createIn(ActivityPartition.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityToDrop, partition, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityToDrop, partition, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); @@ -84,7 +84,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity subActivity = createIn(Activity.class, root); ControlFlow activityEdgeToDrop = createIn(ControlFlow.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityEdgeToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityEdgeToDrop, subActivity, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -97,7 +97,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityPartition partition = createIn(ActivityPartition.class, root); ControlFlow activityEdgeToDrop = createIn(ControlFlow.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityEdgeToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityEdgeToDrop, partition, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -110,11 +110,11 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityFinalNode node = createIn(ActivityFinalNode.class, root); ControlFlow activityEdgeToDrop = createIn(ControlFlow.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityEdgeToDrop, node, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityEdgeToDrop, node, getCrossRef(), getEditableChecker()); - assertEquals(State.FAILED, status.getState()); - assertEquals(Collections.emptySet(), status.getElementsToDisplay()); + assertEquals(State.NOTHING, status.getState()); + assertEquals(Set.of(activityEdgeToDrop), status.getElementsToDisplay()); } @Test @@ -123,7 +123,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity subActivity1 = createIn(Activity.class, root); ActivityFinalNode activityNodeToDrop = createIn(ActivityFinalNode.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityNodeToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityNodeToDrop, subActivity1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -136,7 +136,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityPartition partition1 = createIn(ActivityPartition.class, root); ActivityFinalNode activityNodeToDrop = createIn(ActivityFinalNode.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityNodeToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityNodeToDrop, partition1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -149,7 +149,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityFinalNode node = createIn(ActivityFinalNode.class, root); ActivityFinalNode activityNodeToDrop = createIn(ActivityFinalNode.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityNodeToDrop, node, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityNodeToDrop, node, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); @@ -162,7 +162,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity subActivity1 = createIn(Activity.class, root); ActivityParameterNode activityParameterNodeToDrop = createIn(ActivityParameterNode.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityParameterNodeToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityParameterNodeToDrop, subActivity1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -175,7 +175,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityPartition partition1 = createIn(ActivityPartition.class, root); ActivityParameterNode activityParameterNodeToDrop = createIn(ActivityParameterNode.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityParameterNodeToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityParameterNodeToDrop, partition1, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); @@ -188,7 +188,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity subActivity1 = createIn(Activity.class, root); ActivityPartition activityPartitionToDrop = createIn(ActivityPartition.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityPartitionToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityPartitionToDrop, subActivity1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -201,7 +201,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityPartition partition1 = createIn(ActivityPartition.class, root); ActivityPartition activityPartitionToDrop = createIn(ActivityPartition.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityPartitionToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityPartitionToDrop, partition1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -214,7 +214,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte InterruptibleActivityRegion region1 = createIn(InterruptibleActivityRegion.class, root); ActivityPartition activityPartitionToDrop = createIn(ActivityPartition.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityPartitionToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(activityPartitionToDrop, region1, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); @@ -227,7 +227,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity subActivity1 = createIn(Activity.class, root); Comment commentToDrop = createIn(Comment.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(commentToDrop, subActivity1, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(commentToDrop, subActivity1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -240,7 +240,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityPartition partition1 = createIn(ActivityPartition.class, root); Comment commentToDrop = createIn(Comment.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(commentToDrop, partition1, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(commentToDrop, partition1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -253,7 +253,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityFinalNode node = createIn(ActivityFinalNode.class, root); Comment commentToDrop = createIn(Comment.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(commentToDrop, node, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(commentToDrop, node, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); @@ -266,7 +266,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte Activity subActivity1 = createIn(Activity.class, root); Constraint constraintToDrop = createIn(Constraint.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(constraintToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(constraintToDrop, subActivity1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -279,7 +279,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte StructuredActivityNode structuredActivityNode = createIn(StructuredActivityNode.class, root); Constraint constraintToDrop = createIn(Constraint.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(constraintToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(constraintToDrop, structuredActivityNode, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -292,7 +292,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ActivityPartition partition1 = createIn(ActivityPartition.class, root); Constraint constraintToDrop = createIn(Constraint.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(constraintToDrop, partition1, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(constraintToDrop, partition1, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); @@ -306,7 +306,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ExpansionRegion expansionRegion2 = createIn(ExpansionRegion.class, root); ExpansionNode expansionNodeToDrop = createIn(ExpansionNode.class, expansionRegion1); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(expansionNodeToDrop, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(expansionNodeToDrop, expansionRegion2, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -319,7 +319,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte ExpansionRegion expansionRegion = createIn(ExpansionRegion.class, root); ExpansionNode expansionNodeToDrop = createIn(ExpansionNode.class, expansionRegion); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop(expansionNodeToDrop, root, + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop(expansionNodeToDrop, root, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); @@ -333,7 +333,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte InterruptibleActivityRegion interruptibleActivityRegionToDrop = createIn(InterruptibleActivityRegion.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider .drop(interruptibleActivityRegionToDrop, subActivity1, getCrossRef(), getEditableChecker()); assertEquals(State.NOTHING, status.getState()); @@ -347,7 +347,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProviderTest exte InterruptibleActivityRegion interruptibleActivityRegionToDrop = createIn(InterruptibleActivityRegion.class, root); - DnDStatus status = activityExternalSourceToRepresentationDropBehaviorProvider.drop( + DnDStatus status = this.activityExternalSourceToRepresentationDropBehaviorProvider.drop( interruptibleActivityRegionToDrop, interruptibleActivityRegion, getCrossRef(), getEditableChecker()); assertEquals(State.FAILED, status.getState()); diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropCheckerTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropCheckerTest.java index fff1ffb653b04c86525272801aeebc9510f81217..4ffbd5cbc5c697e160483062e90dcc2e55952992 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropCheckerTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityExternalSourceToRepresentationDropCheckerTest.java @@ -25,7 +25,6 @@ import org.eclipse.uml2.uml.ActivityParameterNode; import org.eclipse.uml2.uml.ActivityPartition; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Constraint; -import org.eclipse.uml2.uml.ControlFlow; import org.eclipse.uml2.uml.ExpansionNode; import org.eclipse.uml2.uml.ExpansionRegion; import org.eclipse.uml2.uml.InterruptibleActivityRegion; @@ -46,15 +45,15 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @BeforeEach public void setUp() { super.setUp(); - activityExternalSourceToRepresentationDropChecker = new ActivityExternalSourceToRepresentationDropChecker(); + this.activityExternalSourceToRepresentationDropChecker = new ActivityExternalSourceToRepresentationDropChecker(); } @Test public void testActivityDropOnActivity() { - Activity activityToDrop = create(Activity.class); - Activity targetActivity = create(Activity.class); + Activity activityToDrop = this.create(Activity.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityToDrop, targetActivity); assertTrue(canDragAndDropStatus.isValid()); @@ -62,65 +61,21 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivityDropOnActivityNode() { - Activity activityToDrop = create(Activity.class); - ActivityFinalNode targetActivityNode = create(ActivityFinalNode.class); + Activity activityToDrop = this.create(Activity.class); + ActivityFinalNode targetActivityNode = this.create(ActivityFinalNode.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityToDrop, targetActivityNode); assertFalse(canDragAndDropStatus.isValid()); } - @Test - public void testActivityEdgeDropOnActivity() { - ControlFlow activityEdgeToDrop = create(ControlFlow.class); - Activity targetActivity = create(Activity.class); - - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker - .canDragAndDrop(activityEdgeToDrop, targetActivity); - - assertTrue(canDragAndDropStatus.isValid()); - } - - @Test - public void testActivityEdgeDropOnActivityPartition() { - ControlFlow activityEdgeToDrop = create(ControlFlow.class); - ActivityPartition targetActivityPartition = create(ActivityPartition.class); - - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker - .canDragAndDrop(activityEdgeToDrop, targetActivityPartition); - - assertTrue(canDragAndDropStatus.isValid()); - } - - @Test - public void testActivityEdgeDropOnStructuredActivityNode() { - ControlFlow activityEdgeToDrop = create(ControlFlow.class); - StructuredActivityNode targetStructuredActivityNode = create(StructuredActivityNode.class); - - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker - .canDragAndDrop(activityEdgeToDrop, targetStructuredActivityNode); - - assertTrue(canDragAndDropStatus.isValid()); - } - - @Test - public void testActivityEdgeDropOnActivityNode() { - ControlFlow activityEdgeToDrop = create(ControlFlow.class); - ActivityFinalNode targetActivityNode = create(ActivityFinalNode.class); - - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker - .canDragAndDrop(activityEdgeToDrop, targetActivityNode); - - assertFalse(canDragAndDropStatus.isValid()); - } - @Test public void testActivitNodeDropOnActivity() { - ActivityFinalNode activityNodeToDrop = create(ActivityFinalNode.class); - Activity targetActivity = create(Activity.class); + ActivityFinalNode activityNodeToDrop = this.create(ActivityFinalNode.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityNodeToDrop, targetActivity); assertTrue(canDragAndDropStatus.isValid()); @@ -128,10 +83,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivitNodeDropOnActivityGroup() { - ActivityFinalNode activityNodeToDrop = create(ActivityFinalNode.class); - ActivityPartition targetActivityPartition = create(ActivityPartition.class); + ActivityFinalNode activityNodeToDrop = this.create(ActivityFinalNode.class); + ActivityPartition targetActivityPartition = this.create(ActivityPartition.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityNodeToDrop, targetActivityPartition); assertTrue(canDragAndDropStatus.isValid()); @@ -139,10 +94,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivitNodeDropOnActivityNode() { - ActivityFinalNode activityNodeToDrop = create(ActivityFinalNode.class); - ActivityFinalNode targetActivityNode = create(ActivityFinalNode.class); + ActivityFinalNode activityNodeToDrop = this.create(ActivityFinalNode.class); + ActivityFinalNode targetActivityNode = this.create(ActivityFinalNode.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityNodeToDrop, targetActivityNode); assertFalse(canDragAndDropStatus.isValid()); @@ -150,10 +105,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivityParameterNodeDropOnActivity() { - ActivityParameterNode activityParameterNodeToDrop = create(ActivityParameterNode.class); - Activity targetActivity = create(Activity.class); + ActivityParameterNode activityParameterNodeToDrop = this.create(ActivityParameterNode.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityParameterNodeToDrop, targetActivity); assertTrue(canDragAndDropStatus.isValid()); @@ -161,10 +116,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivityParameterNodeDropOnActivityGroup() { - ActivityParameterNode activityParameterNodeToDrop = create(ActivityParameterNode.class); - ActivityPartition targetActivityPartition = create(ActivityPartition.class); + ActivityParameterNode activityParameterNodeToDrop = this.create(ActivityParameterNode.class); + ActivityPartition targetActivityPartition = this.create(ActivityPartition.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityParameterNodeToDrop, targetActivityPartition); assertFalse(canDragAndDropStatus.isValid()); @@ -172,10 +127,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivityPartitionDropOnActivity() { - ActivityPartition activityPartitionToDrop = create(ActivityPartition.class); - Activity targetActivity = create(Activity.class); + ActivityPartition activityPartitionToDrop = this.create(ActivityPartition.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityPartitionToDrop, targetActivity); assertTrue(canDragAndDropStatus.isValid()); @@ -183,10 +138,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivityPartitionDropOnActivityPartition() { - ActivityPartition activityPartitionToDrop = create(ActivityPartition.class); - ActivityPartition targetActivityPartition = create(ActivityPartition.class); + ActivityPartition activityPartitionToDrop = this.create(ActivityPartition.class); + ActivityPartition targetActivityPartition = this.create(ActivityPartition.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityPartitionToDrop, targetActivityPartition); assertTrue(canDragAndDropStatus.isValid()); @@ -194,10 +149,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testActivityPartitionDropOnInterruptibleActivityRegion() { - ActivityPartition activityPartitionToDrop = create(ActivityPartition.class); - InterruptibleActivityRegion targetInterruptibleActivityRegion = create(InterruptibleActivityRegion.class); + ActivityPartition activityPartitionToDrop = this.create(ActivityPartition.class); + InterruptibleActivityRegion targetInterruptibleActivityRegion = this.create(InterruptibleActivityRegion.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(activityPartitionToDrop, targetInterruptibleActivityRegion); assertFalse(canDragAndDropStatus.isValid()); @@ -205,10 +160,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testCommentDropOnActivity() { - Comment commentToDrop = create(Comment.class); - Activity targetActivity = create(Activity.class); + Comment commentToDrop = this.create(Comment.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(commentToDrop, targetActivity); assertTrue(canDragAndDropStatus.isValid()); @@ -216,10 +171,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testCommentDropOnActivityGroup() { - Comment commentToDrop = create(Comment.class); - ActivityPartition targetActivityPartition = create(ActivityPartition.class); + Comment commentToDrop = this.create(Comment.class); + ActivityPartition targetActivityPartition = this.create(ActivityPartition.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(commentToDrop, targetActivityPartition); assertTrue(canDragAndDropStatus.isValid()); @@ -227,10 +182,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testCommentDropOnActivityNode() { - Comment commentToDrop = create(Comment.class); - ActivityFinalNode targetActivityNode = create(ActivityFinalNode.class); + Comment commentToDrop = this.create(Comment.class); + ActivityFinalNode targetActivityNode = this.create(ActivityFinalNode.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(commentToDrop, targetActivityNode); assertFalse(canDragAndDropStatus.isValid()); @@ -238,10 +193,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testConstraintDropOnActivity() { - Constraint constraintToDrop = create(Constraint.class); - Activity targetActivity = create(Activity.class); + Constraint constraintToDrop = this.create(Constraint.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(constraintToDrop, targetActivity); assertTrue(canDragAndDropStatus.isValid()); @@ -249,10 +204,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testConstraintDropOnStructuredActivityNode() { - Constraint constraintToDrop = create(Constraint.class); - StructuredActivityNode targetStructuredActivityNode = create(StructuredActivityNode.class); + Constraint constraintToDrop = this.create(Constraint.class); + StructuredActivityNode targetStructuredActivityNode = this.create(StructuredActivityNode.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(constraintToDrop, targetStructuredActivityNode); assertTrue(canDragAndDropStatus.isValid()); @@ -260,10 +215,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testConstraintDropOnActivityPartition() { - Constraint constraintToDrop = create(Constraint.class); - ActivityPartition targetActivityPartition = create(ActivityPartition.class); + Constraint constraintToDrop = this.create(Constraint.class); + ActivityPartition targetActivityPartition = this.create(ActivityPartition.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(constraintToDrop, targetActivityPartition); assertFalse(canDragAndDropStatus.isValid()); @@ -271,10 +226,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testExpansionNodeDropOnExpansionRegion() { - ExpansionNode expansionNodeToDrop = create(ExpansionNode.class); - ExpansionRegion targetExpansionRegion = create(ExpansionRegion.class); + ExpansionNode expansionNodeToDrop = this.create(ExpansionNode.class); + ExpansionRegion targetExpansionRegion = this.create(ExpansionRegion.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(expansionNodeToDrop, targetExpansionRegion); assertTrue(canDragAndDropStatus.isValid()); @@ -282,10 +237,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testExpansionNodeDropOnActivity() { - ExpansionNode expansionNodeToDrop = create(ExpansionNode.class); - Activity targetActivity = create(Activity.class); + ExpansionNode expansionNodeToDrop = this.create(ExpansionNode.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(expansionNodeToDrop, targetActivity); assertFalse(canDragAndDropStatus.isValid()); @@ -293,10 +248,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testInterruptibleActivityRegionDropOnActivity() { - InterruptibleActivityRegion interruptibleActivityRegionToDrop = create(InterruptibleActivityRegion.class); - Activity targetActivity = create(Activity.class); + InterruptibleActivityRegion interruptibleActivityRegionToDrop = this.create(InterruptibleActivityRegion.class); + Activity targetActivity = this.create(Activity.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(interruptibleActivityRegionToDrop, targetActivity); assertTrue(canDragAndDropStatus.isValid()); @@ -304,10 +259,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testInterruptibleActivityRegionDropOnActivityPartition() { - InterruptibleActivityRegion interruptibleActivityRegionToDrop = create(InterruptibleActivityRegion.class); - ActivityPartition targetActivityPartition = create(ActivityPartition.class); + InterruptibleActivityRegion interruptibleActivityRegionToDrop = this.create(InterruptibleActivityRegion.class); + ActivityPartition targetActivityPartition = this.create(ActivityPartition.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(interruptibleActivityRegionToDrop, targetActivityPartition); assertFalse(canDragAndDropStatus.isValid()); @@ -315,10 +270,10 @@ public class ActivityExternalSourceToRepresentationDropCheckerTest extends Abstr @Test public void testInterruptibleActivityRegionDropOnInterruptibleActivityRegion() { - InterruptibleActivityRegion interruptibleActivityRegionToDrop = create(InterruptibleActivityRegion.class); - InterruptibleActivityRegion targetInterruptibleActivityRegion = create(InterruptibleActivityRegion.class); + InterruptibleActivityRegion interruptibleActivityRegionToDrop = this.create(InterruptibleActivityRegion.class); + InterruptibleActivityRegion targetInterruptibleActivityRegion = this.create(InterruptibleActivityRegion.class); - CheckStatus canDragAndDropStatus = activityExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.activityExternalSourceToRepresentationDropChecker .canDragAndDrop(interruptibleActivityRegionToDrop, targetInterruptibleActivityRegion); assertFalse(canDragAndDropStatus.isValid()); diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityInternalSourceToRepresentationDropBehaviorProviderTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityInternalSourceToRepresentationDropBehaviorProviderTest.java index c9a2b5ffbe10e39ebe5a53e98c21290d61620a34..9cf2d531e64f59aeab36545caf626c1129b5ccb5 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityInternalSourceToRepresentationDropBehaviorProviderTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/ActivityInternalSourceToRepresentationDropBehaviorProviderTest.java @@ -617,4 +617,24 @@ public class ActivityInternalSourceToRepresentationDropBehaviorProviderTest exte assertEquals(root, activityEdge.getOwner()); assertEquals(partition2, activityEdge.getInPartitions().get(0)); } + + /** + * Test dropping an {@link StructuredActivityNode} from an Activity to another + * Activity: The Activity container should changed. + */ + @Test + public void testStructuredActivityNodeDropFromActivityToActivity() { + Activity root = create(Activity.class); + Activity subActivity1 = createIn(Activity.class, root); + Activity subActivity2 = createIn(Activity.class, root); + StructuredActivityNode nodeToDrop = create(StructuredActivityNode.class); + nodeToDrop.setActivity(subActivity1); + + Status status = new ActivityInternalSourceToRepresentationDropBehaviorProvider().drop(nodeToDrop, subActivity1, + subActivity2, getCrossRef(), getEditableChecker()); + + assertEquals(State.DONE, status.getState()); + assertFalse(subActivity1.getStructuredNodes().contains(nodeToDrop)); + assertTrue(subActivity2.getStructuredNodes().contains(nodeToDrop)); + } } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropBehaviorProviderTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropBehaviorProviderTest.java index 7ce95004c5ce22fafc9b9dc09729516a4dd02fae..3e8ba2ae73b3bae8928098be6db0920519d8c74a 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropBehaviorProviderTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropBehaviorProviderTest.java @@ -51,12 +51,12 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testActivityDropOnLifeline() { - Interaction interaction = create(Interaction.class); - Activity activity = createIn(Activity.class, interaction); - Lifeline lifeline = createIn(Lifeline.class, interaction); + Interaction interaction = this.create(Interaction.class); + Activity activity = this.createIn(Activity.class, interaction); + Lifeline lifeline = this.createIn(Lifeline.class, interaction); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(activity, - lifeline, getCrossRef(), getEditableChecker()); + lifeline, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.DONE, status.getState()); EList<Property> ownedAttributes = interaction.getOwnedAttributes(); @@ -76,11 +76,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testActivityDropOnInteraction() { - Interaction interaction = create(Interaction.class); - Activity activity = createIn(Activity.class, interaction); + Interaction interaction = this.create(Interaction.class); + Activity activity = this.createIn(Activity.class, interaction); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(activity, - interaction, getCrossRef(), getEditableChecker()); + interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.DONE, status.getState()); EList<Property> ownedAttributes = interaction.getOwnedAttributes(); @@ -94,7 +94,7 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest assertEquals(property, lifeline.getRepresents()); assertEquals(Set.of(lifeline), status.getElementsToDisplay()); } - + /** * Test dropping a {@link Activity} on {@link DurationObservation}. * @@ -102,11 +102,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testActivityDropOnDurationObservation() { - DurationObservation durationObservation = create(DurationObservation.class); - Activity activity = create(Activity.class); + DurationObservation durationObservation = this.create(DurationObservation.class); + Activity activity = this.create(Activity.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(activity, - durationObservation, getCrossRef(), getEditableChecker()); + durationObservation, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.FAILED, status.getState()); } @@ -118,11 +118,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testCommentDropOnLifeline() { - Comment comment = create(Comment.class); - Lifeline lifeline = create(Lifeline.class); + Comment comment = this.create(Comment.class); + Lifeline lifeline = this.create(Lifeline.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(comment, lifeline, - getCrossRef(), getEditableChecker()); + this.getCrossRef(), this.getEditableChecker()); assertEquals(State.FAILED, status.getState()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); @@ -136,11 +136,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testCommentDropOnInteraction() { - Comment comment = create(Comment.class); - Interaction interaction = create(Interaction.class); + Comment comment = this.create(Comment.class); + Interaction interaction = this.create(Interaction.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(comment, - interaction, getCrossRef(), getEditableChecker()); + interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.NOTHING, status.getState()); assertEquals(Set.of(comment), status.getElementsToDisplay()); @@ -153,11 +153,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testConstraintDropOnLifeline() { - Constraint constraint = create(Constraint.class); - Lifeline lifeline = create(Lifeline.class); + Constraint constraint = this.create(Constraint.class); + Lifeline lifeline = this.create(Lifeline.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(constraint, - lifeline, getCrossRef(), getEditableChecker()); + lifeline, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.FAILED, status.getState()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); @@ -171,11 +171,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testConstraintDropOnInteraction() { - Constraint constraint = create(Constraint.class); - Interaction interaction = create(Interaction.class); + Constraint constraint = this.create(Constraint.class); + Interaction interaction = this.create(Interaction.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(constraint, - interaction, getCrossRef(), getEditableChecker()); + interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.NOTHING, status.getState()); assertEquals(Set.of(constraint), status.getElementsToDisplay()); @@ -188,11 +188,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testDurationObservationDropOnLifeline() { - DurationObservation durationObservation = create(DurationObservation.class); - Lifeline lifeline = create(Lifeline.class); + DurationObservation durationObservation = this.create(DurationObservation.class); + Lifeline lifeline = this.create(Lifeline.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider() - .drop(durationObservation, lifeline, getCrossRef(), getEditableChecker()); + .drop(durationObservation, lifeline, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.FAILED, status.getState()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); @@ -206,11 +206,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testDurationObservationDropOnInteraction() { - DurationObservation durationObservation = create(DurationObservation.class); - Interaction interaction = create(Interaction.class); + DurationObservation durationObservation = this.create(DurationObservation.class); + Interaction interaction = this.create(Interaction.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider() - .drop(durationObservation, interaction, getCrossRef(), getEditableChecker()); + .drop(durationObservation, interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.NOTHING, status.getState()); assertEquals(Set.of(durationObservation), status.getElementsToDisplay()); @@ -223,14 +223,14 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testMessageDropOnLifeline() { - Message message = create(Message.class); - Lifeline lifeline = create(Lifeline.class); + Message message = this.create(Message.class); + Lifeline lifeline = this.create(Lifeline.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(message, lifeline, - getCrossRef(), getEditableChecker()); + this.getCrossRef(), this.getEditableChecker()); - assertEquals(State.FAILED, status.getState()); - assertEquals(Collections.emptySet(), status.getElementsToDisplay()); + assertEquals(State.NOTHING, status.getState()); + assertEquals(Set.of(message), status.getElementsToDisplay()); } /** @@ -241,11 +241,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testMessageDropOnInteraction() { - Message message = create(Message.class); - Interaction interaction = create(Interaction.class); + Message message = this.create(Message.class); + Interaction interaction = this.create(Interaction.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(message, - interaction, getCrossRef(), getEditableChecker()); + interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.NOTHING, status.getState()); assertEquals(Set.of(message), status.getElementsToDisplay()); @@ -258,11 +258,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testLifelineDropOnLifeline() { - Lifeline lifelineToDrop = create(Lifeline.class); - Lifeline lifeline = create(Lifeline.class); + Lifeline lifelineToDrop = this.create(Lifeline.class); + Lifeline lifeline = this.create(Lifeline.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(lifelineToDrop, - lifeline, getCrossRef(), getEditableChecker()); + lifeline, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.FAILED, status.getState()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); @@ -276,11 +276,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testLifelineDropOnInteraction() { - Lifeline lifeline = create(Lifeline.class); - Interaction interaction = create(Interaction.class); + Lifeline lifeline = this.create(Lifeline.class); + Interaction interaction = this.create(Interaction.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(lifeline, - interaction, getCrossRef(), getEditableChecker()); + interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.NOTHING, status.getState()); assertEquals(Set.of(lifeline), status.getElementsToDisplay()); @@ -293,11 +293,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testTimeObservationDropOnLifeline() { - TimeObservation timeObservation = create(TimeObservation.class); - Lifeline lifeline = create(Lifeline.class); + TimeObservation timeObservation = this.create(TimeObservation.class); + Lifeline lifeline = this.create(Lifeline.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(timeObservation, - lifeline, getCrossRef(), getEditableChecker()); + lifeline, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.FAILED, status.getState()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); @@ -311,11 +311,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testTimeObservationDropOnInteraction() { - TimeObservation timeObservation = create(TimeObservation.class); - Interaction interaction = create(Interaction.class); + TimeObservation timeObservation = this.create(TimeObservation.class); + Interaction interaction = this.create(Interaction.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(timeObservation, - interaction, getCrossRef(), getEditableChecker()); + interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.NOTHING, status.getState()); assertEquals(Set.of(timeObservation), status.getElementsToDisplay()); @@ -328,11 +328,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testPropertyDropOnLifeline() { - Property property = create(Property.class); - Lifeline lifeline = create(Lifeline.class); + Property property = this.create(Property.class); + Lifeline lifeline = this.create(Lifeline.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(property, - lifeline, getCrossRef(), getEditableChecker()); + lifeline, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.DONE, status.getState()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); @@ -346,11 +346,11 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProviderTest */ @Test public void testPropertyDropOnInteraction() { - Property property = create(Property.class); - Interaction interaction = create(Interaction.class); + Property property = this.create(Property.class); + Interaction interaction = this.create(Interaction.class); DnDStatus status = new CommunicationExternalSourceToRepresentationDropBehaviorProvider().drop(property, - interaction, getCrossRef(), getEditableChecker()); + interaction, this.getCrossRef(), this.getEditableChecker()); assertEquals(State.FAILED, status.getState()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropCheckerTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropCheckerTest.java index 4343ae00482128f6f8bafbcde2b5f08dfc64c7b8..34bef9255cc1be253f590d0e19158cbd89b33ae4 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropCheckerTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CommunicationExternalSourceToRepresentationDropCheckerTest.java @@ -25,7 +25,6 @@ import org.eclipse.uml2.uml.Constraint; import org.eclipse.uml2.uml.DurationObservation; import org.eclipse.uml2.uml.Interaction; import org.eclipse.uml2.uml.Lifeline; -import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.TimeObservation; import org.junit.jupiter.api.BeforeEach; @@ -46,7 +45,7 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends @BeforeEach public void setUp() { super.setUp(); - communicationExternalSourceToRepresentationDropChecker = new CommunicationExternalSourceToRepresentationDropChecker(); + this.communicationExternalSourceToRepresentationDropChecker = new CommunicationExternalSourceToRepresentationDropChecker(); } /** @@ -54,10 +53,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testActivityDropOnComment() { - Activity activity = create(Activity.class); - Comment comment = create(Comment.class); + Activity activity = this.create(Activity.class); + Comment comment = this.create(Comment.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(activity, comment); assertFalse(canDragAndDropStatus.isValid()); } @@ -67,10 +66,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testActivityDropOnInteraction() { - Activity activity = create(Activity.class); - Interaction interaction = create(Interaction.class); + Activity activity = this.create(Activity.class); + Interaction interaction = this.create(Interaction.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(activity, interaction); assertTrue(canDragAndDropStatus.isValid()); } @@ -80,10 +79,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testActivityDropOnLifeline() { - Activity activity = create(Activity.class); - Lifeline lifeline = create(Lifeline.class); + Activity activity = this.create(Activity.class); + Lifeline lifeline = this.create(Lifeline.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(activity, lifeline); assertTrue(canDragAndDropStatus.isValid()); } @@ -93,10 +92,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testCommentDropOnInteraction() { - Comment comment = create(Comment.class); - Interaction interaction = create(Interaction.class); + Comment comment = this.create(Comment.class); + Interaction interaction = this.create(Interaction.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(comment, interaction); assertTrue(canDragAndDropStatus.isValid()); } @@ -106,10 +105,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testCommentDropOnLifeline() { - Comment comment = create(Comment.class); - Lifeline lifeline = create(Lifeline.class); + Comment comment = this.create(Comment.class); + Lifeline lifeline = this.create(Lifeline.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(comment, lifeline); assertFalse(canDragAndDropStatus.isValid()); } @@ -119,10 +118,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testConstraintDropOnInteraction() { - Constraint constraint = create(Constraint.class); - Interaction interaction = create(Interaction.class); + Constraint constraint = this.create(Constraint.class); + Interaction interaction = this.create(Interaction.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(constraint, interaction); assertTrue(canDragAndDropStatus.isValid()); } @@ -132,10 +131,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testConstraintDropOnLifeline() { - Constraint constraint = create(Constraint.class); - Lifeline lifeline = create(Lifeline.class); + Constraint constraint = this.create(Constraint.class); + Lifeline lifeline = this.create(Lifeline.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(constraint, lifeline); assertFalse(canDragAndDropStatus.isValid()); } @@ -146,10 +145,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testDurationObservationDropOnInteraction() { - DurationObservation durationObservation = create(DurationObservation.class); - Interaction interaction = create(Interaction.class); + DurationObservation durationObservation = this.create(DurationObservation.class); + Interaction interaction = this.create(Interaction.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(durationObservation, interaction); assertTrue(canDragAndDropStatus.isValid()); } @@ -160,49 +159,23 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testDurationObservationDropOnLifeline() { - DurationObservation durationObservation = create(DurationObservation.class); - Lifeline lifeline = create(Lifeline.class); + DurationObservation durationObservation = this.create(DurationObservation.class); + Lifeline lifeline = this.create(Lifeline.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(durationObservation, lifeline); assertFalse(canDragAndDropStatus.isValid()); } - /** - * Test dropping a {@link Message} on {@link Interaction} => authorized. - */ - @Test - public void testMessageDropOnInteraction() { - Message message = create(Message.class); - Interaction interaction = create(Interaction.class); - - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker - .canDragAndDrop(message, interaction); - assertTrue(canDragAndDropStatus.isValid()); - } - - /** - * Test dropping a {@link Message} on {@link Lifeline} => not authorized. - */ - @Test - public void testMessageDropOnLifeline() { - Message message = create(Message.class); - Lifeline lifeline = create(Lifeline.class); - - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker - .canDragAndDrop(message, lifeline); - assertFalse(canDragAndDropStatus.isValid()); - } - /** * Test dropping a {@link Property} on {@link Interaction} => not authorized. */ @Test public void testPropertyDropOnInteraction() { - Property property = create(Property.class); - Interaction interaction = create(Interaction.class); + Property property = this.create(Property.class); + Interaction interaction = this.create(Interaction.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(property, interaction); assertFalse(canDragAndDropStatus.isValid()); } @@ -212,10 +185,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testPropertyDropOnLifeline() { - Property property = create(Property.class); - Lifeline lifeline = create(Lifeline.class); + Property property = this.create(Property.class); + Lifeline lifeline = this.create(Lifeline.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(property, lifeline); assertTrue(canDragAndDropStatus.isValid()); } @@ -225,10 +198,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testLifelineDropOnInteraction() { - Lifeline lifeline = create(Lifeline.class); - Interaction interaction = create(Interaction.class); + Lifeline lifeline = this.create(Lifeline.class); + Interaction interaction = this.create(Interaction.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(lifeline, interaction); assertTrue(canDragAndDropStatus.isValid()); } @@ -238,10 +211,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testLifelineDropOnLifeline() { - Lifeline lifelineToDrop = create(Lifeline.class); - Lifeline lifeline = create(Lifeline.class); + Lifeline lifelineToDrop = this.create(Lifeline.class); + Lifeline lifeline = this.create(Lifeline.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(lifelineToDrop, lifeline); assertFalse(canDragAndDropStatus.isValid()); } @@ -251,10 +224,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testTimeObservationDropOnInteraction() { - TimeObservation timeObservation = create(TimeObservation.class); - Interaction interaction = create(Interaction.class); + TimeObservation timeObservation = this.create(TimeObservation.class); + Interaction interaction = this.create(Interaction.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(timeObservation, interaction); assertTrue(canDragAndDropStatus.isValid()); } @@ -265,10 +238,10 @@ public class CommunicationExternalSourceToRepresentationDropCheckerTest extends */ @Test public void testTimeObservationDropOnLifeline() { - TimeObservation timeObservation = create(TimeObservation.class); - Lifeline lifeline = create(Lifeline.class); + TimeObservation timeObservation = this.create(TimeObservation.class); + Lifeline lifeline = this.create(Lifeline.class); - CheckStatus canDragAndDropStatus = communicationExternalSourceToRepresentationDropChecker + CheckStatus canDragAndDropStatus = this.communicationExternalSourceToRepresentationDropChecker .canDragAndDrop(timeObservation, lifeline); assertFalse(canDragAndDropStatus.isValid()); } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropBehaviorProviderTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropBehaviorProviderTest.java index 1899386514b2a63e130ef3c50e29188d6194372f..9cd035a3849ba62104d99ae96f7e9d1536694143 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropBehaviorProviderTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropBehaviorProviderTest.java @@ -21,7 +21,10 @@ import org.eclipse.papyrus.uml.domain.services.drop.diagrams.CompositeStructureE import org.eclipse.papyrus.uml.domain.services.status.State; import org.eclipse.papyrus.uml.domain.services.utils.AbstractUMLTest; import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.CollaborationUse; import org.eclipse.uml2.uml.DataType; +import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.Property; import org.junit.jupiter.api.Test; @@ -65,4 +68,28 @@ public class CompositeStructureExternalSourceToRepresentationDropBehaviorProvide assertEquals(clazz, property.getType()); assertEquals(Collections.emptySet(), status.getElementsToDisplay()); } + + @Test + public void testCollaborationDropOnCollaborationUse() { + CollaborationUse collaborationUse = create(CollaborationUse.class); + Collaboration collaboration = create(Collaboration.class); + + DnDStatus status = new CompositeStructureExternalSourceToRepresentationDropBehaviorProvider() + .drop(collaboration, collaborationUse, getCrossRef(), getEditableChecker()); + assertEquals(State.DONE, status.getState()); + assertEquals(collaboration, collaborationUse.getType()); + } + + @Test + public void testCollaborationDropOnPackage() { + Package pack = create(Package.class); + Collaboration collaboration = create(Collaboration.class); + + DnDStatus status = new CompositeStructureExternalSourceToRepresentationDropBehaviorProvider() + .drop(collaboration, pack, getCrossRef(), getEditableChecker()); + assertEquals(State.DONE, status.getState()); + assertEquals(1, status.getElementsToDisplay().size()); + assertEquals(collaboration, status.getElementsToDisplay().toArray()[0]); + } + } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropCheckerTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropCheckerTest.java index 371619d69be44612b9cffb8740565674498b8dc3..640cb5082d4159caa4875561896069427ee0e337 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropCheckerTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/drop/CompositeStructureExternalSourceToRepresentationDropCheckerTest.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2022 CEA LIST, Obeo + * Copyright (c) 2022, 2023 CEA LIST, Obeo. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -9,7 +9,7 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * OBEO - Initial API and implementation + * Obeo - Initial API and implementation *****************************************************************************/ package org.eclipse.papyrus.uml.domain.services.drop; @@ -23,6 +23,7 @@ import org.eclipse.uml2.uml.Activity; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.CollaborationUse; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.Port; @@ -119,6 +120,20 @@ public class CompositeStructureExternalSourceToRepresentationDropCheckerTest ext assertTrue(canDragAndDropStatus.isValid()); } + /** + * Test dropping a {@link Collaboration} on {@link CollaborationUse} => + * authorized. + */ + @Test + public void testCollaborationDropOnCollaborationUse() { + CollaborationUse collaborationUse = create(CollaborationUse.class); + Collaboration collaboration = create(org.eclipse.uml2.uml.Collaboration.class); + + CheckStatus canDragAndDropStatus = compositeStructureExternalSourceToRepresentationDropChecker + .canDragAndDrop(collaboration, collaborationUse); + assertTrue(canDragAndDropStatus.isValid()); + } + /** * Test dropping a {@link Collaboration} on {@link Comment} => not authorized. */ diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/ElementLabelProviderTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/ElementLabelProviderTest.java index 2b3a26bd9c49d3c222e7e38a15becc64f4a31f5c..0cf83812420e28e9b27f9059281caa6f711969b8 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/ElementLabelProviderTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/ElementLabelProviderTest.java @@ -26,8 +26,11 @@ import static org.eclipse.papyrus.uml.domain.services.labels.UMLCharacters.ST_LE import static org.eclipse.papyrus.uml.domain.services.labels.UMLCharacters.ST_RIGHT; import static org.eclipse.papyrus.uml.domain.services.labels.UMLCharacters.TILDE; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import java.io.IOException; import java.util.List; +import java.util.Map; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; @@ -78,12 +81,14 @@ import org.eclipse.uml2.uml.PackageMerge; import org.eclipse.uml2.uml.Parameter; import org.eclipse.uml2.uml.ParameterDirectionKind; import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Profile; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.ProtocolStateMachine; import org.eclipse.uml2.uml.Realization; import org.eclipse.uml2.uml.Region; import org.eclipse.uml2.uml.SequenceNode; import org.eclipse.uml2.uml.StateMachine; +import org.eclipse.uml2.uml.Stereotype; import org.eclipse.uml2.uml.StructuredActivityNode; import org.eclipse.uml2.uml.Substitution; import org.eclipse.uml2.uml.TimeExpression; @@ -120,6 +125,7 @@ public class ElementLabelProviderTest extends AbstractUMLTest { private static final String LIFELINE = "MyLifeline"; private static final String PROPERTY = "MyProperty"; private static final String EXPRESSION = "MyExpression"; + private static final String LITERAL_STRING = "MyLiteralString"; private static final String LITERAL_STRING_VALUE = "MyLiteralStringValue"; private static final String MY_JOIN_NODE = "MyJoinNode"; @@ -133,6 +139,10 @@ public class ElementLabelProviderTest extends AbstractUMLTest { private static final String OBJECT_FLOW_NAME = "objectFlowName"; private static final String THE_GUARD_VALUE = "theGuardValue"; private static final String WEIGHT = "weight"; + private static final String E_CLASS = "EClass"; //$NON-NLS-1$ + private static final String ACTIVITY = "activity"; + private static final String ACTIVITY1 = "activity1"; + private static final String SINGLE_EXECUTION = "singleExecution"; /** * Basic test case for {@link Usage} label. Prefix \u00ABuse\u00BB should @@ -154,6 +164,13 @@ public class ElementLabelProviderTest extends AbstractUMLTest { .withNameProvider(new DefaultNamedElementNameProvider()).build(); } + private ElementLabelProvider buildLabelProviderWithStereotypePrefix() { + return ElementLabelProvider.builder()// + .withKeywordLabelProvider(new KeywordLabelProvider())// + .withPrefixLabelProvider(new StereotypeLabelPrefixProvider()) + .withNameProvider(new DefaultNamedElementNameProvider()).build(); + } + /** * Basic test case for {@link Abstraction} label. Prefix \u00ABabstraction\u00BB * should appear. @@ -415,9 +432,31 @@ public class ElementLabelProviderTest extends AbstractUMLTest { Activity activity = create(Activity.class); ElementLabelProvider elementLabelProvider = buildLabelProviderNoPrefix(); - assertEquals(ST_LEFT + "activity" + ST_RIGHT, elementLabelProvider.getLabel(activity)); + assertEquals(ST_LEFT + ACTIVITY + ST_RIGHT, elementLabelProvider.getLabel(activity)); activity.setName("a1"); - assertEquals(ST_LEFT + "activity" + ST_RIGHT + EOL + "a1", elementLabelProvider.getLabel(activity)); + assertEquals(ST_LEFT + ACTIVITY + ST_RIGHT + EOL + "a1", elementLabelProvider.getLabel(activity)); + } + + /** + * Check that the {@link Activity} label with a stereotype and two keyword + * (activity and singleExecution) is properly displayed. + */ + @Test + public void testActivityLabelsWithStereotypeAndSingleExecution() { + Profile eCoreProfile = getECoreProfile(); + Model model = create(Model.class); + Activity activity = createIn(Activity.class, model); + activity.setName(ACTIVITY1); + model.applyProfile(eCoreProfile); + Stereotype stereotype = eCoreProfile.getOwnedStereotype(E_CLASS); + activity.applyStereotype(stereotype); + activity.setIsSingleExecution(true); + ElementLabelProvider elementLabelProvider = buildLabelProviderWithStereotypePrefix(); + String expected = "\u00AB%s, %s\u00BB" + EOL // + + "\u00AB%s\u00BB" + EOL // + + "%s"; + expected = expected.formatted(ACTIVITY, SINGLE_EXECUTION, E_CLASS, ACTIVITY1); + assertEquals(expected, elementLabelProvider.getLabel(activity)); } @Test @@ -1011,4 +1050,19 @@ public class ElementLabelProviderTest extends AbstractUMLTest { } return stringBuilder.toString(); } + + private Profile getECoreProfile() { + ResourceSet resourceSet = new ResourceSetImpl(); + Resource profileResource = resourceSet + .createResource(URI.createURI("pathmap://UML_PROFILES/Ecore.profile.uml")); //$NON-NLS-1$ + try { + profileResource.load(Map.of()); + return (Profile) profileResource.getContents().get(0); + + } catch (IOException e) { + fail(e.getMessage()); + } + return null; + } + } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProviderTest.java b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProviderTest.java index 79dbb80e5908e48aab1ec8797476096ea5780348..b48565464b8902b835a639bd536d3eef86c27a94 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProviderTest.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services.test/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProviderTest.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2023 CEA LIST, OBEO + * Copyright (c) 2023 CEA LIST, Obeo. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -9,10 +9,12 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * OBEO - Initial API and implementation + * Obeo - Initial API and implementation *****************************************************************************/ package org.eclipse.papyrus.uml.domain.services.labels; +import static org.eclipse.papyrus.uml.domain.services.labels.UMLCharacters.COMMA; +import static org.eclipse.papyrus.uml.domain.services.labels.UMLCharacters.SPACE; import static org.eclipse.papyrus.uml.domain.services.labels.UMLCharacters.ST_LEFT; import static org.eclipse.papyrus.uml.domain.services.labels.UMLCharacters.ST_RIGHT; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -41,6 +43,7 @@ import org.eclipse.uml2.uml.PrimitiveType; import org.eclipse.uml2.uml.Profile; import org.eclipse.uml2.uml.ProtocolStateMachine; import org.eclipse.uml2.uml.Realization; +import org.eclipse.uml2.uml.Reception; import org.eclipse.uml2.uml.Signal; import org.eclipse.uml2.uml.StateMachine; import org.eclipse.uml2.uml.Stereotype; @@ -53,7 +56,7 @@ import org.junit.jupiter.api.Test; /** * Test class for {@link KeywordLabelProvider}. * - * @author Jessy MALLET + * @author <a href="mailto:jessy.mallet@obeo.fr">Jessy Mallet</a> * */ public class KeywordLabelProviderTest extends AbstractUMLTest { @@ -64,12 +67,12 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @BeforeEach public void setUp() { super.setUp(); - keywordLabelProvider = new KeywordLabelProvider(); + this.keywordLabelProvider = new KeywordLabelProvider(); } @Test public void testOnNull() { - assertEquals(null, keywordLabelProvider.apply(null)); + assertEquals(null, this.keywordLabelProvider.apply(null)); } /** @@ -79,7 +82,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testAbstractionKeyword() { Abstraction abstraction = create(Abstraction.class); - assertEquals(ST_LEFT + "abstraction" + ST_RIGHT, keywordLabelProvider.apply(abstraction)); + assertEquals(ST_LEFT + "abstraction" + ST_RIGHT, this.keywordLabelProvider.apply(abstraction)); } /** @@ -89,7 +92,19 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testActivityKeyword() { Activity activity = create(Activity.class); - assertEquals(ST_LEFT + "activity" + ST_RIGHT, keywordLabelProvider.apply(activity)); + assertEquals(ST_LEFT + "activity" + ST_RIGHT, this.keywordLabelProvider.apply(activity)); + } + + /** + * Test for {@link Activity} with is Single Execution. Prefix + * \u00ABactivity\u00BB, \u00ABsingleExecution\u00BB should appear. + */ + @Test + public void testActivityKeywordWithIsSingleExecution() { + Activity activity = create(Activity.class); + activity.setIsSingleExecution(true); + assertEquals(ST_LEFT + "activity" + COMMA + SPACE + "singleExecution" + ST_RIGHT, + this.keywordLabelProvider.apply(activity)); } /** @@ -99,7 +114,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testArtifactKeyword() { Artifact artifact = create(Artifact.class); - assertEquals(ST_LEFT + "artifact" + ST_RIGHT, keywordLabelProvider.apply(artifact)); + assertEquals(ST_LEFT + "artifact" + ST_RIGHT, this.keywordLabelProvider.apply(artifact)); } /** @@ -109,7 +124,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testCollaborationKeyword() { Collaboration collaboration = create(Collaboration.class); - assertEquals(ST_LEFT + "collaboration" + ST_RIGHT, keywordLabelProvider.apply(collaboration)); + assertEquals(ST_LEFT + "collaboration" + ST_RIGHT, this.keywordLabelProvider.apply(collaboration)); } /** @@ -119,7 +134,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testComponentKeyword() { Component component = create(Component.class); - assertEquals(ST_LEFT + "component" + ST_RIGHT, keywordLabelProvider.apply(component)); + assertEquals(ST_LEFT + "component" + ST_RIGHT, this.keywordLabelProvider.apply(component)); } /** @@ -129,7 +144,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testDataTypeKeyword() { DataType dataType = create(DataType.class); - assertEquals(ST_LEFT + "dataType" + ST_RIGHT, keywordLabelProvider.apply(dataType)); + assertEquals(ST_LEFT + "dataType" + ST_RIGHT, this.keywordLabelProvider.apply(dataType)); } /** @@ -139,7 +154,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testDeviceKeyword() { Device device = create(Device.class); - assertEquals(ST_LEFT + "device" + ST_RIGHT, keywordLabelProvider.apply(device)); + assertEquals(ST_LEFT + "device" + ST_RIGHT, this.keywordLabelProvider.apply(device)); } /** @@ -149,7 +164,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testEnumerationKeyword() { Enumeration enumeration = create(Enumeration.class); - assertEquals(ST_LEFT + "enumeration" + ST_RIGHT, keywordLabelProvider.apply(enumeration)); + assertEquals(ST_LEFT + "enumeration" + ST_RIGHT, this.keywordLabelProvider.apply(enumeration)); } /** @@ -159,7 +174,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testExtendKeyword() { Extend extend = create(Extend.class); - assertEquals(ST_LEFT + "extend" + ST_RIGHT, keywordLabelProvider.apply(extend)); + assertEquals(ST_LEFT + "extend" + ST_RIGHT, this.keywordLabelProvider.apply(extend)); } /** @@ -169,7 +184,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testFunctionBehaviorKeyword() { FunctionBehavior functionBehavior = create(FunctionBehavior.class); - assertEquals(ST_LEFT + "functionBehavior" + ST_RIGHT, keywordLabelProvider.apply(functionBehavior)); + assertEquals(ST_LEFT + "functionBehavior" + ST_RIGHT, this.keywordLabelProvider.apply(functionBehavior)); } /** @@ -179,7 +194,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testIncludeKeyword() { Include include = create(Include.class); - assertEquals(ST_LEFT + "include" + ST_RIGHT, keywordLabelProvider.apply(include)); + assertEquals(ST_LEFT + "include" + ST_RIGHT, this.keywordLabelProvider.apply(include)); } /** @@ -188,7 +203,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testRealizationKeyword() { Realization realization = create(Realization.class); - assertEquals(null, keywordLabelProvider.apply(realization)); + assertEquals(null, this.keywordLabelProvider.apply(realization)); } /** @@ -198,7 +213,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testInformationFlowKeyword() { InformationFlow informationFlow = create(InformationFlow.class); - assertEquals(ST_LEFT + "flow" + ST_RIGHT, keywordLabelProvider.apply(informationFlow)); + assertEquals(ST_LEFT + "flow" + ST_RIGHT, this.keywordLabelProvider.apply(informationFlow)); } /** @@ -208,7 +223,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testInformationItemKeyword() { InformationItem informationItem = create(InformationItem.class); - assertEquals(ST_LEFT + "information" + ST_RIGHT, keywordLabelProvider.apply(informationItem)); + assertEquals(ST_LEFT + "information" + ST_RIGHT, this.keywordLabelProvider.apply(informationItem)); } /** @@ -218,7 +233,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testInteractionKeyword() { Interaction interaction = create(Interaction.class); - assertEquals(ST_LEFT + "interaction" + ST_RIGHT, keywordLabelProvider.apply(interaction)); + assertEquals(ST_LEFT + "interaction" + ST_RIGHT, this.keywordLabelProvider.apply(interaction)); } /** @@ -228,7 +243,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testInterfaceKeyword() { Interface interface1 = create(Interface.class); - assertEquals(ST_LEFT + "interface" + ST_RIGHT, keywordLabelProvider.apply(interface1)); + assertEquals(ST_LEFT + "interface" + ST_RIGHT, this.keywordLabelProvider.apply(interface1)); } /** @@ -238,7 +253,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testManifestationKeyword() { Manifestation manifestation = create(Manifestation.class); - assertEquals(ST_LEFT + "manifest" + ST_RIGHT, keywordLabelProvider.apply(manifestation)); + assertEquals(ST_LEFT + "manifest" + ST_RIGHT, this.keywordLabelProvider.apply(manifestation)); } /** @@ -248,7 +263,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testOpaqueBehaviorKeyword() { OpaqueBehavior opaqueBehavior = create(OpaqueBehavior.class); - assertEquals(ST_LEFT + "opaqueBehavior" + ST_RIGHT, keywordLabelProvider.apply(opaqueBehavior)); + assertEquals(ST_LEFT + "opaqueBehavior" + ST_RIGHT, this.keywordLabelProvider.apply(opaqueBehavior)); } /** @@ -258,9 +273,9 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testPackageImportKeyword() { PackageImport packageImport = create(PackageImport.class); - assertEquals(ST_LEFT + "import" + ST_RIGHT, keywordLabelProvider.apply(packageImport)); + assertEquals(ST_LEFT + "import" + ST_RIGHT, this.keywordLabelProvider.apply(packageImport)); packageImport.setVisibility(VisibilityKind.PRIVATE_LITERAL); - assertEquals(ST_LEFT + "access" + ST_RIGHT, keywordLabelProvider.apply(packageImport)); + assertEquals(ST_LEFT + "access" + ST_RIGHT, this.keywordLabelProvider.apply(packageImport)); } /** @@ -270,7 +285,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testPackageMergeKeyword() { PackageMerge packageMerge = create(PackageMerge.class); - assertEquals(ST_LEFT + "merge" + ST_RIGHT, keywordLabelProvider.apply(packageMerge)); + assertEquals(ST_LEFT + "merge" + ST_RIGHT, this.keywordLabelProvider.apply(packageMerge)); } /** @@ -280,7 +295,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testPrimitiveTypeKeyword() { PrimitiveType primitiveType = create(PrimitiveType.class); - assertEquals(ST_LEFT + "primitive" + ST_RIGHT, keywordLabelProvider.apply(primitiveType)); + assertEquals(ST_LEFT + "primitive" + ST_RIGHT, this.keywordLabelProvider.apply(primitiveType)); } /** @@ -290,7 +305,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testProfileKeyword() { Profile profile = create(Profile.class); - assertEquals(ST_LEFT + "profile" + ST_RIGHT, keywordLabelProvider.apply(profile)); + assertEquals(ST_LEFT + "profile" + ST_RIGHT, this.keywordLabelProvider.apply(profile)); } /** @@ -300,7 +315,17 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testProtocolStateMachineKeyword() { ProtocolStateMachine protocol = create(ProtocolStateMachine.class); - assertEquals(ST_LEFT + "protocol" + ST_RIGHT, keywordLabelProvider.apply(protocol)); + assertEquals(ST_LEFT + "protocol" + ST_RIGHT, this.keywordLabelProvider.apply(protocol)); + } + + /** + * Basic test case for {@link Reception} keyword. Prefix \u00ABsignal\u00BB + * should appear. + */ + @Test + public void testReceptionKeyword() { + Reception reception = create(Reception.class); + assertEquals(ST_LEFT + "signal" + ST_RIGHT, this.keywordLabelProvider.apply(reception)); } /** @@ -310,7 +335,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testSignalKeyword() { Signal signal = create(Signal.class); - assertEquals(ST_LEFT + "signal" + ST_RIGHT, keywordLabelProvider.apply(signal)); + assertEquals(ST_LEFT + "signal" + ST_RIGHT, this.keywordLabelProvider.apply(signal)); } /** @@ -320,7 +345,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testStateMachineKeyword() { StateMachine stateMachine = create(StateMachine.class); - assertEquals(ST_LEFT + "stateMachine" + ST_RIGHT, keywordLabelProvider.apply(stateMachine)); + assertEquals(ST_LEFT + "stateMachine" + ST_RIGHT, this.keywordLabelProvider.apply(stateMachine)); } /** @@ -330,7 +355,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testStereotypeKeyword() { Stereotype stereotype = create(Stereotype.class); - assertEquals(ST_LEFT + "stereotype" + ST_RIGHT, keywordLabelProvider.apply(stereotype)); + assertEquals(ST_LEFT + "stereotype" + ST_RIGHT, this.keywordLabelProvider.apply(stereotype)); } /** @@ -340,7 +365,7 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testSubstitutionKeyword() { Substitution substitution = create(Substitution.class); - assertEquals(ST_LEFT + "substitute" + ST_RIGHT, keywordLabelProvider.apply(substitution)); + assertEquals(ST_LEFT + "substitute" + ST_RIGHT, this.keywordLabelProvider.apply(substitution)); } /** @@ -350,6 +375,6 @@ public class KeywordLabelProviderTest extends AbstractUMLTest { @Test public void testUsageKeyword() { Usage usage = create(Usage.class); - assertEquals(ST_LEFT + "use" + ST_RIGHT, keywordLabelProvider.apply(usage)); + assertEquals(ST_LEFT + "use" + ST_RIGHT, this.keywordLabelProvider.apply(usage)); } } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/META-INF/MANIFEST.MF b/plugins/org.eclipse.papyrus.uml.domain.services/META-INF/MANIFEST.MF index f00a87a3fb1110a64e65d3afa482070f0d5466fd..210925587363c167d787e83fe3ffcd8c4c3529b1 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.papyrus.uml.domain.services/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.papyrus.uml.domain.services -Bundle-Version: 0.12.0.qualifier +Bundle-Version: 0.12.0 Bundle-Localization: plugin Automatic-Module-Name: org.eclipse.papyrus.uml.domain.services Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/pom.xml b/plugins/org.eclipse.papyrus.uml.domain.services/pom.xml index 37b4b182605994dc0ab2d699c0e442524d75495c..4ddb2ad2e6471ca824aa7a020a0a0fcf76ac0e59 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/pom.xml +++ b/plugins/org.eclipse.papyrus.uml.domain.services/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>papyrus-uml-domain-services</groupId> <artifactId>parent</artifactId> - <version>0.12.0-SNAPSHOT</version> + <version>0.12.0</version> <relativePath>../../parent</relativePath> </parent> diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurer.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurer.java index 4da91a0287fd5dcbba8814be2de94b325b65f77a..0b4f82737d790c3cfef0ed6dec286d37fe8677e4 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurer.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/create/ElementConfigurer.java @@ -16,11 +16,9 @@ package org.eclipse.papyrus.uml.domain.services.create; import org.eclipse.emf.ecore.EObject; import org.eclipse.papyrus.uml.domain.services.labels.ElementDefaultNameProvider; import org.eclipse.uml2.uml.AcceptCallAction; -import org.eclipse.uml2.uml.Activity; -import org.eclipse.uml2.uml.ActivityPartition; +import org.eclipse.uml2.uml.ActionExecutionSpecification; import org.eclipse.uml2.uml.AddStructuralFeatureValueAction; import org.eclipse.uml2.uml.AddVariableValueAction; -import org.eclipse.uml2.uml.ActionExecutionSpecification; import org.eclipse.uml2.uml.AggregationKind; import org.eclipse.uml2.uml.CallOperationAction; import org.eclipse.uml2.uml.Classifier; @@ -123,14 +121,6 @@ public class ElementConfigurer implements IElementConfigurer { return super.caseAcceptCallAction(acceptCallAction); } - @Override - public Void caseActivityPartition(ActivityPartition activityPartition) { - if (this.parent instanceof Activity) { - ((Activity) this.parent).getPartitions().add(activityPartition); - } - return super.caseActivityPartition(activityPartition); - } - @Override public Void caseAddStructuralFeatureValueAction( AddStructuralFeatureValueAction addStructuralFeatureValueAction) { diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/destroy/ElementDependencyCollector.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/destroy/ElementDependencyCollector.java index 6acf804c7981872f009581515e5e084d5eab957b..566fefc704a33ad215ad7d4e3569bb71d4317114 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/destroy/ElementDependencyCollector.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/destroy/ElementDependencyCollector.java @@ -36,6 +36,7 @@ import org.eclipse.papyrus.uml.domain.services.services.OccurrenceSpecificationH import org.eclipse.papyrus.uml.domain.services.services.TimeConstraintHelper; import org.eclipse.papyrus.uml.domain.services.services.TimeObservationHelper; import org.eclipse.papyrus.uml.domain.services.services.UMLService; +import org.eclipse.uml2.uml.ActivityNode; import org.eclipse.uml2.uml.Association; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Collaboration; @@ -90,7 +91,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector @Override public Set<EObject> collectDependencies(EObject source) { - DestroyDependencyCollectorSwitch collector = new DestroyDependencyCollectorSwitch(crossReferenceAdapter); + DestroyDependencyCollectorSwitch collector = new DestroyDependencyCollectorSwitch(this.crossReferenceAdapter); collector.doSwitch(source); return collector.getDependentsToRemove(); } @@ -136,7 +137,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector // If all sources from the directed relationship are to be destroyed, add the // relationship destruction if (directedRelationship.getSources().contains(namedElementToDelete)) { - dependentsToRemove.add(directedRelationship); + this.dependentsToRemove.add(directedRelationship); } } Iterator<DirectedRelationship> tgtRelationhipsIt = namedElementToDelete @@ -147,12 +148,26 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector // If all sources from the directed relationship are to be destroyed, add the // relationship destruction if (directedRelationship.getTargets().contains(namedElementToDelete)) { - dependentsToRemove.add(directedRelationship); + this.dependentsToRemove.add(directedRelationship); } } return super.caseNamedElement(namedElementToDelete); } + /** + * Action to launch before deleting a {@link ActivityNode}. See + * org.eclipse.papyrus.uml.service.types.helper.advice.ActivityNodeHelperAdvice.getDestroyActivityEdgeCommand(DestroyDependentsRequest) + * + * @param activityNodeToDelete + * the {@link ActivityNode} to remove. + */ + @Override + public Void caseActivityNode(ActivityNode activityNodeToDelete) { + this.dependentsToRemove.addAll(activityNodeToDelete.getOutgoings()); + this.dependentsToRemove.addAll(activityNodeToDelete.getIncomings()); + return super.caseActivityNode(activityNodeToDelete); + } + /** * Action to launch before deleting a {@link ConnectorEnd}. Copy from * {@link org.eclipse.papyrus.uml.service.types.helper.advice.ConnectorEndHelperAdvice.getBeforeDestroyDependentsCommand(DestroyDependentsRequest))} @@ -168,7 +183,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector public Void caseConnectorEnd(ConnectorEnd connectorEndToDelete) { Connector connector = (Connector) connectorEndToDelete.getOwner(); if (connector.getEnds().size() <= 2) { - dependentsToRemove.add(connector); + this.dependentsToRemove.add(connector); } return super.caseConnectorEnd(connectorEndToDelete); } @@ -191,7 +206,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector UMLPackage.eINSTANCE.getConnectorEnd_PartWithPort() }; Collection<EObject> connectorEndRefs = UMLService.getReferencers(propertyToDelete, refs, this.crossReferenceAdapter); - dependentsToRemove.addAll(connectorEndRefs); + this.dependentsToRemove.addAll(connectorEndRefs); // Get possible associations using this Property as end refs = new EReference[] { UMLPackage.eINSTANCE.getAssociation_MemberEnd() }; @@ -204,7 +219,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector List<Property> remainingMembers = new ArrayList<>(); remainingMembers.addAll(((Association) association).getMemberEnds()); if (remainingMembers.size() <= 2) { - dependentsToRemove.add(association); + this.dependentsToRemove.add(association); } } @@ -225,11 +240,11 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector public Void caseMessage(Message messageToDelete) { MessageEnd sendEvent = messageToDelete.getSendEvent(); if (sendEvent != null && !(isSharedEvent(sendEvent, messageToDelete))) { - dependentsToRemove.add(sendEvent); + this.dependentsToRemove.add(sendEvent); } MessageEnd receiveEvent = messageToDelete.getReceiveEvent(); if (receiveEvent != null && !(isSharedEvent(receiveEvent, messageToDelete))) { - dependentsToRemove.add(receiveEvent); + this.dependentsToRemove.add(receiveEvent); } return super.caseMessage(messageToDelete); } @@ -258,7 +273,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector // Retrieve the list of elements referencing the messageEnd. Set<EObject> crossReferences = new HashSet<EObject>(); - for (Setting setting : crossReferenceAdapter.getInverseReferences(messageEnd)) { + for (Setting setting : this.crossReferenceAdapter.getInverseReferences(messageEnd)) { EObject eObject = setting.getEObject(); if (!setting.getEStructuralFeature().equals(UMLPackage.eINSTANCE.getLifeline_CoveredBy())) { if (eObject.eClass().getEPackage().equals(mmPackage)) { @@ -294,9 +309,9 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector @Override public Void caseClassifier(Classifier classifierToDelete) { // Get related generalizations - dependentsToRemove.addAll( + this.dependentsToRemove.addAll( classifierToDelete.getSourceDirectedRelationships(UMLPackage.eINSTANCE.getGeneralization())); - dependentsToRemove.addAll( + this.dependentsToRemove.addAll( classifierToDelete.getTargetDirectedRelationships(UMLPackage.eINSTANCE.getGeneralization())); // Get related association for this classifier, then delete member ends for @@ -304,7 +319,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector for (Association association : classifierToDelete.getAssociations()) { for (Property end : association.getMemberEnds()) { if (end.getType() == classifierToDelete) { - dependentsToRemove.add(association); + this.dependentsToRemove.add(association); } } } @@ -313,10 +328,10 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector @Override public Void casePackage(Package object) { - crossReferenceAdapter.getInverseReferences(object, true).stream() + this.crossReferenceAdapter.getInverseReferences(object, true).stream() .filter(s -> s.getEStructuralFeature() == UMLPackage.eINSTANCE.getPackageImport_ImportedPackage() || s.getEStructuralFeature() == UMLPackage.eINSTANCE.getPackageMerge_MergedPackage()) - .map(s -> s.getEObject()).forEach(dependentsToRemove::add); + .map(s -> s.getEObject()).forEach(this.dependentsToRemove::add); return super.casePackage(object); } @@ -330,7 +345,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector */ @Override public Void caseCollaboration(Collaboration collaborationToDelete) { - dependentsToRemove.addAll(CollaborationHelper.getRelatedRoleBindings(collaborationToDelete, null, + this.dependentsToRemove.addAll(CollaborationHelper.getRelatedRoleBindings(collaborationToDelete, null, this.crossReferenceAdapter)); return super.caseCollaboration(collaborationToDelete); } @@ -353,7 +368,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector Stream<TimeObservation> timeObservations = OccurrenceSpecificationHelper.getTimeObservations(interaction, destructionToDelete); - dependentsToRemove.addAll(Stream.concat(timeConstraints, timeObservations).collect(toList())); + this.dependentsToRemove.addAll(Stream.concat(timeConstraints, timeObservations).collect(toList())); return super.caseDestructionOccurrenceSpecification(destructionToDelete); } @@ -372,13 +387,13 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector OccurrenceSpecification osStart = esToDelete.getStart(); if (OccurrenceSpecificationHelper.shouldDestroyOccurrenceSpecification(esToDelete, osStart, this.crossReferenceAdapter) && (!(osStart instanceof MessageEnd))) { - dependentsToRemove.add(osStart); + this.dependentsToRemove.add(osStart); } OccurrenceSpecification osFinish = esToDelete.getFinish(); if (OccurrenceSpecificationHelper.shouldDestroyOccurrenceSpecification(esToDelete, osFinish, this.crossReferenceAdapter) && (!(osFinish instanceof MessageEnd))) { - dependentsToRemove.add(osFinish); + this.dependentsToRemove.add(osFinish); } return super.caseExecutionSpecification(esToDelete); @@ -396,19 +411,19 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector for (InteractionFragment ift : lifelineToDelete.getCoveredBys()) { // Destroy covered ExecutionSpecification if (ift instanceof ExecutionSpecification) { - dependentsToRemove.add(ift); + this.dependentsToRemove.add(ift); } // Destroy related Message // Destroy related Message if ((ift instanceof MessageOccurrenceSpecification) && (((MessageOccurrenceSpecification) ift).getMessage() != null)) { - dependentsToRemove.add(((MessageOccurrenceSpecification) ift).getMessage()); + this.dependentsToRemove.add(((MessageOccurrenceSpecification) ift).getMessage()); } // Destroy covered OccurrenceSpecification if (ift instanceof OccurrenceSpecification) { - dependentsToRemove.add(ift); + this.dependentsToRemove.add(ift); } } @@ -416,7 +431,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector PartDecomposition decomposition = lifelineToDelete.getDecomposedAs(); if (decomposition != null && UMLService.isOnlyUsage(decomposition, lifelineToDelete, this.crossReferenceAdapter)) { - dependentsToRemove.add(decomposition); + this.dependentsToRemove.add(decomposition); } return super.caseLifeline(lifelineToDelete); } @@ -445,43 +460,43 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector if (currentEObject instanceof Message) { Message m = (Message) currentEObject; if (osToDelete.equals(m.getSendEvent())) { - dependentsToRemove.add(m); + this.dependentsToRemove.add(m); if (m.getReceiveEvent() != null) { - dependentsToRemove.add(m.getReceiveEvent()); + this.dependentsToRemove.add(m.getReceiveEvent()); } } if (osToDelete.equals(m.getReceiveEvent())) { - dependentsToRemove.add(m); + this.dependentsToRemove.add(m); if (m.getSendEvent() != null) { - dependentsToRemove.add(m.getSendEvent()); + this.dependentsToRemove.add(m.getSendEvent()); } } } if (currentEObject instanceof ExecutionSpecification) { ExecutionSpecification exec = (ExecutionSpecification) currentEObject; if (osToDelete.equals(exec.getStart())) { - dependentsToRemove.add(exec); + this.dependentsToRemove.add(exec); if (exec.getFinish() != null && !(exec.getFinish() instanceof MessageEnd)) { - dependentsToRemove.add(exec.getFinish()); + this.dependentsToRemove.add(exec.getFinish()); } } if (osToDelete.equals(exec.getFinish())) { - dependentsToRemove.add(exec); + this.dependentsToRemove.add(exec); if (exec.getStart() != null && !(exec.getStart() instanceof MessageEnd)) { - dependentsToRemove.add(exec.getStart()); + this.dependentsToRemove.add(exec.getStart()); } } } } } // delete linked time elements - dependentsToRemove + this.dependentsToRemove .addAll(TimeObservationHelper.getTimeObservations(osToDelete, this.crossReferenceAdapter)); - dependentsToRemove + this.dependentsToRemove .addAll(TimeConstraintHelper.getTimeConstraintsOn(osToDelete, this.crossReferenceAdapter)); - dependentsToRemove.addAll( + this.dependentsToRemove.addAll( DurationObservationHelper.getDurationObservationsOn(osToDelete, this.crossReferenceAdapter)); - dependentsToRemove + this.dependentsToRemove .addAll(DurationConstraintHelper.getDurationConstraintsOn(osToDelete, this.crossReferenceAdapter)); // delete linked general ordering @@ -490,8 +505,8 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector * references 'GeneralOrdering::before[1]' and 'GeneralOrdering::after[1]' which * designate this OccurrenceSpecification are mandatory */ - dependentsToRemove.addAll(osToDelete.getToBefores()); - dependentsToRemove.addAll(osToDelete.getToAfters()); + this.dependentsToRemove.addAll(osToDelete.getToBefores()); + this.dependentsToRemove.addAll(osToDelete.getToAfters()); return super.caseOccurrenceSpecification(osToDelete); } @@ -502,8 +517,8 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector */ @Override public Void caseVertex(Vertex vertex) { - dependentsToRemove.addAll(vertex.getIncomings()); - dependentsToRemove.addAll(vertex.getOutgoings()); + this.dependentsToRemove.addAll(vertex.getIncomings()); + this.dependentsToRemove.addAll(vertex.getOutgoings()); return super.caseVertex(vertex); } @@ -521,13 +536,13 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector EList<Property> ownedEnds = association.getOwnedEnds(); for (Property end : association.getMemberEnds()) { if (ownedEnds.contains(end)) { - dependentsToRemove.add(end); + this.dependentsToRemove.add(end); } else if (end.getType() != null) { // when user set the source or target property (not owned by association) type // to null, the association is removed (because it cannot be defined without a // source or target type) but we do not remove the source or target property // with the type null. - dependentsToRemove.add(end); + this.dependentsToRemove.add(end); } } return super.caseAssociation(association); @@ -536,16 +551,16 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector @Override public Void caseUseCase(UseCase useCase) { // Delete related includes - dependentsToRemove.addAll(useCase.getSourceDirectedRelationships(UMLPackage.eINSTANCE.getInclude())); - dependentsToRemove.addAll(useCase.getTargetDirectedRelationships(UMLPackage.eINSTANCE.getInclude())); + this.dependentsToRemove.addAll(useCase.getSourceDirectedRelationships(UMLPackage.eINSTANCE.getInclude())); + this.dependentsToRemove.addAll(useCase.getTargetDirectedRelationships(UMLPackage.eINSTANCE.getInclude())); // Delete related extends - dependentsToRemove.addAll(useCase.getSourceDirectedRelationships(UMLPackage.eINSTANCE.getExtend())); - dependentsToRemove.addAll(useCase.getTargetDirectedRelationships(UMLPackage.eINSTANCE.getExtend())); + this.dependentsToRemove.addAll(useCase.getSourceDirectedRelationships(UMLPackage.eINSTANCE.getExtend())); + this.dependentsToRemove.addAll(useCase.getTargetDirectedRelationships(UMLPackage.eINSTANCE.getExtend())); return super.caseUseCase(useCase); } public Set<EObject> getDependentsToRemove() { - return dependentsToRemove; + return this.dependentsToRemove; } @Override @@ -554,7 +569,7 @@ public class ElementDependencyCollector implements IDestroyerDependencyCollector CombinedFragment combinedFragment = (CombinedFragment) interactionOperand.getOwner(); if (combinedFragment.getOperands().size() == 1 && combinedFragment.getOperands().contains(interactionOperand)) { - dependentsToRemove.add(combinedFragment); + this.dependentsToRemove.add(combinedFragment); } } return super.caseInteractionOperand(interactionOperand); diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropBehaviorProvider.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropBehaviorProvider.java index fed8014ec1e6e0514de8a1cd853d512093a5ad57..2f98f9d324bd51dad03d1ed2782efe80d36405c3 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropBehaviorProvider.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropBehaviorProvider.java @@ -61,7 +61,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseActivity(Activity activity) { - if (target instanceof Activity) { + if (this.target instanceof Activity) { return DnDStatus.createNothingStatus(Set.of(activity)); } return super.caseActivity(activity); @@ -69,15 +69,12 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseActivityEdge(ActivityEdge activityEdge) { - if (target instanceof Activity || target instanceof ActivityGroup) { return DnDStatus.createNothingStatus(Set.of(activityEdge)); - } - return super.caseActivityEdge(activityEdge); } @Override public DnDStatus caseActivityNode(ActivityNode activityNode) { - if (target instanceof Activity || target instanceof ActivityGroup) { + if (this.target instanceof Activity || this.target instanceof ActivityGroup) { return DnDStatus.createNothingStatus(Set.of(activityNode)); } return super.caseActivityNode(activityNode); @@ -85,7 +82,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseActivityParameterNode(ActivityParameterNode activityParameterNode) { - if (target instanceof Activity) { + if (this.target instanceof Activity) { return DnDStatus.createNothingStatus(Set.of(activityParameterNode)); } return DnDStatus.createFailingStatus("ActivityParameterNode can only be drag and drop on an Activity.", @@ -94,7 +91,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseActivityPartition(ActivityPartition activityPartition) { - if (target instanceof Activity || target instanceof ActivityPartition) { + if (this.target instanceof Activity || this.target instanceof ActivityPartition) { return DnDStatus.createNothingStatus(Set.of(activityPartition)); } return super.caseActivityPartition(activityPartition); @@ -102,7 +99,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseComment(Comment comment) { - if (target instanceof Activity || target instanceof ActivityGroup) { + if (this.target instanceof Activity || this.target instanceof ActivityGroup) { return DnDStatus.createNothingStatus(Set.of(comment)); } return super.caseComment(comment); @@ -110,7 +107,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseConstraint(Constraint constraint) { - if (target instanceof Activity || target instanceof StructuredActivityNode) { + if (this.target instanceof Activity || this.target instanceof StructuredActivityNode) { return DnDStatus.createNothingStatus(Set.of(constraint)); } return super.caseConstraint(constraint); @@ -118,7 +115,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseExpansionNode(ExpansionNode expansionNode) { - if (target instanceof ExpansionRegion) { + if (this.target instanceof ExpansionRegion) { return DnDStatus.createNothingStatus(Set.of(expansionNode)); } return DnDStatus.createFailingStatus("ExpansionNode can only be drag and drop on an ExpansionRegion.", @@ -127,7 +124,7 @@ public class ActivityExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseInterruptibleActivityRegion(InterruptibleActivityRegion interruptibleActivityRegion) { - if (target instanceof Activity) { + if (this.target instanceof Activity) { return DnDStatus.createNothingStatus(Set.of(interruptibleActivityRegion)); } return super.caseInterruptibleActivityRegion(interruptibleActivityRegion); diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropChecker.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropChecker.java index d06795618f4ea60760f58f9d4d0bd238c3e823dc..a50cc8fe390c80e5d29458f45516ecd5a7e6af4d 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropChecker.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityExternalSourceToRepresentationDropChecker.java @@ -19,7 +19,6 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.papyrus.uml.domain.services.drop.IExternalSourceToRepresentationDropChecker; import org.eclipse.papyrus.uml.domain.services.status.CheckStatus; import org.eclipse.uml2.uml.Activity; -import org.eclipse.uml2.uml.ActivityEdge; import org.eclipse.uml2.uml.ActivityGroup; import org.eclipse.uml2.uml.ActivityNode; import org.eclipse.uml2.uml.ActivityParameterNode; @@ -65,7 +64,7 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter @Override public CheckStatus caseActivity(Activity activity) { final CheckStatus result; - if (newSemanticContainer instanceof Activity) { + if (this.newSemanticContainer instanceof Activity) { result = CheckStatus.YES; } else { result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, activity.eClass().getName(), @@ -74,25 +73,12 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter return result; } - @Override - public CheckStatus caseActivityEdge(ActivityEdge activityEdge) { - CheckStatus result = null; - if (newSemanticContainer instanceof Activity || newSemanticContainer instanceof ActivityGroup) { - result = CheckStatus.YES; - } else { - result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, activityEdge.eClass().getName(), - UMLPackage.eINSTANCE.getActivity().getName() + COMA - + UMLPackage.eINSTANCE.getActivityGroup().getName())); - } - return result; - } - @Override public CheckStatus caseActivityNode(ActivityNode activityNode) { CheckStatus result = null; - if (newSemanticContainer instanceof Activity || newSemanticContainer instanceof ActivityGroup) { + if (this.newSemanticContainer instanceof Activity || this.newSemanticContainer instanceof ActivityGroup) { result = CheckStatus.YES; - if (newSemanticContainer instanceof SequenceNode && !(activityNode instanceof ExecutableNode)) { + if (this.newSemanticContainer instanceof SequenceNode && !(activityNode instanceof ExecutableNode)) { result = CheckStatus.no(MessageFormat.format(CANNOT_DND_ON_ERROR_MSG, activityNode.eClass().getName(), UMLPackage.eINSTANCE.getSequenceNode().getName())); } @@ -107,7 +93,7 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter @Override public CheckStatus caseActivityParameterNode(ActivityParameterNode activityParameterNode) { final CheckStatus result; - if (newSemanticContainer instanceof Activity) { + if (this.newSemanticContainer instanceof Activity) { result = CheckStatus.YES; } else { result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, @@ -119,7 +105,7 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter @Override public CheckStatus caseActivityPartition(ActivityPartition activityPartition) { final CheckStatus result; - if (newSemanticContainer instanceof Activity || newSemanticContainer instanceof ActivityPartition) { + if (this.newSemanticContainer instanceof Activity || this.newSemanticContainer instanceof ActivityPartition) { result = CheckStatus.YES; } else { result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, @@ -132,7 +118,7 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter @Override public CheckStatus caseComment(Comment comment) { final CheckStatus result; - if (newSemanticContainer instanceof ActivityGroup || newSemanticContainer instanceof Activity) { + if (this.newSemanticContainer instanceof ActivityGroup || this.newSemanticContainer instanceof Activity) { result = CheckStatus.YES; } else { result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, comment.eClass().getName(), @@ -145,7 +131,7 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter @Override public CheckStatus caseConstraint(Constraint constraint) { final CheckStatus result; - if (newSemanticContainer instanceof StructuredActivityNode || newSemanticContainer instanceof Activity) { + if (this.newSemanticContainer instanceof StructuredActivityNode || this.newSemanticContainer instanceof Activity) { result = CheckStatus.YES; } else { result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, constraint.eClass().getName(), @@ -158,7 +144,7 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter @Override public CheckStatus caseExpansionNode(ExpansionNode expansionNode) { final CheckStatus result; - if (newSemanticContainer instanceof ExpansionRegion) { + if (this.newSemanticContainer instanceof ExpansionRegion) { result = CheckStatus.YES; } else { result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, @@ -170,7 +156,7 @@ public class ActivityExternalSourceToRepresentationDropChecker implements IExter @Override public CheckStatus caseInterruptibleActivityRegion(InterruptibleActivityRegion interruptibleActivityRegion) { final CheckStatus result; - if (newSemanticContainer instanceof Activity) { + if (this.newSemanticContainer instanceof Activity) { result = CheckStatus.YES; } else { result = CheckStatus.no(MessageFormat.format(CAN_ONLY_DND_ON_ERROR_MSG, diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityInternalSourceToRepresentationDropBehaviorProvider.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityInternalSourceToRepresentationDropBehaviorProvider.java index b7497fd2dc75a29942aa8db04315f95fc2bafa77..ebd2d384a8bd7559b61e73cc47325d20685e81aa 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityInternalSourceToRepresentationDropBehaviorProvider.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/ActivityInternalSourceToRepresentationDropBehaviorProvider.java @@ -18,6 +18,7 @@ import java.util.Optional; import java.util.Set; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; import org.eclipse.papyrus.uml.domain.services.IEditableChecker; import org.eclipse.papyrus.uml.domain.services.drop.IInternalSourceToRepresentationDropBehaviorProvider; @@ -86,14 +87,14 @@ public class ActivityInternalSourceToRepresentationDropBehaviorProvider @Override public Status caseElement(Element droppedElement) { Status dropStatus; - IFeatureModifier modifier = new ElementFeatureModifier(crossRef, editableChecker); - if (oldContainer != newContainer) { + IFeatureModifier modifier = new ElementFeatureModifier(this.crossRef, this.editableChecker); + if (this.oldContainer != this.newContainer) { String refName = droppedElement.eContainmentFeature().getName(); - if (oldContainer.eClass().getEStructuralFeature(refName) != null - && newContainer.eClass().getEStructuralFeature(refName) != null) { - dropStatus = modifier.removeValue(oldContainer, refName, droppedElement); + if (this.oldContainer.eClass().getEStructuralFeature(refName) != null + && this.newContainer.eClass().getEStructuralFeature(refName) != null) { + dropStatus = modifier.removeValue(this.oldContainer, refName, droppedElement); if (State.DONE == dropStatus.getState()) { - dropStatus = modifier.addValue(newContainer, refName, droppedElement); + dropStatus = modifier.addValue(this.newContainer, refName, droppedElement); } return dropStatus; } @@ -119,21 +120,18 @@ public class ActivityInternalSourceToRepresentationDropBehaviorProvider @Override public Status caseActivityPartition(ActivityPartition droppedActivityPartition) { Status dropStatus; - IFeatureModifier modifier = new ElementFeatureModifier(crossRef, editableChecker); - if (oldContainer != newContainer) { - String refName = droppedActivityPartition.eContainmentFeature().getName(); - dropStatus = modifier.removeValue(oldContainer, refName, droppedActivityPartition); - if (State.DONE == dropStatus.getState()) { - if (newContainer instanceof Activity) { - dropStatus = modifier.addValue(newContainer, - UMLPackage.eINSTANCE.getActivity_OwnedGroup().getName(), droppedActivityPartition); - ((Activity) newContainer).getPartitions().add(droppedActivityPartition); - } - if (newContainer instanceof ActivityPartition) { - dropStatus = modifier.addValue(newContainer, - UMLPackage.eINSTANCE.getActivityPartition_Subpartition().getName(), - droppedActivityPartition); - } + IFeatureModifier modifier = new ElementFeatureModifier(this.crossRef, this.editableChecker); + if (this.oldContainer != this.newContainer) { + if (this.newContainer instanceof Activity) { + dropStatus = modifier.addValue(this.newContainer, + UMLPackage.eINSTANCE.getActivity_Partition().getName(), droppedActivityPartition); + } else if (this.newContainer instanceof ActivityPartition) { + dropStatus = modifier.addValue(this.newContainer, + UMLPackage.eINSTANCE.getActivityPartition_Subpartition().getName(), + droppedActivityPartition); + } else { + dropStatus = Status.createFailingStatus( + "An ActivityPartition can only be dropped in an Activity or ActivityPartition"); } return dropStatus; } @@ -161,42 +159,58 @@ public class ActivityInternalSourceToRepresentationDropBehaviorProvider */ @Override public Status caseActivityNode(ActivityNode droppedActivityNode) { + if (this.oldContainer != this.newContainer) { + return handleActivityNode(droppedActivityNode, UMLPackage.eINSTANCE.getActivity_OwnedNode()); + } + return super.caseActivityNode(droppedActivityNode); + } + + private Status handleActivityNode(ActivityNode droppedActivityNode, + EStructuralFeature parentActivityContainmentFeature) { + IFeatureModifier modifier = new ElementFeatureModifier(this.crossRef, this.editableChecker); Status dropStatus; - IFeatureModifier modifier = new ElementFeatureModifier(crossRef, editableChecker); - if (oldContainer != newContainer) { - if (oldContainer instanceof Activity) { - dropStatus = modifier.removeValue(oldContainer, - UMLPackage.eINSTANCE.getActivity_OwnedNode().getName(), droppedActivityNode); - } else if (oldContainer instanceof ActivityGroup && !(oldContainer instanceof StructuredActivityNode)) { - dropStatus = removeActivityNodeInActivityGroup((ActivityGroup) oldContainer, droppedActivityNode); - } else if (oldContainer instanceof StructuredActivityNode) { - dropStatus = modifier.removeValue(oldContainer, + if (this.oldContainer instanceof Activity) { + dropStatus = modifier.removeValue(this.oldContainer, parentActivityContainmentFeature.getName(), + droppedActivityNode); + } else if (this.oldContainer instanceof ActivityGroup + && !(this.oldContainer instanceof StructuredActivityNode)) { + dropStatus = removeActivityNodeInActivityGroup((ActivityGroup) this.oldContainer, droppedActivityNode); + } else if (this.oldContainer instanceof StructuredActivityNode) { + dropStatus = modifier.removeValue(this.oldContainer, + UMLPackage.eINSTANCE.getStructuredActivityNode_Node().getName(), droppedActivityNode); + } else { + dropStatus = Status.createFailingStatus(MessageFormat.format( + "The old container could not be modified, its type is not managed when dragging and dropping {0}.", + droppedActivityNode.eClass().getName())); + } + if (State.DONE == dropStatus.getState()) { + if (this.newContainer instanceof Activity) { + dropStatus = modifier.addValue(this.newContainer, parentActivityContainmentFeature.getName(), + droppedActivityNode); + } else if (this.newContainer instanceof ActivityGroup + && !(this.newContainer instanceof StructuredActivityNode)) { + dropStatus = addActivityNodeInActivityGroup((ActivityGroup) this.newContainer, droppedActivityNode, + parentActivityContainmentFeature); + } else if (this.newContainer instanceof StructuredActivityNode) { + dropStatus = modifier.addValue(this.newContainer, UMLPackage.eINSTANCE.getStructuredActivityNode_Node().getName(), droppedActivityNode); } else { dropStatus = Status.createFailingStatus(MessageFormat.format( - "The old container could not be modified, its type is not managed when dragging and dropping {0}.", + "The new container could not be modified, its type is not managed when dragging and dropping {0}.", droppedActivityNode.eClass().getName())); } - if (State.DONE == dropStatus.getState()) { - if (newContainer instanceof Activity) { - dropStatus = modifier.addValue(newContainer, - UMLPackage.eINSTANCE.getActivity_OwnedNode().getName(), droppedActivityNode); - } else if (newContainer instanceof ActivityGroup - && !(newContainer instanceof StructuredActivityNode)) { - dropStatus = addActivityNodeInActivityGroup((ActivityGroup) newContainer, droppedActivityNode); - } else if (newContainer instanceof StructuredActivityNode) { - dropStatus = modifier.addValue(newContainer, - UMLPackage.eINSTANCE.getStructuredActivityNode_Node().getName(), droppedActivityNode); - } else { - dropStatus = Status.createFailingStatus(MessageFormat.format( - "The new container could not be modified, its type is not managed when dragging and dropping {0}.", - droppedActivityNode.eClass().getName())); - } - } - updateActivityEdgesFromActivityNode(droppedActivityNode, dropStatus); - return dropStatus; } - return super.caseActivityNode(droppedActivityNode); + updateActivityEdgesFromActivityNode(droppedActivityNode, dropStatus); + return dropStatus; + } + + @Override + public Status caseStructuredActivityNode(StructuredActivityNode droppedStructuredActivityNode) { + if (this.oldContainer != this.newContainer) { + return handleActivityNode(droppedStructuredActivityNode, + UMLPackage.eINSTANCE.getActivity_StructuredNode()); + } + return super.caseStructuredActivityNode(droppedStructuredActivityNode); } /** @@ -260,7 +274,7 @@ public class ActivityInternalSourceToRepresentationDropBehaviorProvider private Status removeActivityNodeInActivityGroup(ActivityGroup container, ActivityNode droppedActivityNode) { Status dropStatus; Activity parentActivity = findActivity(container); - IFeatureModifier modifier = new ElementFeatureModifier(crossRef, editableChecker); + IFeatureModifier modifier = new ElementFeatureModifier(this.crossRef, this.editableChecker); if (parentActivity != null) { dropStatus = modifier.removeValue(parentActivity, UMLPackage.eINSTANCE.getActivity_OwnedNode().getName(), droppedActivityNode); @@ -288,18 +302,24 @@ public class ActivityInternalSourceToRepresentationDropBehaviorProvider * InterruptibleActivityRegion. * * @param container - * the ActivityPartition or - * InterruptibleActivityRegion graphic container + * the ActivityPartition or + * InterruptibleActivityRegion graphic + * container * @param droppedActivityNode - * the element to drop + * the element to drop + * @param parentActivityContainmentFeature + * the containment feature that will own + * the dropped {@link ActivityNode} in + * the parent {@link Activity}. * @return OK or Failing status according to the complete D&D. */ - private Status addActivityNodeInActivityGroup(ActivityGroup container, ActivityNode droppedActivityNode) { + private Status addActivityNodeInActivityGroup(ActivityGroup container, ActivityNode droppedActivityNode, + EStructuralFeature parentActivityContainmentFeature) { Status dropStatus; Activity parentActivity = findActivity(container); - IFeatureModifier modifier = new ElementFeatureModifier(crossRef, editableChecker); + IFeatureModifier modifier = new ElementFeatureModifier(this.crossRef, this.editableChecker); if (parentActivity != null) { - dropStatus = modifier.addValue(parentActivity, UMLPackage.eINSTANCE.getActivity_OwnedNode().getName(), + dropStatus = modifier.addValue(parentActivity, parentActivityContainmentFeature.getName(), droppedActivityNode); String featureName = null; if (State.DONE == dropStatus.getState()) { diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropBehaviorProvider.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropBehaviorProvider.java index b2e5bc634d298d76d8c652a0f63433cb2d3997fe..af303f6b762404af0092361fc235ee8b937eb60a 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropBehaviorProvider.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropBehaviorProvider.java @@ -72,7 +72,7 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseComment(Comment comment) { - if (target instanceof Interaction) { + if (this.target instanceof Interaction) { return DnDStatus.createNothingStatus(Set.of(comment)); } return super.caseComment(comment); @@ -80,7 +80,7 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseConstraint(Constraint constraint) { - if (target instanceof Interaction) { + if (this.target instanceof Interaction) { return DnDStatus.createNothingStatus(Set.of(constraint)); } return super.caseConstraint(constraint); @@ -88,7 +88,7 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseDurationObservation(DurationObservation durationObservation) { - if (target instanceof Interaction) { + if (this.target instanceof Interaction) { return DnDStatus.createNothingStatus(Set.of(durationObservation)); } return super.caseDurationObservation(durationObservation); @@ -96,7 +96,7 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseLifeline(Lifeline lifeline) { - if (target instanceof Interaction) { + if (this.target instanceof Interaction) { return DnDStatus.createNothingStatus(Set.of(lifeline)); } return super.caseLifeline(lifeline); @@ -104,17 +104,15 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseMessage(Message message) { - if (target instanceof Interaction) { - return DnDStatus.createNothingStatus(Set.of(message)); - } - return super.caseMessage(message); + // Since Message is an Edge, it is always DnD, whatever the target mapping + return DnDStatus.createNothingStatus(Set.of(message)); } @Override public DnDStatus caseProperty(Property property) { // Drop a Property on a Lifeline will type (represents) the lifeline - if (target instanceof Lifeline) { - ((Lifeline) target).setRepresents(property); + if (this.target instanceof Lifeline) { + ((Lifeline) this.target).setRepresents(property); return DnDStatus.createOKStatus(Collections.emptySet()); } return super.caseProperty(property); @@ -122,7 +120,7 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseTimeObservation(TimeObservation timeObservation) { - if (target instanceof Interaction) { + if (this.target instanceof Interaction) { return DnDStatus.createNothingStatus(Set.of(timeObservation)); } return super.caseTimeObservation(timeObservation); @@ -130,33 +128,38 @@ public class CommunicationExternalSourceToRepresentationDropBehaviorProvider @Override public DnDStatus caseType(Type type) { - if (target instanceof Interaction || target instanceof Lifeline) { + if (this.target instanceof Interaction || this.target instanceof Lifeline) { ElementFeatureModifier featureModifier = new ElementFeatureModifier(this.crossRef, this.editableChecker); ElementCreator elementCreator = new ElementCreator(new ElementConfigurer(), featureModifier); Lifeline lifeLineToDrop = null; Property propertyToRepresents = null; - if (target instanceof Interaction) { + if (this.target instanceof Interaction) { // Drop a Classifier on an Interaction : create a new lifeline, a new Property // in the interaction typed by the dropped classifier and the new Lifeline will // represent this property. - CreationStatus createProperty = elementCreator.create(target, UMLPackage.eINSTANCE.getProperty().getName(), UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute().getName()); + CreationStatus createProperty = elementCreator.create(this.target, + UMLPackage.eINSTANCE.getProperty().getName(), + UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute().getName()); propertyToRepresents = (Property) createProperty.getElement(); - CreationStatus createLifeline = elementCreator.create(target, UMLPackage.eINSTANCE.getLifeline().getName(), UMLPackage.eINSTANCE.getInteraction_Lifeline().getName()); + CreationStatus createLifeline = elementCreator.create(this.target, + UMLPackage.eINSTANCE.getLifeline().getName(), + UMLPackage.eINSTANCE.getInteraction_Lifeline().getName()); lifeLineToDrop = (Lifeline) createLifeline.getElement(); } else { // Drop a Classifier on a Lifeline : create a new Property in the interaction // typed by the dropped classifier and the target Lifeline will represent this // property. - CreationStatus createProperty = elementCreator.create(getInteraction(target), UMLPackage.eINSTANCE.getProperty().getName(), + CreationStatus createProperty = elementCreator.create(this.getInteraction(this.target), + UMLPackage.eINSTANCE.getProperty().getName(), UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute().getName()); propertyToRepresents = (Property) createProperty.getElement(); - lifeLineToDrop = (Lifeline) target; + lifeLineToDrop = (Lifeline) this.target; } propertyToRepresents.setType(type); lifeLineToDrop.setRepresents(propertyToRepresents); DnDStatus dnDStatus = null; - if (target instanceof Interaction) { + if (this.target instanceof Interaction) { dnDStatus = DnDStatus.createOKStatus(Set.of(lifeLineToDrop)); } else { dnDStatus = DnDStatus.createOKStatus(Collections.emptySet()); diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropChecker.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropChecker.java index fa7c45ea38f37752f975ab26add73aa7395b4cac..a5b959bece61c65a8a5c4a8ff696e0ffadf3249d 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropChecker.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CommunicationExternalSourceToRepresentationDropChecker.java @@ -19,10 +19,8 @@ import org.eclipse.papyrus.uml.domain.services.status.CheckStatus; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Constraint; import org.eclipse.uml2.uml.DurationObservation; -import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.Interaction; import org.eclipse.uml2.uml.Lifeline; -import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.TimeObservation; import org.eclipse.uml2.uml.Type; @@ -55,7 +53,7 @@ public class CommunicationExternalSourceToRepresentationDropChecker @Override public CheckStatus caseComment(Comment comment) { final CheckStatus result; - if (!(newSemanticContainer instanceof Interaction)) { + if (!(this.newSemanticContainer instanceof Interaction)) { result = CheckStatus.no("Comment can only be drag and drop on an Interaction."); } else { result = CheckStatus.YES; @@ -66,7 +64,7 @@ public class CommunicationExternalSourceToRepresentationDropChecker @Override public CheckStatus caseConstraint(Constraint constraint) { final CheckStatus result; - if (!(newSemanticContainer instanceof Interaction)) { + if (!(this.newSemanticContainer instanceof Interaction)) { result = CheckStatus.no("Constraint can only be drag and drop on an Interaction."); } else { result = CheckStatus.YES; @@ -77,7 +75,7 @@ public class CommunicationExternalSourceToRepresentationDropChecker @Override public CheckStatus caseDurationObservation(DurationObservation durationObservation) { final CheckStatus result; - if (!(newSemanticContainer instanceof Interaction)) { + if (!(this.newSemanticContainer instanceof Interaction)) { result = CheckStatus.no("DurationObservation can only be drag and drop on an Interaction."); } else { result = CheckStatus.YES; @@ -88,7 +86,7 @@ public class CommunicationExternalSourceToRepresentationDropChecker @Override public CheckStatus caseLifeline(Lifeline lifeline) { final CheckStatus result; - if (!(newSemanticContainer instanceof Interaction)) { + if (!(this.newSemanticContainer instanceof Interaction)) { result = CheckStatus.no("Lifeline can only be drag and drop on an Interaction."); } else { result = CheckStatus.YES; @@ -96,21 +94,10 @@ public class CommunicationExternalSourceToRepresentationDropChecker return result; } - @Override - public CheckStatus caseMessage(Message message) { - final CheckStatus result; - if (!(newSemanticContainer instanceof Interaction)) { - result = CheckStatus.no("Message can only be drag and drop on an Interaction."); - } else { - result = CheckStatus.YES; - } - return result; - } - @Override public CheckStatus caseProperty(Property property) { final CheckStatus result; - if (!(newSemanticContainer instanceof Lifeline)) { + if (!(this.newSemanticContainer instanceof Lifeline)) { result = CheckStatus.no("Property can only be drag and drop on an Lifeline."); } else { result = CheckStatus.YES; @@ -121,7 +108,7 @@ public class CommunicationExternalSourceToRepresentationDropChecker @Override public CheckStatus caseTimeObservation(TimeObservation timeObservation) { final CheckStatus result; - if (!(newSemanticContainer instanceof Interaction)) { + if (!(this.newSemanticContainer instanceof Interaction)) { result = CheckStatus.no("TimeObservation can only be drag and drop on an Interaction."); } else { result = CheckStatus.YES; @@ -132,7 +119,8 @@ public class CommunicationExternalSourceToRepresentationDropChecker @Override public CheckStatus caseType(Type type) { final CheckStatus result; - if (!(newSemanticContainer instanceof Interaction) && !(newSemanticContainer instanceof Lifeline)) { + if (!(this.newSemanticContainer instanceof Interaction) + && !(this.newSemanticContainer instanceof Lifeline)) { result = CheckStatus.no("Type can only be drag and drop on an Interaction or a Lifeline."); } else { result = CheckStatus.YES; @@ -141,7 +129,7 @@ public class CommunicationExternalSourceToRepresentationDropChecker } @Override - public CheckStatus caseElement(Element obj) { + public CheckStatus defaultCase(EObject object) { return CheckStatus.no("DnD is not authorized."); } } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropBehaviorProvider.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropBehaviorProvider.java index cd6f3d454f924ab202a8031c3fd2b67b6d08dacb..a58c1b82e8df3f2b6877b6210505edf3dfad7295 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropBehaviorProvider.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropBehaviorProvider.java @@ -22,6 +22,8 @@ import org.eclipse.papyrus.uml.domain.services.IEditableChecker; import org.eclipse.papyrus.uml.domain.services.drop.DnDStatus; import org.eclipse.papyrus.uml.domain.services.drop.IExternalSourceToRepresentationDropBehaviorProvider; import org.eclipse.papyrus.uml.domain.services.modify.ElementFeatureModifier; +import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.CollaborationUse; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLPackage; @@ -76,6 +78,17 @@ public class CompositeStructureExternalSourceToRepresentationDropBehaviorProvide return super.caseType(type); } + @Override + public DnDStatus caseCollaboration(Collaboration collaboration) { + if (target instanceof CollaborationUse) { + CollaborationUse targetCollaborationUse = (CollaborationUse) target; + new ElementFeatureModifier(this.crossRef, this.editableChecker).setValue(targetCollaborationUse, + UMLPackage.eINSTANCE.getCollaborationUse_Type().getName(), collaboration); + return DnDStatus.createOKStatus(Set.of(collaboration)); + } + return super.caseCollaboration(collaboration); + } + } } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropChecker.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropChecker.java index fc5378e938ab1e73acfe9349874de8a6799f78d8..096432469804177121ffe768f30a5eb5df7b96e4 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropChecker.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/drop/diagrams/CompositeStructureExternalSourceToRepresentationDropChecker.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2022 CEA LIST, OBEO + * Copyright (c) 2022, 2023 CEA LIST, Obeo. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -9,7 +9,7 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * OBEO - Initial API and implementation + * Obeo - Initial API and implementation *****************************************************************************/ package org.eclipse.papyrus.uml.domain.services.drop.diagrams; @@ -17,6 +17,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.papyrus.uml.domain.services.drop.IExternalSourceToRepresentationDropChecker; import org.eclipse.papyrus.uml.domain.services.status.CheckStatus; import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.CollaborationUse; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.StructuredClassifier; @@ -66,10 +67,12 @@ public class CompositeStructureExternalSourceToRepresentationDropChecker private CheckStatus handleCollaboration(EObject newSemanticContainer) { final CheckStatus result; - if (!(newSemanticContainer instanceof StructuredClassifier) && !(newSemanticContainer instanceof Package) - && !(newSemanticContainer instanceof Property)) { + if (!(newSemanticContainer instanceof StructuredClassifier) && // + !(newSemanticContainer instanceof Package) && // + !(newSemanticContainer instanceof Property) && // + !(newSemanticContainer instanceof CollaborationUse)) { result = CheckStatus - .no("Collaboration can only be drag and drop on a Structured Classifier or Package or Property."); + .no("Collaboration can only be drag and drop on a Structured Classifier, a Package, a Property or a CollaborationUse."); } else { result = CheckStatus.YES; } diff --git a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProvider.java b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProvider.java index 42dd146c387ef12956299143c54c37c2eca09e8e..4c12287b206c05783c5033397b989b2deb1e0b2e 100644 --- a/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProvider.java +++ b/plugins/org.eclipse.papyrus.uml.domain.services/src/org/eclipse/papyrus/uml/domain/services/labels/KeywordLabelProvider.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2023 CEA LIST, OBEO + * Copyright (c) 2023 CEA LIST, Obeo. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -9,10 +9,14 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * OBEO - Initial API and implementation + * Obeo - Initial API and implementation *****************************************************************************/ package org.eclipse.papyrus.uml.domain.services.labels; +import static java.util.stream.Collectors.joining; + +import java.util.ArrayList; +import java.util.List; import java.util.function.Function; import org.eclipse.emf.ecore.EObject; @@ -39,6 +43,7 @@ import org.eclipse.uml2.uml.PrimitiveType; import org.eclipse.uml2.uml.Profile; import org.eclipse.uml2.uml.ProtocolStateMachine; import org.eclipse.uml2.uml.Realization; +import org.eclipse.uml2.uml.Reception; import org.eclipse.uml2.uml.Signal; import org.eclipse.uml2.uml.StateMachine; import org.eclipse.uml2.uml.Stereotype; @@ -50,7 +55,7 @@ import org.eclipse.uml2.uml.util.UMLSwitch; /** * Computes the prefix representing all keywords applied to a given element. * - * @author Jessy MALLET + * @author <a href="mailto:jessy.mallet@obeo.fr">Jessy Mallet</a> * */ public class KeywordLabelProvider implements Function<EObject, String> { @@ -58,158 +63,168 @@ public class KeywordLabelProvider implements Function<EObject, String> { @Override public String apply(EObject t) { if (t != null) { - String keyword = new KeywordProviderSwitch().doSwitch(t); - if (keyword != null) { - return UMLCharacters.ST_LEFT + keyword + UMLCharacters.ST_RIGHT; + List<String> keywords = new KeywordProviderSwitch().doSwitch(t); + if (keywords != null) { + return keywords.stream()// + .collect(joining(UMLCharacters.COMMA + UMLCharacters.SPACE, UMLCharacters.ST_LEFT, + UMLCharacters.ST_RIGHT)); } } return null; } - static class KeywordProviderSwitch extends UMLSwitch<String> { + static class KeywordProviderSwitch extends UMLSwitch<List<String>> { @Override - public String caseAbstraction(Abstraction object) { + public List<String> caseAbstraction(Abstraction object) { if (!(object instanceof Realization)) { - return "abstraction"; + return List.of("abstraction"); } return super.caseAbstraction(object); } @Override - public String caseActivity(Activity object) { - return "activity"; + public List<String> caseActivity(Activity activity) { + List<String> keywords = new ArrayList<>(); + keywords.add("activity"); + if (activity.isSingleExecution()) { + keywords.add("singleExecution"); + } + return keywords; } @Override - public String caseArtifact(Artifact artifact) { - return "artifact"; + public List<String> caseArtifact(Artifact artifact) { + return List.of("artifact"); } @Override - public String caseCollaboration(Collaboration object) { - return "collaboration"; + public List<String> caseCollaboration(Collaboration object) { + return List.of("collaboration"); } @Override - public String caseComponent(Component object) { - return "component"; + public List<String> caseComponent(Component object) { + return List.of("component"); } @Override - public String caseDataType(DataType dataType) { - return "dataType"; + public List<String> caseDataType(DataType dataType) { + return List.of("dataType"); } @Override - public String caseDevice(Device object) { - return "device"; + public List<String> caseDevice(Device object) { + return List.of("device"); } @Override - public String caseEnumeration(Enumeration enumeration) { - return "enumeration"; + public List<String> caseEnumeration(Enumeration enumeration) { + return List.of("enumeration"); } @Override - public String caseExtend(Extend extend) { - return "extend"; + public List<String> caseExtend(Extend extend) { + return List.of("extend"); } @Override - public String caseFunctionBehavior(FunctionBehavior functionBehavior) { - return "functionBehavior"; + public List<String> caseFunctionBehavior(FunctionBehavior functionBehavior) { + return List.of("functionBehavior"); } @Override - public String caseInclude(Include object) { - return "include"; + public List<String> caseInclude(Include object) { + return List.of("include"); } @Override - public String caseInformationFlow(InformationFlow flow) { - return "flow"; + public List<String> caseInformationFlow(InformationFlow flow) { + return List.of("flow"); } @Override - public String caseInformationItem(InformationItem object) { - return "information"; + public List<String> caseInformationItem(InformationItem object) { + return List.of("information"); } @Override - public String caseInteraction(Interaction interaction) { - return "interaction"; + public List<String> caseInteraction(Interaction interaction) { + return List.of("interaction"); } @Override - public String caseInterface(Interface object) { - return "interface"; + public List<String> caseInterface(Interface object) { + return List.of("interface"); } @Override - public String caseManifestation(Manifestation object) { - return "manifest"; + public List<String> caseManifestation(Manifestation object) { + return List.of("manifest"); } @Override - public String caseOpaqueBehavior(OpaqueBehavior opaqueBehavior) { - return "opaqueBehavior"; + public List<String> caseOpaqueBehavior(OpaqueBehavior opaqueBehavior) { + return List.of("opaqueBehavior"); } @Override - public String casePackageImport(PackageImport object) { + public List<String> casePackageImport(PackageImport object) { if (object.getVisibility() == VisibilityKind.PUBLIC_LITERAL) { - return "import"; + return List.of("import"); } else { - return "access"; + return List.of("access"); } } @Override - public String casePackageMerge(PackageMerge object) { - return "merge"; + public List<String> casePackageMerge(PackageMerge object) { + return List.of("merge"); } @Override - public String casePrimitiveType(PrimitiveType object) { - return "primitive"; + public List<String> casePrimitiveType(PrimitiveType object) { + return List.of("primitive"); } @Override - public String caseProfile(Profile object) { - return "profile"; + public List<String> caseProfile(Profile object) { + return List.of("profile"); } @Override - public String caseProtocolStateMachine(ProtocolStateMachine protocolStateMachine) { - return "protocol"; + public List<String> caseProtocolStateMachine(ProtocolStateMachine protocolStateMachine) { + return List.of("protocol"); } @Override - public String caseSignal(Signal signal) { - return "signal"; + public List<String> caseReception(Reception object) { + return List.of("signal"); } @Override - public String caseStateMachine(StateMachine stateMachine) { - return "stateMachine"; + public List<String> caseSignal(Signal signal) { + return List.of("signal"); } @Override - public String caseStereotype(Stereotype stereotype) { - return "stereotype"; + public List<String> caseStateMachine(StateMachine stateMachine) { + return List.of("stateMachine"); } @Override - public String caseSubstitution(Substitution object) { - return "substitute"; + public List<String> caseStereotype(Stereotype stereotype) { + return List.of("stereotype"); } @Override - public String caseUsage(Usage object) { - return "use"; + public List<String> caseSubstitution(Substitution object) { + return List.of("substitute"); } + @Override + public List<String> caseUsage(Usage object) { + return List.of("use"); + } } - } diff --git a/pom.xml b/pom.xml index d31bea87d1e0ec71fa4e02eb7c3c5026eb1c47b7..ce0a4f907fdab173aa4ecba0037e8c4ad70b93ef 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>papyrus-uml-domain-services</groupId> <artifactId>container</artifactId> - <version>0.12.0-SNAPSHOT</version> + <version>0.12.0</version> <packaging>pom</packaging> <name>Papyrus-UML-services</name> diff --git a/releng/category/org.eclipse.papyrus.uml.domain.services.updatesite/pom.xml b/releng/category/org.eclipse.papyrus.uml.domain.services.updatesite/pom.xml index 860bcd25f3ba1c2a02bcbebfb22c74488c9a4ea0..00d0c067fe8e6243d71c0780cd9ec1568c815375 100644 --- a/releng/category/org.eclipse.papyrus.uml.domain.services.updatesite/pom.xml +++ b/releng/category/org.eclipse.papyrus.uml.domain.services.updatesite/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>papyrus-uml-domain-services</groupId> <artifactId>parent</artifactId> - <version>0.12.0-SNAPSHOT</version> + <version>0.12.0</version> <relativePath>../../../parent</relativePath> </parent> diff --git a/releng/targetplatform/org.eclipse.papyrus.uml.domain.services.releng.target/pom.xml b/releng/targetplatform/org.eclipse.papyrus.uml.domain.services.releng.target/pom.xml index e4ffb6fa71f60f98f8e7de872caac73551ea885f..bf4a3ace8209a2e6ebd52f207b3fb817d6c6edc6 100644 --- a/releng/targetplatform/org.eclipse.papyrus.uml.domain.services.releng.target/pom.xml +++ b/releng/targetplatform/org.eclipse.papyrus.uml.domain.services.releng.target/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>papyrus-uml-domain-services</groupId> <artifactId>parent</artifactId> - <version>0.12.0-SNAPSHOT</version> + <version>0.12.0</version> <relativePath>../../../parent</relativePath> </parent>