Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-02-25 14:23:46 +0000
committerChristian W. Damus2014-02-25 14:23:46 +0000
commit6e908943c24e39dc3440998b0014704d1f49ae9e (patch)
tree107a86503ce9aa58e955ae18122449a22991576f /plugins
parent1ec48a64d28235e0b6954eb54ce7df542b67c613 (diff)
downloadorg.eclipse.papyrus-6e908943c24e39dc3440998b0014704d1f49ae9e.tar.gz
org.eclipse.papyrus-6e908943c24e39dc3440998b0014704d1f49ae9e.tar.xz
org.eclipse.papyrus-6e908943c24e39dc3440998b0014704d1f49ae9e.zip
323802: [General] Papyrus shall provide a read only mode
https://bugs.eclipse.org/bugs/show_bug.cgi?id=323802 Make presentation of gradient style properties sensitive to read-only state of the notation view.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ObservableGradientData.java18
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GradientDataModelElement.java40
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java10
3 files changed, 60 insertions, 8 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ObservableGradientData.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ObservableGradientData.java
index 47caae7f46c..5520af4ff41 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ObservableGradientData.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ObservableGradientData.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,10 +8,14 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
+import org.eclipse.core.databinding.observable.IObserving;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
/**
@@ -125,4 +129,16 @@ public class ObservableGradientData extends GradientData {
notifySource();
}
+ public EObject getOwner() {
+ EObject result = null;
+
+ if(source instanceof IObserving) {
+ Object owner = ((IObserving)source).getObserved();
+ if(owner instanceof EObject) {
+ result = (EObject)owner;
+ }
+ }
+
+ return result;
+ }
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GradientDataModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GradientDataModelElement.java
index c68abb5158f..07951aaf382 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GradientDataModelElement.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GradientDataModelElement.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,13 +8,17 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.GradientDataObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.GradientDataObservableValue.GradientProperty;
@@ -31,20 +35,40 @@ import org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement;
*/
public class GradientDataModelElement extends AbstractModelElement {
+ private static final String PROPERTY_PATH = "gradientStyle"; //$NON-NLS-1$
+
/**
* The source GradientData
*/
protected GradientData sourceElement;
/**
+ * The notation style element that owns the {@link GradientData}.
+ */
+ protected EObject owner;
+
+ /**
+ * Constructor.
+ *
+ * @param sourceElement
+ * the source GradientData
+ * @param owner
+ * the owner of the gradient data (may be {@code null})
+ */
+ public GradientDataModelElement(GradientData sourceElement, EObject owner) {
+ this.sourceElement = sourceElement;
+ this.owner = owner;
+ }
+
+ /**
*
* Constructor.
*
* @param sourceElement
- * the soruce GradientData
+ * the source GradientData
*/
public GradientDataModelElement(GradientData sourceElement) {
- this.sourceElement = sourceElement;
+ this(sourceElement, null);
}
@Override
@@ -58,8 +82,14 @@ public class GradientDataModelElement extends AbstractModelElement {
}
@Override
+ public boolean isEditable(String propertyPath) {
+ // Let owner be null for compatibility with plain GradientData objects that we don't know their owners
+ return (owner == null) || !EMFHelper.isReadOnly(owner);
+ }
+
+ @Override
public IStaticContentProvider getContentProvider(String propertyPath) {
- if(propertyPath.equals("gradientStyle")) { //$NON-NLS-1$
+ if(propertyPath.equals(PROPERTY_PATH)) {
return new AbstractStaticContentProvider() {
public Object[] getElements() {
@@ -74,7 +104,7 @@ public class GradientDataModelElement extends AbstractModelElement {
@Override
public ILabelProvider getLabelProvider(String propertyPath) {
- if(propertyPath.equals("gradientStyle")) { //$NON-NLS-1$
+ if(propertyPath.equals(PROPERTY_PATH)) {
return new LabelProvider() {
@Override
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java
index 5bcd44621e2..6a0889ccf7d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
@@ -17,6 +19,7 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.ObservableGradientData;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
@@ -30,7 +33,10 @@ public class NotationModelElementFactory implements ModelElementFactory {
public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
- if(sourceElement instanceof GradientData) {
+ if (sourceElement instanceof ObservableGradientData) {
+ ObservableGradientData gradientData = (ObservableGradientData)sourceElement;
+ return new GradientDataModelElement(gradientData, gradientData.getOwner());
+ } else if(sourceElement instanceof GradientData) {
return new GradientDataModelElement((GradientData)sourceElement);
}
View view = NotationHelper.findView(sourceElement);

Back to the top