diff options
author | Onder GURCAN | 2015-04-16 11:38:09 +0000 |
---|---|---|
committer | Ansgar Radermacher | 2015-04-16 13:10:39 +0000 |
commit | 0002fb0cda50b0245f9d2e26d030a8a1e955e58b (patch) | |
tree | 66759925f5399a1fe0a1b4d3a266672ebe5c0d0b /extraplugins | |
parent | 7688bb53963ef0e8d176689b774f2a83e24e9f82 (diff) | |
download | org.eclipse.papyrus-0002fb0cda50b0245f9d2e26d030a8a1e955e58b.tar.gz org.eclipse.papyrus-0002fb0cda50b0245f9d2e26d030a8a1e955e58b.tar.xz org.eclipse.papyrus-0002fb0cda50b0245f9d2e26d030a8a1e955e58b.zip |
Bug 464485 - [UML RT][Model Explorer] Creating a "UML::Operation"
When a "UML::Operation" is created via Palette, a corresponding
CallEvent is also created and associated. However, in this version,
CallEvent does not have the same name with the created Operation, and,
creation of CallEvent only works from Palette.
Change-Id: I0a3c5b3ccf0d83f11cc77a7ebd00030174bdfb46
Signed-off-by: Onder GURCAN <onder.gurcan@cea.fr>
Reviewed-on: https://git.eclipse.org/r/45919
Reviewed-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
Tested-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
Diffstat (limited to 'extraplugins')
4 files changed, 240 insertions, 6 deletions
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/palettes/UML-RT.ProtocolDiagram.paletteconfiguration b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/palettes/UML-RT.ProtocolDiagram.paletteconfiguration index fcd62eb9452..d040bfccc85 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/palettes/UML-RT.ProtocolDiagram.paletteconfiguration +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/palettes/UML-RT.ProtocolDiagram.paletteconfiguration @@ -23,13 +23,13 @@ <elementDescriptors elementTypeId="org.eclipse.papyrus.umlrt.RTMessageSet_3037"/>
<elementDescriptors elementTypeId="org.eclipse.papyrus.umlrt.RTMessageSet_3038"/>
</ownedConfigurations>
- <ownedConfigurations xsi:type="paletteconfiguration:ToolConfiguration" id="palettemodel.org.eclipse.papyrus.uml.Operation" label="Operation" description="Create an Operation">
+ <ownedConfigurations xsi:type="paletteconfiguration:ToolConfiguration" id="palettemodel.org.eclipse.papyrus.umlrt.Operation" label="Operation" description="Create an Operation">
<icon pluginID="org.eclipse.uml2.uml.edit" iconPath="icons/full/obj16/Operation.gif"/>
- <elementDescriptors elementTypeId="org.eclipse.papyrus.uml.diagram.clazz.Operation_3003"/>
- <elementDescriptors elementTypeId="org.eclipse.papyrus.uml.diagram.clazz.Operation_3007"/>
- <elementDescriptors elementTypeId="org.eclipse.papyrus.uml.diagram.clazz.Operation_3013"/>
- <elementDescriptors elementTypeId="org.eclipse.papyrus.uml.diagram.clazz.Operation_3019"/>
- <elementDescriptors elementTypeId="org.eclipse.papyrus.uml.diagram.clazz.Operation_3042"/>
+ <elementDescriptors elementTypeId="org.eclipse.papyrus.umlrt.Operation_3003"/>
+ <elementDescriptors elementTypeId="org.eclipse.papyrus.umlrt.Operation_3007"/>
+ <elementDescriptors elementTypeId="org.eclipse.papyrus.umlrt.Operation_3013"/>
+ <elementDescriptors elementTypeId="org.eclipse.papyrus.umlrt.Operation_3019"/>
+ <elementDescriptors elementTypeId="org.eclipse.papyrus.umlrt.Operation_3042"/>
</ownedConfigurations>
</drawerConfigurations>
</paletteconfiguration:PaletteConfiguration>
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.elementtypesconfigurations b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.elementtypesconfigurations index 44e660e7254..1f6b9f13c6a 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.elementtypesconfigurations +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.elementtypesconfigurations @@ -145,6 +145,24 @@ <stereotypesQualifiedNames>UMLRealTime::RTMessageSet</stereotypesQualifiedNames>
</matcherConfiguration>
</elementTypeConfigurations>
+ <elementTypeConfigurations
+ xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
+ xmi:id="_At0JAONwEeSMDu6IBsn9eg"
+ name="Operation"
+ identifier="org.eclipse.papyrus.umlrt.Operation">
+ <iconEntry
+ xmi:id="_At0JAeNwEeSMDu6IBsn9eg"
+ iconPath="/icons/full/obj16/Operation.gif"
+ bundleId="org.eclipse.uml2.uml.edit"/>
+ <specializedTypesID>org.eclipse.papyrus.uml.Operation</specializedTypesID>
+ <editHelperAdviceConfiguration
+ xmi:id="_At0JAuNwEeSMDu6IBsn9eg"
+ name="org.eclipse.papyrus.umlrt.custom.advice.OperationEditHelperAdvice"
+ description="advice for Operation"
+ identifier="org.eclipse.papyrus.umlrt.custom.advice.OperationEditHelperAdvice"
+ editHelperAdviceClassName="org.eclipse.papyrus.umlrt.custom.advice.OperationEditHelperAdvice"
+ inheritance="all"/>
+ </elementTypeConfigurations>
<adviceBindingsConfigurations
xsi:type="applystereotypeadviceconfiguration:ApplyStereotypeAdviceConfiguration"
xmi:id="_ubJcyaeUEeSUR5jX0TaAcA"
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.umlclassdiagram.elementtypesconfigurations b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.umlclassdiagram.elementtypesconfigurations index 16ad4e2cb6e..5a9229528b1 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.umlclassdiagram.elementtypesconfigurations +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.umlclassdiagram.elementtypesconfigurations @@ -441,4 +441,94 @@ <stereotypesQualifiedNames>UMLRealTime::RTMessageSet</stereotypesQualifiedNames>
</matcherConfiguration>
</elementTypeConfigurations>
+ <elementTypeConfigurations
+ xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
+ xmi:id="_UKFswON2EeSMDu6IBsn9eg"
+ name="Operation (3003)"
+ identifier="org.eclipse.papyrus.umlrt.Operation_3003"
+ hint="3003">
+ <iconEntry
+ xmi:id="_UKFsweN2EeSMDu6IBsn9eg"
+ iconPath="/icons/full/obj16/Operation.gif"
+ bundleId="org.eclipse.uml2.uml.edit"/>
+ <specializedTypesID>org.eclipse.papyrus.umlrt.Operation</specializedTypesID>
+ <specializedTypesID>org.eclipse.papyrus.uml.diagram.clazz.Operation_3003</specializedTypesID>
+ <matcherConfiguration
+ xsi:type="stereotypeapplicationmatcherconfiguration:StereotypeApplicationMatcherConfiguration"
+ xmi:id="_UKFswuN2EeSMDu6IBsn9eg">
+ <stereotypesQualifiedNames>UMLRealTime::RTMessageSet</stereotypesQualifiedNames>
+ </matcherConfiguration>
+ </elementTypeConfigurations>
+ <elementTypeConfigurations
+ xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
+ xmi:id="_iggYsON2EeSMDu6IBsn9eg"
+ name="Operation (3007)"
+ identifier="org.eclipse.papyrus.umlrt.Operation_3007"
+ hint="3007">
+ <iconEntry
+ xmi:id="_iggYseN2EeSMDu6IBsn9eg"
+ iconPath="/icons/full/obj16/Operation.gif"
+ bundleId="org.eclipse.uml2.uml.edit"/>
+ <specializedTypesID>org.eclipse.papyrus.umlrt.Operation</specializedTypesID>
+ <specializedTypesID>org.eclipse.papyrus.uml.diagram.clazz.Operation_3007</specializedTypesID>
+ <matcherConfiguration
+ xsi:type="stereotypeapplicationmatcherconfiguration:StereotypeApplicationMatcherConfiguration"
+ xmi:id="_iggYsuN2EeSMDu6IBsn9eg">
+ <stereotypesQualifiedNames>UMLRealTime::RTMessageSet</stereotypesQualifiedNames>
+ </matcherConfiguration>
+ </elementTypeConfigurations>
+ <elementTypeConfigurations
+ xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
+ xmi:id="_nR6SMON2EeSMDu6IBsn9eg"
+ name="Operation (3013)"
+ identifier="org.eclipse.papyrus.umlrt.Operation_3013"
+ hint="3013">
+ <iconEntry
+ xmi:id="_nR6SMeN2EeSMDu6IBsn9eg"
+ iconPath="/icons/full/obj16/Operation.gif"
+ bundleId="org.eclipse.uml2.uml.edit"/>
+ <specializedTypesID>org.eclipse.papyrus.umlrt.Operation</specializedTypesID>
+ <specializedTypesID>org.eclipse.papyrus.uml.diagram.clazz.Operation_3013</specializedTypesID>
+ <matcherConfiguration
+ xsi:type="stereotypeapplicationmatcherconfiguration:StereotypeApplicationMatcherConfiguration"
+ xmi:id="_nR6SMuN2EeSMDu6IBsn9eg">
+ <stereotypesQualifiedNames>UMLRealTime::RTMessageSet</stereotypesQualifiedNames>
+ </matcherConfiguration>
+ </elementTypeConfigurations>
+ <elementTypeConfigurations
+ xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
+ xmi:id="_sqMlgON2EeSMDu6IBsn9eg"
+ name="Operation (3019)"
+ identifier="org.eclipse.papyrus.umlrt.Operation_3019"
+ hint="3019">
+ <iconEntry
+ xmi:id="_sqMlgeN2EeSMDu6IBsn9eg"
+ iconPath="/icons/full/obj16/Operation.gif"
+ bundleId="org.eclipse.uml2.uml.edit"/>
+ <specializedTypesID>org.eclipse.papyrus.umlrt.Operation</specializedTypesID>
+ <specializedTypesID>org.eclipse.papyrus.uml.diagram.clazz.Operation_3019</specializedTypesID>
+ <matcherConfiguration
+ xsi:type="stereotypeapplicationmatcherconfiguration:StereotypeApplicationMatcherConfiguration"
+ xmi:id="_sqMlguN2EeSMDu6IBsn9eg">
+ <stereotypesQualifiedNames>UMLRealTime::RTMessageSet</stereotypesQualifiedNames>
+ </matcherConfiguration>
+ </elementTypeConfigurations>
+ <elementTypeConfigurations
+ xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"
+ xmi:id="_xQYGcON2EeSMDu6IBsn9eg"
+ name="Operation (3042)"
+ identifier="org.eclipse.papyrus.umlrt.Operation_3042"
+ hint="3042">
+ <iconEntry
+ xmi:id="_xQYGceN2EeSMDu6IBsn9eg"
+ iconPath="/icons/full/obj16/Operation.gif"
+ bundleId="org.eclipse.uml2.uml.edit"/>
+ <specializedTypesID>org.eclipse.papyrus.umlrt.Operation</specializedTypesID>
+ <specializedTypesID>org.eclipse.papyrus.uml.diagram.clazz.Operation_3042</specializedTypesID>
+ <matcherConfiguration
+ xsi:type="stereotypeapplicationmatcherconfiguration:StereotypeApplicationMatcherConfiguration"
+ xmi:id="_xQYGcuN2EeSMDu6IBsn9eg">
+ <stereotypesQualifiedNames>UMLRealTime::RTMessageSet</stereotypesQualifiedNames>
+ </matcherConfiguration>
+ </elementTypeConfigurations>
</elementtypesconfigurations:ElementTypeSetConfiguration>
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationEditHelperAdvice.java new file mode 100644 index 00000000000..0a3c0dcdcec --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationEditHelperAdvice.java @@ -0,0 +1,126 @@ +/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Onder Gurcan <onder.gurcan@cea.fr>
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.umlrt.custom.advice;
+
+import static org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.CALL_EVENT;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand;
+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.CreateElementRequest;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.uml2.uml.CallEvent;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Package;
+
+
+/**
+ * The helperadvice class used for UMLRealTime::Operation.
+ *
+ * @author Onder Gurcan <onder.gurcan@cea.fr>
+ *
+ */
+public class OperationEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ private CallEvent callEvent;
+
+ private enum Relation {
+ CHILD, SIBLING, PARENT;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
+ final Operation operation = (Operation) request.getElementToConfigure();
+ final String name = NamedElementUtil.getDefaultNameWithIncrementFromBase("CallEvent", operation.eContainer().eContainer().eContents());
+
+ return new ConfigureElementCommand(request) {
+ private IProgressMonitor progressMonitor;
+ private IAdaptable info;
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ this.progressMonitor = progressMonitor;
+ this.info = info;
+
+ // Create the UML::CallEvent element
+ createCallEvent(operation, name);
+
+ return CommandResult.newOKCommandResult(operation);
+ }
+
+ /**
+ * Creates a UML::Usage relation between protocol and rtMessageSet with given name.
+ *
+ * @param protocol
+ * @param name
+ * @param rtMessageSet
+ * @throws ExecutionException
+ */
+ private void createCallEvent(final Operation operation, final String name) throws ExecutionException {
+ // find the corresponding protocol container
+ Package protocolContainer = operation.getNearestPackage();
+ // then create the call event
+ callEvent = (CallEvent) createElement(protocolContainer, name, CALL_EVENT, Relation.CHILD);
+ // finally associate the operation with this call event
+ callEvent.setOperation(operation);
+ }
+
+ /**
+ *
+ * @param referenceElement
+ * @param name
+ * @param elementType
+ * @param relation
+ * @return created element as EObject
+ * @throws ExecutionException
+ */
+ private EObject createElement(Element referenceElement, String name, IElementType elementType, Relation relation) throws ExecutionException {
+ if ((referenceElement == null) || (name == null)) {
+ throw new ExecutionException("Either the referenceElement or the name parameter is null. ");
+ }
+
+ EObject newElement = null;
+
+ CreateElementRequest createElementRequest = new CreateElementRequest(referenceElement.getNearestPackage(), elementType);
+ CreateElementCommand command = new CreateElementCommand(createElementRequest);
+ command.execute(progressMonitor, info);
+ newElement = command.getNewElement();
+
+ if (newElement == null) {
+ throw new ExecutionException("Element creation problem for " + elementType.getDisplayName() + ".");
+ }
+
+ ((NamedElement)newElement).setName(name);
+
+ return newElement;
+ }
+ };
+ }
+}
|