diff options
author | vlorenzo | 2011-05-02 14:47:44 +0000 |
---|---|---|
committer | vlorenzo | 2011-05-02 14:47:44 +0000 |
commit | 87f72b4e224ff31c3d74960f71c79097188f3bfa (patch) | |
tree | 8d34a35016c82a835ae8827800307604c301ce25 /incoming | |
parent | f7f75998b3e90f610f8601782e423a3d6ec2366a (diff) | |
download | org.eclipse.papyrus-87f72b4e224ff31c3d74960f71c79097188f3bfa.tar.gz org.eclipse.papyrus-87f72b4e224ff31c3d74960f71c79097188f3bfa.tar.xz org.eclipse.papyrus-87f72b4e224ff31c3d74960f71c79097188f3bfa.zip |
NEW - bug 344465: [Table Editor] Papyrus should provides Facets and Queries to edit the element stereotyped with SysML
https://bugs.eclipse.org/bugs/show_bug.cgi?id=344465
Diffstat (limited to 'incoming')
22 files changed, 799 insertions, 0 deletions
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/.classpath b/incoming/org.eclipse.papyrus.sysml.facets/.classpath new file mode 100644 index 00000000000..45f024e850e --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/.project b/incoming/org.eclipse.papyrus.sysml.facets/.project new file mode 100644 index 00000000000..f7d6054b667 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.sysml.facets</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.emf.facet.common.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.emf.facet.common.ProjectNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF b/incoming/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..3eb9613ec6f --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.facet.infra.common.core,
+ org.eclipse.emf.facet.infra.query.core,
+ org.eclipse.emf.ecore,
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.sysml;bundle-version="0.8.0",
+ org.eclipse.emf.edit,
+ org.eclipse.emf.transaction,
+ org.eclipse.uml2.common.edit
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .,bin
+Bundle-Version: 0.8.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Activator: org.eclipse.papyrus.sysml.facets.Activator
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.sysml.facets;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/about.html b/incoming/org.eclipse.papyrus.sysml.facets/about.html new file mode 100644 index 00000000000..82d49bf5f81 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/build.properties b/incoming/org.eclipse.papyrus.sysml.facets/build.properties new file mode 100644 index 00000000000..af947bfb91e --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/build.properties @@ -0,0 +1,11 @@ +output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ resources/,\
+ about.html,\
+ plugin.properties
+source.. = src/
+src.includes = resources/,\
+ META-INF/,\
+ about.html
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/plugin.properties b/incoming/org.eclipse.papyrus.sysml.facets/plugin.properties new file mode 100644 index 00000000000..f0cf24e236a --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/plugin.properties @@ -0,0 +1,3 @@ +#Properties file for org.eclipse.papyrus.sysml.facets
+providerName = Eclipse Modeling Project
+pluginName = EMF Facets for Papyrus SysML
\ No newline at end of file diff --git a/incoming/org.eclipse.papyrus.sysml.facets/plugin.xml b/incoming/org.eclipse.papyrus.sysml.facets/plugin.xml new file mode 100644 index 00000000000..db4988ec55b --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/plugin.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+
+<plugin>
+ <extension point="org.eclipse.emf.facet.infra.facet.registration">
+ <facetset file="resources/requirementsFacets.facetSet"/>
+ </extension>
+ <extension point="org.eclipse.emf.facet.infra.query.registration">
+ <modelqueryset file="resources/requirementsQueries.querySet"/>
+ </extension>
+</plugin>
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet b/incoming/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet new file mode 100644 index 00000000000..3f92c320229 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet @@ -0,0 +1,49 @@ +<?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="requirementsFacets" nsURI="http://www.eclipse.org/papyrus/sysml/requirements/SysMLRequirementsFacetSet.facetSet" nsPrefix="SysMLRequirementsFacetSet">
+ <eClassifiers xsi:type="facet:Facet" name="Requirement" abstract="true">
+ <eSuperTypes href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <eStructuralFeatures xsi:type="facet:FacetAttribute" name="text" lowerBound="1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementTextQuery"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementTextQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetAttribute" name="id" lowerBound="1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementIdQuery"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementIdQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="/derived" upperBound="-1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementDerivedQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="/derivedFrom" upperBound="-1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementDerivedFromQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="/satisfiedBy" upperBound="-1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//NamedElement"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementSatisfiedByQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="/redefinedBy" upperBound="-1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//NamedElement"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementRefinedByQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="/tracedTo" upperBound="-1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//NamedElement"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementTracedToQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="/verifiedBy" upperBound="-1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Operation"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementVerifiedByQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="/master" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementMasterQuery"/>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="base_Class" lowerBound="1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementBase_ClassQuery"/>
+ </eStructuralFeatures>
+ </eClassifiers>
+ <extendedPackage href="http://www.eclipse.org/uml2/3.0.0/UML#/"/>
+</facet:FacetSet>
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet b/incoming/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet new file mode 100644 index 00000000000..7b9454118ca --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet @@ -0,0 +1,52 @@ +<?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="requirementsQueries" description="These queries are used to manage the requirements">
+ <associatedMetamodels href="http://www.eclipse.org/uml2/3.0.0/UML#/"/>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementIdQuery" description="Query to get the attribute "id" of the requirement" lowerBound="1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementIdQuery">
+ <returnType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementTextQuery" description="Query to get the attribute "text" of the requirement" lowerBound="1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementTextQuery">
+ <returnType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementDerivedQuery" description="Query to get the reference "derived" of the requirement" upperBound="-1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementDerivedQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementDerivedFromQuery" description="Query to get the reference "derivedBy" of the requirement" upperBound="-1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementDerivedFromQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementSatisfiedByQuery" description="Query to get the reference "satisfiedBy" of the requirement" upperBound="-1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementSatifiedByQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//NamedElement"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementRefinedByQuery" description="Query to get the reference "redefinedBy" of the requirement" upperBound="-1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementRefinedByQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//NamedElement"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementTracedToQuery" description="Query to get the reference "tracedTo" of the requirement" upperBound="-1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementTracedToQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//NamedElement"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementVerifiedByQuery" description="Query to get the reference "verified by" of the requirement" upperBound="-1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementVerifiedByQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Operation"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementMasterQuery" description="Query to get the field reference "master" of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementMasterQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetRequirementBase_ClassQuery" description="Query to get the reference "base_class" of the requirement" lowerBound="1" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.getter.GetRequirementBase_ClassQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="SetRequirementIdQuery" description="Query to set the attribute "id" of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementIdQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="SetRequirementTextQuery" description="Query to set the attribute "text" of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementTextQuery">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
+ </queries>
+</query:ModelQuerySet>
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/Activator.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/Activator.java new file mode 100644 index 00000000000..d285eeebf1d --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/Activator.java @@ -0,0 +1,45 @@ +/*******************************************************************************
+ * Copyright (c) 2010 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software)
+ *******************************************************************************/
+package org.eclipse.papyrus.sysml.facets;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/** The activator class controls the plug-in life cycle */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.sysml"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ Activator.plugin = this;
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ Activator.plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return Activator.plugin;
+ }
+}
diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java new file mode 100644 index 00000000000..baf9708a897 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ +public class GetRequirementBase_ClassQuery implements IJavaModelQuery<Class, Class> { + + public Class evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_BASE_CLASS_ID); + return (Class)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java new file mode 100644 index 00000000000..dd02fa168ad --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.getter; + +import java.util.Collection; + +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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ +public class GetRequirementDerivedFromQuery implements IJavaModelQuery<Class, Collection<Class>> { + + public Collection<Class> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_DERIVED_FROM_ID); + return (Collection<Class>)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java new file mode 100644 index 00000000000..0ad4a44d827 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.getter; + +import java.util.Collection; + +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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ +public class GetRequirementDerivedQuery implements IJavaModelQuery<Class, Collection<Class>> { + + public Collection<Class> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_DERIVED_ID); + return (Collection<Class>)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java new file mode 100644 index 00000000000..971cefde6cb --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java @@ -0,0 +1,39 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the id of the requirement */ +public class GetRequirementIdQuery implements IJavaModelQuery<Class, String> { + + public String evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_ID_ID); + if(value == null) { + return ""; //$NON-NLS-1$ + } + if(value instanceof String) { + return (String)value; + } + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java new file mode 100644 index 00000000000..827180ac391 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ +public class GetRequirementMasterQuery implements IJavaModelQuery<Class, Class> { + + public Class evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_MASTER_ID); + return (Class)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java new file mode 100644 index 00000000000..cc1014e98ac --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.getter; + +import java.util.Collection; + +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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ +public class GetRequirementRefinedByQuery implements IJavaModelQuery<Class, Collection<NamedElement>> { + + public Collection<NamedElement> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_REDEFINED_BY_ID); + return (Collection<NamedElement>)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java new file mode 100644 index 00000000000..c133e91e97c --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.getter; + +import java.util.Collection; + +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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ +public class GetRequirementSatifiedByQuery implements IJavaModelQuery<Class, Collection<NamedElement>> { + + public Collection<NamedElement> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_SATISFIED_BY_ID); + return (Collection<NamedElement>)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java new file mode 100644 index 00000000000..ffe1142693b --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java @@ -0,0 +1,39 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ +public class GetRequirementTextQuery implements IJavaModelQuery<Class, String> { + + public String evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_TEXT_ID); + if(value == null) { + return ""; //$NON-NLS-1$ + } + if(value instanceof String) { + return (String)value; + } + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java new file mode 100644 index 00000000000..f3d0d02835c --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java @@ -0,0 +1,39 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.getter; + +import java.util.Collection; + +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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Stereotype; + +/** + * Query to get the text of the requirement + */ +public class GetRequirementTracedToQuery implements IJavaModelQuery<Class, Collection<NamedElement>> { + + public Collection<NamedElement> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_TRACED_TO_ID); + return (Collection<NamedElement>)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java new file mode 100644 index 00000000000..702a6c73eb3 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java @@ -0,0 +1,38 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.getter; + +import java.util.Collection; + +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.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to get the text of the requirement */ + +public class GetRequirementVerifiedByQuery implements IJavaModelQuery<Class, Collection<Operation>> { + + public Collection<Operation> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + Object value = context.getValue(ste, SysmlResource.REQUIREMENT_VERIFIED_BY_ID); + return (Collection<Operation>)value; + } + return null; + } +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java new file mode 100644 index 00000000000..a60705e49e3 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java @@ -0,0 +1,91 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.setter; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.ecore.EObject; +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.facet.infra.query.runtime.ModelQueryParameterValue; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.papyrus.sysml.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to set the attribute "id" of the requirement */ +public class SetRequirementIdQuery implements IJavaModelQueryWithEditingDomain<Class, EObject> { + + /** + * + * @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 EObject evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + // TODO Auto-generated method stub + return null; + } + + /** + * + * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDomain#evaluate(org.eclipse.emf.ecore.EObject, + * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList, org.eclipse.emf.edit.domain.EditingDomain) + * + * @param arg0 + * @param parameter + * @param arg2 + * @return + * @throws ModelQueryExecutionException + */ + public EObject evaluate(final Class context, final ParameterValueList parameter, final EditingDomain editingDomain) throws ModelQueryExecutionException { + final Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null) { + if(parameter.size() != 0) { + final ModelQueryParameterValue newValue = parameter.get(0); + if(newValue != null && newValue.getValue() instanceof String) { + Command command = null; + TransactionalEditingDomain domain = null; + if(!(editingDomain instanceof TransactionalEditingDomain)) { + //if we work with a uml file, it is possible to get a UML2AdapterFactoryEditingDomain instead of TransactionEditingDomain + domain = TransactionUtil.getEditingDomain(context); + } else { + domain = (TransactionalEditingDomain)editingDomain; + } + if(domain != null) { + command = new RecordingCommand(domain) { + + @Override + protected void doExecute() { + context.setValue(ste, SysmlResource.REQUIREMENT_ID_ID, newValue.getValue()); + } + }; + } + if(command != null && command.canExecute()) { + domain.getCommandStack().execute(command); + } + } + } + } + return context; + } + +} diff --git a/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java new file mode 100644 index 00000000000..cc0683a3a89 --- /dev/null +++ b/incoming/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java @@ -0,0 +1,78 @@ +/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.sysml.facets.query.value.setter; + +import org.eclipse.emf.ecore.EObject; +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.facet.infra.query.runtime.ModelQueryParameterValue; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.sysml.util.SysmlResource; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Stereotype; + +/** Query to set the attribute "text" of the requirement */ +public class SetRequirementTextQuery implements IJavaModelQueryWithEditingDomain<Class, EObject> { + + /** + * + * @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 EObject evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { + // TODO Auto-generated method stub + return null; + } + + /** + * + * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDomain#evaluate(org.eclipse.emf.ecore.EObject, + * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList, org.eclipse.emf.edit.domain.EditingDomain) + * + * @param context + * @param parameter + * @param editingDomain + * @return + * @throws ModelQueryExecutionException + */ + public EObject evaluate(final Class context, final ParameterValueList parameter, final EditingDomain editingDomain) throws ModelQueryExecutionException { + final Stereotype ste = context.getAppliedStereotype(SysmlResource.REQUIREMENT_ID); + if(ste != null && editingDomain instanceof TransactionalEditingDomain) { + if(parameter.size() != 0) { + final ModelQueryParameterValue newValue = parameter.get(0); + if(newValue != null && newValue.getValue() instanceof String) { + RecordingCommand command = new RecordingCommand((TransactionalEditingDomain)editingDomain) { + + @Override + protected void doExecute() { + context.setValue(ste, SysmlResource.REQUIREMENT_TEXT_ID, newValue.getValue()); + } + }; + if(command.canExecute()) { + editingDomain.getCommandStack().execute(command); + } + } + } + } + return context; + } +} |