Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-11-10 09:10:39 +0000
committerCamille Letavernier2015-11-10 09:10:39 +0000
commit84360d0f239ccb65f943204b85a29a444f2d122e (patch)
tree87c94e92e143b2b643e425812a00c47d88386527
parent9a33e9c53d8ab13c4d9b3dc2495d3c1615e938bb (diff)
downloadorg.eclipse.papyrus-84360d0f239ccb65f943204b85a29a444f2d122e.tar.gz
org.eclipse.papyrus-84360d0f239ccb65f943204b85a29a444f2d122e.tar.xz
org.eclipse.papyrus-84360d0f239ccb65f943204b85a29a444f2d122e.zip
478789: Papyrus Notation Model is used for non Papyrus Editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=478789 - Add extra checks to the Papyrus ShapeDecoratorProvider to ensure it is enabled only on Papyrus models Change-Id: I2a79851f1437cc0334c4d43a059b4e3d2f67363a Signed-off-by: Camille Letavernier <camille.letavernier@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java
index 40ae09a86f3..a36cd20a1c6 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ShapeDecoratorProvider.java
@@ -20,6 +20,9 @@ import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOpe
import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider;
import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
/**
* Provides the decorator for the shape, based on the shape service
@@ -52,6 +55,21 @@ public class ShapeDecoratorProvider extends AbstractProvider implements IDecorat
}
IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation).getDecoratorTarget();
+
+ View notationElement = NotationHelper.findView(decoratorTarget);
+ if (notationElement == null) {
+ return false;
+ }
+
+ try {
+ ServicesRegistry papyrusRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(notationElement);
+ if (papyrusRegistry == null) {
+ return false;
+ }
+ } catch (Exception ex) {
+ return false; // Not a Papyrus model
+ }
+
return ShapeDecorator.getDecoratorTargetNode(decoratorTarget) != null;
}

Back to the top