Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatilov2015-07-30 12:03:06 +0000
committerGerrit Code Review @ Eclipse.org2015-08-03 12:33:22 +0000
commitb40fb7d26d31c146c262a42ea919e347b5f0d757 (patch)
treedd3f3e35ba10101b83fa698afdc0e6aacc11f53c
parente6846e7efbc79c14851338e5842f25cf42034a3f (diff)
downloadorg.eclipse.papyrus-b40fb7d26d31c146c262a42ea919e347b5f0d757.tar.gz
org.eclipse.papyrus-b40fb7d26d31c146c262a42ea919e347b5f0d757.tar.xz
org.eclipse.papyrus-b40fb7d26d31c146c262a42ea919e347b5f0d757.zip
[Profile Diagram] Constraint drops without context link
Change-Id: Ia8254f94150457281f74f4f4d6fbc48d6e5eddfa Signed-off-by: ashatilov <shatilov@montages.com>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/Domain2Notation.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ShowHideRelatedLinkEditPolicy.java43
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/providers/CustomUMLParserProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileDiagramEditPart.java3
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestClassDiagramContextLink.java57
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/AllCanonicalTests.java8
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/TestProfileDiagramContextLink.java35
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestContextLink.java113
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestLink.java6
11 files changed, 228 insertions, 75 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/Domain2Notation.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/Domain2Notation.java
index 49a9a21f761..15db6da9b59 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/Domain2Notation.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/Domain2Notation.java
@@ -64,10 +64,12 @@ public class Domain2Notation extends HashMap<EObject, Set<View>> {
*/
public void putView(View view) {
EObject element = view.getElement();
- if (element == null) {
+ if (element == null && view instanceof Connector) {
final EObject source = ((Connector) view).getSource().getElement();
final EObject target = ((Connector) view).getTarget().getElement();
element = new EdgeWithNoSemanticElementRepresentationImpl(source, target, view.getType());
+ } else if (element == null) {
+ return;
}
Set<View> set = this.get(element);
if (set != null) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java
index ba11a4cf0a6..3f23ad2411f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ProfileDiagramDragDropEditPolicy.java
@@ -50,10 +50,12 @@ import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.GMFtoGEFCommandWrapper;
import org.eclipse.papyrus.infra.gmfdiag.common.adapter.SemanticAdapter;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.CommonDeferredCreateConnectionViewCommand;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.strategy.paste.ShowConstraintContextLink;
import org.eclipse.papyrus.uml.diagram.common.util.Util;
import org.eclipse.papyrus.uml.diagram.profile.custom.commands.SetStereotypeVisibleOnMetaclassCommand;
import org.eclipse.papyrus.uml.diagram.profile.custom.helper.MultiAssociationHelper;
@@ -228,7 +230,7 @@ public class ProfileDiagramDragDropEditPolicy extends CommonDiagramDragDropEditP
return dropComment(dropRequest, semanticElement, nodeVISUALID);
case ConstraintEditPart.VISUAL_ID:
case ConstraintEditPartCN.VISUAL_ID:
- return dropConstraint(dropRequest, semanticElement, nodeVISUALID);
+ return dropConstraint(dropRequest, (Constraint) semanticElement, nodeVISUALID);
case MetaclassEditPart.VISUAL_ID:
case MetaclassEditPartCN.VISUAL_ID:
return dropMetaclass(dropRequest, semanticElement, nodeVISUALID);
@@ -304,28 +306,20 @@ public class ProfileDiagramDragDropEditPolicy extends CommonDiagramDragDropEditP
*
* @param dropRequest
* the drop request
- * @param semanticLink
- * the semantic link
+ * @param constraint
+ * the dropped constraint
* @param nodeVISUALID
* the node visual id
*
* @return the command
*/
- protected Command dropConstraint(DropObjectsRequest dropRequest, Element semanticLink, int nodeVISUALID) {
- // Test canvas element
- GraphicalEditPart graphicalParentEditPart = (GraphicalEditPart) getHost();
- EObject graphicalParentObject = graphicalParentEditPart.resolveSemanticElement();
- if (!(graphicalParentObject instanceof org.eclipse.uml2.uml.Package)) {
- return UnexecutableCommand.INSTANCE;
+ protected Command dropConstraint(DropObjectsRequest dropRequest, Constraint constraint, int nodeVISUALID) {
+ ICommand dropConstraintCommand = getDefaultDropNodeCommand(nodeVISUALID, dropRequest.getLocation(), constraint, dropRequest);
+ if (constraint.getContext() != null) {
+ ShowConstraintContextLink showConstraintContextLink = new ShowConstraintContextLink(getEditingDomain(), (GraphicalEditPart) getHost(), constraint);
+ dropConstraintCommand = dropConstraintCommand.compose(showConstraintContextLink);
}
- if (nodeVISUALID == ConstraintEditPart.VISUAL_ID) {
- return getDropConstraintCommand((Constraint) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Constraint_1014,
- (IHintedType) UMLElementTypes.ConstraintConstrainedElement_4014);
- } else if (nodeVISUALID == ConstraintEditPartCN.VISUAL_ID) {
- return getDropConstraintCommand((Constraint) semanticLink, getViewer(), getDiagramPreferencesHint(), dropRequest.getLocation(), ((GraphicalEditPart) getHost()).getNotationView(), (IHintedType) UMLElementTypes.Constraint_1028,
- (IHintedType) UMLElementTypes.ConstraintConstrainedElement_4014);
- }
- return UnexecutableCommand.INSTANCE;
+ return GMFtoGEFCommandWrapper.wrap(dropConstraintCommand);
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ShowHideRelatedLinkEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ShowHideRelatedLinkEditPolicy.java
new file mode 100644
index 00000000000..0dea709fcfe
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/policies/ShowHideRelatedLinkEditPolicy.java
@@ -0,0 +1,43 @@
+package org.eclipse.papyrus.uml.diagram.profile.custom.policies;
+
+import org.eclipse.gmf.tooling.runtime.structure.DiagramStructure;
+import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractUMLShowHideRelatedLinkEditPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.edit.parts.CustomUMLDiagramUpdater;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLVisualIDRegistry;
+
+/**
+ * Show Hide link editpolicy for Profile Diagram
+ *
+ */
+public class ShowHideRelatedLinkEditPolicy extends AbstractUMLShowHideRelatedLinkEditPolicy {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param host
+ */
+ public ShowHideRelatedLinkEditPolicy() {
+ super();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public DiagramUpdater getDiagramUpdater() {
+ return CustomUMLDiagramUpdater.INSTANCE;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IDiagramInformationProviderEditPolicy#getDiagramStructure()
+ *
+ * @return
+ */
+ public DiagramStructure getDiagramStructure() {
+ return UMLVisualIDRegistry.TYPED_INSTANCE;
+ }
+} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/providers/CustomUMLParserProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/providers/CustomUMLParserProvider.java
index 3090b8d2e40..91c656e3787 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/providers/CustomUMLParserProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/providers/CustomUMLParserProvider.java
@@ -22,7 +22,7 @@ public class CustomUMLParserProvider extends UMLParserProvider {
case AppliedStereotypeElementImportEditPart.VISUAL_ID:
return getAppliedStereotypeParser("ElementImport"); //$NON-NLS-1$
case ContextLinkAppliedStereotypeEditPart.VISUAL_ID:
- return getAppliedStereotypeParser("context"); //$NON-NLS-1$
+ return getAppliedStereotypeParser("context"); //$NON-NLS-1$
}
return super.getParser(visualID);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen
index 50fb9a51cd2..606183e7a07 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/model/profilediagram.gmfgen
@@ -44,6 +44,10 @@
xsi:type="gmfgen:CustomBehaviour"
key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE"
editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy"/>
+ <behaviour
+ xsi:type="gmfgen:CustomBehaviour"
+ key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.AbstractShowHideRelatedLinkEditPolicy.SHOW_HIDE_RELATED_LINK_ROLE"
+ editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.profile.custom.policies.ShowHideRelatedLinkEditPolicy"/>
<domainDiagramElement
href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Profile"/>
<childNodes
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileDiagramEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileDiagramEditPart.java
index 39712249851..80b2b94690a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileDiagramEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ProfileDiagramEditPart.java
@@ -14,12 +14,14 @@ package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusDiagramEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.AbstractShowHideRelatedLinkEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCompartmentSemanticEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.profile.custom.policies.CustomCreationRoleEditPolicy;
import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ProfileDiagramDragDropEditPolicy;
import org.eclipse.papyrus.uml.diagram.profile.custom.policies.RemoveOrphanViewPolicy;
+import org.eclipse.papyrus.uml.diagram.profile.custom.policies.ShowHideRelatedLinkEditPolicy;
/**
* @generated
@@ -57,6 +59,7 @@ public class ProfileDiagramEditPart extends PapyrusDiagramEditPart {
installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ProfileDiagramDragDropEditPolicy());
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomCreationRoleEditPolicy());
+ installEditPolicy(AbstractShowHideRelatedLinkEditPolicy.SHOW_HIDE_RELATED_LINK_ROLE, new ShowHideRelatedLinkEditPolicy());
// removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
}
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestClassDiagramContextLink.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestClassDiagramContextLink.java
index f5116b3c170..59e60f3333c 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestClassDiagramContextLink.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/canonical/TestClassDiagramContextLink.java
@@ -13,26 +13,16 @@
package org.eclipse.papyrus.uml.diagram.clazz.test.canonical;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand;
import org.eclipse.papyrus.uml.diagram.clazz.custom.edit.part.CustomUMLDiagramUpdater;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.clazz.test.IClassDiagramTestsConstants;
-import org.eclipse.papyrus.uml.diagram.tests.canonical.TestLink;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestContextLink;
import org.junit.Test;
-public class TestClassDiagramContextLink extends TestLink {
+public class TestClassDiagramContextLink extends TestContextLink {
@Override
public DiagramUpdater getDiagramUpdater() {
@@ -54,47 +44,8 @@ public class TestClassDiagramContextLink extends TestLink {
return IClassDiagramTestsConstants.FILE_NAME;
}
- /**
- * Creation of the second context link from Constraint should be forbidden
- */
@Test
- public void testCreateSecondContextLinkFromConstraint() {
- GraphicalEditPart class1EditPart = createNodeOnDiagram(UMLElementTypes.Class_2008, new Point(100, 100), 1);
- GraphicalEditPart class2EditPart = createNodeOnDiagram(UMLElementTypes.Class_2008, new Point(100, 300), 2);
- GraphicalEditPart constraintEditPart = createNodeOnDiagram(UMLElementTypes.Constraint_2011, new Point(300, 100), 3);
- createLink(UMLElementTypes.ConstraintContext_8500, constraintEditPart, class1EditPart, false,true);
- createLink(UMLElementTypes.ConstraintContext_8500, constraintEditPart, class2EditPart, true,false);
- }
-
- private GraphicalEditPart createNodeOnDiagram(IElementType nodeType, Point loc, int expectedChildsCount) {
- CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(nodeType, getDiagramEditPart().getDiagramPreferencesHint());
- requestcreation.setLocation(loc);
- Command command = getDiagramEditPart().getCommand(requestcreation);
- assertNotNull(CREATION + COMMAND_NULL, command);
- assertTrue(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- return (GraphicalEditPart) getDiagramEditPart().getChildren().get(expectedChildsCount - 1);
- }
-
- /**
- * create a link
- * @param linkType
- * @param source
- * @param target
- * @param nullCommand if the resulted command must be null
- * @param canExecute true if the command must be executable - if null command is true this parameter is not tested
- */
- private void createLink(IElementType linkType, GraphicalEditPart source, GraphicalEditPart target,boolean nullCommand, boolean canExecute) {
- Command command = target.getCommand(createConnectionViewRequest(linkType, source, target));
- if( nullCommand){
- org.junit.Assert.assertNull(CREATION + " must be null", command);
- return;
- }
- assertNotNull(CREATION + COMMAND_NULL, command);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == canExecute);
- if (canExecute) {
- diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- }
+ public void testToManageContextLink() {
+ manageContextLink(UMLElementTypes.Constraint_2011, UMLElementTypes.Class_2008, UMLElementTypes.ConstraintContext_8500, UMLElementTypes.Package_2007);
}
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/AllCanonicalTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/AllCanonicalTests.java
index 82cf7cd87cf..9904dcbcdb1 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/AllCanonicalTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/AllCanonicalTests.java
@@ -16,6 +16,12 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-@Suite.SuiteClasses({ TestProfileDiagramTopNode.class, TestProfileDiagramChildNode.class, TestProfileDiagramLink.class, TestImportMetaClass.class, TestProfileDiagramExtension.class })
+@Suite.SuiteClasses({
+ TestProfileDiagramTopNode.class,
+ TestProfileDiagramChildNode.class,
+ TestProfileDiagramLink.class,
+ TestImportMetaClass.class,
+ TestProfileDiagramExtension.class,
+ TestProfileDiagramContextLink.class })
public class AllCanonicalTests {
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/TestProfileDiagramContextLink.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/TestProfileDiagramContextLink.java
new file mode 100644
index 00000000000..0fa55490281
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/tests/canonical/TestProfileDiagramContextLink.java
@@ -0,0 +1,35 @@
+package org.eclipse.papyrus.uml.diagram.profile.tests.canonical;
+
+import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.profile.CreateProfileDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramUpdater;
+import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.tests.canonical.TestContextLink;
+import org.junit.Test;
+
+public class TestProfileDiagramContextLink extends TestContextLink {
+
+ @Override
+ public DiagramUpdater getDiagramUpdater() {
+ return UMLDiagramUpdater.INSTANCE;
+ }
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateProfileDiagramCommand();
+ }
+
+ protected String getProjectName() {
+ return "ProfileDiagramTestProject";
+ }
+
+ protected String getFileName() {
+ return "ProfileDiagramTest.profile.di";
+ }
+
+ @Test
+ public void testToManageContextLink() {
+ manageContextLink(UMLElementTypes.Constraint_1014, UMLElementTypes.Class_2008, UMLElementTypes.ConstraintContext_8500, UMLElementTypes.Package_2007);
+ }
+} \ No newline at end of file
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestContextLink.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestContextLink.java
new file mode 100644
index 00000000000..9b24aa780e1
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestContextLink.java
@@ -0,0 +1,113 @@
+package org.eclipse.papyrus.uml.diagram.tests.canonical;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Element;
+
+public abstract class TestContextLink extends TestLink {
+
+ protected void manageContextLink(IElementType sourceType, IElementType targetType, IElementType linkType, IElementType containerType) {
+ testToManageLink(sourceType, targetType, linkType, containerType, false, null);
+ checkUnexecutableCreateLinkCommand(linkType, source, target);
+ checkUnexecutableCreateLinkCommand(linkType, source, targetPlayer);
+ }
+
+ @Override
+ public void testToCreateALink(IElementType linkType, String initialName) {
+ testCreateLink(linkType, initialName);
+ }
+
+ @Override
+ public void testToManageLink(IElementType sourceType, IElementType targetType, IElementType linkType, IElementType containerType, boolean allowedOntheSame, String initialName) {
+ installEnvironment(sourceType, targetType);
+ testToCreateALink(linkType, initialName);
+ testToManageDropConstraint();
+ }
+
+ private void testToManageDropConstraint() {
+ testConstraintViewDeletion();
+ testDropConstraint();
+ }
+
+ private void testConstraintViewDeletion() {
+ assertEquals(VIEW_DELETION + INITIALIZATION_TEST, 4, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(VIEW_DELETION + INITIALIZATION_TEST, 1, ((Diagram) getRootView()).getEdges().size());
+ assertEquals(VIEW_DELETION + INITIALIZATION_TEST, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = source.getCommand(deleteViewRequest);
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
+ assertEquals(VIEW_DELETION + TEST_THE_EXECUTION, 3, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(VIEW_DELETION + TEST_THE_EXECUTION, 0, ((Diagram) getRootView()).getEdges().size());
+ assertEquals(VIEW_DELETION + TEST_THE_EXECUTION, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
+ assertEquals(VIEW_DELETION + TEST_THE_UNDO, 4, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(VIEW_DELETION + TEST_THE_UNDO, 1, ((Diagram) getRootView()).getEdges().size());
+ assertEquals(VIEW_DELETION + TEST_THE_UNDO, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
+ assertEquals(VIEW_DELETION + TEST_THE_REDO, 3, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(VIEW_DELETION + TEST_THE_REDO, 0, ((Diagram) getRootView()).getEdges().size());
+ assertEquals(VIEW_DELETION + TEST_THE_REDO, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ }
+
+ private void testDropConstraint() {
+ assertEquals(DROP + INITIALIZATION_TEST, 3, getDiagramEditPart().getChildren().size());
+ assertEquals(DROP + INITIALIZATION_TEST, 3, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(DROP + INITIALIZATION_TEST, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(CREATION + INITIALIZATION_TEST, 0, ((Diagram) getRootView()).getEdges().size());
+ DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
+ ArrayList<Element> list = new ArrayList<Element>();
+ list.add(((Element) target.resolveSemanticElement()).getOwnedElements().get(0));
+ dropObjectsRequest.setObjects(list);
+ dropObjectsRequest.setLocation(new Point(20, 20));
+ Command command = getDiagramEditPart().getCommand(dropObjectsRequest);
+ assertNotNull(DROP + COMMAND_NULL, command);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
+ assertEquals(DROP + TEST_THE_EXECUTION, 4, getDiagramEditPart().getChildren().size());
+ assertEquals(DROP + TEST_THE_EXECUTION, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(DROP + TEST_THE_EXECUTION, 4, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(DROP + TEST_THE_EXECUTION, 1, ((Diagram) getRootView()).getEdges().size());
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
+ assertEquals(DROP + TEST_THE_UNDO, 3, getDiagramEditPart().getChildren().size());
+ assertEquals(DROP + TEST_THE_UNDO, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(DROP + TEST_THE_UNDO, 3, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(DROP + TEST_THE_UNDO, 0, ((Diagram) getRootView()).getEdges().size());
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
+ assertEquals(DROP + TEST_THE_REDO, 4, getDiagramEditPart().getChildren().size());
+ assertEquals(DROP + TEST_THE_REDO, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
+ assertEquals(DROP + TEST_THE_REDO, 4, ((Diagram) getRootView()).getChildren().size());
+ assertEquals(DROP + TEST_THE_REDO, 1, ((Diagram) getRootView()).getEdges().size());
+ }
+
+ @Override
+ public void installEnvironment(IElementType sourceType, IElementType targetType) {
+ rootSemanticOwnedElements = 3;
+ super.installEnvironment(sourceType, targetType);
+ assertTrue(CREATION + INITIALIZATION_TEST, source.resolveSemanticElement() instanceof Constraint);
+ }
+
+ private void checkUnexecutableCreateLinkCommand(IElementType linkType, GraphicalEditPart source, GraphicalEditPart target) {
+ Command command = target.getCommand(createConnectionViewRequest(linkType, source, target));
+ assertNull("Creation of the second context link from the constraint should be forbidden.", command);
+ }
+} \ No newline at end of file
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestLink.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestLink.java
index 3955edba3cd..5861bcbe821 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestLink.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.tests/src/org/eclipse/papyrus/uml/diagram/tests/canonical/TestLink.java
@@ -102,6 +102,8 @@ public abstract class TestLink extends AbstractPapyrusTestCase {
private FixtureEditPartConfigurator targetConfigurator;
+ protected int rootSemanticOwnedElements = 5;
+
@Rule
public final TestRule annotationRule = new AnnotationRule();
@@ -293,13 +295,13 @@ public abstract class TestLink extends AbstractPapyrusTestCase {
assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
assertTrue(CREATION + INITIALIZATION_TEST, ((Diagram) getRootView()).getEdges().size() == 1);
- assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 5);
+ assertEquals(CREATION + INITIALIZATION_TEST, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
assertTrue(CREATION + TEST_THE_UNDO, getRootView().getChildren().size() == 4);
assertTrue(CREATION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 4);
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
assertTrue(CREATION + TEST_THE_REDO, ((Diagram) getRootView()).getEdges().size() == 1);
- assertTrue(CREATION + TEST_THE_REDO, getRootSemanticModel().getOwnedElements().size() == 5);
+ assertEquals(CREATION + TEST_THE_REDO, rootSemanticOwnedElements, getRootSemanticModel().getOwnedElements().size());
ConnectionEditPart linkEditPart = (ConnectionEditPart) getDiagramEditPart().getConnections().get(0);
testLinkEditPart(linkEditPart, initialName);
}

Back to the top