0

i have a dialog to show some values. Now I need to know if the user has changed something.

All fields are wrapped in an eclipse DatabindingContext.

...
bindingContext.bindValue(process_observable_milage, process_bean_mileage, new UpdateValueStrategy(), null);
...

If I change some fields, the propertyChangeSupport listener inside the model gets fired. (Setter of the property is called).

this.firePropertyChange(SignalEntity.SIGNALNAME, this.signalname, this.signalname = name);

Now I need a global Listener to detect if any value was changed.

I tried it with the following without success:

    IObservableValue globalValidity = new WritableValue();
    globalValidity.addChangeListener(new IChangeListener() {
        @Override
        public void handleChange(ChangeEvent event) {
             dirty = true;
        }
    });
    bindingContext.bindValue(globalValidity, new AggregateValidationStatus(bindingContext.getBindings(), AggregateValidationStatus.MAX_SEVERITY), null, null);

This is from another class with some afterConvertValidators added. So I thought I have to use "addValueChangeListener" instead but even this is not working.

    IObservableValue globalValidity = new WritableValue();
    globalValidity.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(ValueChangeEvent event) {
            dirty = true;
        }
    });
    bindingContext.bindValue(globalValidity, new AggregateValidationStatus(bindingContext.getBindings(), AggregateValidationStatus.MAX_SEVERITY), null, null);

Any ideas how to achieve this?

Best regards

Pascal
  • 2,059
  • 3
  • 31
  • 52

1 Answers1

0

I use:

IObservableValue setError = PojoProperties.value("error").observe(new SetError());

bindingContext.bindValue(setError, new AggregateValidationStatus(bindingContext.getBindings(), AggregateValidationStatus.MAX_SEVERITY));


private class SetError
{
  public IStatus getError()
  { 
    return ValidationStatus.ok();
  }

  public void setError(final IStatus status)
  {
    final String msg = status.isOK() ? null : status.getMessage();

    // TODO deal with message / status
  }
}
greg-449
  • 109,219
  • 232
  • 102
  • 145