Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreperico2010-01-21 16:10:31 +0000
committereperico2010-01-21 16:10:31 +0000
commit9cf37f13e2a0a4214bfebd1f82d631bf478c0aee (patch)
tree00c2d7dde9aaac5b24f72645e4c914f88b77c6de /plugins/profile-tool
parent0ae0e040a823f2c35aa66c4af85735b4ea8ef5e0 (diff)
downloadorg.eclipse.papyrus-9cf37f13e2a0a4214bfebd1f82d631bf478c0aee.tar.gz
org.eclipse.papyrus-9cf37f13e2a0a4214bfebd1f82d631bf478c0aee.tar.xz
org.eclipse.papyrus-9cf37f13e2a0a4214bfebd1f82d631bf478c0aee.zip
NEW - bug 297816: [SysML] Provide a Parametric diagram
https://bugs.eclipse.org/bugs/show_bug.cgi?id=297816 -Manage diagram initialization through the papyrus wizard
Diffstat (limited to 'plugins/profile-tool')
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/profile-tool/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java b/plugins/profile-tool/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java
index b8cf28d84d9..c1ed8a3510c 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java
@@ -13,8 +13,13 @@
*****************************************************************************/
package org.eclipse.papyrus.diagramprofile.utils;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
@@ -25,6 +30,18 @@ import org.eclipse.uml2.uml.Stereotype;
*/
public class StereotypeUtils {
+ /** extension point ID to load profile */
+ public static final String extensionPointIdForProfile = "org.eclipse.uml2.uml.generated_package";
+
+ /** URI for profile */
+ public static final String uriExtensionPointIdForProfile = "uri";
+
+ /** location for profile */
+ public static final String locationExtensionPointIdForProfile = "location";
+
+ /** URI for SysML profile */
+ public static final String SYSML_URI = "http://www.eclipse.org/papyrus/0.7.0/SysML";
+
/**
* Get the base Element from a stereotype application.
*
@@ -88,4 +105,53 @@ public class StereotypeUtils {
return s != null;
}
+ /**
+ * Load a profile from an URI
+ *
+ * @return the profile
+ */
+ public static Profile loadProfile(String uri, ResourceSet set) {
+ String locationURI = "";
+ Profile profile = null;
+ IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ extensionPointIdForProfile);
+ for (IConfigurationElement e : extensions) {
+ String extensionURI = e.getAttribute(uriExtensionPointIdForProfile);
+ if (extensionURI.equals(uri)) {
+ locationURI = e.getAttribute(locationExtensionPointIdForProfile);
+ URI profileURI = URI.createURI(locationURI);
+ if (set != null) {
+ Resource resource = set.getResource(profileURI, true);
+ for (EObject obj : resource.getContents()) {
+ if (obj instanceof Profile) {
+ profile = (Profile) obj;
+ return profile;
+ }
+ }
+ }
+ }
+ }
+ return profile;
+ }
+
+ /**
+ * Apply a profile on a package, from an URI
+ */
+ public static void applyProfile(String uri, Package element) {
+ Profile profile = loadProfile(uri, element.eResource().getResourceSet());
+ if (profile != null) {
+ element.applyProfile(profile);
+ }
+ }
+
+ /**
+ * Apply the SysML profile on the specified element
+ */
+ public static void applySysMLProfile(Package element) {
+ Profile profile = loadProfile(SYSML_URI, element.eResource().getResourceSet());
+ if (profile != null) {
+ element.applyProfile(profile);
+ }
+ }
+
}

Back to the top