From 1d473e1ffb66262cd7b03df235b529ecc0b8dde7 Mon Sep 17 00:00:00 2001 From: Camille Letavernier Date: Mon, 24 Nov 2014 17:37:47 +0100 Subject: 453078: [All Diagrams] Make GMF::View owned styles editable from the properties view https://bugs.eclipse.org/bugs/show_bug.cgi?id=453078 --- .../constraint/GMFNotationConstraint.java | 24 ++++++- .../properties/modelelement/GMFModelElement.java | 81 +++++++++++++++++++++- .../constraints/EMFInstanceOfConstraint.java | 6 +- 3 files changed, 103 insertions(+), 8 deletions(-) diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/GMFNotationConstraint.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/GMFNotationConstraint.java index cec54f28f80..84ea516cb71 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/GMFNotationConstraint.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/GMFNotationConstraint.java @@ -11,8 +11,13 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.properties.constraint; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EObject; import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.notation.NamedStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.Style; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.constraints.constraints.EMFInstanceOfConstraint; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; @@ -49,7 +54,22 @@ public class GMFNotationConstraint extends EMFInstanceOfConstraint { view = (View) eObject; } - return view == null ? false : super.match(view); - } + if (view == null) { + return false; + } + + if (super.match(view)) { // Match via "instance of" + return true; + } + EClassifier classifier = NotationPackage.eINSTANCE.getEClassifier(className); + if (classifier instanceof EClass) { + Style style = view.getStyle((EClass) classifier); + + // NamedStyle are application-specific and should be handled separately + return style != null && !(style instanceof NamedStyle); + } + + return false; + } } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java index 31fa12825db..3b7b310d969 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java @@ -11,6 +11,8 @@ *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement; +import java.util.List; + import org.eclipse.core.databinding.observable.IObservable; import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.value.IObservableValue; @@ -20,12 +22,15 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.NamedStyle; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.Style; +import org.eclipse.gmf.runtime.notation.View; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.emf.providers.EMFContentProvider; import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject; import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; import org.eclipse.papyrus.infra.gmfdiag.properties.Activator; @@ -81,7 +86,12 @@ public class GMFModelElement extends EMFModelElement { if (propertyPath.endsWith("owner")) { return true; } - return super.isFeatureEditable(propertyPath); + + if (super.isFeatureEditable(propertyPath)) { + return true; + } + + return getStyleFor(propertyPath) != null; } @Override @@ -106,7 +116,7 @@ public class GMFModelElement extends EMFModelElement { EStructuralFeature feature = getFeature(propertyPath); if (feature == null) { - return null; + return findStyleObservable(propertyPath); } if (feature.getEType() == NotationPackage.eINSTANCE.getGradientData()) { @@ -122,6 +132,54 @@ public class GMFModelElement extends EMFModelElement { return value; } + protected Style getStyleFor(String propertyPath) { + if (!(source instanceof View)) { + return null; + } + + View view = (View) source; + + for (Style style : (List