Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusElementFilteredLabelProvider.java23
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementItemProviderDecorator.java18
-rw-r--r--plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementUtil.java58
3 files changed, 70 insertions, 29 deletions
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusElementFilteredLabelProvider.java b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusElementFilteredLabelProvider.java
index 27f2c4c03..896f94c3c 100644
--- a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusElementFilteredLabelProvider.java
+++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusElementFilteredLabelProvider.java
@@ -15,13 +15,9 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandler;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
/**
* Filtered label provider for Papyrus UML elements.
@@ -30,9 +26,6 @@ import org.eclipse.uml2.uml.Profile;
*/
public class PapyrusElementFilteredLabelProvider extends UMLLabelProvider implements IFilteredLabelProvider {
- /** Papyrus profile URI. */
- private static final String PAPYRUS_PROFILE_URI = "http://www.eclipse.org/papyrus.*"; //$NON-NLS-1$
-
/** The properties handler. */
private PropertiesHandler propertiesHandler;
@@ -49,21 +42,7 @@ public class PapyrusElementFilteredLabelProvider extends UMLLabelProvider implem
* @return <code>true</code> if the Label provider handles the given object
*/
public boolean accept(Object object) {
- EObject eObject = EMFHelper.getEObject(object);
- if (!(eObject instanceof Element)) {
- return false;
- }
- Element element = (Element)eObject;
- Package nearestPackage = element.getNearestPackage();
- if (nearestPackage == null) {
- return false;
- }
- for (Profile profile : nearestPackage.getAllAppliedProfiles()) {
- if (profile.getURI() != null && profile.getURI().matches(PAPYRUS_PROFILE_URI)) {
- return true;
- }
- }
- return false;
+ return PapyrusStereotypedElementUtil.isPapyrusStereotypedElement(object);
}
@Override
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementItemProviderDecorator.java b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementItemProviderDecorator.java
index 52b684ed6..22123b57d 100644
--- a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementItemProviderDecorator.java
+++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementItemProviderDecorator.java
@@ -49,19 +49,23 @@ public class PapyrusStereotypedElementItemProviderDecorator extends StereotypedE
@Override
public String getText(Object object) {
- LabelProviderService labelProviderService = Activator.getDefault().getLabelProviderService();
- if (labelProviderService != null) {
- return labelProviderService.getLabelProvider(PAPYRUS_LABEL_PROVIDER_COMPARE_CONTEXT, object)
- .getText(object);
+ if (PapyrusStereotypedElementUtil.isPapyrusStereotypedElement(object)) {
+ LabelProviderService labelProviderService = Activator.getDefault().getLabelProviderService();
+ if (labelProviderService != null) {
+ return labelProviderService.getLabelProvider(PAPYRUS_LABEL_PROVIDER_COMPARE_CONTEXT, object)
+ .getText(object);
+ }
}
return super.getText(object);
}
@Override
public Object getImage(Object object) {
- LabelProviderService labelProviderService = Activator.getDefault().getLabelProviderService();
- if (labelProviderService != null) {
- return labelProviderService.getLabelProvider(object).getImage(object);
+ if (PapyrusStereotypedElementUtil.isPapyrusStereotypedElement(object)) {
+ LabelProviderService labelProviderService = Activator.getDefault().getLabelProviderService();
+ if (labelProviderService != null) {
+ return labelProviderService.getLabelProvider(object).getImage(object);
+ }
}
return super.getImage(object);
}
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementUtil.java b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementUtil.java
new file mode 100644
index 000000000..0ce841675
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusStereotypedElementUtil.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2016 EclipseSource Services GmbH
+ * *
+ * 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
+ *
+ * Alexandra Buzila (EclipseSource) - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.emf.compre.uml2.edit.papyrus.internal.decorator;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ * Utility class for Papyrus Stereotyped Elements.
+ *
+ * @author Alexandra Buzila
+ */
+public final class PapyrusStereotypedElementUtil {
+
+ /** Papyrus profile URI. */
+ private static final String PAPYRUS_PROFILE_URI = "http://www.eclipse.org/papyrus.*"; //$NON-NLS-1$
+
+ /** Constructor. */
+ private PapyrusStereotypedElementUtil() {
+ }
+
+ /**
+ * Returns <code>true</code> if the given object is a Papyrus stereotyped {@link Element}.
+ *
+ * @param object
+ * the element to check
+ * @return <code>true</code> if the given object is a Papyrus stereotyped {@link Element}
+ */
+ public static boolean isPapyrusStereotypedElement(Object object) {
+ EObject eObject = EMFHelper.getEObject(object);
+ if (!(eObject instanceof Element)) {
+ return false;
+ }
+ Element element = (Element)eObject;
+ Package nearestPackage = element.getNearestPackage();
+ if (nearestPackage == null) {
+ return false;
+ }
+ for (Profile profile : nearestPackage.getAllAppliedProfiles()) {
+ if (profile.getURI() != null && profile.getURI().matches(PAPYRUS_PROFILE_URI)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}

Back to the top