Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2009-04-22 13:16:49 -0400
committerpelder2009-04-22 13:16:49 -0400
commitd3d432a4cf802facd3973599b7676b0d5f9f1a7a (patch)
tree78946a57995e86cfaf058b88a4e89902140c81f0
parentc6949c094ef97871cc3aa406f68e9653d585689b (diff)
downloadorg.eclipse.jet-d3d432a4cf802facd3973599b7676b0d5f9f1a7a.tar.gz
org.eclipse.jet-d3d432a4cf802facd3973599b7676b0d5f9f1a7a.tar.xz
org.eclipse.jet-d3d432a4cf802facd3973599b7676b0d5f9f1a7a.zip
[215339] Support access to UML2 profiles, stereotypes and stereotype properties
-rw-r--r--plugins/org.eclipse.jet.uml2/.classpath7
-rw-r--r--plugins/org.eclipse.jet.uml2/.project28
-rw-r--r--plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.ui.prefs4
-rw-r--r--plugins/org.eclipse.jet.uml2/META-INF/MANIFEST.MF9
-rw-r--r--plugins/org.eclipse.jet.uml2/OSGI-INF/l10n/bundle.properties3
-rw-r--r--plugins/org.eclipse.jet.uml2/about.html29
-rw-r--r--plugins/org.eclipse.jet.uml2/build.properties7
-rw-r--r--plugins/org.eclipse.jet.uml2/fragment.xml14
-rw-r--r--plugins/org.eclipse.jet.uml2/src/org/eclipse/jet/internal/uml2/functions/StereotypeFunction.java71
10 files changed, 179 insertions, 0 deletions
diff --git a/plugins/org.eclipse.jet.uml2/.classpath b/plugins/org.eclipse.jet.uml2/.classpath
new file mode 100644
index 0000000..2fbb7a2
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.jet.uml2/.project b/plugins/org.eclipse.jet.uml2/.project
new file mode 100644
index 0000000..0f65ade
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jet.uml2</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>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f1066d2
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Wed Apr 22 10:44:51 EDT 2009
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.compliance=1.4
diff --git a/plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..5bb1d39
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,4 @@
+#Wed Apr 22 12:46:33 EDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * Copyright (c) ${year} IBM Corporation and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\: \r\n * IBM - Initial API and implementation\r\n *\r\n */\r\n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/plugins/org.eclipse.jet.uml2/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet.uml2/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..d8558fe
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.f0
+Bundle-SymbolicName: org.eclipse.jet.uml2;singleton:=true
+Bundle-Version: 0.9.100.qualifier
+Bundle-Vendor: %Bundle-Vendor.f0
+Fragment-Host: org.eclipse.jet;bundle-version="0.9.100"
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Require-Bundle: org.eclipse.uml2.uml;bundle-version="[2.3.0,4.0.0)"
diff --git a/plugins/org.eclipse.jet.uml2/OSGI-INF/l10n/bundle.properties b/plugins/org.eclipse.jet.uml2/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..1152392
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.jet.uml2
+Bundle-Vendor.f0 = Eclipse Modeling Project
+Bundle-Name.f0 = JET extensions for UML2 model traversal \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.uml2/about.html b/plugins/org.eclipse.jet.uml2/about.html
new file mode 100644
index 0000000..f221daa
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/about.html
@@ -0,0 +1,29 @@
+<!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">
+ <h3>About This Content</h3>
+
+ <p>April 22, 2009</p>
+ <h3>License</h3>
+
+ <p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).
+ Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+ Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+ at <a href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/legal/epl-v10.html</a>.
+ For purposes of the EPL, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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>
+ <p align="right"><small><a href="#top">go to top</a></small></p>
+
+</body>
+</html>
diff --git a/plugins/org.eclipse.jet.uml2/build.properties b/plugins/org.eclipse.jet.uml2/build.properties
new file mode 100644
index 0000000..cd1e92a
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ fragment.xml,\
+ OSGI-INF/l10n/bundle.properties,\
+ about.html
diff --git a/plugins/org.eclipse.jet.uml2/fragment.xml b/plugins/org.eclipse.jet.uml2/fragment.xml
new file mode 100644
index 0000000..bb21b4a
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/fragment.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<fragment>
+ <extension
+ point="org.eclipse.jet.xpathFunctions">
+ <function
+ implementation="org.eclipse.jet.internal.uml2.functions.StereotypeFunction"
+ maxArgs="2"
+ minArgs="1"
+ name="uml2.stereotype">
+ </function>
+ </extension>
+
+</fragment>
diff --git a/plugins/org.eclipse.jet.uml2/src/org/eclipse/jet/internal/uml2/functions/StereotypeFunction.java b/plugins/org.eclipse.jet.uml2/src/org/eclipse/jet/internal/uml2/functions/StereotypeFunction.java
new file mode 100644
index 0000000..820c88d
--- /dev/null
+++ b/plugins/org.eclipse.jet.uml2/src/org/eclipse/jet/internal/uml2/functions/StereotypeFunction.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2009 IBM Corporation and others.
+ * 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:
+ * IBM - Initial API and implementation
+ *
+ */
+
+package org.eclipse.jet.internal.uml2.functions;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.XPathFunction;
+import org.eclipse.jet.xpath.XPathFunctionWithContext;
+import org.eclipse.jet.xpath.XPathUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * Implement the XPath function uml2.stereotype([element, ] qualified-name).
+ *
+ */
+public class StereotypeFunction implements XPathFunction,
+ XPathFunctionWithContext {
+
+ private Context context;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.xpath.XPathFunction#evaluate(java.util.List)
+ */
+ public Object evaluate(List args) {
+ Object target = args.size() == 1 ? context.getContextNode() : getFirstObject(args.get(0));
+ String qualifiedName = XPathUtil.xpathString(args.get(args.size() - 1));
+
+ if(target instanceof Element) {
+ final Element e = (Element)target;
+ final Stereotype st = e.getAppliedStereotype(qualifiedName);
+ final EObject stInstance = st != null ? e.getStereotypeApplication(st) : null;
+ return stInstance != null ? Collections.singletonList(stInstance) : Collections.EMPTY_LIST;
+ } else {
+ return Collections.EMPTY_LIST;
+ }
+ }
+
+ private Object getFirstObject(Object object) {
+ if(object instanceof Collection) {
+ final Collection c = (Collection)object;
+ return c.size() > 0 ? c.iterator().next() : null;
+ } else {
+ return object;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.xpath.XPathFunctionWithContext#setContext(org.eclipse.jet.xpath.Context)
+ */
+ public void setContext(Context context) {
+ this.context = context;
+ // TODO Auto-generated method stub
+
+ }
+
+}

Back to the top