diff options
author | vlorenzo | 2011-07-22 12:10:14 +0000 |
---|---|---|
committer | vlorenzo | 2011-07-22 12:10:14 +0000 |
commit | 47f884efe844ea3a8715bd2af83336c195c50ed0 (patch) | |
tree | cc5b99b874370bf2fdf13ebff245c1a01e53da76 /plugins | |
parent | 175a25f8cde47e4410ce0092b427ec520d13897b (diff) | |
download | org.eclipse.papyrus-47f884efe844ea3a8715bd2af83336c195c50ed0.tar.gz org.eclipse.papyrus-47f884efe844ea3a8715bd2af83336c195c50ed0.tar.xz org.eclipse.papyrus-47f884efe844ea3a8715bd2af83336c195c50ed0.zip |
Merged Branch 0.8.X changes 5098::5109 for the plugin oep.sysml.facets
NEW - bug 352852: [Table Editor] The SysML profile should be represented by Facets for the table
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352852
Diffstat (limited to 'plugins')
6 files changed, 154 insertions, 1 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/plugin.xml b/plugins/sysml/org.eclipse.papyrus.sysml.facets/plugin.xml index db4988ec55b..7f2b95565b0 100644 --- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/plugin.xml +++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/plugin.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse version="3.4"?>
<plugin>
@@ -8,4 +8,10 @@ <extension point="org.eclipse.emf.facet.infra.query.registration">
<modelqueryset file="resources/requirementsQueries.querySet"/>
</extension>
+ <extension point="org.eclipse.emf.facet.infra.query.registration">
+ <modelqueryset file="resources/portAndFlowsQueries.querySet"/>
+ </extension>
+ <extension point="org.eclipse.emf.facet.infra.facet.registration">
+ <facetset file="resources/portAndFlowsFacets.facetSet"/>
+ </extension>
</plugin>
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/portAndFlowsFacets.facetSet b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/portAndFlowsFacets.facetSet new file mode 100644 index 00000000000..2c84994c523 --- /dev/null +++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/portAndFlowsFacets.facetSet @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="ASCII"?>
+<facet:FacetSet xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:facet="http://www.eclipse.org/EmfFacet/infra/facet/0.8.incubation" xmlns:query="http://www.eclipse.org/EmfFacet/infra/query/0.8.incubation" name="portAndFlowsFacets" nsURI="http://www.eclipse.org/papyrus/sysml/portAndFlows/SysMLPortAndFlowsFacetSet.facetSet" nsPrefix="SysMLPortAndFlowsFacetSet">
+ <eClassifiers xsi:type="facet:Facet" name="FlowPort" abstract="true">
+ <eSuperTypes href="http://www.eclipse.org/uml2/3.0.0/UML#//Port"/>
+ <eStructuralFeatures xsi:type="facet:FacetAttribute" name="/isAtomic" changeable="false" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/uml2/3.0.0/UML#//Boolean"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="emffacet:/query/portAndFlowsQueries#GetFlowPortIsAtomicQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetAttribute" name="direction" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EEnum" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows/FlowDirection"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="emffacet:/query/portAndFlowsQueries#GetFlowPortDirectionQuery"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="emffacet:/query/portAndFlowsQueries#SetFlowPortDirectionQuery"/>
+ </eStructuralFeatures>
+ </eClassifiers>
+ <extendedPackage href="http://www.eclipse.org/uml2/3.0.0/UML#/"/>
+</facet:FacetSet>
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/portAndFlowsQueries.querySet b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/portAndFlowsQueries.querySet new file mode 100644 index 00000000000..703f5dc4188 --- /dev/null +++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/portAndFlowsQueries.querySet @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="ASCII"?>
+<query:ModelQuerySet xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:query="http://www.eclipse.org/EmfFacet/infra/query/0.8.incubation" name="portAndFlowsQueries" description="These queries are used to manage the PortAndFlowsProfile">
+ <associatedMetamodels href="http://www.eclipse.org/uml2/3.0.0/UML#/"/>
+ <associatedMetamodels href="http://www.eclipse.org/emf/2002/Ecore#/"/>
+ <associatedMetamodels href="http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows"/>
+ <queries xsi:type="query:JavaModelQuery" name="GetFlowPortIsAtomicQuery" description="Query to get the derived attribute "isAtomic" of the FlowPort" implementationClassName="org.eclipse.papyrus.sysml.facets.portandflows.query.value.getter.GetFlowPortIsAtomicQuery">
+ <returnType xsi:type="ecore:EDataType" href="http://www.eclipse.org/uml2/3.0.0/UML#//Boolean"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Port"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetFlowPortDirectionQuery" description="Query to qet the attribute "Direction" of the FlowPort" implementationClassName="org.eclipse.papyrus.sysml.facets.portandflows.query.value.getter.GetFlowPortDirectionQuery">
+ <returnType xsi:type="ecore:EEnum" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows/FlowDirection"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Port"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="SetFlowPortDirectionQuery" description="Query to qet the attribute "Direction" of the FlowPort" implementationClassName="org.eclipse.papyrus.sysml.facets.portandflows.query.value.setter.SetFlowPortDirectionQuery">
+ <returnType xsi:type="ecore:EEnum" href="http://www.eclipse.org/papyrus/0.7.0/SysML#//portandflows/FlowDirection"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Port"/>
+ </queries>
+</query:ModelQuerySet>
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/getter/GetFlowPortDirectionQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/getter/GetFlowPortDirectionQuery.java new file mode 100644 index 00000000000..56ed15c1956 --- /dev/null +++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/getter/GetFlowPortDirectionQuery.java @@ -0,0 +1,22 @@ +package org.eclipse.papyrus.sysml.facets.portandflows.query.value.getter; + +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.sysml.portandflows.FlowPort; +import org.eclipse.papyrus.sysml.util.ElementUtil; +import org.eclipse.uml2.uml.Port; + +/** Query to qet the attribute "Direction" of the FlowPort */ +public class GetFlowPortDirectionQuery implements IJavaModelQuery<Port, FlowDirection> { + + public FlowDirection evaluate(final Port context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + FlowPort flowPort = ElementUtil.getStereotypeApplication(context, FlowPort.class); + if(flowPort != null) { + return flowPort.getDirection(); + } + return null; + } +} diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/getter/GetFlowPortIsAtomicQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/getter/GetFlowPortIsAtomicQuery.java new file mode 100644 index 00000000000..03dbb606914 --- /dev/null +++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/getter/GetFlowPortIsAtomicQuery.java @@ -0,0 +1,31 @@ +package org.eclipse.papyrus.sysml.facets.portandflows.query.value.getter; + +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.papyrus.sysml.portandflows.FlowPort; +import org.eclipse.papyrus.sysml.util.ElementUtil; +import org.eclipse.uml2.uml.Port; + +/** Query to get the derived attribute "isAtomic" of the FlowPort */ +public class GetFlowPortIsAtomicQuery implements IJavaModelQuery<Port, Boolean> { + + /** + * + * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject, + * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList) + * + * @param context + * @param parameterValues + * @return + * @throws ModelQueryExecutionException + */ + public Boolean evaluate(final Port context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + FlowPort flowPort = ElementUtil.getStereotypeApplication(context, FlowPort.class); + if(flowPort != null) { + return flowPort.isIsAtomic(); + } + return null; + } +} diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/setter/SetFlowPortDirectionQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/setter/SetFlowPortDirectionQuery.java new file mode 100644 index 00000000000..757d1754e98 --- /dev/null +++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/portandflows/query/value/setter/SetFlowPortDirectionQuery.java @@ -0,0 +1,60 @@ +package org.eclipse.papyrus.sysml.facets.portandflows.query.value.setter; +import org.eclipse.emf.common.util.Enumerator; +import org.eclipse.emf.edit.command.SetCommand; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; +import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDomain; +import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.core.services.ServiceException; +import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers; +import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification; +import org.eclipse.papyrus.sysml.facets.messages.Messages; +import org.eclipse.papyrus.sysml.portandflows.FlowDirection; +import org.eclipse.papyrus.sysml.portandflows.FlowPort; +import org.eclipse.papyrus.sysml.portandflows.PortandflowsPackage; +import org.eclipse.papyrus.sysml.util.ElementUtil; +import org.eclipse.papyrus.ui.toolbox.notification.Type; +import org.eclipse.uml2.uml.Port; + +/** Query to qet the attribute "Direction" of the FlowPort */ +public class SetFlowPortDirectionQuery implements IJavaModelQueryWithEditingDomain<Port, FlowDirection> { + + public FlowDirection evaluate(final Port context, final ParameterValueList parameterValues) + throws ModelQueryExecutionException { + //nothing to do + return null; + } + + public FlowDirection evaluate(Port context, ParameterValueList parameterValues, EditingDomain editingDomain) throws ModelQueryExecutionException { + FlowPort flowPort = ElementUtil.getStereotypeApplication(context, FlowPort.class); + + if(flowPort != null) { + if(!((parameterValues.isEmpty()) || (parameterValues.get(0) == null))) { + + + + // Retrieve new value from parameter and update if the property value has changed. + Enumerator newValue = (parameterValues.get(0).getValue() instanceof Enumerator) ? (Enumerator)parameterValues.get(0).getValue() : null; + if(newValue != flowPort.getDirection()) { + try { + TransactionalEditingDomain domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain(); + SetCommand command = new SetCommand(domain, flowPort, PortandflowsPackage.eINSTANCE.getFlowPort_Direction(), newValue); + if(command.canExecute()) { + domain.getCommandStack().execute(command); + } + + } catch (ServiceException e) { + throw new ModelQueryExecutionException(e); + } + + } + } + } else { + editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, "The edited element is not a SysML FlowPort.", Type.ERROR))); + } + + return null; + } +} |