Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2011-02-07 05:21:28 -0500
committerptessier2011-02-07 05:21:28 -0500
commit89c32ab6b7fee7bbb51dd391ee0434088639446a (patch)
tree319571427ad29c4e68a478088f2d03bca869f91f /tests/recipes/plugins
parentaa745fd24457ea77f2b9b434506a343cf7b2b737 (diff)
downloadorg.eclipse.papyrus-89c32ab6b7fee7bbb51dd391ee0434088639446a.tar.gz
org.eclipse.papyrus-89c32ab6b7fee7bbb51dd391ee0434088639446a.tar.xz
org.eclipse.papyrus-89c32ab6b7fee7bbb51dd391ee0434088639446a.zip
336371: [Model Explorer] add element to do recipe test
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336371
Diffstat (limited to 'tests/recipes/plugins')
-rw-r--r--tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/META-INF/MANIFEST.MF2
-rw-r--r--tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/resource/umlModelExplorerRecipe.querySet4
-rw-r--r--tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/src/org/eclipse/papyrus/uml/modelexplorer/recipetest/GetAllPorts.java29
3 files changed, 34 insertions, 1 deletions
diff --git a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/META-INF/MANIFEST.MF b/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/META-INF/MANIFEST.MF
index 4c58f34c2cb..7a27278f301 100644
--- a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/META-INF/MANIFEST.MF
+++ b/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/META-INF/MANIFEST.MF
@@ -8,9 +8,9 @@ Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,bin
Bundle-Version: 0.0.1.qualifier
Bundle-Name: %pluginName
+Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.uml.modelexplorer.recipetest.Act
ivator
-Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.uml.modelexplorer.recipetest;
singleton:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/resource/umlModelExplorerRecipe.querySet b/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/resource/umlModelExplorerRecipe.querySet
index 33acb96acd8..7f5ac542a67 100644
--- a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/resource/umlModelExplorerRecipe.querySet
+++ b/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/resource/umlModelExplorerRecipe.querySet
@@ -5,4 +5,8 @@
<returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Dependency"/>
<scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Package"/>
</queries>
+ <queries xsi:type="query:JavaModelQuery" name="getAllPorts" description="get all ports from a classifier" upperBound="-1" implementationClassName="org.eclipse.papyrus.uml.modelexplorer.recipetest.GetAllPorts">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Property"/>
+ <scope href="http://www.eclipse.org/uml2/3.0.0/UML#//Classifier"/>
+ </queries>
</query:ModelQuerySet>
diff --git a/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/src/org/eclipse/papyrus/uml/modelexplorer/recipetest/GetAllPorts.java b/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/src/org/eclipse/papyrus/uml/modelexplorer/recipetest/GetAllPorts.java
new file mode 100644
index 00000000000..449e5512750
--- /dev/null
+++ b/tests/recipes/plugins/uml/org.eclipse.papyrus.uml.modelexplorer.recipetest/src/org/eclipse/papyrus/uml/modelexplorer/recipetest/GetAllPorts.java
@@ -0,0 +1,29 @@
+package org.eclipse.papyrus.uml.modelexplorer.recipetest;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Classifier;
+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;
+
+/** get all ports from a classifier */
+public class GetAllPorts implements IJavaModelQuery<Classifier, Collection<Property>> {
+ public Collection<Property> evaluate(final Classifier context, final ParameterValueList parameterValues)
+ throws ModelQueryExecutionException {
+ ArrayList<Property> result= new ArrayList<Property>();
+ Iterator<Property> iter= context.getAllAttributes().iterator();
+ while(iter.hasNext()){
+ Property currentElement= iter.next();
+ if( currentElement instanceof Port){
+ result.add((Port)currentElement);
+ }
+ }
+ return result;
+ }
+}

Back to the top