diff options
33 files changed, 1098 insertions, 240 deletions
diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt index 1f8cf8f332e..5ba870b9450 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.properties/propertyView/UML-RT/ui/SingleProtocol.xwt @@ -18,10 +18,10 @@ <ppel:PropertiesLayout numColumns="3"></ppel:PropertiesLayout> </Composite.layout> <ppe:MultiReference input="{Binding}" - property="UMLRealTimeExt:Protocol:Incoming" customLabel="Incoming"></ppe:MultiReference> - <ppe:MultiReference input="{Binding}" property="UMLRealTimeExt:Protocol:Outgoing" customLabel="Outgoing"></ppe:MultiReference> <ppe:MultiReference input="{Binding}" + property="UMLRealTimeExt:Protocol:Incoming" customLabel="Incoming"></ppe:MultiReference> + <ppe:MultiReference input="{Binding}" property="UMLRealTimeExt:Protocol:InOut" customLabel="In-Out"></ppe:MultiReference> </Composite> </Composite>
\ No newline at end of file diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/META-INF/MANIFEST.MF b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/META-INF/MANIFEST.MF index e61c2bc8a30..a51f774f440 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/META-INF/MANIFEST.MF +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/META-INF/MANIFEST.MF @@ -4,23 +4,28 @@ Export-Package: org.eclipse.papyrus.umlrt.ui,org.eclipse.papyrus.umlrt .ui.provider,org.eclipse.papyrus.umlrt.ui.queries Bundle-Name: UML-RT UI plugin Bundle-Version: 1.1.0.qualifier -Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime,org.eclipse.pa - pyrus.uml.diagram.common;bundle-version="1.1.0",org.eclipse.papyrus.u - mlrt;bundle-version="1.1.0",org.eclipse.papyrus.infra.newchild;bundle - -version="1.1.0",org.eclipse.papyrus.infra.elementtypesconfigurations - ;bundle-version="1.1.0",org.eclipse.emf.ecore,org.eclipse.uml2.uml,or - g.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.1.0",org.ec - lipse.papyrus.emf.facet.query.java.core;bundle-version="1.1.0",org.ec - lipse.papyrus.uml.tools;bundle-version="1.1.0",org.eclipse.papyrus.in - fra.emf;bundle-version="1.1.0",org.eclipse.papyrus.emf.facet.custom.m - etamodel;bundle-version="1.1.0",org.eclipse.gmf.runtime.emf.type.core - ;bundle-version="1.9.0",org.eclipse.papyrus.infra.core.log;bundle-ver - sion="1.1.0",org.eclipse.papyrus.emf.facet.custom.ui;bundle-version=" - 1.1.0",org.eclipse.papyrus.infra.services.labelprovider;bundle-versio - n="1.1.0",org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1 - .1.0",org.eclipse.papyrus.infra.widgets;bundle-version="1.1.0",org.ec - lipse.papyrus.uml.modelexplorer;bundle-version="1.1.0",org.eclipse.pa - pyrus.views.modelexplorer;bundle-version="1.1.0" +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.papyrus.uml.diagram.common;bundle-version="1.1.0", + org.eclipse.papyrus.umlrt;bundle-version="1.1.0", + org.eclipse.papyrus.infra.newchild;bundle-version="1.1.0", + org.eclipse.papyrus.infra.elementtypesconfigurations;bundle-version="1.1.0", + org.eclipse.emf.ecore, + org.eclipse.uml2.uml, + org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.1.0", + org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="1.1.0", + org.eclipse.papyrus.uml.tools;bundle-version="1.1.0", + org.eclipse.papyrus.infra.emf;bundle-version="1.1.0", + org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="1.1.0", + org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.9.0", + org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0", + org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.1.0", + org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.1.0", + org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.1.0", + org.eclipse.papyrus.infra.widgets;bundle-version="1.1.0", + org.eclipse.papyrus.uml.modelexplorer;bundle-version="1.1.0", + org.eclipse.papyrus.views.modelexplorer;bundle-version="1.1.0", + org.eclipse.core.expressions;bundle-version="3.4.600" Bundle-ManifestVersion: 2 Bundle-Activator: org.eclipse.papyrus.umlrt.ui.Activator Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration index 5fa2c7981ae..14ea28b433c 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/configuration/UMLRT.configuration @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <configuration:PapyrusConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmi:id="_oa8yUBP7EeSS0oyATXohNA" defaultStakeholder="_stSKMBP7EeSS0oyATXohNA"> - <stakeholders xmi:id="_stSKMBP7EeSS0oyATXohNA" name="MetaModeler" viewpoints="_3T-cEBP7EeSS0oyATXohNA"/> + <stakeholders xmi:id="_stSKMBP7EeSS0oyATXohNA" name="UML-RT Modeler" viewpoints="_3T-cEBP7EeSS0oyATXohNA"/> <viewpoints xsi:type="configuration:PapyrusViewpoint" xmi:id="_3T-cEBP7EeSS0oyATXohNA" name="UMLRT Viewpoint"> <modelKinds xsi:type="configuration:PapyrusDiagram" xmi:id="_Z79eQHcZEeSnWeKqQOfW2A" name="UML-RT Capsule Diagram" icon="platform:/plugin/org.eclipse.papyrus.uml.diagram.clazz/icons/obj16/Diagram_Class.gif" implementationID="CompositeStructure" categories="_vUL7ABP7EeSS0oyATXohNA" customPalette="" customStyle=""> <modelRules xmi:id="_I9zbAHk9EeSk0Zv84QxXew"> @@ -43,5 +43,5 @@ </modelKinds> </viewpoints> <metamodel href="http://www.eclipse.org/uml2/5.0.0/UML#/"/> - <categories xmi:id="_vUL7ABP7EeSS0oyATXohNA" name="uml"/> + <categories xmi:id="_vUL7ABP7EeSS0oyATXohNA" name="UML-RT"/> </configuration:PapyrusConfiguration> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom index 3bb6d1bd92d..42f60b86b58 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/Protocol.custom @@ -11,7 +11,7 @@ name="UML-RT Protocols" documentation="Simplification of the display of UML-RT protocols" mustBeLoadedByDefault="true" - rank="-1"> + rank="-100"> <eClassifiers xsi:type="efacet:Facet" name="ProtocolContainerFacet" @@ -128,6 +128,34 @@ xsi:type="query:OperationCallQuery" operation="//ProtocolContainment_OnlyRTMessages/GetRTMessagesIn"/> </facetElements> + <facetElements + xsi:type="efacet:FacetReference" + name="out" + upperBound="-1" + volatile="true" + transient="true" + derived="true"> + <eType + xsi:type="ecore:EClass" + href="http://www.eclipse.org/uml2/5.0.0/UML#//Operation"/> + <query + xsi:type="query:OperationCallQuery" + operation="//ProtocolContainment_OnlyRTMessages/GetRTMessagesOut"/> + </facetElements> + <facetElements + xsi:type="efacet:FacetReference" + name="inout" + upperBound="-1" + volatile="true" + transient="true" + derived="true"> + <eType + xsi:type="ecore:EClass" + href="http://www.eclipse.org/uml2/5.0.0/UML#//Operation"/> + <query + xsi:type="query:OperationCallQuery" + operation="//ProtocolContainment_OnlyRTMessages/GetRTMessagesInOut"/> + </facetElements> <facetOperations name="GetRTMessagesIn" upperBound="-1" @@ -140,6 +168,28 @@ implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.GetRTMessagesInQuery"/> </facetOperations> <facetOperations + name="GetRTMessagesOut" + upperBound="-1" + documentation="Returns all Messages from the Out MessageSets"> + <eType + xsi:type="ecore:EClass" + href="http://www.eclipse.org/uml2/5.0.0/UML#//Operation"/> + <query + xsi:type="javaQuery:JavaQuery" + implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.GetRTMessagesOutQuery"/> + </facetOperations> + <facetOperations + name="GetRTMessagesInOut" + upperBound="-1" + documentation="Returns all Messages from the Inout MessageSets"> + <eType + xsi:type="ecore:EClass" + href="http://www.eclipse.org/uml2/5.0.0/UML#//Operation"/> + <query + xsi:type="javaQuery:JavaQuery" + implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.GetRTMessagesInOutQuery"/> + </facetOperations> + <facetOperations name="DisplayMessageSetsOnly"> <eType xsi:type="ecore:EDataType" @@ -155,7 +205,25 @@ implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.DisplayMessagesOnlyQuery"/> <override xsi:type="efacet:FacetOperation" - href="platform:/plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/isVisible"/> + href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/isVisible"/> + </facetOperations> + <facetOperations + name="HideCollapseLinks"> + <eType + xsi:type="ecore:EDataType" + href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + <eParameters + name="eStructuralFeature"> + <eType + xsi:type="ecore:EClass" + href="http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature"/> + </eParameters> + <query + xsi:type="javaQuery:JavaQuery" + implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.collaboration.HideCollapseLinksExceptDirectionQuery"/> + <override + xsi:type="efacet:FacetOperation" + href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/collapseLink"/> </facetOperations> </eClassifiers> </custom:Customization> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom index 76ff4a53c90..727e609a5f4 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/facet/SimpleUMLRT.custom @@ -1,15 +1,39 @@ <?xml version="1.0" encoding="UTF-8"?> -<custom:Customization xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:custom="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:efacet="http://www.eclipse.org/papyrus/emf/facet/efacet/0.2.incubation/efacet" xmlns:javaQuery="http://www.eclipse.org/papyrus/emf/facet/query/java/0.2.incubation/javaquery" name="simpleUMLRT" documentation="Display structure of a UML-RT model"> - <eClassifiers xsi:type="custom:EClassCustomization" name="Element"> - <extendedMetaclass href="http://www.eclipse.org/uml2/5.0.0/UML#//Element"/> - <facetOperations name="GetLabel"> - <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> - <eParameters name="eObject"> - <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/> +<custom:Customization + xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:custom="http://www.eclipse.org/papyrus/emf/facet/custom/0.2.incubation/custom" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:efacet="http://www.eclipse.org/papyrus/emf/facet/efacet/0.2.incubation/efacet" + xmlns:javaQuery="http://www.eclipse.org/papyrus/emf/facet/query/java/0.2.incubation/javaquery" + name="simpleUMLRT" + documentation="Display structure of a UML-RT model" + rank="-50"> + <eClassifiers + xsi:type="custom:EClassCustomization" + name="NamedElement"> + <extendedMetaclass + href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement"/> + <facetOperations + name="GetLabel"> + <eType + xsi:type="ecore:EDataType" + href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eParameters + name="eObject"> + <eType + xsi:type="ecore:EClass" + href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/> </eParameters> - <query xsi:type="javaQuery:JavaQuery" implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.GetLabelQuery"/> - <override xsi:type="efacet:FacetOperation" href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/label"/> + <query + xsi:type="javaQuery:JavaQuery" + implementationClassName="org.eclipse.papyrus.umlrt.ui.queries.GetLabelQuery"/> + <override + xsi:type="efacet:FacetOperation" + href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject/label"/> </facetOperations> - <extendedFacets href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject"/> + <extendedFacets + href="../../../plugin/org.eclipse.papyrus.emf.facet.custom.ui/resources/customproperties.efacet#//CustomizedEObject"/> </eClassifiers> </custom:Customization> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_in.gif b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_in.gif Binary files differindex 19567890aa8..f2dfacbea66 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_in.gif +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_in.gif diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_inout.gif b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_inout.gif Binary files differindex d22392de13e..9b29810215c 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_inout.gif +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_inout.gif diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_out.gif b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_out.gif Binary files differindex 4fb41501036..0f139f33e42 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_out.gif +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_out.gif diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_undefined.gif b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_undefined.gif Binary files differindex 486faff8aac..91b89b8d02a 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_undefined.gif +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/icons/rt_message_undefined.gif diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi index 83878d81d7b..a9ea68846e9 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/newchildmenu/newChildMenu.xmi @@ -30,6 +30,15 @@ label="RTMessageSet" elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageSet"/> <menu xsi:type="ElementCreationMenuModel:CreationMenu" - label="IN RTMessage " + label="RTMessage OUT" + icon="platform:/plugin/org.eclipse.papyrus.umlrt.ui/icons/rt_message_out.gif" + elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageOut"/> + <menu xsi:type="ElementCreationMenuModel:CreationMenu" + label="RTMessage INOUT" + icon="platform:/plugin/org.eclipse.papyrus.umlrt.ui/icons/rt_message_inout.gif" + elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageInOut"/> + <menu xsi:type="ElementCreationMenuModel:CreationMenu" + label="RTMessage IN" + icon="platform:/plugin/org.eclipse.papyrus.umlrt.ui/icons/rt_message_in.gif" elementTypeIdRef="org.eclipse.papyrus.umlrt.RTMessageIn"/> </ElementCreationMenuModel:Folder> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/plugin.xml b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/plugin.xml index 841d8e46318..7d911fdcfc4 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/plugin.xml +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/plugin.xml @@ -64,5 +64,61 @@ provider="org.eclipse.papyrus.umlrt.ui.provider.UMLRTFilteredLabelProvider"> </labelProvider> </extension> - + <handler + class="org.eclipse.papyrus.views.modelexplorer.handler.CopyHandler" + commandId="org.eclipse.ui.edit.copy"> + <activeWhen> + <and> + <with + variable="activePart"> + <instanceof + value="org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView"> + </instanceof> + </with> + <with + variable="selection"> + <test + forcePluginActivation="true" + property="org.eclipse.papyrus.views.modelexplorer.tester.isEObject" + value="true"> + </test> + </with> + </and> + </activeWhen> + </handler> + <extension + point="org.eclipse.core.expressions.propertyTesters"> + <propertyTester + class="org.eclipse.papyrus.umlrt.ui.provider.PropertyTester" + id="org.eclipse.papyrus.umlrt.ui.modelexplorer.tester" + namespace="org.eclipse.papyrus.views.modelexplorer.tester" + properties="isRTPRotocol" + type="org.eclipse.jface.viewers.IStructuredSelection"> + </propertyTester> +</extension> + <extension + point="org.eclipse.ui.handlers"> + <handler + class="org.eclipse.papyrus.umlrt.ui.handlers.RTProtocolCopyHandler" + commandId="org.eclipse.ui.edit.copy"> + <activeWhen> + <and> + <with + variable="activePart"> + <instanceof + value="org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView"> + </instanceof> + </with> + <with + variable="selection"> + <test + forcePluginActivation="true" + property="org.eclipse.papyrus.umlrt.ui.modelexplorer.tester.isRTPRotocol" + value="true"> + </test> + </with> + </and> + </activeWhen> + </handler> + </extension> </plugin> diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/handlers/RTProtocolCopyHandler.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/handlers/RTProtocolCopyHandler.java new file mode 100644 index 00000000000..4f25a416989 --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/handlers/RTProtocolCopyHandler.java @@ -0,0 +1,41 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.ui.handlers; + +import org.eclipse.papyrus.views.modelexplorer.handler.CopyHandler; + +/** + * Specific copy handler for model explorer + */ +public class RTProtocolCopyHandler extends CopyHandler { + + + // /** + // * Construct copy command from the selection + // * + // * @param editingDomain + // * @param selectedElements + // * @return + // */ + // public static Command buildCopyCommand(TransactionalEditingDomain editingDomain, Collection<EObject> selectedElements) { + //// DefaultCopyCommand defaultCopyCommand = new DefaultCopyCommand(editingDomain, papyrusClipboard, selectedElements); + //// List<IStrategy> allStrategies = PasteStrategyManager.getInstance().getAllStrategies(); + //// for (IStrategy iStrategy : allStrategies) { + //// IPasteStrategy iPasteStrategy = (IPasteStrategy) iStrategy; + //// iPasteStrategy.prepare(papyrusClipboard, selectedElements); + //// } + //// return defaultCopyCommand; + // return super.buildCopyCommand(editingDomain, selectedElements, ) + // } +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/PropertyTester.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/PropertyTester.java new file mode 100644 index 00000000000..86e27b6f741 --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/PropertyTester.java @@ -0,0 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.ui.provider; + +import java.util.Iterator; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator; + +/** + * @author RS211865 + * + */ +public class PropertyTester extends org.eclipse.core.expressions.PropertyTester { + + /** property to test if the selected elements is an eObject */ + public static final String IS_RT_PROTOCOL = "isRTPRotocol"; //$NON-NLS-1$ + + /** + * {@inheritDoc} + */ + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (IS_RT_PROTOCOL.equals(property) && receiver instanceof IStructuredSelection) { + boolean answer = isRTObject((IStructuredSelection) receiver); + return Boolean.valueOf(answer).equals(expectedValue); + } + return false; + } + + /** + * @param receiver + * @return + */ + protected boolean isRTObject(IStructuredSelection selection) { + boolean isSelectionOK = false; + for (IElementType type : UMLRTElementTypesEnumerator.getAllRTTypes()) { + if (type instanceof ISpecializationType && ((ISpecializationType) type).getMatcher() != null) { + if (!selection.isEmpty()) { + Iterator<?> iter = selection.iterator(); + while (iter.hasNext()) { + EObject current = EMFHelper.getEObject(iter.next()); + if (((ISpecializationType) type).getMatcher().matches(current)) { + isSelectionOK = true; + } + } + } + } + if (isSelectionOK) { + return true; + } + } + + return false; + } + +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java index 36c4669a6a1..fa3a70c2ccc 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTFilteredLabelProvider.java @@ -13,54 +13,20 @@ package org.eclipse.papyrus.umlrt.ui.provider; -import java.util.HashMap; -import java.util.Map; - import org.eclipse.emf.ecore.EObject; import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider; -import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; -import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; -import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; import org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator; -import org.eclipse.papyrus.umlrt.custom.utils.RTMessageUtils; import org.eclipse.papyrus.umlrt.ui.Activator; -import org.eclipse.swt.graphics.Image; import org.eclipse.uml2.uml.Element; /** * Label provider used by the label provider service */ -public class UMLRTFilteredLabelProvider implements IFilteredLabelProvider { - - public final Map<String, String> typeIdtoIconPath; - - /** path to the icons in the plugin */ - protected static String ICON_PATH = "/icons/"; - - protected static String RT_MESSAGE_IN_ICON = ICON_PATH + "rt_message_in.gif";//$NON-NLS-1$ - protected static String RT_MESSAGE_IN_OUT_ICON = ICON_PATH + "rt_message_inout.gif";//$NON-NLS-1$ - protected static String RT_MESSAGE_OUT_ICON = ICON_PATH + "rt_message_out.gif";//$NON-NLS-1$ - protected static String RT_MESSAGE_UNDEFINED_ICON = ICON_PATH + "rt_message_undefined.gif";//$NON-NLS-1$ - - /** - * Default constructor - */ - public UMLRTFilteredLabelProvider() { - typeIdtoIconPath = new HashMap<String, String>(); - typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_ID, ICON_PATH + "capsule.png"); //$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_PART_ID, ICON_PATH + "capsule_part.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_CONTAINER_ID, ICON_PATH + "protocol_container.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_ID, ICON_PATH + "protocol.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_CONNECTOR_ID, ICON_PATH + "rt_connector.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_EXCLUDED_ELEMENT_ID, ICON_PATH + "rt_excludedElement.gif");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_SET_ID, ICON_PATH + "rt_messageset.png");//$NON-NLS-1$ - typeIdtoIconPath.put(IUMLRTElementTypes.RT_PORT_ID, ICON_PATH + "rt_port.png");//$NON-NLS-1$ - } +public class UMLRTFilteredLabelProvider extends UMLRTLabelProvider implements IFilteredLabelProvider { /** * {@inheritDoc} @@ -95,147 +61,30 @@ public class UMLRTFilteredLabelProvider implements IFilteredLabelProvider { * {@inheritDoc} */ @Override - public Image getImage(Object element) { + public String getText(Object element) { EObject semanticObject = EMFHelper.getEObject(element); - - if (!(semanticObject instanceof Element)) { - Activator.log.debug("Trying to display an UMLRT image for a non UML-RT element"); - return null; + if (semanticObject == null) { + return super.getText(element); } - // depending on the element type that matches, return a different icon - String matchingTypeMatcher = getMatchingType(semanticObject); - - if( matchingTypeMatcher ==null) { - return null; - } - - Image image = null; - // a match was done. give a different icon given the value - switch (matchingTypeMatcher) { -// case IUMLRTElementTypes.RT_MESSAGE_SET_ID: -// // for RT message, direction can give different icons -// -// // the element has the RT messageset stereotype applied. It should be possible to retrieve it and even better the direction -// RTMessageKind kind = MessageSetUtils.getMessageKind(semanticObject); -// if (kind != null) { -// switch (kind) { -// case IN: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_IN_ICON); -// break; -// case OUT: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_OUT_ICON); -// break; -// case IN_OUT: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_IN_OUT_ICON); -// break; -// default: -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_UNDEFINED_ICON); -// break; -// } -// break; -// } -// image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_SET_UNDEFINED_ICON); -// break; - case IUMLRTElementTypes.RT_MESSAGE_ID: - // for RT message, direction can give different icons + // specific for RT Message label + ISpecializationType inMessageType = (ISpecializationType) UMLRTElementTypesEnumerator.RT_MESSAGE_IN; + ISpecializationType outMessageType = (ISpecializationType) UMLRTElementTypesEnumerator.RT_MESSAGE_OUT; + ISpecializationType inOutMessageType = (ISpecializationType) UMLRTElementTypesEnumerator.RT_MESSAGE_INOUT; - RTMessageKind kind = RTMessageUtils.getMessageKind(semanticObject); - if (kind != null) { - switch (kind) { - case IN: - image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_ICON); - break; - case OUT: - image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_OUT_ICON); - break; - case IN_OUT: - image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_OUT_ICON); - break; - default: - image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_UNDEFINED_ICON); - break; - } - break; - } - default: - image = getElementImage(matchingTypeMatcher, semanticObject); - break; + if (inMessageType != null && inMessageType.getMatcher() != null && inMessageType.getMatcher().matches((EObject) semanticObject)) { + return "in " + super.getText(element); } - return image; - } - - /** - * Return the element type identifier for the given semantic EObject, given the predefined UML-RT list - * - * @param semanticObject - * the element to display - * @return the unique UML-RT element type identifier or <code>null</code> - */ - protected String getMatchingType(EObject semanticObject) { - for (IElementType type : UMLRTElementTypesEnumerator.getAllRTTypes()) { - if (type instanceof ISpecializationType) { - if (((ISpecializationType) type).getMatcher().matches(semanticObject)) { - return type.getId(); - } - } + if (outMessageType != null && outMessageType.getMatcher() != null && outMessageType.getMatcher().matches((EObject) semanticObject)) { + return "out " + super.getText(element); } - return null; - } - /** - * @param type - * @param element - * @return - */ - protected Image getElementImage(String id, EObject semanticObject) { - String iconPath = typeIdtoIconPath.get(id); - if (iconPath != null) { - return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, iconPath); + if (inOutMessageType != null && inOutMessageType.getMatcher() != null && inOutMessageType.getMatcher().matches((EObject) semanticObject)) { + return "inout " + super.getText(element); } - return null; - - } - - /** - * {@inheritDoc} - */ - @Override - public String getText(Object element) { - return new UMLLabelProvider().getText(element); - } - - /** - * {@inheritDoc} - */ - @Override - public void addListener(ILabelProviderListener listener) { - - } - - /** - * {@inheritDoc} - */ - @Override - public void dispose() { - - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public void removeListener(ILabelProviderListener listener) { + return super.getText(element); } } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java index 80dcd232baf..0de3594cd45 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/provider/UMLRTLabelProvider.java @@ -13,14 +13,57 @@ package org.eclipse.papyrus.umlrt.ui.provider; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.tools.providers.DelegatingItemLabelProvider; +import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider; +import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; +import org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator; +import org.eclipse.papyrus.umlrt.ui.Activator; import org.eclipse.swt.graphics.Image; +import org.eclipse.uml2.uml.Element; /** * UML-RT specific label provider. */ -public class UMLRTLabelProvider extends UMLLabelProvider { +public class UMLRTLabelProvider extends UMLFilteredLabelProvider { + + public final Map<String, String> typeIdtoIconPath; + + /** path to the icons in the plugin */ + protected static String ICON_PATH = "/icons/"; + + protected static String RT_MESSAGE_IN_ICON = ICON_PATH + "rt_message_in.gif";//$NON-NLS-1$ + protected static String RT_MESSAGE_IN_OUT_ICON = ICON_PATH + "rt_message_inout.gif";//$NON-NLS-1$ + protected static String RT_MESSAGE_OUT_ICON = ICON_PATH + "rt_message_out.gif";//$NON-NLS-1$ + protected static String RT_MESSAGE_UNDEFINED_ICON = ICON_PATH + "rt_message_undefined.gif";//$NON-NLS-1$ + + private static final IItemLabelProvider labelProvider = new DelegatingItemLabelProvider(); + + /** + * Default constructor + */ + public UMLRTLabelProvider() { + typeIdtoIconPath = new HashMap<String, String>(); + typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_ID, ICON_PATH + "capsule.png"); //$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.CAPSULE_PART_ID, ICON_PATH + "capsule_part.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_CONTAINER_ID, ICON_PATH + "protocol_container.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.PROTOCOL_ID, ICON_PATH + "protocol.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_CONNECTOR_ID, ICON_PATH + "rt_connector.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_EXCLUDED_ELEMENT_ID, ICON_PATH + "rt_excludedElement.gif");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_SET_ID, ICON_PATH + "rt_messageset.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_PORT_ID, ICON_PATH + "rt_port.png");//$NON-NLS-1$ + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_IN_ID, RT_MESSAGE_IN_ICON); + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_INOUT_ID, RT_MESSAGE_IN_OUT_ICON); + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_OUT_ID, RT_MESSAGE_OUT_ICON); + typeIdtoIconPath.put(IUMLRTElementTypes.RT_MESSAGE_ID, RT_MESSAGE_UNDEFINED_ICON); + } /** * @see org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider#getImage(org.eclipse.emf.ecore.EObject) @@ -29,8 +72,83 @@ public class UMLRTLabelProvider extends UMLLabelProvider { * @return */ @Override - protected Image getImage(EObject element) { - return super.getImage(element); + public Image getImage(Object element) { + EObject semanticObject = EMFHelper.getEObject(element); + + if (!(semanticObject instanceof Element)) { + Activator.log.debug("Trying to display an UMLRT image for a non UML-RT element"); + return null; + } + + // depending on the element type that matches, return a different icon + String matchingTypeMatcher = getMatchingType(semanticObject); + + if (matchingTypeMatcher == null) { + return null; + } + + Image image = null; + // a match was done. give a different icon given the value + switch (matchingTypeMatcher) { + case IUMLRTElementTypes.RT_MESSAGE_IN_ID: + image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_ICON); + break; + case IUMLRTElementTypes.RT_MESSAGE_OUT_ID: + image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_OUT_ICON); + break; + case IUMLRTElementTypes.RT_MESSAGE_INOUT_ID: + image = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, RT_MESSAGE_IN_OUT_ICON); + break; + default: + image = getElementImage(matchingTypeMatcher, semanticObject); + break; + } + + return image; + } + + + /** + * @see org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider#getText(java.lang.Object) + * + * @param element + * @return + */ + @Override + public String getText(Object element) { + return labelProvider.getText(element); + } + + /** + * Return the element type identifier for the given semantic EObject, given the predefined UML-RT list + * + * @param semanticObject + * the element to display + * @return the unique UML-RT element type identifier or <code>null</code> + */ + protected String getMatchingType(EObject semanticObject) { + for (IElementType type : UMLRTElementTypesEnumerator.getAllRTTypes()) { + if (type instanceof ISpecializationType) { + if (((ISpecializationType) type).getMatcher().matches(semanticObject)) { + return type.getId(); + } + } + } + return null; + } + + /** + * @param type + * @param element + * @return + */ + protected Image getElementImage(String id, EObject semanticObject) { + String iconPath = typeIdtoIconPath.get(id); + if (iconPath != null) { + return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, iconPath); + } + return null; + } } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java index ba55df2049d..bb81ffd9d5d 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessageSetsOnlyQuery.java @@ -1,3 +1,15 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.ui.queries; import org.eclipse.emf.ecore.EStructuralFeature; diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java index c0531887cb9..26bc3e22908 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/DisplayMessagesOnlyQuery.java @@ -1,3 +1,15 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.ui.queries; import org.eclipse.emf.ecore.EStructuralFeature; diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java index 6b48abf5346..ac634be0195 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetLabelQuery.java @@ -14,23 +14,26 @@ package org.eclipse.papyrus.umlrt.ui.queries; import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; -import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; -import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; -import org.eclipse.uml2.uml.Element; +import org.eclipse.papyrus.uml.modelexplorer.queries.GetComplexName; +import org.eclipse.papyrus.umlrt.ui.provider.UMLRTFilteredLabelProvider; +import org.eclipse.uml2.uml.NamedElement; -public class GetLabelQuery implements IJavaQuery2<Element, String> { +public class GetLabelQuery extends GetComplexName { - private static final UMLLabelProvider UML_LABEL_PROVIDER= new UMLLabelProvider(); + private static final UMLRTFilteredLabelProvider UML_LABEL_PROVIDER = new UMLRTFilteredLabelProvider(); /** * {@inheritDoc} */ - public String evaluate(final Element context, + public String evaluate(final NamedElement context, final IParameterValueList2 parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException { + if (UML_LABEL_PROVIDER.accept(context)) { + return UML_LABEL_PROVIDER.getText(context); + } + return super.evaluate(context, parameterValues, facetManager); - return "RT_"+UML_LABEL_PROVIDER.getText(context); } } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetRTMessagesInOutQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetRTMessagesInOutQuery.java new file mode 100644 index 00000000000..ccf782b830e --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetRTMessagesInOutQuery.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.ui.queries; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; +import org.eclipse.papyrus.umlrt.custom.utils.ProtocolUtils; +import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.Operation; + +public class GetRTMessagesInOutQuery implements IJavaQuery2<EObject, List<Operation>> { + public List<Operation> evaluate(final EObject context, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + if (context instanceof Collaboration) { + return ProtocolUtils.getRTMessages((Collaboration) context, RTMessageKind.IN_OUT, true); + } + return null; + } +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetRTMessagesOutQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetRTMessagesOutQuery.java new file mode 100644 index 00000000000..bbb0e336c1d --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/GetRTMessagesOutQuery.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.ui.queries; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; +import org.eclipse.papyrus.umlrt.custom.utils.ProtocolUtils; +import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.Operation; + +public class GetRTMessagesOutQuery implements IJavaQuery2<EObject, List<Operation>> { + public List<Operation> evaluate(final EObject context, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + if (context instanceof Collaboration) { + return ProtocolUtils.getRTMessages((Collaboration) context, RTMessageKind.OUT, true); + } + return null; + } +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/collaboration/HideCollapseLinksExceptDirectionQuery.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/collaboration/HideCollapseLinksExceptDirectionQuery.java new file mode 100644 index 00000000000..2b2e4abfe67 --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.ui/src/org/eclipse/papyrus/umlrt/ui/queries/collaboration/HideCollapseLinksExceptDirectionQuery.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.ui.queries.collaboration; + +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.uml2.uml.Collaboration; + +public class HideCollapseLinksExceptDirectionQuery implements IJavaQuery2<Collaboration, Boolean> { + public Boolean evaluate(final Collaboration context, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + // display only in / out and inout features. They should not be collapsed also + ParameterValue parameterValue = parameterValues.getParameterValueByName("eStructuralFeature"); + EStructuralFeature eStructuralFeature = (EStructuralFeature) parameterValue.getValue(); + // the eStructure is a containmentReference or Facet Reference? + if (eStructuralFeature instanceof FacetReference) { + // check this is in / out or inout + String name = ((FacetReference) eStructuralFeature).getName(); + if ("in".equals(name) || "out".equals(name) || "inout".equals(name)) { + return true; + } + } + return false; + } +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.wizard/plugin.xml b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.wizard/plugin.xml index 47d6ff2e8fe..7f2c1742729 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt.wizard/plugin.xml +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt.wizard/plugin.xml @@ -1,17 +1,26 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.papyrus.uml.diagram.wizards.templates">
- <template
- di_file="resources/templates/rt-template.di"
- file="resources/templates/rt-template.uml"
- id="org.eclipse.papyrus.umlrt.wizard.template"
- isDefault="false"
- language="uml"
- name="An empty UML RealTime model"
- notation_file="resources/templates/rt-template.notation">
- </template>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.papyrus.uml.diagram.wizards.templates"> + <template + di_file="resources/templates/rt-template.di" + file="resources/templates/rt-template.uml" + id="org.eclipse.papyrus.umlrt.wizard.template" + isDefault="false" + language="uml" + name="An empty UML RealTime model" + notation_file="resources/templates/rt-template.notation"> + </template> + <template + di_file="resources/templates/rt-templateWithStateMachineProfileApplied.di" + file="resources/templates/rt-templateWithStateMachineProfileApplied.uml" + id="org.eclipse.papyrus.umlrt.wizard.template" + isDefault="false" + language="uml" + name="UML RealTime model With Optional StateMachine profile applied" + notation_file="resources/templates/rt-templateWithStateMachineProfileApplied.notation"> + </template> + </extension> + +</plugin> 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 93893ccb1d2..a463e322d87 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.elementtypesconfigurations +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/elementtypes/uml-rt.elementtypesconfigurations @@ -199,6 +199,48 @@ xmi:id="_PLPkEOqQEeS-F5lSZrhlvg" matcherClassName="org.eclipse.papyrus.umlrt.custom.advice.RTMessageInMatcher"/> </elementTypeConfigurations> + <elementTypeConfigurations + xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" + xmi:id="_Vv9-gOzDEeSbg9FMiG2BVg" + name="RTMessageIN" + identifier="org.eclipse.papyrus.umlrt.RTMessageOut"> + <iconEntry + xmi:id="_Vv9-gezDEeSbg9FMiG2BVg" + iconPath="/icons/full/obj16/Operation.gif" + bundleId="org.eclipse.uml2.uml.edit"/> + <specializedTypesID>org.eclipse.papyrus.umlrt.RTMessage</specializedTypesID> + <editHelperAdviceConfiguration + xmi:id="_Vv9-guzDEeSbg9FMiG2BVg" + name="org.eclipse.papyrus.umlrt.custom.advice.OperationAsMessageOutEditHelperAdvice" + description="advice for Operation as RTMessage OUT" + identifier="org.eclipse.papyrus.umlrt.custom.advice.OperationAsMessageOutEditHelperAdvice" + editHelperAdviceClassName="org.eclipse.papyrus.umlrt.custom.advice.OperationAsMessageOutEditHelperAdvice" + inheritance="all"/> + <matcherConfiguration + xmi:id="_Vv9-g-zDEeSbg9FMiG2BVg" + matcherClassName="org.eclipse.papyrus.umlrt.custom.advice.RTMessageOutMatcher"/> + </elementTypeConfigurations> + <elementTypeConfigurations + xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" + xmi:id="_WBNfgOzDEeSbg9FMiG2BVg" + name="RTMessageINOUT" + identifier="org.eclipse.papyrus.umlrt.RTMessageInOut"> + <iconEntry + xmi:id="_WBNfgezDEeSbg9FMiG2BVg" + iconPath="/icons/full/obj16/Operation.gif" + bundleId="org.eclipse.uml2.uml.edit"/> + <specializedTypesID>org.eclipse.papyrus.umlrt.RTMessage</specializedTypesID> + <editHelperAdviceConfiguration + xmi:id="_WBNfguzDEeSbg9FMiG2BVg" + name="org.eclipse.papyrus.umlrt.custom.advice.OperationAsMessageInOutEditHelperAdvice" + description="advice for Operation as Message INOUT" + identifier="org.eclipse.papyrus.umlrt.custom.advice.OperationAsMessageInOutEditHelperAdvice" + editHelperAdviceClassName="org.eclipse.papyrus.umlrt.custom.advice.OperationAsMessageInOutEditHelperAdvice" + inheritance="all"/> + <matcherConfiguration + xmi:id="_WBNfg-zDEeSbg9FMiG2BVg" + matcherClassName="org.eclipse.papyrus.umlrt.custom.advice.RTMessageInOutMatcher"/> + </elementTypeConfigurations> <adviceBindingsConfigurations xsi:type="applystereotypeadviceconfiguration:ApplyStereotypeAdviceConfiguration" xmi:id="_ubJcyaeUEeSUR5jX0TaAcA" diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/IUMLRTElementTypes.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/IUMLRTElementTypes.java index ef93ca750ab..2e198dfcd95 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/IUMLRTElementTypes.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/IUMLRTElementTypes.java @@ -36,5 +36,5 @@ public interface IUMLRTElementTypes { public static final String RT_MESSAGE_ID = "org.eclipse.papyrus.umlrt.RTMessage"; public static final String RT_MESSAGE_IN_ID = "org.eclipse.papyrus.umlrt.RTMessageIn"; public static final String RT_MESSAGE_OUT_ID = "org.eclipse.papyrus.umlrt.RTMessageOut"; - public static final String RT_MESSAGE_INOUT_ID = "org.eclipse.papyrus.umlrt.RTMessageInout"; + public static final String RT_MESSAGE_INOUT_ID = "org.eclipse.papyrus.umlrt.RTMessageInOut"; } diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/UMLRTElementTypesEnumerator.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/UMLRTElementTypesEnumerator.java index db4723b61bc..95983142689 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/UMLRTElementTypesEnumerator.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/UMLRTElementTypesEnumerator.java @@ -41,11 +41,10 @@ public class UMLRTElementTypesEnumerator extends AbstractElementTypeEnumerator i public static final IHintedType RT_MESSAGE = (IHintedType) getElementType(RT_MESSAGE_ID); public static final IHintedType RT_MESSAGE_IN = (IHintedType) getElementType(RT_MESSAGE_IN_ID); - // public static final IHintedType RT_MESSAGE_OUT = (IHintedType) getElementType(RT_MESSAGE_OUT_ID); - // public static final IHintedType RT_MESSAGE_INOUT = (IHintedType) getElementType(RT_MESSAGE_INOUT_ID); + public static final IHintedType RT_MESSAGE_OUT = (IHintedType) getElementType(RT_MESSAGE_OUT_ID); + public static final IHintedType RT_MESSAGE_INOUT = (IHintedType) getElementType(RT_MESSAGE_INOUT_ID); - - private static final List<IHintedType> rtTypes = Arrays.asList(RT_MESSAGE_SET, PROTOCOL_CONTAINER, PROTOCOL, CAPSULE, CAPSULE_PART, RT_PORT, RT_CONNECTOR, RT_EXCLUDED_ELEMENT, RT_MESSAGE, RT_MESSAGE_IN); + private static final List<IHintedType> rtTypes = Arrays.asList(RT_MESSAGE_SET, PROTOCOL_CONTAINER, PROTOCOL, CAPSULE, CAPSULE_PART, RT_PORT, RT_CONNECTOR, RT_EXCLUDED_ELEMENT, RT_MESSAGE_IN, RT_MESSAGE_OUT, RT_MESSAGE_INOUT, RT_MESSAGE); /** * Returns all the specific semantic element types for UML-RT diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInOutEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInOutEditHelperAdvice.java new file mode 100644 index 00000000000..7b3f4ef2a81 --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageInOutEditHelperAdvice.java @@ -0,0 +1,96 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.custom.advice; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; +import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; +import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; +import org.eclipse.uml2.uml.Interface; + +/** + * Specialization of the Operation as message in message sets, but specific to message sets with kind=IN + */ +public class OperationAsMessageInOutEditHelperAdvice extends OperationAsMessageEditHelperAdvice { + + /** + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) + * + * @param request + * @return + */ + @Override + public boolean approveRequest(IEditCommandRequest request) { + if (request instanceof CreateElementRequest) { + // check container. + EObject container = ((CreateElementRequest) request).getContainer(); + if (!(container instanceof Interface)) { + return false; + } + + IElementType messageSetType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); + if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded + if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { + return false; + } + + // this is really a message set. Should go for the kind + if (RTMessageKind.IN_OUT == MessageSetUtils.getMessageKind(container)) { + return true; + } + } + + // should not be possible to create except RT interface + return false; + } + + + return super.approveRequest(request); + } + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getBeforeCreateCommand(CreateElementRequest request) { + // check container. + EObject container = request.getContainer(); + if (!(container instanceof Interface)) { + return UnexecutableCommand.INSTANCE; + } + + IElementType messageSetType= ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); + if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded + if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { + return UnexecutableCommand.INSTANCE; + } + + // this is really a message set. Should go for the kind + if (RTMessageKind.IN_OUT == MessageSetUtils.getMessageKind(container)) { + return super.getBeforeCreateCommand(request); + } + } + + // should not be possible to create except RT interface + return UnexecutableCommand.INSTANCE; + } + +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageOutEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageOutEditHelperAdvice.java new file mode 100644 index 00000000000..0056b5ab707 --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/OperationAsMessageOutEditHelperAdvice.java @@ -0,0 +1,95 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.custom.advice; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; +import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; +import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; +import org.eclipse.uml2.uml.Interface; + +/** + * Specialization of the Operation as message in message sets, but specific to message sets with kind=IN + */ +public class OperationAsMessageOutEditHelperAdvice extends OperationAsMessageEditHelperAdvice { + + /** + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) + * + * @param request + * @return + */ + @Override + public boolean approveRequest(IEditCommandRequest request) { + if (request instanceof CreateElementRequest) { + // check container. + EObject container = ((CreateElementRequest) request).getContainer(); + if (!(container instanceof Interface)) { + return false; + } + + IElementType messageSetType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); + if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded + if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { + return false; + } + + // this is really a message set. Should go for the kind + if (RTMessageKind.OUT == MessageSetUtils.getMessageKind(container)) { + return true; + } + } + + // should not be possible to create except RT interface + return false; + } + + + return super.approveRequest(request); + } + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getBeforeCreateCommand(CreateElementRequest request) { + // check container. + EObject container = request.getContainer(); + if (!(container instanceof Interface)) { + return UnexecutableCommand.INSTANCE; + } + + IElementType messageSetType= ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_SET_ID); + if (messageSetType instanceof ISpecializationType) { // check at the same time UMLRT element types are correctly loaded + if (!((ISpecializationType) messageSetType).getMatcher().matches(container)) { + return UnexecutableCommand.INSTANCE; + } + + // this is really a message set. Should go for the kind + if (RTMessageKind.OUT == MessageSetUtils.getMessageKind(container)) { + return super.getBeforeCreateCommand(request); + } + } + + // should not be possible to create except RT interface + return UnexecutableCommand.INSTANCE; + } +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolContainerEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolContainerEditHelperAdvice.java index b9d7c4d9592..a707295afa1 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolContainerEditHelperAdvice.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolContainerEditHelperAdvice.java @@ -40,7 +40,7 @@ import org.eclipse.uml2.uml.UMLPackage; */ public class ProtocolContainerEditHelperAdvice extends AbstractEditHelperAdvice { -/** + /** * {@inheritDoc} */ @Override diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolEditHelperAdvice.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolEditHelperAdvice.java index 0aca34e3e9a..ccc65637640 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolEditHelperAdvice.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/ProtocolEditHelperAdvice.java @@ -19,6 +19,10 @@ import static org.eclipse.papyrus.uml.service.types.element.UMLElementTypes.USAG import static org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator.PROTOCOL_CONTAINER; import static org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator.RT_MESSAGE_SET; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; @@ -27,22 +31,29 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.RecordingCommand; 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.ElementTypeRegistry; 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.commands.DestroyElementCommand; +import org.eclipse.gmf.runtime.emf.type.core.commands.GetEditContextCommand; 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.gmf.runtime.emf.type.core.requests.DestroyElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper; import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageSet; +import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; +import org.eclipse.papyrus.umlrt.custom.UMLRTElementTypesEnumerator; import org.eclipse.papyrus.umlrt.custom.utils.MessageSetUtils; import org.eclipse.papyrus.umlrt.custom.utils.ProtocolContainerUtils; import org.eclipse.papyrus.umlrt.custom.utils.ProtocolUtils; +import org.eclipse.papyrus.umlrt.internals.Activator; import org.eclipse.uml2.uml.Collaboration; import org.eclipse.uml2.uml.Interface; import org.eclipse.uml2.uml.InterfaceRealization; @@ -71,6 +82,92 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { * {@inheritDoc} */ @Override + public boolean approveRequest(IEditCommandRequest request) { + if (request instanceof CreateElementRequest) { + CreateElementRequest createElementRequest = ((CreateElementRequest) request); + // retrieve element type from this request and check if this is a kind of UMLRT::Message + IElementType type = createElementRequest.getElementType(); + + // type should only be compatible with UMLRT::OperationAsMessages + IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_ID); + // should not be null, otherwise, element type model is not loaded correctly. abort. + if (umlRTMessageType == null) { + Activator.log.debug("RTMessage element type is not accessible"); + return super.approveRequest(request); + } + + // check type is compatible with UMLRT::OperationAsMessages. If yes, allow creation + List<IElementType> types = new ArrayList<IElementType>(Arrays.asList(type.getAllSuperTypes())); + types.add(type); + if (types.contains(umlRTMessageType)) { + return true; + } else { + if (types.contains(ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Generalization"))) { + return true; + } else { + return false; + } + + // return super.approveRequest(createElementRequest); + } + } + return super.approveRequest(request); + } + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getBeforeEditContextCommand(GetEditContextRequest request) { + IEditCommandRequest editCommandRequest = request.getEditCommandRequest(); + if (editCommandRequest instanceof CreateElementRequest) { + // check the element to create is a sub kind of RTMessage + CreateElementRequest createElementRequest = ((CreateElementRequest) editCommandRequest); + // retrieve element type from this request and check if this is a kind of UMLRT::Message + IElementType type = createElementRequest.getElementType(); + + // type should only be compatible with UMLRT::OperationAsMessages + IElementType umlRTMessageType = ElementTypeRegistry.getInstance().getType(IUMLRTElementTypes.RT_MESSAGE_ID); + // should not be null, otherwise, element type model is not loaded correctly. abort. + if (umlRTMessageType == null || type == null) { + Activator.log.debug("RTMessage element type is not accessible"); + return super.getBeforeEditContextCommand(request); + } + + // check type is compatible with UMLRT::OperationAsMessages. If yes, allow creation + List<IElementType> types = new ArrayList<IElementType>(Arrays.asList(type.getAllSuperTypes())); + types.add(type); + if (types.contains(umlRTMessageType)) { + // return the right message set here rather than the protocol container + + GetEditContextCommand command = new GetEditContextCommand(request); + if (request.getEditContext() instanceof Collaboration) { + // retrieve all needed element types + IElementType rTMessageTypeIn = UMLRTElementTypesEnumerator.RT_MESSAGE_IN; + IElementType rTMessageTypeOut = UMLRTElementTypesEnumerator.RT_MESSAGE_OUT; + IElementType rTMessageTypeInOut = UMLRTElementTypesEnumerator.RT_MESSAGE_INOUT; + if (types.contains(rTMessageTypeIn)) { + command.setEditContext(ProtocolUtils.getMessageSetIn((Collaboration) request.getEditContext())); + } else if (types.contains(rTMessageTypeOut)) { + command.setEditContext(ProtocolUtils.getMessageSetOut((Collaboration) request.getEditContext())); + } else if (types.contains(rTMessageTypeInOut)) { + command.setEditContext(ProtocolUtils.getMessageSetInOut((Collaboration) request.getEditContext())); + } else { + return super.getBeforeEditContextCommand(request); + } + } + return command; + } + + } + + return super.getBeforeEditContextCommand(request); + } + + /** + * {@inheritDoc} + */ + @Override protected ICommand getAfterSetCommand(SetRequest request) { if(UMLPackage.eINSTANCE.getNamedElement_Name().equals(request.getFeature() ) ){ @@ -86,12 +183,13 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { @Override protected void doExecute() { - Package protocolContainer = ProtocolUtils.getPackageContainer(protocol); + Package protocolContainer = ProtocolUtils.getProtocolContainer(protocol); if(protocolContainer ==null) { return; } protocolContainer.setName(newName); + protocol.setName(newName); // rename protocol, avoid dependency to avoid circular dependencies towards advices Interface interfaceIn = ProtocolContainerUtils.getMessageSetIn(protocolContainer); @@ -167,6 +265,8 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { createInterfaceRealization(protocol, nameInOut, rtMessageSetInOutInt); createUsage(protocol, nameInOut, rtMessageSetInOutInt); + protocol.setName(name); + return CommandResult.newOKCommandResult(protocol); } @@ -249,6 +349,27 @@ public class ProtocolEditHelperAdvice extends AbstractEditHelperAdvice { } }; } + + /** + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest) + * + * @param request + * @return + */ + @Override + protected ICommand getAfterConfigureCommand(ConfigureRequest request) { + final Collaboration protocol = (Collaboration) request.getElementToConfigure(); + final String name = protocol.getPackage().getName(); + + return new ConfigureElementCommand(request) { + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + protocol.setName(name); + return CommandResult.newOKCommandResult(); + } + }; + } /** * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInOutMatcher.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInOutMatcher.java new file mode 100644 index 00000000000..9cf74560f6f --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageInOutMatcher.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.custom.advice; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; +import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; +import org.eclipse.papyrus.umlrt.custom.utils.RTMessageUtils; + +/** + * + */ +public class RTMessageInOutMatcher implements IElementMatcher { + + /** + * {@inheritDoc} + */ + @Override + public boolean matches(EObject eObject) { + return RTMessageUtils.isRTMessage(eObject, RTMessageKind.IN_OUT); + } + +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageOutMatcher.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageOutMatcher.java new file mode 100644 index 00000000000..5e0a5a9188f --- /dev/null +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/advice/RTMessageOutMatcher.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2015 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.umlrt.custom.advice; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; +import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; +import org.eclipse.papyrus.umlrt.custom.utils.RTMessageUtils; + +/** + * + */ +public class RTMessageOutMatcher implements IElementMatcher { + + /** + * {@inheritDoc} + */ + @Override + public boolean matches(EObject eObject) { + return RTMessageUtils.isRTMessage(eObject, RTMessageKind.OUT); + } + +} diff --git a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java index 155038e0d35..fb601353856 100644 --- a/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java +++ b/extraplugins/umlrt/org.eclipse.papyrus.umlrt/src/org/eclipse/papyrus/umlrt/custom/utils/ProtocolUtils.java @@ -24,6 +24,7 @@ import org.eclipse.papyrus.umlrt.UMLRealTime.RTMessageKind; import org.eclipse.papyrus.umlrt.custom.IUMLRTElementTypes; import org.eclipse.papyrus.umlrt.internals.Activator; import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.Interface; import org.eclipse.uml2.uml.Operation; import org.eclipse.uml2.uml.Package; @@ -39,7 +40,7 @@ public class ProtocolUtils { * the collaboration for which the protocol container is searched * @return the collaboration for which the protocol container is searched or <code>null</code> if none is found */ - public static Package getPackageContainer(Collaboration protocol) { + public static Package getProtocolContainer(Collaboration protocol) { return protocol.getNearestPackage(); } @@ -66,7 +67,7 @@ public class ProtocolUtils { * @return */ public static List<Operation> getRTMessages(Collaboration protocol, RTMessageKind direction, boolean showInherited) { - Package protocolContainer = getPackageContainer(protocol); + Package protocolContainer = getProtocolContainer(protocol); if(protocolContainer ==null) { Activator.log.error("Impossible to get the root protocol container", null); return Collections.emptyList(); @@ -75,4 +76,41 @@ public class ProtocolUtils { return ProtocolContainerUtils.getRTMessages(protocolContainer, direction, showInherited); } + /** + * @param editContext + * @return + */ + public static Interface getMessageSet(Collaboration editContext, RTMessageKind direction) { + Package protocolContainer = getProtocolContainer(editContext); + + if (protocolContainer != null) { + return ProtocolContainerUtils.getMessageSet(protocolContainer, direction); + } + return null; + } + + /** + * @param editContext + * @return + */ + public static Interface getMessageSetIn(Collaboration editContext) { + return getMessageSet(editContext, RTMessageKind.IN); + } + + /** + * @param editContext + * @return + */ + public static Interface getMessageSetOut(Collaboration editContext) { + return getMessageSet(editContext, RTMessageKind.OUT); + } + + /** + * @param editContext + * @return + */ + public static Interface getMessageSetInOut(Collaboration editContext) { + return getMessageSet(editContext, RTMessageKind.IN_OUT); + } + } diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java index c764f2f8234..4a70180661d 100644 --- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java +++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java @@ -13,6 +13,7 @@ *****************************************************************************/ package org.eclipse.papyrus.views.modelexplorer.handler; +import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -37,7 +38,11 @@ public class CopyHandler extends AbstractCommandHandler { * @return */ public static boolean isCopyEnabled(Collection<EObject> selectedElements) { - return !selectedElements.isEmpty(); + return !getElementsToPutInClipboard(selectedElements).isEmpty(); + } + + protected static List<EObject> getElementsToPutInClipboard(Collection<EObject> selectedElements) { + return new ArrayList<EObject>(selectedElements); } /** @@ -49,7 +54,7 @@ public class CopyHandler extends AbstractCommandHandler { */ public static Command buildCopyCommand(TransactionalEditingDomain editingDomain, Collection<EObject> selectedElements) { PapyrusClipboard<Object> papyrusClipboard = PapyrusClipboard.getNewInstance(); - DefaultCopyCommand defaultCopyCommand = new DefaultCopyCommand(editingDomain, papyrusClipboard, selectedElements); + DefaultCopyCommand defaultCopyCommand = new DefaultCopyCommand(editingDomain, papyrusClipboard, getElementsToPutInClipboard(selectedElements)); List<IStrategy> allStrategies = PasteStrategyManager.getInstance().getAllStrategies(); for (IStrategy iStrategy : allStrategies) { IPasteStrategy iPasteStrategy = (IPasteStrategy) iStrategy; |