Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-11-24 16:37:47 +0000
committerCamille Letavernier2014-11-24 16:37:47 +0000
commit1d473e1ffb66262cd7b03df235b529ecc0b8dde7 (patch)
tree6c196d9c0fb31251965a4c91884ad077545c21c0
parent4ed0079027a9aba16082ecabce022caf72f118ec (diff)
downloadorg.eclipse.papyrus-bugs/453078-styleProperties.tar.gz
org.eclipse.papyrus-bugs/453078-styleProperties.tar.xz
org.eclipse.papyrus-bugs/453078-styleProperties.zip
453078: [All Diagrams] Make GMF::View owned styles editable from thebugs/453078-styleProperties
properties view https://bugs.eclipse.org/bugs/show_bug.cgi?id=453078
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/GMFNotationConstraint.java24
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java81
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/EMFInstanceOfConstraint.java6
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<Style>) view.getStyles()) {
+ // NamedStyles are application-specific and should be handled separately
+ if (style instanceof NamedStyle) {
+ continue;
+ }
+
+ EStructuralFeature styleFeature = style.eClass().getEStructuralFeature(propertyPath);
+ if (styleFeature != null) {
+ return style;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Fallback: if the object doesn't have the required property, search for its owned styles
+ *
+ * @param propertyPath
+ * @return
+ */
+ protected IObservable findStyleObservable(String propertyPath) {
+ Style style = getStyleFor(propertyPath);
+ if (style == null) {
+ return null;
+ }
+
+ EStructuralFeature styleFeature = style.eClass().getEStructuralFeature(propertyPath);
+ if (styleFeature == null) {
+ return null; // Shouldn't happen, since this is already checked by getStyleFor()
+ }
+
+ if (styleFeature.getUpperBound() != 1) {
+ IObservableList list = domain == null ? EMFProperties.list(styleFeature).observe(source) : new PapyrusObservableList(EMFProperties.list(styleFeature).observe(source), domain, style, styleFeature);
+ return list;
+ }
+
+ IObservableValue value = domain == null ? EMFProperties.value(styleFeature).observe(source) : new PapyrusObservableValue(style, styleFeature, domain);
+ return value;
+ }
+
@Override
public ILabelProvider getLabelProvider(String propertyPath) {
if (propertyPath.endsWith("prototype")) {
@@ -187,7 +245,24 @@ public class GMFModelElement extends EMFModelElement {
}
};
}
- return super.getContentProvider(propertyPath);
+
+
+ IStaticContentProvider provider = super.getContentProvider(propertyPath);
+ if (provider != null && !(provider instanceof EmptyContentProvider)) {
+ return provider;
+ }
+
+ Style style = getStyleFor(propertyPath);
+ if (style == null) {
+ return null;
+ }
+
+ EStructuralFeature feature = style.eClass().getEStructuralFeature(propertyPath);
+ if (feature == null) {
+ return null; // Shouldn't happen, since getStyleFor() already checks that
+ }
+
+ return new EMFContentProvider(style, style.eClass().getEStructuralFeature(propertyPath));
}
/**
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/EMFInstanceOfConstraint.java b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/EMFInstanceOfConstraint.java
index 1f83c5e1f16..a5b4171bab0 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/EMFInstanceOfConstraint.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/EMFInstanceOfConstraint.java
@@ -27,11 +27,11 @@ import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
*/
public class EMFInstanceOfConstraint extends AbstractConstraint {
- private String className;
+ protected String className;
- private String nsUri;
+ protected String nsUri;
- private EPackage metamodel;
+ protected EPackage metamodel;
@Override
protected void setDescriptor(SimpleConstraint descriptor) {

Back to the top