diff options
author | Alexandra Buzila | 2016-04-21 15:28:53 +0000 |
---|---|---|
committer | Laurent Delaigue | 2016-05-18 12:29:24 +0000 |
commit | 32501a924de6abf7537f7ea8e3a129156b28b465 (patch) | |
tree | 29301e63710042758b80429b7c5c56744c03d6ab | |
parent | bea0b16d234714968cf3e949edf901779dc6201a (diff) | |
download | org.eclipse.emf.compare-32501a924de6abf7537f7ea8e3a129156b28b465.tar.gz org.eclipse.emf.compare-32501a924de6abf7537f7ea8e3a129156b28b465.tar.xz org.eclipse.emf.compare-32501a924de6abf7537f7ea8e3a129156b28b465.zip |
[492190] Stereotypes not displayed in SMV for SYSML elements
Introduced a FilteredLabelProvider for Papyrus UML elements that
retrieves their label based on the available customizations for the
given element.
Bug: 492190
Change-Id: Ifec7f17d89bcc9f9601ee959fe3db6e5a3dc61b2
Signed-off-by: Alexandra Buzila <abuzila@eclipsesource.com>
8 files changed, 168 insertions, 14 deletions
diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/.checkstyle b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/.checkstyle new file mode 100644 index 000000000..89c72ff46 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/.checkstyle @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false"> + <local-check-config name="EMF Compare" location="/org.eclipse.emf.compare-parent/codeStyle/EMFCompareCheckstyle5Configuration.xml" type="project" description=""> + <additional-data name="protect-config-file" value="false"/> + </local-check-config> + <fileset name="all" enabled="true" check-config-name="EMF Compare" local="true"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> +</fileset-config> diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/.project b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/.project index aabe1a179..d4ef08bd3 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/.project +++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/.project @@ -20,9 +20,15 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> </natures> </projectDescription> diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/META-INF/MANIFEST.MF index 23cc3a84f..5dfa36ec9 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/META-INF/MANIFEST.MF @@ -12,9 +12,16 @@ Require-Bundle: org.eclipse.ui, org.eclipse.emf.compare.edit, org.eclipse.uml2.uml, org.eclipse.papyrus.infra.services.labelprovider, - org.eclipse.papyrus.infra.core + org.eclipse.papyrus.infra.core;bundle-version="1.0.2", + org.eclipse.papyrus.infra.emf, + org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.0.2", + org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.0.2", + org.eclipse.papyrus.uml.tools Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Import-Package: com.google.common.base;version="[11.0.0,16.0.0)", - com.google.common.collect;version="[11.0.0,16.0.0)" + com.google.common.collect;version="[11.0.0,16.0.0)", + org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet Bundle-Localization: plugin +Export-Package: org.eclipse.emf.compre.uml2.edit.papyrus, + org.eclipse.emf.compre.uml2.edit.papyrus.internal.decorator;x-internal:=true diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/plugin.xml b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/plugin.xml index 35eec7948..8741c3eba 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/plugin.xml +++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/plugin.xml @@ -20,5 +20,18 @@ uri="http://www.eclipse.org/uml2/5.0.0/UML"> </factory> </extension> + <extension + point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider"> + <labelProvider + priority="10" + provider="org.eclipse.emf.compre.uml2.edit.papyrus.internal.decorator.PapyrusElementFilteredLabelProvider"> + <labelProviderContext + context="org.eclipse.emf.compare.uml2.edit.papyrus"> + </labelProviderContext> + </labelProvider> + <context + id="org.eclipse.emf.compare.uml2.edit.papyrus"> + </context> + </extension> </plugin> diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/Activator.java b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/Activator.java index a8f607a4f..2065736a4 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/Activator.java +++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/Activator.java @@ -20,20 +20,23 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; /** - * The activator class controls the plug-in life cycle + * The activator class controls the plug-in life cycle. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> */ public class Activator extends AbstractUIPlugin { - // The plug-in ID + /** The plug-in ID. */ public static final String PLUGIN_ID = "org.eclipse.emf.compre.uml2.edit.papyrus"; //$NON-NLS-1$ - // The shared instance + /** The shared instance. */ private static Activator plugin; + /** The label provider service. */ private LabelProviderService labelProviderService; /** - * The constructor + * The constructor. */ public Activator() { } @@ -59,16 +62,15 @@ public class Activator extends AbstractUIPlugin { try { labelProviderService.disposeService(); } catch (ServiceException ex) { - Activator.getDefault().getLog().log( - new Status(IStatus.WARNING, Activator.PLUGIN_ID, - "Unable to dispose Papyrus Label Provider Service", ex)); //$NON-NLS-1$ + Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, + "Unable to dispose Papyrus Label Provider Service", ex)); //$NON-NLS-1$ } } super.stop(context); } /** - * Returns the shared instance + * Returns the shared instance. * * @return the shared instance */ @@ -76,6 +78,11 @@ public class Activator extends AbstractUIPlugin { return plugin; } + /** + * Returns the Papyrus {@link LabelProviderService}. + * + * @return the label provider service or <code>null</code> if the service could not be started + */ public LabelProviderService getLabelProviderService() { if (labelProviderService == null) { labelProviderService = new LabelProviderServiceImpl(); @@ -84,9 +91,8 @@ public class Activator extends AbstractUIPlugin { } catch (ServiceException ex) { // prevent service from being used if it could not be started labelProviderService = null; - getDefault().getLog().log( - new Status(IStatus.WARNING, Activator.PLUGIN_ID, - "Unable to start Papyrus Label Provider Service", ex)); //$NON-NLS-1$ + getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, + "Unable to start Papyrus Label Provider Service", ex)); //$NON-NLS-1$ } } return labelProviderService; 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 new file mode 100644 index 000000000..27f2c4c03 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusElementFilteredLabelProvider.java @@ -0,0 +1,100 @@ +/***************************************************************************** + * 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.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. + * + * @author Alexandra Buzila (EclipseSource) + */ +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; + + /** Constructor. */ + public PapyrusElementFilteredLabelProvider() { + this.propertiesHandler = new PropertiesHandler(getCustomizationManager()); + } + + /** + * Returns <code>true</code> if the label provider applies to the given object. + * + * @param object + * the object + * @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; + } + + @Override + public String getText(Object object) { + EObject element = (EObject)object; + ICustomizationManager customizationManager = getCustomizationManager(); + if (customizationManager == null) { + return super.getText(element); + } + try { + return customizationManager.getCustomValueOf(element, propertiesHandler.getLabelProperty(), + String.class); + } catch (CustomizationException e) { + // fall back to super class + return super.getText(element); + } + } + + @Override + public Image getImage(Object object) { + EObject element = (EObject)object; + ICustomizationManager customizationManager = getCustomizationManager(); + if (customizationManager == null) { + return super.getImage(element); + } + try { + return customizationManager.getCustomValueOf(element, propertiesHandler.getImageProperty(), + Image.class); + } catch (CustomizationException e) { + // fall back to super class + return super.getImage(element); + } + } +} diff --git a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusProfileItemProviderAdapterFactoryDecorator.java b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusProfileItemProviderAdapterFactoryDecorator.java index 1d875285e..8fe4d8ebe 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusProfileItemProviderAdapterFactoryDecorator.java +++ b/plugins/org.eclipse.emf.compare.uml2.edit.papyrus/src/org/eclipse/emf/compre/uml2/edit/papyrus/internal/decorator/PapyrusProfileItemProviderAdapterFactoryDecorator.java @@ -14,6 +14,8 @@ import org.eclipse.emf.compare.uml2.internal.provider.decorator.UMLProfileItemPr import org.eclipse.emf.edit.provider.IItemProviderDecorator; /** + * Decorator adapter factory for Papyrus UML stereotyped element. + * * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> */ public class PapyrusProfileItemProviderAdapterFactoryDecorator extends UMLProfileItemProviderAdapterFactoryDecorator { 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 af47ed84d..b170ba99c 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 @@ -34,6 +34,15 @@ import org.eclipse.uml2.uml.Stereotype; */ public class PapyrusStereotypedElementItemProviderDecorator extends StereotypedElementItemProviderDecorator { + /** Context id for the comparison papyrus label providers. */ + private static final String PAPYRUS_LABEL_PROVIDER_COMPARE_CONTEXT = "org.eclipse.emf.compare.uml2.edit.papyrus"; //$NON-NLS-1$ + + /** + * Default constructor. + * + * @param adapterFactory + * the adapter factory to be used by the label providers. + */ public PapyrusStereotypedElementItemProviderDecorator(ComposeableAdapterFactory adapterFactory) { super(adapterFactory); } @@ -42,7 +51,8 @@ public class PapyrusStereotypedElementItemProviderDecorator extends StereotypedE public String getText(Object object) { LabelProviderService labelProviderService = Activator.getDefault().getLabelProviderService(); if (labelProviderService != null) { - return labelProviderService.getLabelProvider(object).getText(object); + return labelProviderService.getLabelProvider(PAPYRUS_LABEL_PROVIDER_COMPARE_CONTEXT, object) + .getText(object); } return super.getText(object); } |