Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-02-19 07:57:27 -0500
committerCamille Letavernier2014-02-19 07:57:27 -0500
commite1ea66c63e08b3129c691f89183d368930eb8fdb (patch)
tree3f6cc4ab9b27ccc38209fb03d074be8ebf48ed8b
parent112b8e395202be05fc482f152ad9e38435946b3e (diff)
downloadorg.eclipse.papyrus-e1ea66c63e08b3129c691f89183d368930eb8fdb.tar.gz
org.eclipse.papyrus-e1ea66c63e08b3129c691f89183d368930eb8fdb.tar.xz
org.eclipse.papyrus-e1ea66c63e08b3129c691f89183d368930eb8fdb.zip
416739: [Property View] Custom Papyrus properties don't raise any
notification when their own value evolved https://bugs.eclipse.org/bugs/show_bug.cgi?id=416739 Apply patch from S. Gabel
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java61
1 files changed, 56 insertions, 5 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java
index 363e20170f5..ef570e9bf9b 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java
@@ -8,11 +8,19 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Esterel Technologies - Implements adapter for listening to eAnnotation life cycle (add and remove operations)
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.databinding;
+import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.value.ValueDiff;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.notation.View;
@@ -34,14 +42,14 @@ import org.eclipse.papyrus.uml.tools.databinding.CommandBasedObservableValue;
*/
public class ElementCustomizationObservableValue extends AbstractUMLAggregatedObservableValue implements CommandBasedObservableValue, AggregatedObservable {
- private EditPart sourceElement;
-
private Property property;
private TransactionalEditingDomain transactionalDomain;
private View notationElement;
+ private Adapter eAnnotationAdapter;
+
/**
*
* Constructor.
@@ -53,16 +61,24 @@ public class ElementCustomizationObservableValue extends AbstractUMLAggregatedOb
*/
public ElementCustomizationObservableValue(EditPart sourceElement, Property property) {
super(EMFHelper.resolveEditingDomain(sourceElement));
- this.sourceElement = sourceElement;
this.property = property;
notationElement = (View)sourceElement.getModel();
+ notationElement.eAdapters().add(eAnnotationAdapter = new EAnnotationAdapter());
if(domain instanceof TransactionalEditingDomain) {
transactionalDomain = (TransactionalEditingDomain)domain;
}
}
- //TODO : The value is not correctly refreshed when someone else edits it
- //Some listeners need to be added
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void dispose() {
+ super.dispose();
+ // remove the eAnnotation adapter when the observable is disposed
+ notationElement.eAdapters().remove(eAnnotationAdapter);
+ }
+
public Object getValueType() {
switch(property) {
case QUALIFIED_NAME:
@@ -156,4 +172,39 @@ public class ElementCustomizationObservableValue extends AbstractUMLAggregatedOb
QUALIFIED_NAME
}
+ /**
+ * Internal class for listening to add/remove operations of {@link EAnnotation} objects.
+ */
+ private class EAnnotationAdapter extends AdapterImpl {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ if(notification.getFeature() == EcorePackage.Literals.EMODEL_ELEMENT__EANNOTATIONS) {
+ switch(notification.getEventType()) {
+ case Notification.ADD:
+ fireValueChange(notification);
+ break;
+ case Notification.REMOVE:
+ fireValueChange(notification);
+ default:
+ break;
+ }
+ }
+ }
+
+ /**
+ * Fires the value changes to the observable.
+ *
+ * @param notification
+ * The EMF notification to propagate
+ */
+ private void fireValueChange(final Notification notification) {
+ ValueDiff diff = Diffs.createValueDiff(notification.getOldValue(), notification.getNewValue());
+ ElementCustomizationObservableValue.this.fireValueChange(diff);
+ }
+ }
+
}

Back to the top