Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [DataBinding] Databinding support for Dialogs(How to bind the status of data binding to a Dialog?)
[DataBinding] Databinding support for Dialogs [message #515234] Thu, 18 February 2010 04:26 Go to next message
Tibor Bekesi is currently offline Tibor Bekesi
Messages: 7
Registered: July 2009
Junior Member
Hi Everybody,

There is a very useful class, WizardPageSupport that connects the validation result from the given data binding context to the given wizard page.

However, I would like to use something very similar on my Eclipse Forms FormDialog to be able to display the validation results on the form heading area of my dialog.

What do you suggest, how should I solve this?

Or more generally: how to connect the validation results of a data binding context to a simple SWT Dialog or FormDialog?

Best regards,
Tibor
Re: [DataBinding] Databinding support for Dialogs [message #518422 is a reply to message #515234] Mon, 01 March 2010 14:11 Go to previous message
Matthew Hall is currently offline Matthew Hall
Messages: 368
Registered: July 2009
Senior Member
Tibor Bekesi wrote:
> Hi Everybody,
>
> There is a very useful class, WizardPageSupport that connects the
> validation result from the given data binding context to the given
> wizard page.
>
> However, I would like to use something very similar on my Eclipse Forms
> FormDialog to be able to display the validation results on the form
> heading area of my dialog.
>
> What do you suggest, how should I solve this?
>
> Or more generally: how to connect the validation results of a data
> binding context to a simple SWT Dialog or FormDialog?

I'm not familiar with FormDialog, but assuming we're talking about a
setMessage(String message, int messageType) setter method, it would be
very easy to implement your own value property, and then bind the
aggregate validation status to an observable created from that value
property, e.g.:

public class FormDialogMessageProperty extends SimpleValueProperty {
public Object getElementType() { return IStatus.class; }

protected void doGetValue(Object source) {
FormDialog dialog = (FormDialog) source;
return createStatus(dialog.getMessageType(), dialog.getMessage());
}

private IStatus createStatus(int messageType, String message) {
// convert from IMessageProvider message type constants to IStatus
// severity constants
}

protected void doSetValue(Object source, Object value) {
FormDialog dialog = (FormDialog) source;
IStatus status = (IStatue) value;
int messageType = toMessageType(status.getSeverity());
String message = status.getMessage();
dialog.setMessage(messageType, message);
}

public INativePropertyListener adaptListener(
ISimplePropertyListener listener) {
return null; // I'm assuming there is no listener API here
}
}

With this in place you could simply bind an AggregateValidationStatus to
the dialog message:

DataBindingContext dbc = ...

IObservableValue validationStatus = new AggregateValidationStatus(
dbc, AggregateValidationStatus.MAX_SEVERITY);
dbc.bindValue(new FormDialogMessageProperty().observe(dialog),
validationStatus);

You may also want to override the observe(Realm, Object) method in your
value property to hook a listener that disposes the returned observable
when the dialog is disposed.

Hope this helps,

Matthew
Previous Topic:[Databinding] TreeViewer with items that contain lists (that should appear as subtrees)
Next Topic:initial focus in wizard page
Goto Forum:
  


Current Time: Tue Jul 29 17:10:39 EDT 2014

Powered by FUDForum. Page generated in 0.02236 seconds