diff options
Diffstat (limited to 'plugins')
29 files changed, 1979 insertions, 12 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF index 6878c7d853b..dc379434611 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF @@ -8,9 +8,10 @@ Export-Package: org.eclipse.papyrus.uml.diagram.activity, org.eclipse.papyrus.uml.diagram.activity.edit.dialogs,
org.eclipse.papyrus.uml.diagram.activity.edit.helpers,
org.eclipse.papyrus.uml.diagram.activity.edit.part,
- org.eclipse.papyrus.uml.diagram.activity.edit.part.ActivityGroup;x-friends:=org.eclipse.papyrus.uml.diagram.activity.tests,
+ org.eclipse.papyrus.uml.diagram.activity.edit.part.ActivityGroup;x-friends:="org.eclipse.papyrus.uml.diagram.activity.tests",
org.eclipse.papyrus.uml.diagram.activity.edit.parts,
org.eclipse.papyrus.uml.diagram.activity.edit.policies,
+ org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences,
org.eclipse.papyrus.uml.diagram.activity.expressions,
org.eclipse.papyrus.uml.diagram.activity.figures,
org.eclipse.papyrus.uml.diagram.activity.handlers,
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css index 97e4068b76a..1eba26f1505 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css @@ -1,3 +1,3 @@ -CallBehaviorAction, CallOperationAction, SendSignalAction{
+CallBehaviorAction, CallOperationAction, SendSignalAction, AcceptEventAction, AcceptCallAction {
canonical: true;
}
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-messages.properties index 8494ce4b4d8..837127838fe 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-messages.properties +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-messages.properties @@ -90,4 +90,6 @@ SpecificKeywordStructuredActivityNodeVisibility_visibility=Use specific keyword StructuredActivityNodePreferencePage_showSpecificKeyword=Use specific keyword for this element BehaviorToCallBehaviorActionDropStrategy_Label=Activity Diagram Drop Strategy: Droping a behavior to generate a CallBehaviorAction BehaviorToCallBehaviorActionDropStrategy_Description=Droping a behavior to generate a CallBehaviorAction +AutomatedModelCompletionPreferencesInitializer_None=None +AutomatedModelCompletionPreferencesInitializer_PinSynchronization=Pin synchronization # End of non generated values 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();
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations index 3a7ea78a0b2..0b3e6f113ae 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations @@ -1,11 +1,36 @@ -<?xml version="1.0" encoding="ASCII" standalone="no"?><elementtypesconfigurations:ElementTypeSetConfiguration xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" identifier="org.eclipse.papyrus.uml.diagram.activity.elementTypeSet" metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML" name="PapyrusUMLActivityDiagram" xmi:id="_x8G0YGaNEeSyJIsxLao1Pw" xmi:version="2.0">
- <adviceBindingsConfigurations editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallBehaviorActionEditHelperAdvice" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallBehaviorActionEditHelperAdvice" xmi:id="_zAcw0GaOEeSyJIsxLao1Pw" xsi:type="elementtypesconfigurations:AdviceBindingConfiguration">
- <target href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu4bb9x0EeWVxMf7SXAfhg" xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"/>
+<?xml version="1.0" encoding="ASCII"?>
+<elementtypesconfigurations:ElementTypeSetConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmi:id="_x8G0YGaNEeSyJIsxLao1Pw" identifier="org.eclipse.papyrus.uml.diagram.activity.elementTypeSet" name="PapyrusUMLActivityDiagram" metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML">
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_zAcw0GaOEeSyJIsxLao1Pw" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallBehaviorActionEditHelperAdvice" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallBehaviorActionEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu4bb9x0EeWVxMf7SXAfhg"/>
</adviceBindingsConfigurations>
- <adviceBindingsConfigurations editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallOperationActionEditHelperAdvice" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallOperationActionEditHelperAdvice" inheritance="all" xmi:id="_9UmhMGaOEeSyJIsxLao1Pw" xsi:type="elementtypesconfigurations:AdviceBindingConfiguration">
- <target href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu4bc9x0EeWVxMf7SXAfhg" xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"/>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_9UmhMGaOEeSyJIsxLao1Pw" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallOperationActionEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallOperationActionEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu4bc9x0EeWVxMf7SXAfhg"/>
</adviceBindingsConfigurations>
- <adviceBindingsConfigurations editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SendSignalActionEditHelperAdvice" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SendSignalActionEditHelperAdvice" inheritance="all" xmi:id="_Eu2FMGaPEeSyJIsxLao1Pw" xsi:type="elementtypesconfigurations:AdviceBindingConfiguration">
- <target href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu6RPtx0EeWVxMf7SXAfhg" xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"/>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_Eu2FMGaPEeSyJIsxLao1Pw" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SendSignalActionEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SendSignalActionEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="../../org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_eu6RPtx0EeWVxMf7SXAfhg"/>
</adviceBindingsConfigurations>
-</elementtypesconfigurations:ElementTypeSetConfiguration>
\ No newline at end of file + <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_ZqJusJt8EeatALl2pL8MPg" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.AcceptEventActionEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.AcceptEventActionEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_ScQcu1YCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_qc9DEKzLEeaKg_9XdFC-Jg" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.TriggerEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.TriggerEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_SdLCt1YCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_3Kg-0KyfEeaLH65NXKluhw" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SignalEventEditHelperAdvice" description="" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SignalEventEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_SdB44VYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_VsWYYKy_EeaLH65NXKluhw" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SignalEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.SignalEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_SdB431YCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_h552MKzGEeaKg_9XdFC-Jg" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallEventEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.CallEventEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_ScaNylYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_-7K_QKzBEeaLH65NXKluhw" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.OperationEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.OperationEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sc8ZVFYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_1ZLnMK1nEeaKg_9XdFC-Jg" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.PropertyEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.PropertyEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sc-1cFYCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_dpWU0K1nEeaKg_9XdFC-Jg" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ParameterEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ParameterEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#_Sc9nc1YCEeS0WsAAtVmToA"/>
+ </adviceBindingsConfigurations>
+</elementtypesconfigurations:ElementTypeSetConfiguration>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml index 367af736ff6..272d89bd7c7 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml @@ -2162,6 +2162,19 @@ self.structuralFeature.oclAsType(Property).opposite.type = self.object.type]]> stylesheetPath="css/default-theme-contribution-activity-diagram.css"> </stylesheet> </extension> +<extension + point="org.eclipse.ui.preferencePages"> + <page + category="org.eclipse.papyrus.uml.diagram.common.automatedModelCompletionPreferencePage" + class="org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.ActivityAutomatedModelCompletionPreferencePage" + id="org.eclipse.papyrus.uml.diagram.activity.automatedModelCompletionPreferencePage" + name="Activities"> + </page> +</extension> +<extension point="org.eclipse.core.runtime.preferences"> + <?gmfgen generated="false"?> + <initializer class="org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer"/> +</extension> <extension point="org.eclipse.papyrus.infra.gmfdiag.common.paletteDefinition"> <?gmfgen generated="true"?> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml index 3b6b37d142b..a2c5a31a360 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml @@ -525,4 +525,13 @@ target="1.3.0"> </diagramReconciler> </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory" + class="org.eclipse.ui.internal.dialogs.EmptyPreferencePage" + id="org.eclipse.papyrus.uml.diagram.common.automatedModelCompletionPreferencePage" + name="Automated Model Completion"> + </page> + </extension> </plugin> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java index e94d390daf4..86579c5325b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/Messages.java @@ -20,6 +20,10 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.diagram.common.messages.messages"; //$NON-NLS-1$ + public static String AbstractAutomatedModelCompletionPreferencesPage_Accelerators; + + public static String AbstractAutomatedModelCompletionPreferencesPage_Elements; + public static String ShowHideRelatedLinkSelectionDialog_Comment_; public static String ShowHideRelatedLinkSelectionDialog_CommentLink; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties index 0ced120eb38..365038c99f7 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/messages/messages.properties @@ -1,3 +1,5 @@ +AbstractAutomatedModelCompletionPreferencesPage_Accelerators=Accelerators +AbstractAutomatedModelCompletionPreferencesPage_Elements=Elements CreateOrShowExistingElementHelper_CreateOrRestoreX=Create or Restore {0} CreateOrShowExistingElementHelper_XBetweenTheseElementAlreadyExists={0} between these elements already exists in the model.\nDo you want to restore it? CreateOrShowExistingElementHelper_AlwaysCreateNewLink=Do not show this again. Always create a new link. diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/preferences/AbstractAutomatedModelCompletionPreferencesPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/preferences/AbstractAutomatedModelCompletionPreferencesPage.java new file mode 100644 index 00000000000..25dfbf8126e --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/preferences/AbstractAutomatedModelCompletionPreferencesPage.java @@ -0,0 +1,232 @@ +/***************************************************************************** + * 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.common.preferences; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider; +import org.eclipse.papyrus.uml.diagram.common.Activator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.TableEditor; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * Automated pin derivation for AcceptEventAction and AcceptCallAction + * + * This class provide graphical interface for Automated Model Completion Preferences Page. + * Sub classes must initialize the contentProvider property + */ +public abstract class AbstractAutomatedModelCompletionPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage { + + final static String FIRST_COLUMN_NAME = org.eclipse.papyrus.uml.diagram.common.messages.Messages.AbstractAutomatedModelCompletionPreferencesPage_Elements; + + final static String SECOND_COLUMN_NAME = org.eclipse.papyrus.uml.diagram.common.messages.Messages.AbstractAutomatedModelCompletionPreferencesPage_Accelerators; + + final static int ROW_HEIGHT = 25; + + /** + * Save the associate comboBox to the AutomatedModelCompletionDescriptor + */ + private HashMap<AutomatedModelCompletionPreferenceDescriptor, Combo> mapInstanceComboBox; + + /** + * The content of the table + */ + protected List<AutomatedModelCompletionPreferenceDescriptor> automatedModelCompletionDescriptorsList; + + /** + * Constructor. + * + */ + public AbstractAutomatedModelCompletionPreferencesPage() { + automatedModelCompletionDescriptorsList = new ArrayList<>(); + } + + /** + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + * + * @param workbench + */ + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } + + /** + * Perform apply. + * + * @see org.eclipse.jface.preference.PreferencePage#performApply() + */ + @Override + protected void performApply() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + + // save preferences + for (Map.Entry<AutomatedModelCompletionPreferenceDescriptor, Combo> entry : mapInstanceComboBox.entrySet()) { + String value = entry.getValue().getText(); + store.setValue(entry.getKey().getPreferenceConstant(), value); + } + } + + /** + * @see org.eclipse.jface.preference.PreferencePage#performOk() + * + * @return + */ + @Override + public boolean performOk() { + performApply(); + return super.performOk(); + } + + /** + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + * + */ + @Override + protected void performDefaults() { + IPreferenceStore preferences = Activator.getDefault().getPreferenceStore(); + + for (Map.Entry<AutomatedModelCompletionPreferenceDescriptor, Combo> entry : mapInstanceComboBox.entrySet()) { + String selected = preferences.getDefaultString(entry.getKey().getPreferenceConstant()); + entry.getValue().setText(selected); + } + super.performDefaults(); + } + + /** + * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) + * + * @param parent + * @return + */ + @Override + protected Control createContents(Composite parent) { + Composite self = new Composite(parent, SWT.NONE); + self.setLayout(new GridLayout(1, true)); + self.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // TableViewer + final TableViewer tableViewer = new TableViewer(self, SWT.BORDER); + + // Table + Table table = tableViewer.getTable(); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + table.setLayoutData(gridData); + + tableViewer.setContentProvider(CollectionContentProvider.instance); + tableViewer.setLabelProvider(new ColumnLabelProvider() { + + @Override + public void update(ViewerCell cell) { + if (cell.getColumnIndex() == 0) { + super.update(cell); + } else { + return; + } + } + + @Override + public String getText(Object element) { + if (element instanceof AutomatedModelCompletionPreferenceDescriptor) { + String text = ((AutomatedModelCompletionPreferenceDescriptor) element).getElement().toString(); + text = text.replaceAll("org.eclipse.uml2.uml.", ""); //$NON-NLS-1$ //$NON-NLS-2$ + text = text.replaceFirst("interface\\s", ""); //$NON-NLS-1$ //$NON-NLS-2$ + return text; + } + return super.getText(element); + } + }); + + TableLayout layout = new TableLayout(); + + new TableColumn(table, SWT.LEFT); + layout.addColumnData(new ColumnWeightData(100, 250, true)); + + new TableColumn(table, SWT.LEFT); + layout.addColumnData(new ColumnWeightData(100, 250, true)); + + table.setLayout(layout); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + table.getColumn(0).setText(FIRST_COLUMN_NAME); + table.getColumn(1).setText(SECOND_COLUMN_NAME); + + // Set content + tableViewer.setInput(automatedModelCompletionDescriptorsList); + + // Create comboBox + mapInstanceComboBox = new HashMap<AutomatedModelCompletionPreferenceDescriptor, Combo>(); + for (TableItem item : table.getItems()) { + if (item.getData() instanceof AutomatedModelCompletionPreferenceDescriptor) { + TableEditor editor = new TableEditor(table); + + final Combo comboBox = new Combo(table, SWT.DROP_DOWN); + List<String> list = ((AutomatedModelCompletionPreferenceDescriptor) item.getData()).getListOfAccelerator(); + java.util.Collections.sort(list); + for (String updater : list) { + comboBox.add(updater); + } + + // set selection + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + comboBox.setText(store.getString(((AutomatedModelCompletionPreferenceDescriptor) item.getData()).getPreferenceConstant())); + + final TableItem currentItem = item; + + final AutomatedModelCompletionPreferenceDescriptor strategy = (AutomatedModelCompletionPreferenceDescriptor) currentItem.getData(); + + mapInstanceComboBox.put(strategy, comboBox); + + editor.setEditor(comboBox, item, 1); + editor.horizontalAlignment = SWT.CENTER; + editor.grabHorizontal = true; + + } + } + + // resize the row height + table.addListener(SWT.MeasureItem, new Listener() { + @Override + public void handleEvent(Event event) { + event.height = ROW_HEIGHT; + + } + }); + + return self; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/preferences/AutomatedModelCompletionPreferenceDescriptor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/preferences/AutomatedModelCompletionPreferenceDescriptor.java new file mode 100644 index 00000000000..3fec04ef183 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/preferences/AutomatedModelCompletionPreferenceDescriptor.java @@ -0,0 +1,128 @@ +/***************************************************************************** + * 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.common.preferences; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.uml2.uml.Element; + +/** + * + * Automated pin derivation for AcceptEventAction and AcceptCallAction + * + */ +public class AutomatedModelCompletionPreferenceDescriptor { + + /** + * element is the node on which the updater is applied + */ + private Class<? extends Element> element; + + /** + * listOfAccelerator + */ + private List<String> listOfAccelerator; + + /** + * preferenceConstant of this accelerator + */ + private String preferenceConstant; + + /** + * Constructor. + * + */ + public AutomatedModelCompletionPreferenceDescriptor(String preferenceConstant) { + this.element = Element.class; + this.listOfAccelerator = new ArrayList<>(); + this.preferenceConstant = preferenceConstant; + } + + /** + * Constructor. + * + */ + public AutomatedModelCompletionPreferenceDescriptor(Class<? extends Element> node, List<String> listOfUpdater, String preferenceConstant) { + this.element = node; + this.listOfAccelerator = listOfUpdater; + this.preferenceConstant = preferenceConstant; + } + + /** + * this method add updater to the listOfUpdater + * + * @param updater + * @return true if the list change + */ + boolean addAccelerator(String updater) { + return listOfAccelerator.add(updater); + } + + /** + * this method remove updater to the listOfUpdater + * + * @param updater + * @return true if the list contain the specified element + */ + boolean removeAccelerator(String updater) { + return listOfAccelerator.remove(updater); + } + + /** + * @return the element + */ + public Class<? extends Element> getElement() { + return element; + } + + /** + * @param element + * the element to set + */ + public void setElement(Class<? extends Element> element) { + this.element = element; + } + + /** + * @return the listOfAccelerator + */ + public List<String> getListOfAccelerator() { + return listOfAccelerator; + } + + /** + * @param listOfAccelerator + * the listOfAccelerator to set + */ + public void setListOfAccelerator(List<String> listOfAccelerator) { + this.listOfAccelerator = listOfAccelerator; + } + + /** + * @return the preferenceConstant + */ + public String getPreferenceConstant() { + return preferenceConstant; + } + + /** + * @param preferenceConstant + * the preferenceConstant to set + */ + public void setPreferenceConstant(String preferenceConstant) { + this.preferenceConstant = preferenceConstant; + } + +} |