diff options
11 files changed, 442 insertions, 2 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css index 3f55a2de3a2..b476c26c188 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css @@ -7,6 +7,7 @@ CreateLinkAction, CreateObjectAction,
DestroyLinkAction,
ReadLinkAction,
+ReadSelfAction,
ReadStructuralFeatureAction,
SendSignalAction,
StartClassifierBehaviorAction,
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ReadSelfActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ReadSelfActionEditHelperAdvice.java new file mode 100644 index 00000000000..1bf94a1a6da --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ReadSelfActionEditHelperAdvice.java @@ -0,0 +1,56 @@ +/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
+
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.diagram.activity.edit.commands.util.PinUpdateCommand;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFactory;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.uml2.uml.ReadSelfAction;
+
+/**
+ *
+ * Pin of ReadSelfAction should be create and update automatically
+ *
+ */
+public class ReadSelfActionEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
+ // 1] get the preference for ReadSelfAction
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePin = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.READ_SELF_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ // 2] check preference
+ if (synchronizePin) {
+ ReadSelfAction editedModelElement = (ReadSelfAction) request.getElementToConfigure();
+ if (editedModelElement != null) {
+ // 3] call the command for the ReadSelfAction
+ IPinUpdater<ReadSelfAction> updater = PinUpdaterFactory.getInstance().instantiate(editedModelElement);
+ return new PinUpdateCommand<ReadSelfAction>("Update read self action pins", updater, editedModelElement);
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java index ce74266e604..a8d08072c4f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java @@ -28,6 +28,7 @@ import org.eclipse.uml2.uml.AcceptCallAction; import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.StartClassifierBehaviorActionPinUpdater;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.StartObjectBehaviorActionPinUpdater;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.ReadSelfActionPinUpdater;
import org.eclipse.uml2.uml.ActivityNode;
import org.eclipse.uml2.uml.AddStructuralFeatureValueAction;
import org.eclipse.uml2.uml.CallBehaviorAction;
@@ -37,6 +38,7 @@ import org.eclipse.uml2.uml.CreateObjectAction; import org.eclipse.uml2.uml.DestroyLinkAction;
import org.eclipse.uml2.uml.ReadLinkAction;
import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
+import org.eclipse.uml2.uml.ReadSelfAction;
import org.eclipse.uml2.uml.SendSignalAction;
import org.eclipse.uml2.uml.TestIdentityAction;
import org.eclipse.uml2.uml.ValueSpecificationAction;
@@ -111,6 +113,8 @@ public class PinUpdaterFactory { updater = (IPinUpdater<T>) new StartClassifierBehaviorActionPinUpdater();
} else if (node instanceof StartObjectBehaviorAction) {
updater = (IPinUpdater<T>) new StartObjectBehaviorActionPinUpdater();
+ } else if (node instanceof ReadSelfAction) {
+ updater = (IPinUpdater<T>) new ReadSelfActionPinUpdater();
}
return updater;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/ReadSelfActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/ReadSelfActionPinUpdater.java new file mode 100644 index 00000000000..4e2e290bd51 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/ReadSelfActionPinUpdater.java @@ -0,0 +1,54 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * J�r�mie TATIBOUET (CEA LIST) - Initial API and implementation + * S�bastien REVOL (CEA LIST) - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions; + +import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractActionPinUpdater; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.OutputPin; +import org.eclipse.uml2.uml.ReadSelfAction; +import org.eclipse.uml2.uml.UMLFactory; + +/** + * + * Pin of ReadSelfAction should be create and update automatically + * + */ +public class ReadSelfActionPinUpdater extends AbstractActionPinUpdater<ReadSelfAction> { + + /** + * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater#updatePins(org.eclipse.uml2.uml.ActivityNode) + * + * @param node + */ + @Override + public void updatePins(ReadSelfAction node) { + // 1] create the result pin + // the type of the result output pin is the "context" + if (node != null) { + node.setName("this"); + OutputPin result = UMLFactory.eINSTANCE.createOutputPin(); + result.setName("result"); + result.setLower(1); + result.setUpper(1); + Activity container = node.getActivity(); + if (container != null) { + result.setType(container.getContext()); + } + node.setResult(result); + } + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java index c5c0ff85011..c2ca69a19b2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java @@ -26,6 +26,7 @@ import org.eclipse.uml2.uml.CreateLinkAction; import org.eclipse.uml2.uml.CreateObjectAction; import org.eclipse.uml2.uml.DestroyLinkAction; import org.eclipse.uml2.uml.ReadLinkAction; +import org.eclipse.uml2.uml.ReadSelfAction; import org.eclipse.uml2.uml.ReadStructuralFeatureAction; import org.eclipse.uml2.uml.StartClassifierBehaviorAction; import org.eclipse.uml2.uml.StartObjectBehaviorAction; @@ -84,6 +85,7 @@ public class ActivityAutomatedModelCompletionPreferencePage extends AbstractAuto actionList.add(CreateLinkAction.class); actionList.add(CreateObjectAction.class); actionList.add(DestroyLinkAction.class); + actionList.add(ReadSelfAction.class); actionList.add(ReadLinkAction.class); actionList.add(ReadStructuralFeatureAction.class); actionList.add(StartClassifierBehaviorAction.class); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java index a3e2d8ac9e0..9478b9c28b4 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java @@ -50,6 +50,7 @@ public class AutomatedModelCompletionPreferencesInitializer extends AbstractPref store.setDefault(IAutomatedModelCompletionPreferencesConstants.CREATE_LINK_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION); store.setDefault(IAutomatedModelCompletionPreferencesConstants.CREATE_OBJECT_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION); store.setDefault(IAutomatedModelCompletionPreferencesConstants.DESTROY_LINK_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION); + store.setDefault(IAutomatedModelCompletionPreferencesConstants.READ_SELF_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION); store.setDefault(IAutomatedModelCompletionPreferencesConstants.READ_LINK_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION); store.setDefault(IAutomatedModelCompletionPreferencesConstants.READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION); store.setDefault(IAutomatedModelCompletionPreferencesConstants.START_CLASSIFIER_BEHAVIOR_ACTION, PIN_SYNCHRONIZATION); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java index 28fc2e81482..9c88fbe1bea 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java @@ -34,6 +34,8 @@ public interface IAutomatedModelCompletionPreferencesConstants { final public String READ_LINK_ACTION_ACCELERATOR = "org.eclipse.papyrus.uml.diagram.activity.preferences.readLinkAction"; + final public String READ_SELF_ACTION_ACCELERATOR = "org.eclipse.papyrus.uml.diagram.activity.preferences.readSelfAction"; + final public String READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR = "org.eclipse.papyrus.uml.diagram.activity.preferences.readStructuralFeatureAction"; final public String START_CLASSIFIER_BEHAVIOR_ACTION = "org.eclipse.papyrus.uml.diagram.activity.preferences.startClassifierBehaviorAction"; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations index f9360ecdda1..912ddbf18bf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations @@ -42,6 +42,9 @@ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_8PlT8NcMEeaqY_uVBFnnsA" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.StartObjectBehaviorActionEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.StartObjectBehaviorActionEditHelperAdvice">
<target xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu6RWNx0EeWVxMf7SXAfhg"/>
</adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_8WPb4NfYEeaDuNpRnlDJcw" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ReadSelfActionEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ReadSelfActionEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu6RGNx0EeWVxMf7SXAfhg"/>
+ </adviceBindingsConfigurations>
<adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_qc9DEKzLEeaKg_9XdFC-Jg" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.TriggerEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.TriggerEditHelperAdvice">
<target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_SdLCt1YCEeS0WsAAtVmToA"/>
</adviceBindingsConfigurations>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java index a6c98ad83cf..a79768ae694 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/TestActivityDiagramChildNode.java @@ -14,12 +14,16 @@ package org.eclipse.papyrus.uml.diagram.activity.tests.canonical; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.papyrus.infra.gmfdiag.common.updater.DiagramUpdater; import org.eclipse.papyrus.junit.framework.classification.FailingTest; import org.eclipse.papyrus.junit.framework.classification.InteractiveTest; +import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer; +import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants; import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramUpdater; import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes; import org.eclipse.papyrus.uml.diagram.activity.tests.IActivityDiagramTestsConstants; +import org.eclipse.papyrus.uml.diagram.common.Activator; import org.eclipse.uml2.uml.UMLPackage; import org.junit.Test; @@ -185,6 +189,11 @@ public class TestActivityDiagramChildNode extends AbstractTestActivityChildNode */ @Test public void testToManageReadSelfAction() { + // Pin of ReadSelfAction should be create and update automatically + // Set Automated Model Completion preference to NONE + IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore(); + prefStore.setValue(IAutomatedModelCompletionPreferencesConstants.READ_SELF_ACTION_ACCELERATOR, AutomatedModelCompletionPreferencesInitializer.NONE); + testToManageNode(UMLElementTypes.ReadSelfAction_Shape, UMLPackage.eINSTANCE.getReadSelfAction(), UMLElementTypes.StructuredActivityNode_Shape, true); } diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/derivation/pins/AllPinDerivationTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/derivation/pins/AllPinDerivationTests.java index 906605f0be2..19e845a8e49 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/derivation/pins/AllPinDerivationTests.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/derivation/pins/AllPinDerivationTests.java @@ -19,8 +19,9 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(ClassificationSuite.class)
@SuiteClasses({ TestAcceptCallActionPinDerivation.class, TestAcceptEventActionPinDerivation.class, TestAddStructuralFeatureValueActionPinDerivation.class, TestCallBehaviorActionPinDerivation.class, TestCallOperationActionPinDerivation.class,
- TestCreateLinkActionPinDerivation.class, TestCreateObjectActionPinDerivation.class, TestDestroyLinkActionPinDerivation.class, TestReadLinkActionPinDerivation.class, TestReadStructuralFeatureActionPinDerivation.class,
- TestSendSignalActionPinDerivation.class, TestStartClassifierBehaviorActionPinDerivation.class, TestStartObjectBehaviorActionPinDerivation.class, TestTestIdentityActionPinDerivation.class, TestValueSpecificationActionPinDerivation.class })
+ TestCreateLinkActionPinDerivation.class, TestCreateObjectActionPinDerivation.class, TestDestroyLinkActionPinDerivation.class, TestReadLinkActionPinDerivation.class, TestReadSelfActionPinDerivation.class,
+ TestReadStructuralFeatureActionPinDerivation.class, TestSendSignalActionPinDerivation.class, TestStartClassifierBehaviorActionPinDerivation.class, TestStartObjectBehaviorActionPinDerivation.class, TestTestIdentityActionPinDerivation.class,
+ TestValueSpecificationActionPinDerivation.class })
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/derivation/pins/TestReadSelfActionPinDerivation.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/derivation/pins/TestReadSelfActionPinDerivation.java new file mode 100644 index 00000000000..a2284967f06 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/derivation/pins/TestReadSelfActionPinDerivation.java @@ -0,0 +1,307 @@ +/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.tests.derivation.pins;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ReadSelfActionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
+import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.ReadSelfAction;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * Pin of ReadSelfAction should be create and update automatically
+ *
+ */
+public class TestReadSelfActionPinDerivation extends AbstractTestPinDerivation {
+
+ /**
+ * CallBehaviorAction advice identifier
+ */
+ private final String TARGET_ADVICE_IDENTIFIER = "org.eclipse.papyrus.uml.diagram.activity.edit.advices.ReadSelfActionEditHelperAdvice";
+
+ private Class classA;
+
+ private Class classB;
+
+ private Class classC;
+
+ private Activity activityA_SpecifiedOperation;
+
+ private Activity activityB_ownedBehavior;
+
+ private Activity activityB_nestedClassifier;
+
+ private Activity activityC_classiferBahaviour;
+
+ private Activity activityD_InRootElement;
+
+ private ReadSelfAction readSelfActionA;
+
+ private ReadSelfAction readSelfActionB1;
+
+ private ReadSelfAction readSelfActionB2;
+
+ private ReadSelfAction readSelfActionC;
+
+ private ReadSelfAction readSelfActionD;
+
+ /**
+ * Constructor.
+ */
+ public TestReadSelfActionPinDerivation() {
+ this.populateBaseTestModel();
+ // Set Automated Model Completion preference to PIN_SYNCHRONIZATION
+ IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ prefStore.setValue(IAutomatedModelCompletionPreferencesConstants.READ_SELF_ACTION_ACCELERATOR, AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION);
+ }
+
+ /**
+ * Role:
+ * - Ensure that the advice for the ReadSelfAction is available
+ */
+ @Test
+ public void testAdviceForReadSelfActionExists() {
+ Assert.assertNotNull("ReadSelfAction advice for activity models is missing", this.getAdvice(TARGET_ADVICE_IDENTIFIER));
+ }
+
+ /**
+ * Role:
+ * - For adding a ReadSelfAction to the activity, insure that the pin is correctly typed.
+ * ActivityA is owned by the rootElement
+ * ActivityA specified an operation of the classA
+ *
+ * Scenario:
+ * - 1] ReadSelfAction is add to the activity
+ * - 2] Synchronization is performed via the advice
+ * - ReadSelfAction has now 1 pin
+ * - 1 result typed by the activity
+ */
+ @Test
+ public void testPinDerivation_ActivitySpecifiedOperation() {
+ ConfigureRequest request = new ConfigureRequest(this.editingDomain, this.readSelfActionA, UMLElementTypes.getElementType(ReadSelfActionEditPart.VISUAL_ID));
+ IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(this.readSelfActionA);
+ ICommand editReadSelfActionCommand = elementEditService.getEditCommand(request);
+ if (!editReadSelfActionCommand.canExecute()) {
+ Assert.fail("The ReadSelfAction cannot be edited (Edit command is not executable)");
+ }
+ this.editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(editReadSelfActionCommand));
+
+ // Assert result
+ Assert.assertTrue("ReadSelfAction shall have a result pin", this.readSelfActionA.getResult() != null);
+ Assert.assertTrue("ReadSelfAction shall have a result pin typed by classA", this.readSelfActionA.getResult().getType() == null);
+
+ if (!editReadSelfActionCommand.canUndo()) {
+ Assert.fail("It shall be possible to undo the pin derivation");
+ }
+ this.editingDomain.getCommandStack().undo();
+ }
+
+ /**
+ * Role:
+ * - For adding a ReadSelfAction to the activity, insure that the pin is correctly typed.
+ * ActivityB is an ownedBehavior of the classB
+ *
+ * Scenario:
+ * - 1] ReadSelfAction is add to the activity
+ * - 2] Synchronization is performed via the advice
+ * - ReadSelfAction has now 1 pin
+ * - 1 result typed by classB
+ */
+ @Test
+ public void testPinDerivation_ActivityOwnedBeahaviour() {
+ ConfigureRequest request = new ConfigureRequest(this.editingDomain, this.readSelfActionB1, UMLElementTypes.getElementType(ReadSelfActionEditPart.VISUAL_ID));
+ IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(this.readSelfActionB1);
+ ICommand editReadSelfActionCommand = elementEditService.getEditCommand(request);
+ if (!editReadSelfActionCommand.canExecute()) {
+ Assert.fail("The ReadSelfAction cannot be edited (Edit command is not executable)");
+ }
+ this.editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(editReadSelfActionCommand));
+
+ // Assert result
+ Assert.assertTrue("ReadSelfAction shall have a result pin", this.readSelfActionB1.getResult() != null);
+ Assert.assertTrue("ReadSelfAction shall have a result pin typed by classB", this.readSelfActionB1.getResult().getType() == classB);
+
+ if (!editReadSelfActionCommand.canUndo()) {
+ Assert.fail("It shall be possible to undo the pin derivation");
+ }
+ this.editingDomain.getCommandStack().undo();
+ }
+
+ /**
+ * Role:
+ * - For adding a ReadSelfAction to the activity, insure that the pin is correctly typed.
+ * ActivityB is an nestedClassifier of the classB
+ *
+ * Scenario:
+ * - 1] ReadSelfAction is add to the activity
+ * - 2] Synchronization is performed via the advice
+ * - ReadSelfAction has now 1 pin
+ * - 1 result typed by activityB_nestedClassifer
+ */
+ @Test
+ public void testPinDerivation_ActivityNestedClassifer() {
+ ConfigureRequest request = new ConfigureRequest(this.editingDomain, this.readSelfActionB2, UMLElementTypes.getElementType(ReadSelfActionEditPart.VISUAL_ID));
+ IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(this.readSelfActionB2);
+ ICommand editReadSelfActionCommand = elementEditService.getEditCommand(request);
+ if (!editReadSelfActionCommand.canExecute()) {
+ Assert.fail("The ReadSelfAction cannot be edited (Edit command is not executable)");
+ }
+ this.editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(editReadSelfActionCommand));
+
+ // Assert result
+ Assert.assertTrue("ReadSelfAction shall have a result pin", this.readSelfActionB2.getResult() != null);
+ Assert.assertTrue("ReadSelfAction shall have a result pin typed by classB", this.readSelfActionB2.getResult().getType() == null);
+
+ if (!editReadSelfActionCommand.canUndo()) {
+ Assert.fail("It shall be possible to undo the pin derivation");
+ }
+ this.editingDomain.getCommandStack().undo();
+ }
+
+ /**
+ * Role:
+ * - For adding a ReadSelfAction to the activity, insure that the pin is correctly typed.
+ * ActivityC is owned by classC
+ * ActivityC is classifierBehaviour of classC
+ *
+ * Scenario:
+ * - 1] ReadSelfAction is add to the activity
+ * - 2] Synchronization is performed via the advice
+ * - ReadSelfAction has now 1 pin
+ * - 1 result typed by classC
+ */
+ @Test
+ public void testPinDerivation_ActivityAsClassifierBehaviour() {
+ ConfigureRequest request = new ConfigureRequest(this.editingDomain, this.readSelfActionC, UMLElementTypes.getElementType(ReadSelfActionEditPart.VISUAL_ID));
+ IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(this.readSelfActionC);
+ ICommand editReadSelfActionCommand = elementEditService.getEditCommand(request);
+ if (!editReadSelfActionCommand.canExecute()) {
+ Assert.fail("The ReadSelfAction cannot be edited (Edit command is not executable)");
+ }
+ this.editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(editReadSelfActionCommand));
+
+ // Assert result
+ Assert.assertTrue("ReadSelfAction shall have a result pin", this.readSelfActionC.getResult() != null);
+ Assert.assertTrue("ReadSelfAction shall have a result pin typed by classB", this.readSelfActionC.getResult().getType() == classC);
+
+ if (!editReadSelfActionCommand.canUndo()) {
+ Assert.fail("It shall be possible to undo the pin derivation");
+ }
+ this.editingDomain.getCommandStack().undo();
+ }
+
+ /**
+ * Role:
+ * - For adding a ReadSelfAction to the activity, insure that the pin is correctly typed.
+ * ActivityC is owned by the rootElement
+ *
+ * Scenario:
+ * - 1] ReadSelfAction is add to the activity
+ * - 2] Synchronization is performed via the advice
+ * - ReadSelfAction has now 1 pin
+ * - 1 result typed by activityD
+ */
+ @Test
+ public void testPinDerivation_ActivityInRootElement() {
+ ConfigureRequest request = new ConfigureRequest(this.editingDomain, this.readSelfActionD, UMLElementTypes.getElementType(ReadSelfActionEditPart.VISUAL_ID));
+ IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(this.readSelfActionD);
+ ICommand editReadSelfActionCommand = elementEditService.getEditCommand(request);
+ if (!editReadSelfActionCommand.canExecute()) {
+ Assert.fail("The ReadSelfAction cannot be edited (Edit command is not executable)");
+ }
+ this.editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(editReadSelfActionCommand));
+
+ // Assert result
+ Assert.assertTrue("ReadSelfAction shall have a result pin", this.readSelfActionD.getResult() != null);
+ Assert.assertTrue("ReadSelfAction shall have a result pin not typed", this.readSelfActionD.getResult().getType() == null);
+
+ if (!editReadSelfActionCommand.canUndo()) {
+ Assert.fail("It shall be possible to undo the pin derivation");
+ }
+ this.editingDomain.getCommandStack().undo();
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.tests.derivation.pins.AbstractTestPinDerivation#populateBaseTestModel()
+ *
+ */
+ @Override
+ public void populateBaseTestModel() {
+ super.populateBaseTestModel();
+
+ // Create Activity A => specification
+ this.readSelfActionA = UMLFactory.eINSTANCE.createReadSelfAction();
+ classA = UMLFactory.eINSTANCE.createClass();
+ classA.setName("a");
+ classA.getOwnedOperations().add(UMLFactory.eINSTANCE.createOperation());
+ activityA_SpecifiedOperation = UMLFactory.eINSTANCE.createActivity();
+ activityA_SpecifiedOperation.setSpecification(classA.getOwnedOperations().get(0));
+ activityA_SpecifiedOperation.getOwnedNodes().add(readSelfActionA);
+
+ // Create Activity B => OwnedBehaviour and NestedClassifier
+ this.readSelfActionB1 = UMLFactory.eINSTANCE.createReadSelfAction();
+ this.readSelfActionB2 = UMLFactory.eINSTANCE.createReadSelfAction();
+ classB = UMLFactory.eINSTANCE.createClass();
+ classB.setName("b");
+ activityB_ownedBehavior = UMLFactory.eINSTANCE.createActivity();
+ activityB_ownedBehavior.getOwnedNodes().add(readSelfActionB1);
+ classB.getOwnedBehaviors().add(activityB_ownedBehavior);
+ activityB_nestedClassifier = UMLFactory.eINSTANCE.createActivity();
+ activityB_nestedClassifier.getOwnedNodes().add(readSelfActionB2);
+ classB.getNestedClassifiers().add(activityB_nestedClassifier);
+
+ // Create Activity C => classifierBehaviour
+ this.readSelfActionC = UMLFactory.eINSTANCE.createReadSelfAction();
+ classC = UMLFactory.eINSTANCE.createClass();
+ classC.setName("c");
+ activityC_classiferBahaviour = UMLFactory.eINSTANCE.createActivity();
+ activityC_classiferBahaviour.getOwnedNodes().add(readSelfActionC);
+ classC.getOwnedBehaviors().add(activityC_classiferBahaviour);
+ classC.setClassifierBehavior(activityC_classiferBahaviour);
+
+ // Create Activity D => rootElement
+ this.readSelfActionD = UMLFactory.eINSTANCE.createReadSelfAction();
+ activityD_InRootElement = UMLFactory.eINSTANCE.createActivity();
+ activityD_InRootElement.getOwnedNodes().add(readSelfActionD);
+
+ // Add the different elements to the model
+ this.umlTestModel.getPackagedElements().add(activityA_SpecifiedOperation);
+ this.umlTestModel.getPackagedElements().add(this.classA);
+ this.umlTestModel.getPackagedElements().add(this.classB);
+ this.umlTestModel.getPackagedElements().add(this.classC);
+ this.umlTestModel.getPackagedElements().add(this.activityD_InRootElement);
+
+ // Add the test model within the model set
+ Resource umlTestModelResource = new ResourceImpl();
+ umlTestModelResource.setURI(URI.createURI("UMLBaseTestModel.tmp"));
+ umlTestModelResource.getContents().add(this.umlTestModel);
+ this.modelSet.getResources().add(umlTestModelResource);
+ }
+}
|