Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2011-07-20 09:49:41 -0400
committervlorenzo2011-07-20 09:49:41 -0400
commit0ffe6228b11e6b925d7c8b211901af164171e870 (patch)
tree4d08d24f7247d28df93b6720e8a0d01bf96d5372 /plugins/sysml/org.eclipse.papyrus.sysml.facets
parentd08f8331d878381ace0206bc5e5933d423ffc637 (diff)
downloadorg.eclipse.papyrus-0ffe6228b11e6b925d7c8b211901af164171e870.tar.gz
org.eclipse.papyrus-0ffe6228b11e6b925d7c8b211901af164171e870.tar.xz
org.eclipse.papyrus-0ffe6228b11e6b925d7c8b211901af164171e870.zip
Merge Branch 0.8.X changes 5089::5096 for the plugin oep.sysml.facets
NEW - bug 351681: [Requirement Table] Papyrus should provides specific celleditors to edit derived values https://bugs.eclipse.org/bugs/show_bug.cgi?id=351681
Diffstat (limited to 'plugins/sysml/org.eclipse.papyrus.sysml.facets')
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF14
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet11
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet28
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/Messages.java40
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/messages.properties6
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java4
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java6
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java6
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java2
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java2
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java2
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java2
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java2
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java2
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java2
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedFromQuery.java135
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedQuery.java135
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java53
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementMasterQuery.java102
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementRefinedByQuery.java115
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementSatisfiedByQuery.java122
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java48
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTracedToQuery.java152
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementVerifiedByQuery.java101
24 files changed, 1029 insertions, 63 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF b/plugins/sysml/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF
index 2db0bbae840..2a1d36910af 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/META-INF/MANIFEST.MF
@@ -7,15 +7,21 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.sysml;bundle-version="0.8.0",
org.eclipse.emf.edit,
org.eclipse.uml2.common.edit,
- org.eclipse.papyrus.core;bundle-version="0.8.0"
+ org.eclipse.papyrus.core;bundle-version="0.8.0",
+ org.eclipse.papyrus.service.edit,
+ org.eclipse.papyrus.sysml.service.types,
+ org.eclipse.papyrus.uml.standard,
+ org.eclipse.papyrus.uml.service.types,
+ org.eclipse.papyrus.sysml.diagram.common;bundle-version="0.8.1",
+ org.eclipse.papyrus.ui.toolbox
+Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,bin
Bundle-Version: 0.9.0.qualifier
+Bundle-Localization: plugin
Bundle-Name: %pluginName
-Bundle-Activator: org.eclipse.papyrus.sysml.facets.Activator
Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.sysml.facets.Activator
Bundle-SymbolicName: org.eclipse.papyrus.sysml.facets;singleton:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet
index a3095424567..f16d6fe63b3 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsFacets.facetSet
@@ -15,32 +15,39 @@
<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"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementDerivedQuery"/>
</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"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementDerivedFromQuery"/>
</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"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementSatisfiedByQuery"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="facet:FacetReference" name="/refinedBy" 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"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementRefinedByQuery"/>
</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"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementTracedToQuery"/>
</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"/>
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//NamedElement"/>
<valueQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#GetRequirementVerifiedByQuery"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementVerifiedByQuery"/>
</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"/>
+ <setQuery xsi:type="query:JavaModelQuery" href="requirementsQueries.querySet#SetRequirementMasterQuery"/>
</eStructuralFeatures>
- <eStructuralFeatures xsi:type="facet:FacetReference" name="base_Class" lowerBound="1" volatile="true" unsettable="true">
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="base_Class" lowerBound="1" changeable="false" 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>
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet
index 0e07ab9d109..17e008dcf56 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/resources/requirementsQueries.querySet
@@ -49,4 +49,32 @@
<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="SetRequirementDerivedFromQuery" description="Query to set the derived attribute &quot;derived From&quot; of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementDerivedFromQuery">
+ <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="SetRequirementDerivedQuery" description="Query to set the derived attribute &quot;derived&quot; of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementDerivedQuery">
+ <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="SetRequirementMasterQuery" description="Query to set the derived attribute &quot;master&quot; of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementMasterQuery">
+ <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="SetRequirementSatisfiedByQuery" description="Query to set the derived attribute &quot;satisfiedBy&quot; of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementSatisfiedByQuery">
+ <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#//NamedElement"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="SetRequirementVerifiedByQuery" description="Query to set the derived attribute &quot;verifiedBy&quot; of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementVerifiedByQuery">
+ <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#//NamedElement"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="SetRequirementTracedToQuery" description="Query to set the derived attribute &quot;tracedTo&quot; of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementTracedToQuery">
+ <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#//NamedElement"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="SetRequirementRefinedByQuery" description="Query to set the derived attribute &quot;refinedBy&quot; of the requirement" implementationClassName="org.eclipse.papyrus.sysml.facets.query.value.setter.SetRequirementRefinedByQuery">
+ <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#//NamedElement"/>
+ </queries>
</query:ModelQuerySet>
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/Messages.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/Messages.java
new file mode 100644
index 00000000000..fe75aa339c7
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/Messages.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * 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.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.sysml.facets.messages.messages"; //$NON-NLS-1$
+
+ public static String SetRequirementDerivedFromQuery_DeriveReqtCantBeCreated;
+
+ public static String SetRequirementDerivedQuery_DeriveReqtCanBeCreated;
+
+ public static String SetRequirementMasterQuery_CopyCantBeCreated;
+
+ public static String SetRequirementRefinedByQuery_StandardIsNotAppliedOnTheModel;
+
+ public static String SetRequirementTextQuery_AssignmentCantBeDone;
+
+ public static String SetRequirementTextQuery_NotASysMLRequirement;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/messages.properties b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/messages.properties
new file mode 100644
index 00000000000..ab7c93339f5
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/messages/messages.properties
@@ -0,0 +1,6 @@
+SetRequirementDerivedFromQuery_DeriveReqtCantBeCreated=The link DeriveReqt can't be created between {0} and {1}.
+SetRequirementDerivedQuery_DeriveReqtCanBeCreated=The link DeriveReqt can't be created between {0} and {1}.
+SetRequirementMasterQuery_CopyCantBeCreated=The link Copy can't be created between {0} and {1}.
+SetRequirementRefinedByQuery_StandardIsNotAppliedOnTheModel=The required profile Standard is not applied on the model.
+SetRequirementTextQuery_AssignmentCantBeDone=Assignment can't be done.
+SetRequirementTextQuery_NotASysMLRequirement=The edited element is not a SysML Requirement.
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java
index 2415fda65cd..27adcf4c60f 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementBase_ClassQuery.java
@@ -23,8 +23,8 @@ import org.eclipse.uml2.uml.Class;
/** 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 {
+ public Class evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- return (requirement != null) ? requirement.getBase_Class() : null;
+ return (requirement != null) ? requirement.getBase_Class() : null;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java
index 5e2957c649b..809a4d7159d 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedFromQuery.java
@@ -28,12 +28,12 @@ public class GetRequirementDerivedFromQuery implements IJavaModelQuery<Class, Co
public Collection<Class> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Collection<Class> result = new ArrayList<Class>();
-
+
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- if (requirement != null) {
+ if(requirement != null) {
for(Requirement current : requirement.getDerivedFrom()) {
result.add(current.getBase_Class());
- }
+ }
}
return result;
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java
index 65fc058f805..ef0a24bc5b1 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementDerivedQuery.java
@@ -28,12 +28,12 @@ public class GetRequirementDerivedQuery implements IJavaModelQuery<Class, Collec
public Collection<Class> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Collection<Class> result = new ArrayList<Class>();
-
+
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- if (requirement != null) {
+ if(requirement != null) {
for(Requirement current : requirement.getDerived()) {
result.add(current.getBase_Class());
- }
+ }
}
return result;
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java
index 39680fda78f..0b338753647 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementIdQuery.java
@@ -25,6 +25,6 @@ public class GetRequirementIdQuery implements IJavaModelQuery<Class, String> {
public String evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- return (requirement != null) ? requirement.getId() : null;
+ return (requirement != null) ? requirement.getId() : null;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java
index 0a17ec63a38..b9d77a6cb69 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementMasterQuery.java
@@ -25,6 +25,6 @@ public class GetRequirementMasterQuery implements IJavaModelQuery<Class, Class>
public Class evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- return ((requirement != null) && (requirement.getMaster() != null)) ? requirement.getMaster().getBase_Class() : null;
+ return ((requirement != null) && (requirement.getMaster() != null)) ? requirement.getMaster().getBase_Class() : null;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java
index 7f799be771c..2d02cc2e04a 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementRefinedByQuery.java
@@ -28,6 +28,6 @@ public class GetRequirementRefinedByQuery implements IJavaModelQuery<Class, Coll
public Collection<NamedElement> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- return (requirement != null) ? requirement.getRefinedBy() : null;
+ return (requirement != null) ? requirement.getRefinedBy() : null;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java
index a146948e6c4..af2201d4ed4 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementSatifiedByQuery.java
@@ -28,6 +28,6 @@ public class GetRequirementSatifiedByQuery implements IJavaModelQuery<Class, Col
public Collection<NamedElement> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- return (requirement != null) ? requirement.getSatisfiedBy() : null;
+ return (requirement != null) ? requirement.getSatisfiedBy() : null;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java
index 35f7449dba1..3665e2c6cc7 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTextQuery.java
@@ -25,6 +25,6 @@ public class GetRequirementTextQuery implements IJavaModelQuery<Class, String> {
public String evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- return (requirement != null) ? requirement.getText() : null;
+ return (requirement != null) ? requirement.getText() : null;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java
index 5c88aa9513c..e1e6b43f1cb 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementTracedToQuery.java
@@ -30,6 +30,6 @@ public class GetRequirementTracedToQuery implements IJavaModelQuery<Class, Colle
public Collection<NamedElement> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- return (requirement != null) ? requirement.getTracedTo() : null;
+ return (requirement != null) ? requirement.getTracedTo() : null;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java
index 011cef9b919..a17658e12bf 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/getter/GetRequirementVerifiedByQuery.java
@@ -33,7 +33,7 @@ public class GetRequirementVerifiedByQuery implements IJavaModelQuery<Class, Col
public Collection<NamedElement> evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
- if (requirement != null) {
+ if(requirement != null) {
return requirement.getVerifiedBy();
}
return null;
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedFromQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedFromQuery.java
new file mode 100644
index 00000000000..a7deef4344b
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedFromQuery.java
@@ -0,0 +1,135 @@
+/**
+ *
+ * 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) - initial API and implementation
+ */
+package org.eclipse.papyrus.sysml.facets.query.value.setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+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.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
+import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.service.edit.service.IElementEditService;
+import org.eclipse.papyrus.sysml.facets.messages.Messages;
+import org.eclipse.papyrus.sysml.requirements.DeriveReqt;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.NamedElement;
+
+/** Query to set the derived attribute "derived" of the requirement */
+public class SetRequirementDerivedFromQuery 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
+ */
+ @Override
+ public EObject evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ //nothing to do
+ 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
+ */
+ @Override
+ public EObject evaluate(final Class context, final ParameterValueList parameter, final EditingDomain editingDomain) throws ModelQueryExecutionException {
+ CompositeCommand cmd = new CompositeCommand("Edit the feature /DerivedFrom"); //$NON-NLS-1$
+ /*
+ * we need to do this test, because, the facets can be applied on a default table.
+ * In this case, we can't be sure the edited element is a Requirement
+ */
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+ Requirement req = ElementUtil.getStereotypeApplication(context, Requirement.class);
+ EList<Dependency> dependencies = context.getClientDependencies();
+ EList<Requirement> currentDerivedFrom = req.getDerivedFrom();
+ List<Class> currentDerivedFrom_base_Class = new ArrayList<Class>();
+ for(Requirement currentReq : currentDerivedFrom) {
+ currentDerivedFrom_base_Class.add(currentReq.getBase_Class());
+ }
+
+
+ ModelQueryParameterValue object = parameter.get(0);
+ Object values = object.getValue();
+ Assert.isTrue(values instanceof List<?>);
+ List<?> newDerivedFrom = (List<?>)values;
+
+ //we destroy the unnecessary Derive_Reqt
+ for(Dependency current : dependencies) {
+ if(ElementUtil.getStereotypeApplication(current, DeriveReqt.class) != null) {
+ EList<NamedElement> suppliers = current.getSuppliers();
+ //we assume that there is only one supplier
+ if(suppliers.size() == 1) {
+ NamedElement supplier = suppliers.get(0);
+ if(!newDerivedFrom.contains(supplier)) {//we destroy this dependencies
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(current);
+ DestroyElementRequest request = new DestroyElementRequest(current, false);
+ ICommand desroyCommand = provider.getEditCommand(request);
+ cmd.add(desroyCommand);
+ }
+ }
+ }
+ }
+
+ for(Object current : (List<?>)values) {
+ //we create the derive_reqt only if it doesn't exist
+
+ if(!currentDerivedFrom_base_Class.contains(current)) {
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(context);
+ CreateRelationshipRequest createRequest = new CreateRelationshipRequest(context.getNearestPackage(), context, (EObject)current, SysMLElementTypes.DERIVE_REQT);
+ cmd.add(provider.getEditCommand(createRequest));
+ } else {
+
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, NLS.bind(Messages.SetRequirementDerivedFromQuery_DeriveReqtCantBeCreated, context.getName(), ((NamedElement)current).getName()), Type.ERROR));
+ }
+ }
+ }
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR));
+ }
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedQuery.java
new file mode 100644
index 00000000000..03a2361ffb6
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementDerivedQuery.java
@@ -0,0 +1,135 @@
+/*****************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+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.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
+import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.service.edit.service.IElementEditService;
+import org.eclipse.papyrus.sysml.facets.messages.Messages;
+import org.eclipse.papyrus.sysml.requirements.DeriveReqt;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.NamedElement;
+
+/** Query to set the derived attribute "derived" of the requirement */
+public class SetRequirementDerivedQuery 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
+ */
+ @Override
+ public EObject evaluate(Class context, ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ //nothing to do
+ 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 parameterValues
+ * @param editingDomain
+ * @return
+ * @throws ModelQueryExecutionException
+ */
+ @Override
+ public EObject evaluate(Class context, ParameterValueList parameter, EditingDomain editingDomain) throws ModelQueryExecutionException {
+ CompositeCommand cmd = new CompositeCommand("Edit the feature /Derived"); //$NON-NLS-1$
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+ Requirement req = ElementUtil.getStereotypeApplication(context, Requirement.class);
+
+ EList<DirectedRelationship> dependencies = context.getTargetDirectedRelationships();
+ EList<Requirement> currentDerived = req.getDerived();
+ List<Class> currentDerived_base_Class = new ArrayList<Class>();
+ for(Requirement currentReq : currentDerived) {
+ currentDerived_base_Class.add(currentReq.getBase_Class());
+ }
+
+
+ ModelQueryParameterValue object = parameter.get(0);
+ Object values = object.getValue();
+ Assert.isTrue(values instanceof List<?>);
+ List<?> newDerivedFrom = (List<?>)values;
+
+ //we destroy the unnecessary Derive_Reqt
+ for(DirectedRelationship current : dependencies) {
+ if(ElementUtil.getStereotypeApplication(current, DeriveReqt.class) != null) {
+ EList<NamedElement> clients = ((Dependency)current).getClients();
+ //we assume that there is only one client
+ if(clients.size() == 1) {
+ NamedElement supplier = clients.get(0);
+ if(!newDerivedFrom.contains(supplier)) {//we destroy this dependencies
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(current);
+ DestroyElementRequest request = new DestroyElementRequest(current, false);
+ ICommand desroyCommand = provider.getEditCommand(request);
+ cmd.add(desroyCommand);
+ }
+ }
+ }
+ }
+
+
+ for(Object current : (List<?>)values) {
+ //we create the derive_reqt only if it doesn't exist
+ if(!currentDerived_base_Class.contains(current)) {
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(context);
+
+ CreateElementRequest createRequest = new CreateRelationshipRequest(context.getNearestPackage(), (EObject)current, context, SysMLElementTypes.DERIVE_REQT);
+ cmd.add(provider.getEditCommand(createRequest));
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, NLS.bind(Messages.SetRequirementDerivedQuery_DeriveReqtCanBeCreated, context.getName(), ((NamedElement)current).getName()), Type.ERROR));
+ }
+ }
+
+ }
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR));
+ }
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java
index e127063773f..17f0756c6d7 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementIdQuery.java
@@ -21,10 +21,14 @@ import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDom
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.requirements.Requirement;
import org.eclipse.papyrus.sysml.requirements.RequirementsPackage;
import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
import org.eclipse.uml2.uml.Class;
/** Query to set the attribute "id" of the requirement */
@@ -40,8 +44,9 @@ public class SetRequirementIdQuery implements IJavaModelQueryWithEditingDomain<C
* @return
* @throws ModelQueryExecutionException
*/
+ @Override
public EObject evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
- // TODO Auto-generated method stub
+ //nothing to do
return null;
}
@@ -56,31 +61,37 @@ public class SetRequirementIdQuery implements IJavaModelQueryWithEditingDomain<C
* @return
* @throws ModelQueryExecutionException
*/
+ @Override
public EObject evaluate(final Class context, final ParameterValueList parameter, final EditingDomain editingDomain) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
-
- if ((requirement == null) || (parameter.isEmpty()) || (parameter.get(0) == null)) {
- return context; // Abort.
- }
-
- // Retrieve new value from parameter and update if the property value has changed.
- String newValue = (parameter.get(0).getValue() instanceof String) ? (String) parameter.get(0).getValue() : null;
- if (newValue != requirement.getId()) {
-
- try {
-
- TransactionalEditingDomain domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
- SetCommand command = new SetCommand(domain, requirement, RequirementsPackage.eINSTANCE.getRequirement_Id(), newValue);
- if (command.canExecute()) {
- domain.getCommandStack().execute(command);
+
+ if(requirement != null) {
+ if(!((parameter.isEmpty()) || (parameter.get(0) == null))) {
+
+
+
+ // Retrieve new value from parameter and update if the property value has changed.
+ String newValue = (parameter.get(0).getValue() instanceof String) ? (String)parameter.get(0).getValue() : null;
+ if(newValue != requirement.getId()) {
+
+ try {
+
+ TransactionalEditingDomain domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ SetCommand command = new SetCommand(domain, requirement, RequirementsPackage.eINSTANCE.getRequirement_Id(), newValue);
+ if(command.canExecute()) {
+ domain.getCommandStack().execute(command);
+ }
+
+ } catch (ServiceException e) {
+ throw new ModelQueryExecutionException(e);
+ }
+
}
-
- } catch (ServiceException e) {
- throw new ModelQueryExecutionException(e);
}
-
+ } else {
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR)));
}
-
+
return context;
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementMasterQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementMasterQuery.java
new file mode 100644
index 00000000000..a0126af0c8f
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementMasterQuery.java
@@ -0,0 +1,102 @@
+/*****************************************************************************
+ * 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.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+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.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
+import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.service.edit.service.IElementEditService;
+import org.eclipse.papyrus.sysml.facets.messages.Messages;
+import org.eclipse.papyrus.sysml.requirements.Copy;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.NamedElement;
+
+/** Query to set the derived attribute "master" of the requirement */
+public class SetRequirementMasterQuery implements IJavaModelQueryWithEditingDomain<Class, EObject> {
+
+ @Override
+ public EObject evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ // nothing to do
+ return null;
+ }
+
+ @Override
+ public EObject evaluate(Class context, ParameterValueList parameterValues, EditingDomain editingDomain) throws ModelQueryExecutionException {
+ CompositeCommand cmd = new CompositeCommand("Edit the derived attribute /master"); //$NON-NLS-1$
+ ModelQueryParameterValue object = parameterValues.get(0);
+ Object value = object.getValue();
+ Class newMaster = null;
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+ if(value != null) {
+ Assert.isTrue(value instanceof Class);
+ newMaster = (Class)value;
+ }
+ Assert.isTrue(ElementUtil.getStereotypeApplication(context, Requirement.class) != null);
+
+ EList<Dependency> dependencies = context.getClientDependencies();
+
+ //we destroy the unnecessary Copy
+ for(DirectedRelationship current : dependencies) {
+ if(ElementUtil.getStereotypeApplication(current, Copy.class) != null) {
+ EList<NamedElement> target = ((Dependency)current).getSuppliers();
+ //we assume that there is only one client
+ if(target.size() == 1) {
+ NamedElement client = target.get(0);
+ if(newMaster != client) {//we destroy this dependency
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(current);
+ DestroyElementRequest request = new DestroyElementRequest(current, false);
+ ICommand destroyCommand = provider.getEditCommand(request);
+ cmd.add(destroyCommand);
+ }
+ }
+ }
+ }
+
+ if(newMaster != null) {
+ if(ElementUtil.getStereotypeApplication(newMaster, Requirement.class) != null) {
+ //we create the Element Copy
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(context);
+ CreateElementRequest createRequest = new CreateRelationshipRequest(context.getNearestPackage(), context, newMaster, SysMLElementTypes.COPY);
+ cmd.add(provider.getEditCommand(createRequest));
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, NLS.bind(Messages.SetRequirementMasterQuery_CopyCantBeCreated, context.getName(), ((NamedElement)newMaster).getName()), Type.ERROR));
+ }
+ }
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR));
+ }
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementRefinedByQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementRefinedByQuery.java
new file mode 100644
index 00000000000..dac2f87e4c3
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementRefinedByQuery.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+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.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
+import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.service.edit.service.IElementEditService;
+import org.eclipse.papyrus.sysml.facets.messages.Messages;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.papyrus.uml.standard.Refine;
+import org.eclipse.papyrus.uml.standard.util.StandardResource;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.NamedElement;
+
+/** Query to set the derived attribute "refinedBy" of the requirement */
+public class SetRequirementRefinedByQuery implements IJavaModelQueryWithEditingDomain<NamedElement, 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
+ */
+ @Override
+ public EObject evaluate(final NamedElement context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ //nothing to do
+ return null;
+ }
+
+ @Override
+ public EObject evaluate(NamedElement context, ParameterValueList parameterValues, EditingDomain editingDomain) throws ModelQueryExecutionException {
+ CompositeCommand cmd = new CompositeCommand("Edit the feature /refinedBy"); //$NON-NLS-1$
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+ if(context.getNearestPackage().getAppliedProfile(StandardResource.STANDARD_ID) == null) {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementRefinedByQuery_StandardIsNotAppliedOnTheModel, Type.ERROR));
+ } else {
+ Requirement req = ElementUtil.getStereotypeApplication(context, Requirement.class);
+ EList<DirectedRelationship> dependencies = context.getTargetDirectedRelationships();
+ EList<NamedElement> currentRefinedBy = req.getRefinedBy();
+
+
+ ModelQueryParameterValue object = parameterValues.get(0);
+ Object values = object.getValue();
+ Assert.isTrue(values instanceof List<?>);
+ List<?> newRefinedBy = (List<?>)values;
+
+ //we destroy the unnecessary Refine
+ for(DirectedRelationship current : dependencies) {
+ if(ElementUtil.getStereotypeApplication(current, Refine.class) != null) {
+
+ EList<NamedElement> clients = ((Dependency)current).getClients();
+ //we assume that there is only one client
+ if(clients.size() == 1) {
+ NamedElement client = clients.get(0);
+ if(!newRefinedBy.contains(client)) {//we destroy this dependencies
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(current);
+ DestroyElementRequest request = new DestroyElementRequest(current, false);
+ ICommand destroyCommand = provider.getEditCommand(request);
+ cmd.add(destroyCommand);
+ }
+ }
+ }
+ }
+
+ for(Object current : (List<?>)values) {
+ //we create the Trace only if it doesn't exist
+ Assert.isTrue(current instanceof NamedElement);
+ if(!currentRefinedBy.contains(current)) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(context);
+ CreateRelationshipRequest createRequest = new CreateRelationshipRequest(context.getNearestPackage(), (NamedElement)current, context, UMLElementTypes.REFINE);
+ cmd.add(provider.getEditCommand(createRequest));
+ }
+ }
+ }
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR));
+ }
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementSatisfiedByQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementSatisfiedByQuery.java
new file mode 100644
index 00000000000..0e54d0bbd8c
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementSatisfiedByQuery.java
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+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.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
+import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.service.edit.service.IElementEditService;
+import org.eclipse.papyrus.sysml.facets.messages.Messages;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.papyrus.sysml.requirements.Satisfy;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.NamedElement;
+
+/** Query to set the derived attribute "satisfiedBy" of the requirement */
+public class SetRequirementSatisfiedByQuery implements IJavaModelQueryWithEditingDomain<NamedElement, 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
+ */
+ @Override
+ public EObject evaluate(final NamedElement context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ // nothing to do
+ 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 parameterValues
+ * @param editingDomain
+ * @return
+ * @throws ModelQueryExecutionException
+ */
+ @Override
+ public EObject evaluate(NamedElement context, ParameterValueList parameterValues, EditingDomain editingDomain) throws ModelQueryExecutionException {
+ CompositeCommand cmd = new CompositeCommand("Edit the derived attribute /SatisfiedBy"); //$NON-NLS-1$
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+
+ Requirement req = ElementUtil.getStereotypeApplication(context, Requirement.class);
+ EList<DirectedRelationship> dependencies = context.getTargetDirectedRelationships();
+ EList<NamedElement> currentSatisfiedBy = req.getSatisfiedBy();
+
+
+
+ ModelQueryParameterValue object = parameterValues.get(0);
+ Object values = object.getValue();
+ Assert.isTrue(values instanceof List<?>);
+ List<?> newSatisfiedBy = (List<?>)values;
+
+ //we destroy the unnecessary Satisfy
+ for(DirectedRelationship current : dependencies) {
+ if(ElementUtil.getStereotypeApplication(current, Satisfy.class) != null) {
+ EList<NamedElement> clients = ((Dependency)current).getClients();
+ //we assume that there is only one client
+ if(clients.size() == 1) {
+ NamedElement client = clients.get(0);
+ if(!newSatisfiedBy.contains(client)) {//we destroy this dependencies
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(current);
+ DestroyElementRequest request = new DestroyElementRequest(current, false);
+ ICommand desroyCommand = provider.getEditCommand(request);
+ cmd.add(desroyCommand);
+ }
+ }
+ }
+ }
+
+ for(Object current : (List<?>)values) {
+ //we create the derive_reqt only if it doesn't exist
+ Assert.isTrue(current instanceof NamedElement);
+ if(!currentSatisfiedBy.contains(current)) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(context);
+ CreateRelationshipRequest createRequest = new CreateRelationshipRequest(context.getNearestPackage(), (NamedElement)current, context, SysMLElementTypes.SATISFY);
+ cmd.add(provider.getEditCommand(createRequest));
+ }
+ }
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR));
+ }
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java
index 43fd3a33753..a8c328f8e4b 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTextQuery.java
@@ -21,10 +21,14 @@ import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDom
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.requirements.Requirement;
import org.eclipse.papyrus.sysml.requirements.RequirementsPackage;
import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
import org.eclipse.uml2.uml.Class;
/** Query to set the attribute "text" of the requirement */
@@ -41,7 +45,7 @@ public class SetRequirementTextQuery implements IJavaModelQueryWithEditingDomain
* @throws ModelQueryExecutionException
*/
public EObject evaluate(final Class context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
- // TODO Auto-generated method stub
+ // nothing to do
return null;
}
@@ -58,29 +62,31 @@ public class SetRequirementTextQuery implements IJavaModelQueryWithEditingDomain
*/
public EObject evaluate(final Class context, final ParameterValueList parameter, final EditingDomain editingDomain) throws ModelQueryExecutionException {
Requirement requirement = ElementUtil.getStereotypeApplication(context, Requirement.class);
-
- if ((requirement == null) || (parameter.isEmpty()) || (parameter.get(0) == null)) {
- return context; // Abort.
- }
-
- // Retrieve new value from parameter and update if the property value has changed.
- String newValue = (parameter.get(0).getValue() instanceof String) ? (String) parameter.get(0).getValue() : null;
- if (newValue != requirement.getId()) {
-
- try {
-
- TransactionalEditingDomain domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
- SetCommand command = new SetCommand(domain, requirement, RequirementsPackage.eINSTANCE.getRequirement_Text(), newValue);
- if (command.canExecute()) {
- domain.getCommandStack().execute(command);
+
+ if(requirement != null) {
+ if(!((parameter.isEmpty()) || (parameter.get(0) == null))) {
+
+ // Retrieve new value from parameter and update if the property value has changed.
+ String newValue = (parameter.get(0).getValue() instanceof String) ? (String)parameter.get(0).getValue() : null;
+ if(newValue != requirement.getId()) {
+
+ try {
+
+ TransactionalEditingDomain domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ SetCommand command = new SetCommand(domain, requirement, RequirementsPackage.eINSTANCE.getRequirement_Text(), newValue);
+ if(command.canExecute()) {
+ domain.getCommandStack().execute(command);
+ }
+
+ } catch (ServiceException e) {
+ throw new ModelQueryExecutionException(e);
+ }
+
}
-
- } catch (ServiceException e) {
- throw new ModelQueryExecutionException(e);
}
-
+ } else {
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR)));
}
-
return context;
}
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTracedToQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTracedToQuery.java
new file mode 100644
index 00000000000..636951ab7b2
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementTracedToQuery.java
@@ -0,0 +1,152 @@
+/*****************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+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.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
+import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.service.edit.service.IElementEditService;
+import org.eclipse.papyrus.sysml.facets.messages.Messages;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.papyrus.uml.standard.Trace;
+import org.eclipse.papyrus.uml.standard.util.StandardResource;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Stereotype;
+
+/** Query to set the derived attribute "tracedTo" of the requirement */
+public class SetRequirementTracedToQuery implements IJavaModelQueryWithEditingDomain<NamedElement, 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
+ */
+ @Override
+ public EObject evaluate(final NamedElement context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ // nothing to do
+ 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 parameterValues
+ * @param editingDomain
+ * @return
+ * @throws ModelQueryExecutionException
+ */
+ @Override
+ public EObject evaluate(NamedElement context, ParameterValueList parameterValues, EditingDomain editingDomain) throws ModelQueryExecutionException {
+ CompositeCommand cmd = new CompositeCommand("Edit the feature /TracedTo"); //$NON-NLS-1$
+ int result = MessageDialog.OK;
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+ if(context.getNearestPackage().getAppliedProfile(StandardResource.STANDARD_ID) == null) {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementRefinedByQuery_StandardIsNotAppliedOnTheModel, Type.ERROR));
+ } else {
+ Requirement req = ElementUtil.getStereotypeApplication(context, Requirement.class);
+ EList<DirectedRelationship> dependencies = context.getTargetDirectedRelationships();
+
+ EList<?> currentTracedTo = req.getTracedTo();
+
+ ModelQueryParameterValue object = parameterValues.get(0);
+ Object values = object.getValue();
+ Assert.isTrue(values instanceof List<?>);
+ List<?> newTracedTo = (List<?>)values;
+
+ //we destroy the unnecessary tracedTo
+ for(DirectedRelationship current : dependencies) {
+ if(ElementUtil.getStereotypeApplication(current, Trace.class) != null && isStricteTrace(current)) {
+ EList<NamedElement> clients = ((Dependency)current).getClients();
+ //we assume that there is only one client
+ if(clients.size() == 1) {
+ NamedElement client = clients.get(0);
+ if(!newTracedTo.contains(client)) {//we destroy this dependencies
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(current);
+ DestroyElementRequest request = new DestroyElementRequest(current, false);
+ ICommand desroyCommand = provider.getEditCommand(request);
+ cmd.add(desroyCommand);
+ }
+
+ }
+ }
+ }
+
+ for(Object current : (List<?>)values) {
+ //we create the Trace only if it doesn't exist
+ Assert.isTrue(current instanceof NamedElement);
+ if(!currentTracedTo.contains(current)) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(context);
+ CreateRelationshipRequest createRequest = new CreateRelationshipRequest(context.getNearestPackage(), (NamedElement)current, context, UMLElementTypes.TRACE);
+ cmd.add(provider.getEditCommand(createRequest));
+ }
+ }
+ }
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR));
+ }
+ if(result == MessageDialog.OK) {
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param link
+ * a {@link DirectedRelationship}
+ * @return
+ * <code>true</code> if the link is Stereotyped with Trace (and <code>false</code> if the link is stereotyped with a subtype of Trace
+ */
+ private boolean isStricteTrace(DirectedRelationship link) {
+ EList<Stereotype> appliedStereotypes = link.getAppliedStereotypes();
+ for(Stereotype ste : appliedStereotypes) {
+ if((ste instanceof Trace)) {
+ EObject stereotypeApplication = link.getStereotypeApplication(ste);
+ if(Trace.class.isInstance(stereotypeApplication)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementVerifiedByQuery.java b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementVerifiedByQuery.java
new file mode 100644
index 00000000000..13ee82c4753
--- /dev/null
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.facets/src/org/eclipse/papyrus/sysml/facets/query/value/setter/SetRequirementVerifiedByQuery.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+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.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.core.utils.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.gmf.diagram.common.commands.IdentityCommandWithNotification;
+import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.service.edit.service.IElementEditService;
+import org.eclipse.papyrus.sysml.facets.messages.Messages;
+import org.eclipse.papyrus.sysml.requirements.Requirement;
+import org.eclipse.papyrus.sysml.requirements.Verify;
+import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.papyrus.sysml.util.ElementUtil;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.NamedElement;
+
+/** Query to set the derived attribute "verifiedBy" of the requirement */
+public class SetRequirementVerifiedByQuery implements IJavaModelQueryWithEditingDomain<NamedElement, EObject> {
+
+ @Override
+ public EObject evaluate(final NamedElement context, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public EObject evaluate(NamedElement context, ParameterValueList parameterValues, EditingDomain editingDomain) throws ModelQueryExecutionException {
+ CompositeCommand cmd = new CompositeCommand("Edit the feature /VerifiedBy"); //$NON-NLS-1$
+ if(ElementUtil.getStereotypeApplication(context, Requirement.class) != null) {
+
+ Requirement req = ElementUtil.getStereotypeApplication(context, Requirement.class);
+ EList<DirectedRelationship> dependencies = context.getTargetDirectedRelationships();
+ EList<?> currentVerifiedBy = req.getVerifiedBy();
+
+
+
+ ModelQueryParameterValue object = parameterValues.get(0);
+ Object values = object.getValue();
+ Assert.isTrue(values instanceof List<?>);
+ List<?> newVerifiedBy = (List<?>)values;
+
+ //we destroy the unnecessary Verified
+ for(DirectedRelationship current : dependencies) {
+ if(ElementUtil.getStereotypeApplication(current, Verify.class) != null) {
+ EList<NamedElement> clients = ((Dependency)current).getClients();
+ //we assume that there is only one client
+ if(clients.size() == 1) {
+ NamedElement client = clients.get(0);
+ if(!newVerifiedBy.contains(client)) {//we destroy this dependencies
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(current);
+ DestroyElementRequest request = new DestroyElementRequest(current, false);
+ ICommand desroyCommand = provider.getEditCommand(request);
+ cmd.add(desroyCommand);
+ }
+ }
+ }
+ }
+
+ for(Object current : (List<?>)values) {
+ //we create the derive_reqt only if it doesn't exist
+ Assert.isTrue(current instanceof NamedElement);
+ if(!currentVerifiedBy.contains(current)) {
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(context);
+ CreateRelationshipRequest createRequest = new CreateRelationshipRequest(context.getNearestPackage(), (NamedElement)current, context, SysMLElementTypes.VERIFY);
+ cmd.add(provider.getEditCommand(createRequest));
+ }
+ }
+ } else {
+ cmd.add(new IdentityCommandWithNotification(Messages.SetRequirementTextQuery_AssignmentCantBeDone, Messages.SetRequirementTextQuery_NotASysMLRequirement, Type.ERROR));
+ }
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+}

Back to the top