Skip to main content


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 09:26 Go to next message
Tibor Bekesi is currently offline Tibor BekesiFriend
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 19:11 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
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:Implementing IPartitionTokenScanner With Multi-Line Tokens
Next Topic:Model refactoring and data Binding
Goto Forum:
  


Current Time: Sat Apr 20 01:11:32 GMT 2024

Powered by FUDForum. Page generated in 0.02737 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top