Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2017-01-19 08:33:51 +0000
committerFlorian Noyrit2017-04-19 09:21:15 +0000
commit13fb1caa4f2ce2f0a9830c6c178f6571dd500d8c (patch)
tree4f03eb0e32911a5a963f2d374db2f86d4b523325 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus
parent320a4377d303954215633cb92c4e95d21f2749e8 (diff)
downloadorg.eclipse.papyrus-13fb1caa4f2ce2f0a9830c6c178f6571dd500d8c.tar.gz
org.eclipse.papyrus-13fb1caa4f2ce2f0a9830c6c178f6571dd500d8c.tar.xz
org.eclipse.papyrus-13fb1caa4f2ce2f0a9830c6c178f6571dd500d8c.zip
Bug 508735 - [ActivityDiagram] Pins of ReadStructuralFeatureAction
should be create and update automatically Change-Id: I9a24a56358170aec2dcb0b7b8b20ed0e5cbe875b Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java20
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ReadStructuralFeatureActionEditHelperAdvice.java84
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/ReadStructuralFeatureActionPinUpdater.java72
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java2
7 files changed, 185 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java
index 1f9ba1816c7..a4a71f79152 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java
@@ -32,6 +32,7 @@ import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
import org.eclipse.uml2.uml.SignalEvent;
import org.eclipse.uml2.uml.Trigger;
import org.eclipse.uml2.uml.UMLPackage;
@@ -85,6 +86,25 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
}
}
}
+ // Pins of ReadStructuralFeatureAction should be create and update automatically
+ // 1] check if the setFeature is not Name (only type and multiplicity is interesting)
+ if (!request.getFeature().equals(UMLPackage.eINSTANCE.getNamedElement_Name())) {
+ // 2] get the preference for ReadStructuralFeatureAction
+ synchronizePinPreference = prefStore.getString(IAutomatedModelCompletionPreferencesConstants.READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION);
+ // 3] check preference
+ if (synchronizePinPreference) {
+ // 4] get all ReadStructuralFeatureAction
+ List<ReadStructuralFeatureAction> allReadStructuralFeatureAction = ElementUtil.getInstancesFilteredByType(root, ReadStructuralFeatureAction.class, null);
+ // 5] loop into the list of ReadStructuralFeatureAction
+ for (ReadStructuralFeatureAction readStructuralFeatureAction : allReadStructuralFeatureAction) {
+ if (readStructuralFeatureAction.getStructuralFeature() == property) {
+ // 6] call the command for the ReadStructuralFeatureAction whose the structuralFeature reference the property
+ IPinUpdater<ReadStructuralFeatureAction> updater = PinUpdaterFactory.getInstance().instantiate(readStructuralFeatureAction);
+ command.add(new PinUpdateCommand<ReadStructuralFeatureAction>("Update read structural feature action pins", updater, readStructuralFeatureAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
if (!command.isEmpty()) {
return command;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ReadStructuralFeatureActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ReadStructuralFeatureActionEditHelperAdvice.java
new file mode 100644
index 00000000000..e5f36fa1f23
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ReadStructuralFeatureActionEditHelperAdvice.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * 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.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.gmf.runtime.emf.type.core.requests.SetRequest;
+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.ReadStructuralFeatureAction;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ *
+ * Pins of ReadStructuralFeatureAction should be create and update automatically
+ *
+ */
+public class ReadStructuralFeatureActionEditHelperAdvice 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 ReadStructuralFeatureAction
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePin = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ // 2] check preference
+ if (synchronizePin) {
+ ReadStructuralFeatureAction readStructuralFeatureAction = (ReadStructuralFeatureAction) request.getElementToConfigure();
+ if (readStructuralFeatureAction != null) {
+ // 3] call the command for the ReadStructuralFeatureAction
+ IPinUpdater<ReadStructuralFeatureAction> updater = PinUpdaterFactory.getInstance().instantiate(readStructuralFeatureAction);
+ return new PinUpdateCommand<ReadStructuralFeatureAction>("Update read structural feature action pins", updater, readStructuralFeatureAction); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is StructuralFeature
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getStructuralFeatureAction_StructuralFeature())) {
+ // 2] get the preference for ReadStructuralFeatureAction
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePin = prefStore.getString(IAutomatedModelCompletionPreferencesConstants.READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION);
+ // 3] check preference
+ if (synchronizePin) {
+ ReadStructuralFeatureAction readStructuralFeatureAction = (ReadStructuralFeatureAction) request.getElementToEdit();
+ if (readStructuralFeatureAction != null) {
+ // 4] call the command for the ReadStructuralFeatureAction
+ IPinUpdater<ReadStructuralFeatureAction> updater = PinUpdaterFactory.getInstance().instantiate(readStructuralFeatureAction);
+ return new PinUpdateCommand<ReadStructuralFeatureAction>("Update read structural feature action pins", updater, readStructuralFeatureAction); //$NON-NLS-1$
+ }
+ }
+ }
+ 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 02666620720..e6e8da78310 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
@@ -16,11 +16,13 @@ package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.AcceptCallActionPinUpdater;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.AcceptEventActionPinUpdater;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.ReadStructuralFeatureActionPinUpdater;
import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.uml2.uml.ActivityNode;
import org.eclipse.uml2.uml.CallBehaviorAction;
import org.eclipse.uml2.uml.CallOperationAction;
+import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
import org.eclipse.uml2.uml.SendSignalAction;
public class PinUpdaterFactory {
@@ -71,6 +73,8 @@ public class PinUpdaterFactory {
updater = (IPinUpdater<T>) new AcceptCallActionPinUpdater();
} else if (node instanceof AcceptEventAction) {
updater = (IPinUpdater<T>) new AcceptEventActionPinUpdater();
+ } else if (node instanceof ReadStructuralFeatureAction) {
+ updater = (IPinUpdater<T>) new ReadStructuralFeatureActionPinUpdater();
}
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/ReadStructuralFeatureActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/ReadStructuralFeatureActionPinUpdater.java
new file mode 100644
index 00000000000..1ff83d6103e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/ReadStructuralFeatureActionPinUpdater.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * 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.edit.utils.updater.intermediateactions;
+
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractActionPinUpdater;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
+import org.eclipse.uml2.uml.StructuralFeature;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * Pins of ReadStructuralFeatureAction should be create and update automatically
+ *
+ * This class define derivation rules
+ */
+public class ReadStructuralFeatureActionPinUpdater extends AbstractActionPinUpdater<ReadStructuralFeatureAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater#updatePins(org.eclipse.uml2.uml.ActivityNode)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(ReadStructuralFeatureAction node) {
+ // 1] create object pin if it is not created yet
+ InputPin object = node.getObject();
+ if(object == null){
+ object = UMLFactory.eINSTANCE.createInputPin();
+ object.setLower(1);
+ object.setUpper(1);
+ object.setName("object"); //$NON-NLS-1$
+ }
+
+ // 2] update or create the result pin if the structural feature is set
+ // the result pin should have the same type, multiplicity as the structural feature
+ StructuralFeature structuralFeature = node.getStructuralFeature();
+ if(structuralFeature != null) {
+ OutputPin result = node.getResult();
+ if(result == null){
+ result = UMLFactory.eINSTANCE.createOutputPin();
+ }
+ result.setLower(structuralFeature.getLower());
+ result.setUpper(structuralFeature.getUpper());
+ result.setName("result"); //$NON-NLS-1$
+ result.setType(structuralFeature.getType());
+
+ // 3] update object pin type with the classifier owning the feature
+ if(structuralFeature instanceof Property){
+ if(structuralFeature.getFeaturingClassifiers().size() != 0){
+ object.setType(structuralFeature.getFeaturingClassifiers().get(0));
+ }
+ }
+ node.setResult(result);
+ }
+
+ node.setObject(object);
+ }
+
+}
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 a166a906ea3..cae2ae926d1 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
@@ -21,6 +21,7 @@ import org.eclipse.papyrus.uml.diagram.common.preferences.AutomatedModelCompleti
import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
/**
*
@@ -70,6 +71,7 @@ public class ActivityAutomatedModelCompletionPreferencePage extends AbstractAuto
List<Class<? extends ActivityNode>> actionList = new ArrayList<>();
actionList.add(AcceptCallAction.class);
actionList.add(AcceptEventAction.class);
+ actionList.add(ReadStructuralFeatureAction.class);
return actionList;
}
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 ce96a956268..eb38a38122d 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
@@ -46,6 +46,7 @@ public class AutomatedModelCompletionPreferencesInitializer extends AbstractPref
IPreferenceStore store = getPreferenceStore();
store.setDefault(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION);
store.setDefault(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION);
+ store.setDefault(IAutomatedModelCompletionPreferencesConstants.READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR, 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 92eb33d8111..e8c9aa2005f 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
@@ -23,4 +23,6 @@ public interface IAutomatedModelCompletionPreferencesConstants {
final public String ACCEPT_CALL_ACTION_ACCELERATOR = "org.eclipse.papyrus.uml.diagram.activity.preferences.acceptCallAction";
final public String ACCEPTE_EVENT_ACTION_ACCELERATOR = "org.eclipse.papyrus.uml.diagram.activity.preferences.acceptEventAction";
+
+ final public String READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR = "org.eclipse.papyrus.uml.diagram.activity.preferences.readStructuralFeatureAction";
}

Back to the top