summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2014-05-27 06:52:45 (EDT)
committerMickael ADAM2014-05-27 08:41:53 (EDT)
commita9b1321eb916a0f9f88eae885afd7e53f89d58eb (patch)
tree7ad8ca9be0cfb806740fc79c44ad8429307a72df
parent67130185a0837c9082a1b38864ed9e77fcaa5997 (diff)
downloadorg.eclipse.papyrus-a9b1321eb916a0f9f88eae885afd7e53f89d58eb.zip
org.eclipse.papyrus-a9b1321eb916a0f9f88eae885afd7e53f89d58eb.tar.gz
org.eclipse.papyrus-a9b1321eb916a0f9f88eae885afd7e53f89d58eb.tar.bz2
435415: [Property View] Errors occur when member end of an associationrefs/changes/47/27347/4
is edited https://bugs.eclipse.org/bugs/show_bug.cgi?id=435415 Patch Set 1: - Add safety belt at isReadOnly() in the case of the widget is disposed - Don't change the Status if the widget is disposed Patch Set 2: - Unapply safety belt on readOnly and patch setBinding() of AbstractValueEditor Patch Set 2: - Add comments Change-Id: Ica03b6b45f5e97afcb79388a78fa443c977aac57 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java29
1 files changed, 5 insertions, 24 deletions
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java
index 6e82e25..f99ed5b 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java
@@ -10,11 +10,11 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Add binding implementation
* Christian W. Damus (CEA) - bug 402525
+ * Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - bug 435415
*
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
-
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.databinding.observable.ChangeEvent;
@@ -75,7 +75,6 @@ public abstract class AbstractValueEditor extends AbstractEditor {
protected ControlDecoration controlDecoration;
-
protected static final Color VALID = new Color(Display.getCurrent(), 144, 238, 144); //CSS LightGreen
protected static final Color DEFAULT = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
@@ -125,14 +124,12 @@ public abstract class AbstractValueEditor extends AbstractEditor {
*/
protected void setWidgetObservable(IObservableValue widgetObservable, boolean commitOnChange) {
this.widgetObservable = widgetObservable;
-
if(commitOnChange) {
this.widgetObservable.addChangeListener(new IChangeListener() {
@Override
public void handleChange(ChangeEvent event) {
commit();
-
}
});
}
@@ -145,7 +142,6 @@ public abstract class AbstractValueEditor extends AbstractEditor {
*/
protected void setWidgetObservable(IObservableValue widgetObservable) {
setWidgetObservable(widgetObservable, false);
-
}
/**
@@ -157,7 +153,6 @@ public abstract class AbstractValueEditor extends AbstractEditor {
public void setModelObservable(IObservableValue modelProperty) {
this.modelProperty = modelProperty;
doBinding();
-
}
/**
@@ -171,7 +166,6 @@ public abstract class AbstractValueEditor extends AbstractEditor {
if(modelToTargetStrategy == null) {
modelToTargetStrategy = new UpdateValueStrategy();
}
-
targetToModelStrategy.setConverter(targetToModel);
modelToTargetStrategy.setConverter(modelToTarget);
}
@@ -203,7 +197,6 @@ public abstract class AbstractValueEditor extends AbstractEditor {
if(modelProperty == null || widgetObservable == null) {
return;
}
-
setBinding();
}
@@ -218,28 +211,23 @@ public abstract class AbstractValueEditor extends AbstractEditor {
/**
* Initialize binding
*/
-
private void setBinding() {
binding = getBindingContext().bindValue(widgetObservable, modelProperty, targetToModelStrategy, modelToTargetStrategy);
binding.getValidationStatus().addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
- IStatus status = (IStatus)binding.getValidationStatus().getValue();
- updateStatus(status);
-
- if(!isReadOnly() && !AbstractValueEditor.this.isDisposed()) { //Bug 434787 : Shouldn't not execute the timer thread if the widget is disposed
+ //Check if the widget is disposed before isReadOnly() to avoid NPE
+ if(!AbstractValueEditor.this.isDisposed() && !isReadOnly()) { //Bug 434787 : Shouldn't not execute the timer thread if the widget is disposed
+ IStatus status = (IStatus)binding.getValidationStatus().getValue(); //Bug 435415 : Update the status only if the widget isn't disposed
+ updateStatus(status);
changeColorField();
}
}
-
});
-
-
}
public void updateStatus(IStatus status) {
-
}
/**
@@ -247,7 +235,6 @@ public abstract class AbstractValueEditor extends AbstractEditor {
*
* @param targetToModelValidator
*/
-
public void setTargetAfterGetValidator(AbstractValidator targetToModelValidator) {
if(targetToModelValidator != null) {
targetToModelStrategy.setAfterGetValidator(targetToModelValidator);
@@ -260,20 +247,17 @@ public abstract class AbstractValueEditor extends AbstractEditor {
*
* @param modelValidator
*/
-
public void setModelValidator(IValidator targetToModelValidator) {
if(targetToModelValidator != null) {
this.modelValidator = targetToModelValidator;
targetToModelStrategy.setBeforeSetValidator(targetToModelValidator);
modelToTargetStrategy.setAfterGetValidator(targetToModelValidator);
-
}
}
/**
* Initialize both strategies with default values
*/
-
public void setStrategies() {
if(modelToTargetStrategy == null) {
modelToTargetStrategy = new UpdateValueStrategy();
@@ -281,15 +265,12 @@ public abstract class AbstractValueEditor extends AbstractEditor {
if(targetToModelStrategy == null) {
targetToModelStrategy = new UpdateValueStrategy();
}
-
}
-
@Override
protected Object getContextElement() {
// Our observables for features of EMF objects are expected to implement IObserving because
// the observe the value of the object's feature
return (modelProperty instanceof IObserving) ? ((IObserving)modelProperty).getObserved() : null;
}
-
}