Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-03-14 13:51:50 +0000
committerLaurent Wouters2014-03-14 13:54:22 +0000
commitf515b310417b386c79d9fbd2500c5373a7179aa7 (patch)
tree1785439bb2467282b35964ab71c18f8e2fffff38 /plugins/uml/org.eclipse.papyrus.uml.profile
parent832ceab5e78772d2b483348f620de7b47a4c091f (diff)
downloadorg.eclipse.papyrus-f515b310417b386c79d9fbd2500c5373a7179aa7.tar.gz
org.eclipse.papyrus-f515b310417b386c79d9fbd2500c5373a7179aa7.tar.xz
org.eclipse.papyrus-f515b310417b386c79d9fbd2500c5373a7179aa7.zip
399860: Papyrus shall enable to customize the creation policy of views
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399860 Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.profile')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml6
-rwxr-xr-xplugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/UMLProfileHelper.java67
3 files changed, 75 insertions, 1 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF
index 79c424569c1..7aba328d79f 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF
@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.papyrus.uml.tools.utils;bundle-version="1.0.0",
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0",
com.google.guava;bundle-version="11.0.0",
org.eclipse.papyrus.emf.facet.custom.core;bundle-version="0.4.0",
- org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="0.4.0"
+ org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="0.4.0",
+ org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.uml.profile,
org.eclipse.papyrus.uml.profile.constraints,
org.eclipse.papyrus.uml.profile.definition,
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml
index a9d6d447afd..e0c8c8dcb98 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml
+++ b/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml
@@ -164,5 +164,11 @@
provider="org.eclipse.papyrus.uml.profile.providers.ProfileDefinitionLabelProvider">
</labelProvider>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.viewpoints.policy.profilehelper">
+ <helper
+ class="org.eclipse.papyrus.uml.profile.UMLProfileHelper">
+ </helper>
+ </extension>
</plugin>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/UMLProfileHelper.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/UMLProfileHelper.java
new file mode 100755
index 00000000000..ae0bd2aa74d
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/UMLProfileHelper.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.profile;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.papyrus.infra.viewpoints.policy.IProfileHelper;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+
+
+/**
+ * Implementation of the IProfileHelper interface for UML profiles
+ * @author Laurent Wouters
+ */
+public class UMLProfileHelper implements IProfileHelper {
+
+ /**
+ * @see org.eclipse.papyrus.infra.viewpoints.policy.IProfileHelper#getAppliedProfiles(org.eclipse.emf.ecore.EObject)
+ */
+ public Collection<EPackage> getAppliedProfiles(EObject model) {
+ ArrayList<EPackage> result = new ArrayList<EPackage>();
+ if (!(model instanceof Element))
+ return result;
+ Element element = (Element)model;
+ Package p = element.getNearestPackage();
+ if (p == null)
+ return result;
+ for (Profile profile : p.getAllAppliedProfiles()) {
+ if (!result.contains(profile.getDefinition()))
+ result.add(profile.getDefinition());
+ }
+ return result;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.viewpoints.policy.IProfileHelper#getAppliedStereotypes(org.eclipse.emf.ecore.EObject)
+ */
+ public Collection<EClass> getAppliedStereotypes(EObject object) {
+ ArrayList<EClass> result = new ArrayList<EClass>();
+ if (!(object instanceof Element))
+ return result;
+ Element element = (Element)object;
+ for (EObject app : element.getStereotypeApplications()) {
+ if (!result.contains(app.eClass()))
+ result.add(app.eClass());
+ }
+ return result;
+ }
+}

Back to the top