Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2016-11-08 14:34:38 +0000
committerFlorian Noyrit2017-04-19 09:16:29 +0000
commit320a4377d303954215633cb92c4e95d21f2749e8 (patch)
treea617ba5019869a4fcb983fa8e7c73dc03ac58228 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus
parentb37f9403c106de972fd4f25dcdd0aeed40588f7f (diff)
downloadorg.eclipse.papyrus-320a4377d303954215633cb92c4e95d21f2749e8.tar.gz
org.eclipse.papyrus-320a4377d303954215633cb92c4e95d21f2749e8.tar.xz
org.eclipse.papyrus-320a4377d303954215633cb92c4e95d21f2749e8.zip
Bug 510611 - [Activity Diagram] Automated pin derivation for
AcceptEventAction and AcceptCallAction Change-Id: I49bb0c9398ca49ccffb255c218d88dd92c918a0e 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/AcceptEventActionEditHelperAdvice.java128
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java86
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java89
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java97
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java95
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java93
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java88
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java104
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/util/ImportUMLPrimitiveTypePackageCommand.java100
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractActionPinUpdater.java96
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/UpdaterPinUtils.java74
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptCallActionPinUpdater.java98
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptEventActionPinUpdater.java228
-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.java76
-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.java57
-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.java26
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/part/CustomMessages.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/preferences/DiagramSpecificPreferenceInitializer.java4
19 files changed, 1553 insertions, 2 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/AcceptEventActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/AcceptEventActionEditHelperAdvice.java
new file mode 100644
index 00000000000..2542c704004
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/AcceptEventActionEditHelperAdvice.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * 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.ImportUMLPrimitiveTypePackageCommand;
+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.UpdaterPinUtils;
+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.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ *
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ */
+public class AcceptEventActionEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * This method import UML primitive type package
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
+ // 1] get the preference for acceptEventAction or callEvent action
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION))
+ && (request.getElementToConfigure() instanceof AcceptCallAction);
+ synchronizePinPreference |= (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION))
+ && (request.getElementToConfigure() instanceof AcceptEventAction);
+ // 2] check preference
+ if (synchronizePinPreference) {
+ Package root = PackageUtil.getRootPackage((Element) request.getElementToConfigure());
+ if (!UpdaterPinUtils.isPrimitiveTypeLibraryImported(root)) {
+ // 3] call command to import c
+ return new ImportUMLPrimitiveTypePackageCommand("Import UML primitive type package", root); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This method call command to synchronize pin
+ *
+ * @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 acceptEventAction or callEvent action
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION))
+ && (request.getElementToConfigure() instanceof AcceptCallAction);
+ synchronizePinPreference |= (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION))
+ && (request.getElementToConfigure() instanceof AcceptEventAction);
+ // 2] check preference
+ if (synchronizePinPreference) {
+ AcceptEventAction acceptEventAction = (AcceptEventAction) request.getElementToConfigure();
+ if (acceptEventAction != null) {
+ // 3] call command to synchronize pin
+ return new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", PinUpdaterFactory.getInstance().instantiate(acceptEventAction), acceptEventAction); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This method call command to synchronize pin
+ *
+ * @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 trigger of isUnmarshall
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getAcceptEventAction_Trigger()) || request.getFeature().equals(UMLPackage.eINSTANCE.getAcceptEventAction_IsUnmarshall())) {
+ // 2] get the preference for acceptEventAction or callEvent action
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION))
+ && (request.getElementToEdit() instanceof AcceptCallAction);
+ synchronizePinPreference |= (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION))
+ && (request.getElementToEdit() instanceof AcceptEventAction);
+ // 3] check preference
+ if (synchronizePinPreference) {
+ AcceptEventAction acceptEventAction = (AcceptEventAction) request.getElementToEdit();
+ if (acceptEventAction != null) {
+ // 4] call command to synchronize pin
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ return new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction); //$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/advices/CallEventEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java
new file mode 100644
index 00000000000..4b279495d14
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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 java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+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.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.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.CallEvent;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * Call pin derivation command on modification of a callEvent
+ */
+public class CallEventEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * This method call command to synchronize pin
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is operation
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getCallEvent_Operation())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = false;
+ CompositeCommand command = new CompositeCommand("Update callEvent"); //$NON-NLS-1$
+ CallEvent callEvent = (CallEvent) request.getElementToEdit();
+ Package root = PackageUtil.getRootPackage(callEvent);
+ if (root != null) {
+ // 2] check the preference for AcceptCallEvent
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 3] get allAcceptCallAction
+ List<AcceptCallAction> allAcceptCallAction = ElementUtil.getInstancesFilteredByType(root, AcceptCallAction.class, null);
+ for (AcceptCallAction acceptCallAction : allAcceptCallAction) {
+ if (acceptCallAction instanceof AcceptCallAction) {
+ for (Trigger t : acceptCallAction.getTriggers()) {
+ if (t.getEvent() instanceof CallEvent && t.getEvent() == callEvent) {
+ // 4] call the command for the acceptCallAction whose trigger reference the callEvent
+ IPinUpdater<AcceptCallAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
+ command.add(new PinUpdateCommand<AcceptCallAction>("Update accept event action pins", updater, acceptCallAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ if (!command.isEmpty()) {
+ return command;
+ }
+ }
+ }
+ return super.getAfterSetCommand(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java
new file mode 100644
index 00000000000..a846be7fd8a
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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 java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+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.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.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.CallEvent;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * Call pin derivation command on modification of an operation
+ */
+public class OperationEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * This method call command to synchronize pin
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is ownedParameter
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getBehavioralFeature_OwnedParameter())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = false;
+ CompositeCommand command = new CompositeCommand("Update operation"); //$NON-NLS-1$
+ Operation operation = (Operation) request.getElementToEdit();
+ Package root = PackageUtil.getRootPackage(operation);
+ if (root != null) {
+ // 2] check the preference for AcceptCallEvent
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 3] get allAcceptCallAction
+ List<AcceptCallAction> allAcceptCallAction = ElementUtil.getInstancesFilteredByType(root, AcceptCallAction.class, null);
+ for (AcceptCallAction acceptCallAction : allAcceptCallAction) {
+ if (acceptCallAction instanceof AcceptCallAction) {
+ for (Trigger t : acceptCallAction.getTriggers()) {
+ if (t.getEvent() instanceof CallEvent) {
+ if (((CallEvent) t.getEvent()).getOperation() == operation) {
+ // 6] call the command for the acceptCallAction whose trigger reference a callEvent which reference the operation
+ IPinUpdater<AcceptCallAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
+ return new PinUpdateCommand<AcceptCallAction>("Update accept event action pins", updater, acceptCallAction); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!command.isEmpty()) {
+ return command;
+ }
+ }
+ }
+ return super.getAfterSetCommand(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java
new file mode 100644
index 00000000000..eb44fa4c3b2
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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 java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+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.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.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.CallEvent;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * Call pin derivation command on modification of a parameter
+ */
+public class ParameterEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * This method call command to synchronize pin
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is Name, Type or Multiplicity
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getTypedElement_Type()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getMultiplicityElement_Lower()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getMultiplicityElement_Upper()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getParameter_Direction()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getNamedElement_Name())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = false;
+ CompositeCommand command = new CompositeCommand("Update parameter"); //$NON-NLS-1$
+ Parameter parameter = (Parameter) request.getElementToEdit();
+ Package root = PackageUtil.getRootPackage(parameter);
+ if (root != null) {
+ // 2] check the preference for AcceptCallEvent
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 3] get allAcceptCallAction
+ List<AcceptCallAction> allAcceptCallAction = ElementUtil.getInstancesFilteredByType(root, AcceptCallAction.class, null);
+ for (AcceptCallAction acceptCallAction : allAcceptCallAction) {
+ if (acceptCallAction instanceof AcceptCallAction) {
+ for (Trigger t : acceptCallAction.getTriggers()) {
+ if (t.getEvent() instanceof CallEvent) {
+ for (Parameter p : ((CallEvent) t.getEvent()).getOperation().getOwnedParameters()) {
+ if (p == parameter) {
+ // 4] call the command for the acceptEventAction whose trigger reference a callEvent
+ // which reference an operation which owned the parameter
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptCallAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!command.isEmpty()) {
+ return command;
+ }
+ }
+ }
+ return super.getAfterSetCommand(request);
+ }
+}
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
new file mode 100644
index 00000000000..1f9ba1816c7
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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 java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+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.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.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+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.SignalEvent;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * Call pin derivation command on modification of a property
+ */
+public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is Name, Type or Multiplicity
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getTypedElement_Type()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getMultiplicityElement_Lower()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getMultiplicityElement_Upper()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getNamedElement_Name())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = false;
+ CompositeCommand command = new CompositeCommand("Update pins on modification of a property"); //$NON-NLS-1$
+ Property property = (Property) request.getElementToEdit();
+ Package root = PackageUtil.getRootPackage(property);
+ if (root != null) {
+ List<AcceptEventAction> allAcceptEventAction = null;
+ // 2] check the preference for AcceptEventAction
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 3] get all AcceptEventAction
+ allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
+ for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
+ if (!(acceptEventAction instanceof AcceptCallAction)) { // instance of AcceptEventAction and not AcceptCallEvent
+ for (Trigger t : acceptEventAction.getTriggers()) {
+ if (t.getEvent() instanceof SignalEvent) {
+ for (Property p : ((SignalEvent) t.getEvent()).getSignal().getAllAttributes()) { // get all properties including those inherited from its parents
+ if (p == property) {
+ // 4] call the command for the acceptEventAction whose trigger reference a signalEvent
+ // which reference an signal which owned the property
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!command.isEmpty()) {
+ return command;
+ }
+ }
+ }
+ return super.getAfterSetCommand(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java
new file mode 100644
index 00000000000..6d9ca68df93
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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 java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+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.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.papyrus.uml.diagram.common.util.Util;
+import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.SignalEvent;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * Call pin derivation command on modification of a signal
+ */
+public class SignalEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * This method call command to synchronize pin
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is ownedAttribute
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getSignal_OwnedAttribute())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = false;
+ CompositeCommand command = new CompositeCommand("Update signal"); //$NON-NLS-1$
+ Signal signal = (Signal) request.getElementToEdit();
+ Package root = PackageUtil.getRootPackage(signal);
+ if (root != null) {
+ List<AcceptEventAction> allAcceptEventAction = null;
+ // 2] check the preference for AcceptEventAction
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 3] get all AcceptEventAction
+ allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
+ for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
+ if (!(acceptEventAction instanceof AcceptCallAction)) { // instance of AcceptEventAction and not AcceptCallEvent
+ for (Trigger t : acceptEventAction.getTriggers()) {
+ if (t.getEvent() instanceof SignalEvent) {
+ SignalEvent signalEvent = (SignalEvent) t.getEvent();
+ if (signalEvent.getSignal() == signal || Util.getAllSuperClasses(null, signalEvent.getSignal()).contains(signal)) {
+ // 4] call the command for the acceptEventAction whose trigger reference a signalEvent which reference the signal
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!command.isEmpty()) {
+ return command;
+ }
+ }
+ }
+ return super.getAfterSetCommand(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java
new file mode 100644
index 00000000000..4a9f45e59c5
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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 java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+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.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.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.SignalEvent;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * Call pin derivation command on modification of a signalEvent
+ */
+public class SignalEventEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * This method call command to synchronize pin
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is signal
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getSignalEvent_Signal())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = false;
+ CompositeCommand command = new CompositeCommand("Update signalEvent"); //$NON-NLS-1$
+ SignalEvent signalEvent = (SignalEvent) request.getElementToEdit();
+ Package root = PackageUtil.getRootPackage(signalEvent);
+ if (root != null) {
+ List<AcceptEventAction> allAcceptEventAction = null;
+ // 2] check the preference for AcceptEventAction
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 3] get all AcceptEventAction
+ allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
+ for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
+ if (!(acceptEventAction instanceof AcceptCallAction)) { // instance of AcceptEventAction and not AcceptCallEvent
+ for (Trigger t : acceptEventAction.getTriggers()) {
+ if (t.getEvent() instanceof SignalEvent && t.getEvent() == signalEvent) {
+ // 4] call the command for the acceptEventAction whose trigger reference the signalEvent
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ if (!command.isEmpty()) {
+ return command;
+ }
+ }
+ }
+ return super.getAfterSetCommand(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java
new file mode 100644
index 00000000000..8e9527d422c
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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 java.util.List;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+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.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.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * Call pin derivation command on modification of a trigger
+ */
+public class TriggerEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is event
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getTrigger_Event())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePinPreference = false;
+ CompositeCommand command = new CompositeCommand("Update trigger"); //$NON-NLS-1$
+ Trigger trigger = (Trigger) request.getElementToEdit();
+ Package root = PackageUtil.getRootPackage(trigger);
+ if (root != null) {
+ List<AcceptEventAction> allAcceptEventAction = null;
+ // 2] check the preference for AcceptEventAction
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 3] get all AcceptEventAction
+ allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
+ for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
+ if (!(acceptEventAction instanceof AcceptCallAction)) {
+ for (Trigger t : acceptEventAction.getTriggers()) {
+ if (t == trigger) {
+ // 4] call the command for the acceptEventAction whose trigger is equal to the current one
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ // 5] check the preference for AcceptCallEvent
+ synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ if (synchronizePinPreference) {
+ // 6] get allAcceptEventAction if we don't get it before
+ if (allAcceptEventAction == null) {
+ allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
+ }
+ for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
+ if (acceptEventAction instanceof AcceptCallAction) {
+ for (Trigger t : acceptEventAction.getTriggers()) {
+ if (t == trigger) {
+ // 7] call the command for the acceptEventAction whose trigger is equal to the current one
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ if (!command.isEmpty()) {
+ return command;
+ }
+ }
+ }
+ return super.getAfterSetCommand(request);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/util/ImportUMLPrimitiveTypePackageCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/util/ImportUMLPrimitiveTypePackageCommand.java
new file mode 100644
index 00000000000..7d7deb2e571
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/util/ImportUMLPrimitiveTypePackageCommand.java
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * 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.commands.util;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.resource.UMLResource;
+
+/**
+ *
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ */
+public class ImportUMLPrimitiveTypePackageCommand extends AbstractCommand {
+
+ private Package root;
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ */
+ public ImportUMLPrimitiveTypePackageCommand(String label, Package rootPackage) {
+ super(label);
+ this.root = rootPackage;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param progressMonitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ CommandResult result = CommandResult.newOKCommandResult();
+ try {
+ Package umlPackage = null;
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource resource = resourceSet.getResource(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI), true);
+ umlPackage = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.PACKAGE);
+ root.createPackageImport(umlPackage);
+ } catch (WrappedException e) {
+ result = CommandResult.newErrorCommandResult(e);
+ }
+
+ return result;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doRedoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param progressMonitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doUndoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param progressMonitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ 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/AbstractActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractActionPinUpdater.java
new file mode 100644
index 00000000000..45d0d8b69f2
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractActionPinUpdater.java
@@ -0,0 +1,96 @@
+/*****************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Action;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.ActivityEdge;
+import org.eclipse.uml2.uml.ActivityPartition;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Pin;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.StructuredActivityNode;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ *
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ */
+public abstract class AbstractActionPinUpdater<NodeType extends Action> implements IPinUpdater<NodeType> {
+
+ /**
+ * Get the UML primitive type of the model corresponding to typeName
+ *
+ * @param typeName
+ * @param model
+ * @return the UML primitive type of the model
+ */
+ protected PrimitiveType getUMLPrimitiveType(final String typeName, Model model){
+ // Retrieve the primitive type corresponding to the specified type name.
+ // It is only possible to retrieve a primitive type if in the current model
+ // context the primitive types library is available (i.e., is imported). In
+ // any other case, null is returned.
+ PrimitiveType primitiveType = null;
+ // 1] check if primitive typed is already imported
+ if(UpdaterPinUtils.isPrimitiveTypeLibraryImported(model)){
+ // 2] get UML primitive types package
+ Package primitiveTypePackage = UpdaterPinUtils.getPrimitiveTypesPackage(model);
+ Iterator<Type> ownedTypesIterator = primitiveTypePackage.getOwnedTypes().iterator();
+ // 3] loop into package elements to get the required type
+ while(ownedTypesIterator.hasNext()){
+ Type type = ownedTypesIterator.next();
+ if(type instanceof PrimitiveType && type.getName().equals(typeName)){
+ primitiveType = (PrimitiveType) type;
+ }
+ }
+ }
+ return primitiveType;
+ }
+
+ /**
+ * The deletion of a pin has an impact on edges that are using as a source or a target.
+ * To ensure model consistency, the deletion of a pin implies deletion of edges referencing
+ * this pin either as a source or a target.
+ *
+ * @param pin
+ */
+ protected static void deleteEdges(Pin pin) {
+ // 1] get all incoming and outgoing edges
+ List<ActivityEdge> edgeToDelete = new ArrayList<ActivityEdge>(pin.getIncomings());
+ edgeToDelete.addAll(pin.getOutgoings());
+ Iterator<ActivityEdge> edgeToDeleteIterator = edgeToDelete.iterator();
+ // 2] loop into all edges
+ while (edgeToDeleteIterator.hasNext()) {
+ ActivityEdge edge = edgeToDeleteIterator.next();
+ Element owner = edge.getOwner();
+ if (owner != null) {
+ // 3] remove edges
+ if (owner instanceof StructuredActivityNode) {
+ ((StructuredActivityNode) owner).getEdges().remove(edge);
+ } else if (owner instanceof Activity) {
+ ((Activity) owner).getEdges().remove(edge);
+ } else if (owner instanceof ActivityPartition) {
+ ((ActivityPartition) owner).getEdges().remove(edge);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
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 d34fb4ccece..02666620720 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
@@ -7,13 +7,17 @@
* 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
+ * J�r�mie TATIBOUET (CEA LIST) - Initial API and implementation
+ * S�bastien REVOL (CEA LIST) - Initial API and implementation
*
*****************************************************************************/
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.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;
@@ -63,6 +67,10 @@ public class PinUpdaterFactory {
updater = (IPinUpdater<T>) new CallOperationActionPinUpdater();
} else if (node instanceof SendSignalAction) {
updater = (IPinUpdater<T>) new SendSignalActionPinUpdater();
+ } else if (node instanceof AcceptCallAction) {
+ updater = (IPinUpdater<T>) new AcceptCallActionPinUpdater();
+ } else if (node instanceof AcceptEventAction) {
+ updater = (IPinUpdater<T>) new AcceptEventActionPinUpdater();
}
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/UpdaterPinUtils.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/UpdaterPinUtils.java
new file mode 100644
index 00000000000..b3f42a34a73
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/UpdaterPinUtils.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * 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
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.Iterator;
+
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+
+/**
+ *
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ */
+public class UpdaterPinUtils {
+
+ private final static String UML_PRIMITIVE_TYPES_URI = "http://www.omg.org/spec/PrimitiveTypes/20131001";
+
+ /**
+ * This method test if the UML primitive type package is already imported in the model
+ *
+ * @param entryPoint
+ * @return return true if the UML primitive type package is already imported in the model, false otherwise
+ */
+ public static boolean isPrimitiveTypeLibraryImported(Element entryPoint) {
+ boolean imported = false;
+ if (entryPoint != null) {
+ Model model = entryPoint.getModel();
+ Iterator<PackageImport> packageImportIterator = model.getPackageImports().iterator();
+ while (!imported && packageImportIterator.hasNext()) {
+ PackageImport packageImport = packageImportIterator.next();
+ if (packageImport.getImportedPackage().isModelLibrary()
+ && packageImport.getImportedPackage().getURI().equals(UML_PRIMITIVE_TYPES_URI)) {
+ imported = true;
+ }
+ }
+ }
+ return imported;
+ }
+
+ /**
+ * Get the UML primitive type package
+ *
+ * @param element
+ * @return the UML primitive type package
+ */
+ public static Package getPrimitiveTypesPackage(Element element) {
+ Package primitiveTypesPackage = null;
+ Model model = element.getModel();
+ Iterator<PackageImport> packageImportIterator = model.getPackageImports().iterator();
+ while (primitiveTypesPackage == null && packageImportIterator.hasNext()) {
+ PackageImport packageImport = packageImportIterator.next();
+ if (packageImport.getImportedPackage().isModelLibrary()
+ && packageImport.getImportedPackage().getURI().equals(UML_PRIMITIVE_TYPES_URI)) {
+ primitiveTypesPackage = packageImport.getImportedPackage();
+ }
+ }
+ return primitiveTypesPackage;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptCallActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptCallActionPinUpdater.java
new file mode 100644
index 00000000000..bb2019ec829
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptCallActionPinUpdater.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractActionPinUpdater;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.CallEvent;
+import org.eclipse.uml2.uml.Event;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * This class define derivation rules
+ */
+public class AcceptCallActionPinUpdater extends AbstractActionPinUpdater<AcceptCallAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater#updatePins(org.eclipse.uml2.uml.ActivityNode)
+ *
+ * @param node
+ *
+ */
+ @Override
+ public void updatePins(AcceptCallAction node) {
+ if (node != null) {
+ List<OutputPin> originPins = node.getResults();
+ List<OutputPin> keepOutputPins = new ArrayList<>();
+
+ // 1] create return information pin if it is not created yet
+ OutputPin returnInformation = ((AcceptCallAction) node).getReturnInformation();
+ if (returnInformation == null) {
+ returnInformation = UMLFactory.eINSTANCE.createOutputPin();
+ returnInformation.setName("return information"); //$NON-NLS-1$
+ ((AcceptCallAction) node).setReturnInformation(returnInformation);
+ // set isUnmarshall to true because according to the UML norm it should not be false
+ node.setIsUnmarshall(true);
+ }
+
+ // 2] if there is only one trigger search for pins we will keep (pin which matches to a parameter of the referenced operation)
+ // according to the UML norm this action should have only one trigger and it should be a callEvent
+ if (node.getTriggers().size() == 1) {
+ Trigger trigger = node.getTriggers().get(0);
+ Event event = trigger.getEvent();
+ if (event instanceof CallEvent) {
+ // 3] loop into parameters of the referenced operation
+ for (Parameter parameter : ((CallEvent) event).getOperation().getOwnedParameters()) {
+ // 4] check if the parameter match with a pin or create it if not pin match, then add it to the keepOutputPins list
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
+ OutputPin outputPin = node.getResult(parameter.getName(), parameter.getType(), true, true);
+ if (parameter.getType() == null) {
+ outputPin.setType(null); // confirm because null in the previous method means any type
+ }
+ outputPin.setType(parameter.getType());
+ outputPin.setLower(parameter.getLower());
+ outputPin.setUpper(parameter.getUpper());
+ outputPin.setName(parameter.getName());
+ keepOutputPins.add(outputPin);
+ }
+ }
+
+ }
+ }
+
+ // 5] Delete pin which are not in the keepOutputPin list
+ for (OutputPin pin : originPins) {
+ if (!keepOutputPins.contains(pin)) {
+ // delete edge from and to this pin
+ deleteEdges(pin);
+ }
+ }
+
+ // 6] remove old pin and add created pins and keeping pins
+ originPins.clear();
+ originPins.addAll(keepOutputPins);
+ }
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptEventActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptEventActionPinUpdater.java
new file mode 100644
index 00000000000..005cdfbf1b8
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/AcceptEventActionPinUpdater.java
@@ -0,0 +1,228 @@
+/*****************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractActionPinUpdater;
+import org.eclipse.papyrus.uml.diagram.common.util.Util;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Event;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.SignalEvent;
+import org.eclipse.uml2.uml.TimeEvent;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * This class define derivation rules
+ */
+public class AcceptEventActionPinUpdater extends AbstractActionPinUpdater<AcceptEventAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater#updatePins(org.eclipse.uml2.uml.ActivityNode)
+ *
+ * @param node
+ *
+ */
+ @Override
+ public void updatePins(AcceptEventAction node) {
+ if (node != null) {
+ List<OutputPin> originPins = node.getResults();
+ List<OutputPin> keepOutputPins = new ArrayList<>();
+
+ // 1] isUnmarchal is true
+ if (node.isUnmarshall()) {
+ // 2] only one trigger
+ if (node.getTriggers().size() == 1) {
+ Event event = node.getTriggers().get(0).getEvent();
+ // 3] check if the event is a signalEvent (as many result pin as property of the signal)
+ if (event instanceof SignalEvent) {
+ // 4] loop into properties of the signal referenced by the signalEvent of the trigger
+ for (Property property : ((SignalEvent) event).getSignal().getAllAttributes()) {
+ // 5] update the result pin: search the pin with the property name and the property type,
+ // if it is not existing it is created
+ // then this pin is add to the keepOutputPins list
+ OutputPin outputPin = node.getResult(property.getName(), property.getType(), true, true);
+ if (property.getType() == null) {
+ outputPin.setType(null); // confirm because null in the previous method means any type
+ }
+ outputPin.setLower(property.getLower());
+ outputPin.setUpper(property.getUpper());
+ keepOutputPins.add(outputPin);
+ }
+ // 6] check if the event is a timeEvent (one result pin name time and typed by Real)
+ // this pin is add to the keepOutputPins list
+ } else if (event instanceof TimeEvent) {
+ OutputPin outputPin = node.getResult("time", getUMLPrimitiveType("Real", node.getModel()), true, true);
+ outputPin.setLower(1);
+ outputPin.setUpper(1);
+ keepOutputPins.add(outputPin);
+ }
+ // 7] multiple triggers
+ } else if (!node.getTriggers().isEmpty()) {
+ // 8] Check if all Event are SignalEvents (as many pins as property of the common ancestor of all signals)
+ // those pins are add to the keepOutputPins list
+ boolean isOnlySignalEvent = true;
+ for (Trigger trigger : node.getTriggers()) {
+ if (!(trigger.getEvent() instanceof SignalEvent)) {
+ isOnlySignalEvent = false;
+ break;
+ }
+ }
+ if (isOnlySignalEvent) {
+ // 9] search common ancestor of all signals referenced by signalEvents
+ Classifier comonAncestor = getTypeForMultipleTriggers(node.getTriggers());
+ if (comonAncestor != null) {
+ for (Property property : comonAncestor.getAllAttributes()) {
+ OutputPin outputPin = node.getResult(property.getName(), property.getType(), true, true);
+ if (property.getType() == null) {
+ outputPin.setType(null); // confirm because null in the previous method means any type
+ }
+ outputPin.setLower(property.getLower());
+ outputPin.setUpper(property.getUpper());
+ keepOutputPins.add(outputPin);
+ }
+ }
+ } else {
+ // 10] Check if all Event are TimeEvents (one result pin name time and untype)
+ // this pin is add to the keepOutputPins list
+ boolean onlyTimeEvent = true;
+ for (Trigger trigger : node.getTriggers()) {
+ if (!(trigger.getEvent() instanceof TimeEvent)) {
+ onlyTimeEvent = false;
+ break;
+ }
+ }
+ if (onlyTimeEvent) {
+ OutputPin outputPin = node.getResult("time", null, true, true);
+ outputPin.setType(null);
+ outputPin.setLower(1);
+ outputPin.setUpper(1);
+ keepOutputPins.add(outputPin);
+ }
+ }
+ }
+ // 11] isUnmarshall is false
+ } else {
+ // 12] only one trigger
+ if (node.getTriggers().size() == 1) {
+ Trigger trigger = node.getTriggers().get(0);
+ Event event = trigger.getEvent();
+ if (event instanceof SignalEvent) {
+ OutputPin outputPin = node.getResult("result", ((SignalEvent) event).getSignal(), true, true);
+ if (((SignalEvent) event).getSignal() == null) {
+ outputPin.setType(null); // confirm because null in the previous method means any type
+ }
+ outputPin.setLower(1);
+ outputPin.setUpper(1);
+ keepOutputPins.add(outputPin);
+ } else if (event instanceof TimeEvent) {
+ OutputPin outputPin = node.getResult("time", getUMLPrimitiveType("Real", node.getModel()), true, true);
+ outputPin.setLower(1);
+ outputPin.setUpper(1);
+ keepOutputPins.add(outputPin);
+ }
+ // 13] multiple trigger
+ } else if (node.getTriggers().size() != 0) {
+ // 14] Check if all Event are SignalEvents (only one result pin type by the common ancestor of all signals)
+ boolean isOnlySignalEvent = true;
+ for (Trigger trigger : node.getTriggers()) {
+ if (!(trigger.getEvent() instanceof SignalEvent)) {
+ isOnlySignalEvent = false;
+ break;
+ }
+ }
+ if (isOnlySignalEvent) {
+ List<Trigger> triggers = node.getTriggers();
+ Type type = getTypeForMultipleTriggers(triggers);
+ OutputPin outputPin = node.getResult("result", type, true, true); //$NON-NLS-1$
+ if (type == null) {
+ outputPin.setType(null); // confirm because null in the previous method means any type
+ }
+ outputPin.setLower(1);
+ outputPin.setUpper(1);
+ keepOutputPins.add(outputPin);
+ // 15] not only SignalEvent (one result pin untyped)
+ } else {
+ OutputPin outputPin = node.getResult("result", null, true, true); //$NON-NLS-1$
+ outputPin.setType(null); // confirm because null in the previous method means any type
+ outputPin.setLower(1);
+ outputPin.setUpper(1);
+ keepOutputPins.add(outputPin);
+ }
+ }
+ }
+
+ // 16] Delete pin which are not in the keepOutputPin list
+ for (OutputPin pin : originPins) {
+ if (!keepOutputPins.contains(pin)) {
+ // delete edge from and to this pin
+ deleteEdges(pin);
+ }
+ }
+
+ // 17] remove old pin and add created pins and keeping pins
+ originPins.clear();
+ originPins.addAll(keepOutputPins);
+ }
+ }
+
+ /**
+ * Get the common ancestor supposing all triggers referenced a signalEvent
+ *
+ * @param triggers
+ * @return
+ */
+ private Classifier getTypeForMultipleTriggers(List<Trigger> triggers) {
+ if (!triggers.isEmpty()) {
+ // 1] get super class of the signal referencing by the first trigger
+ List<Classifier> commonSuperClass = new ArrayList<>(Util.getAllSuperClasses(null, ((SignalEvent) triggers.get(0).getEvent()).getSignal()));
+ commonSuperClass.add(((SignalEvent) triggers.get(0).getEvent()).getSignal());
+ Set<Classifier> nonCommonClassifier = new HashSet<Classifier>();
+ // 2] loop into triggers
+ for (Trigger t : triggers) {
+ // 3] loop into the list of the commonSuperClass
+ // put into nonCommonClassifier list all super classifier of the signal referenced by the trigger
+ // which is not in the commonSuperClass list
+ for (Classifier c : commonSuperClass) {
+ if (!(Util.getAllSuperClasses(null, ((SignalEvent) t.getEvent()).getSignal()).contains(c)) && ((SignalEvent) t.getEvent()).getSignal() != c) {
+ nonCommonClassifier.add(c);
+ }
+ }
+ }
+
+ // 4] remove all nonCommonClassifier from commonSuperClass
+ commonSuperClass.removeAll(nonCommonClassifier);
+
+ // 5] Get the classifier which inherited of all common super class
+ for (Classifier classifier : commonSuperClass) {
+ List<Classifier> inheritedClassifier = new ArrayList<>(Util.getAllSuperClasses(null, classifier));
+ inheritedClassifier.add(classifier);
+ if (inheritedClassifier.containsAll(commonSuperClass)) {
+ return classifier;
+ }
+ }
+
+ }
+ 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/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
new file mode 100644
index 00000000000..a166a906ea3
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.uml.diagram.common.preferences.AbstractAutomatedModelCompletionPreferencesPage;
+import org.eclipse.papyrus.uml.diagram.common.preferences.AutomatedModelCompletionPreferenceDescriptor;
+import org.eclipse.uml2.uml.AcceptCallAction;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.ActivityNode;
+
+/**
+ *
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ */
+public class ActivityAutomatedModelCompletionPreferencePage extends AbstractAutomatedModelCompletionPreferencesPage {
+
+ /**
+ * Constructor.
+ *
+ */
+ public ActivityAutomatedModelCompletionPreferencePage() {
+ super();
+ initContentProvider(getActionList());
+ }
+
+ /**
+ * This method initialize the automatedModelCompletionDescriptorsList property
+ */
+ protected void initContentProvider(List<Class<? extends ActivityNode>> actionList) {
+ List<String> automatedModelCompletionList = new ArrayList<>();
+ automatedModelCompletionList.add(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION);
+ automatedModelCompletionList.add(AutomatedModelCompletionPreferencesInitializer.NONE);
+
+ for (Class<? extends ActivityNode> action : actionList) {
+ // get only the name of the action
+ // initial form : interface org.eclipse.uml2.uml.<ActionName>
+ String actionName = action.toString();
+ actionName = actionName.replaceAll("org.eclipse.uml2.uml.", "");
+ actionName = actionName.replaceFirst("interface\\s", "");
+ actionName = actionName.substring(0, 1).toLowerCase() + actionName.substring(1);
+ // get preference constant like : org.eclipse.papyrus.uml.diagram.activity.preferences.<ActionName>
+ String prefConst = "org.eclipse.papyrus.uml.diagram.activity.preferences.";
+ prefConst = prefConst.concat(actionName);
+
+ automatedModelCompletionDescriptorsList.add(new AutomatedModelCompletionPreferenceDescriptor(action, automatedModelCompletionList, prefConst));
+ }
+ }
+
+ /**
+ * This method create a list of actions which will be display in the preference page
+ *
+ * @return the list of actions
+ */
+ protected List<Class<? extends ActivityNode>> getActionList() {
+ List<Class<? extends ActivityNode>> actionList = new ArrayList<>();
+ actionList.add(AcceptCallAction.class);
+ actionList.add(AcceptEventAction.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
new file mode 100644
index 00000000000..ce96a956268
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.diagram.activity.part.CustomMessages;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+
+/**
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ * This class initialize preference
+ */
+public class AutomatedModelCompletionPreferencesInitializer extends AbstractPreferenceInitializer {
+
+ final static public String PIN_SYNCHRONIZATION = CustomMessages.AutomatedModelCompletionPreferencesInitializer_PinSynchronization;
+
+ final static public String NONE = CustomMessages.AutomatedModelCompletionPreferencesInitializer_None;
+
+ /**
+ * Constructor.
+ *
+ */
+ public AutomatedModelCompletionPreferencesInitializer() {
+ super();
+ }
+
+ /**
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ *
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = getPreferenceStore();
+ store.setDefault(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION);
+ store.setDefault(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION);
+ }
+
+ /**
+ * Get the preference store
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+}
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
new file mode 100644
index 00000000000..92eb33d8111
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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.preferences;
+
+/**
+ *
+ * Automated pin derivation for AcceptEventAction and AcceptCallAction
+ *
+ */
+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";
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/part/CustomMessages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/part/CustomMessages.java
index bc45363da71..0cf96cfebb2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/part/CustomMessages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/part/CustomMessages.java
@@ -191,4 +191,8 @@ public class CustomMessages extends NLS {
public static String BehaviorToCallBehaviorActionDropStrategy_Label;
public static String BehaviorToCallBehaviorActionDropStrategy_Description;
+
+ public static String AutomatedModelCompletionPreferencesInitializer_None;
+
+ public static String AutomatedModelCompletionPreferencesInitializer_PinSynchronization;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/preferences/DiagramSpecificPreferenceInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/preferences/DiagramSpecificPreferenceInitializer.java
index 50393675d1f..483a9afe2b1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/preferences/DiagramSpecificPreferenceInitializer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/preferences/DiagramSpecificPreferenceInitializer.java
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.uml.diagram.activity.preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
/**
@@ -52,6 +53,9 @@ public class DiagramSpecificPreferenceInitializer extends AbstractPreferenceInit
store.setDefault(IActivityPreferenceConstants.PREF_STRUCTURED_SPECIFIC_KEYWORD_DISPLAY_LOOP_NODE, true);
store.setDefault(IActivityPreferenceConstants.PREF_STRUCTURED_SPECIFIC_KEYWORD_DISPLAY_SEQUENCE_NODE, true);
store.setDefault(IActivityPreferenceConstants.PREF_STRUCTURED_SPECIFIC_KEYWORD_DISPLAY_STRUCTURED_NODE, true);
+ // Automated Model Completion Preferences
+ AutomatedModelCompletionPreferencesInitializer automatedModelCompletionPreferencesInitializer = new AutomatedModelCompletionPreferencesInitializer();
+ automatedModelCompletionPreferencesInitializer.initializeDefaultPreferences();
}
/**

Back to the top