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/sysml/org.eclipse.papyrus.sysml.facets/src | |
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/sysml/org.eclipse.papyrus.sysml.facets/src')
3 files changed, 113 insertions, 0 deletions
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; + } +} |