Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [DataBinding] Connect Databinding Error Message with Eclipse Forms
[DataBinding] Connect Databinding Error Message with Eclipse Forms [message #328971] Mon, 09 June 2008 16:21 Go to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hello,

I'm using Eclipse Forms and Eclipse Databinding for the individual text
elements.

In Eclipse Forms I can display messages, e.g.

form.setMessage("This is an error message", IMessageProvider.ERROR);


Is there a simple way of connecting the message part of the form to the
databinding?

Currently I'm defining an label which I'm connecting to the error message of
the databinding. I'm then registering a changeListener to this label and I'm
updating then the message of the Form.

errorLabel.setLayoutData(gridData);

uiElement = SWTObservables.observeText(errorLabel);

// Lets Change the color of the field

uiElement.addChangeListener(new IChangeListener(){

@Override

public void handleChange(ChangeEvent event) {

if (uiElement.getValue().equals("OK")){

firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_WHITE));


} else{

firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_RED));

}

}

});

bindingContext.bindValue(uiElement, new
AggregateValidationStatus(bindingContext.getBindings(),
AggregateValidationStatus.MAX_SEVERITY), null, null);


I believe that it must be possible to connect the message directly with the
databinding validation but I cannot not find an example.

Any advice?

Best regards, Lars
Re: [DataBinding] Connect Databinding Error Message with Eclipse Forms [message #328974 is a reply to message #328971] Mon, 09 June 2008 17:59 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Lars,

AggregateValidationStatus is an IObservableValue so it is not necessary
to bind to a dummy label. You can listen to the status directly:

final IObservableValue validationStatus = new AggregateValidationStatus(
bindingContext.getBindings(),
AggregateValidationStatus.MAX_SEVERITY);
validationStatus.addChangeListener(new IChangeListener() {
public void handleChange(ChangeEvent event) {
IStatus status = (IStatus) status.getValue();
if (status.isOK()) {
// handle ok status
} else {
// handle non-ok status
}
}
});

It may be helpful to look at the source for WizardPageSupport,
particularly in the handleStatusChanged() method to see how wizard pages
are supported (which are not too different from UI Forms as far as
setting error messages).

Matthew

Lars Vogel wrote:
> Hello,
>
> I'm using Eclipse Forms and Eclipse Databinding for the individual text
> elements.
>
> In Eclipse Forms I can display messages, e.g.
>
> form.setMessage("This is an error message", IMessageProvider.ERROR);
>
>
> Is there a simple way of connecting the message part of the form to the
> databinding?
>
> Currently I'm defining an label which I'm connecting to the error message of
> the databinding. I'm then registering a changeListener to this label and I'm
> updating then the message of the Form.
>
> errorLabel.setLayoutData(gridData);
>
> uiElement = SWTObservables.observeText(errorLabel);
>
> // Lets Change the color of the field
>
> uiElement.addChangeListener(new IChangeListener(){
>
> @Override
>
> public void handleChange(ChangeEvent event) {
>
> if (uiElement.getValue().equals("OK")){
>
> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_WHITE));
>
>
> } else{
>
> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_RED));
>
> }
>
> }
>
> });
>
> bindingContext.bindValue(uiElement, new
> AggregateValidationStatus(bindingContext.getBindings(),
> AggregateValidationStatus.MAX_SEVERITY), null, null);
>
>
> I believe that it must be possible to connect the message directly with the
> databinding validation but I cannot not find an example.
>
> Any advice?
>
> Best regards, Lars
>
>
Re: [DataBinding] Connect Databinding Error Message with Eclipse Forms [message #328978 is a reply to message #328974] Mon, 09 June 2008 19:10 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Matthew,

cool. Thank you, Lars

"Matthew Hall" <matthall@woodcraftmill.com> wrote in message
news:g2jnib$qg2$1@build.eclipse.org...
> Lars,
>
> AggregateValidationStatus is an IObservableValue so it is not necessary
> to bind to a dummy label. You can listen to the status directly:
>
> final IObservableValue validationStatus = new AggregateValidationStatus(
> bindingContext.getBindings(),
> AggregateValidationStatus.MAX_SEVERITY);
> validationStatus.addChangeListener(new IChangeListener() {
> public void handleChange(ChangeEvent event) {
> IStatus status = (IStatus) status.getValue();
> if (status.isOK()) {
> // handle ok status
> } else {
> // handle non-ok status
> }
> }
> });
>
> It may be helpful to look at the source for WizardPageSupport,
> particularly in the handleStatusChanged() method to see how wizard pages
> are supported (which are not too different from UI Forms as far as setting
> error messages).
>
> Matthew
>
> Lars Vogel wrote:
>> Hello,
>>
>> I'm using Eclipse Forms and Eclipse Databinding for the individual text
>> elements.
>>
>> In Eclipse Forms I can display messages, e.g.
>>
>> form.setMessage("This is an error message", IMessageProvider.ERROR);
>>
>>
>> Is there a simple way of connecting the message part of the form to the
>> databinding?
>>
>> Currently I'm defining an label which I'm connecting to the error message
>> of the databinding. I'm then registering a changeListener to this label
>> and I'm updating then the message of the Form.
>>
>> errorLabel.setLayoutData(gridData);
>>
>> uiElement = SWTObservables.observeText(errorLabel);
>>
>> // Lets Change the color of the field
>>
>> uiElement.addChangeListener(new IChangeListener(){
>>
>> @Override
>>
>> public void handleChange(ChangeEvent event) {
>>
>> if (uiElement.getValue().equals("OK")){
>>
>> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_WHITE));
>>
>>
>> } else{
>>
>> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_RED));
>>
>> }
>>
>> }
>>
>> });
>>
>> bindingContext.bindValue(uiElement, new
>> AggregateValidationStatus(bindingContext.getBindings(),
>> AggregateValidationStatus.MAX_SEVERITY), null, null);
>>
>>
>> I believe that it must be possible to connect the message directly with
>> the databinding validation but I cannot not find an example.
>>
>> Any advice?
>>
>> Best regards, Lars
>
Re: [DataBinding] Connect Databinding Error Message with Eclipse Forms [message #328979 is a reply to message #328974] Mon, 09 June 2008 19:20 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hi Matthew,

There was a small typo in your code. I believe it should have been:
IStatus status = (IStatus) validationStatus.getValue();

Thank again for your help.

Best regards, Lars


"Matthew Hall" <matthall@woodcraftmill.com> wrote in message
news:g2jnib$qg2$1@build.eclipse.org...
> Lars,
>
> AggregateValidationStatus is an IObservableValue so it is not necessary
> to bind to a dummy label. You can listen to the status directly:
>
> final IObservableValue validationStatus = new AggregateValidationStatus(
> bindingContext.getBindings(),
> AggregateValidationStatus.MAX_SEVERITY);
> validationStatus.addChangeListener(new IChangeListener() {
> public void handleChange(ChangeEvent event) {
> IStatus status = (IStatus) status.getValue();
> if (status.isOK()) {
> // handle ok status
> } else {
> // handle non-ok status
> }
> }
> });
>
> It may be helpful to look at the source for WizardPageSupport,
> particularly in the handleStatusChanged() method to see how wizard pages
> are supported (which are not too different from UI Forms as far as setting
> error messages).
>
> Matthew
>
> Lars Vogel wrote:
>> Hello,
>>
>> I'm using Eclipse Forms and Eclipse Databinding for the individual text
>> elements.
>>
>> In Eclipse Forms I can display messages, e.g.
>>
>> form.setMessage("This is an error message", IMessageProvider.ERROR);
>>
>>
>> Is there a simple way of connecting the message part of the form to the
>> databinding?
>>
>> Currently I'm defining an label which I'm connecting to the error message
>> of the databinding. I'm then registering a changeListener to this label
>> and I'm updating then the message of the Form.
>>
>> errorLabel.setLayoutData(gridData);
>>
>> uiElement = SWTObservables.observeText(errorLabel);
>>
>> // Lets Change the color of the field
>>
>> uiElement.addChangeListener(new IChangeListener(){
>>
>> @Override
>>
>> public void handleChange(ChangeEvent event) {
>>
>> if (uiElement.getValue().equals("OK")){
>>
>> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_WHITE));
>>
>>
>> } else{
>>
>> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_RED));
>>
>> }
>>
>> }
>>
>> });
>>
>> bindingContext.bindValue(uiElement, new
>> AggregateValidationStatus(bindingContext.getBindings(),
>> AggregateValidationStatus.MAX_SEVERITY), null, null);
>>
>>
>> I believe that it must be possible to connect the message directly with
>> the databinding validation but I cannot not find an example.
>>
>> Any advice?
>>
>> Best regards, Lars
>
Re: [DataBinding] Connect Databinding Error Message with Eclipse Forms [message #328991 is a reply to message #328979] Tue, 10 June 2008 03:48 Go to previous message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=219661

"Lars Vogel" <Lars.Vogel@gmail.com> wrote in message
news:g2jvpk$eao$1@build.eclipse.org...
> Hi Matthew,
>
> There was a small typo in your code. I believe it should have been:
> IStatus status = (IStatus) validationStatus.getValue();
>
> Thank again for your help.
>
> Best regards, Lars
>
>
> "Matthew Hall" <matthall@woodcraftmill.com> wrote in message
> news:g2jnib$qg2$1@build.eclipse.org...
>> Lars,
>>
>> AggregateValidationStatus is an IObservableValue so it is not necessary
>> to bind to a dummy label. You can listen to the status directly:
>>
>> final IObservableValue validationStatus = new AggregateValidationStatus(
>> bindingContext.getBindings(),
>> AggregateValidationStatus.MAX_SEVERITY);
>> validationStatus.addChangeListener(new IChangeListener() {
>> public void handleChange(ChangeEvent event) {
>> IStatus status = (IStatus) status.getValue();
>> if (status.isOK()) {
>> // handle ok status
>> } else {
>> // handle non-ok status
>> }
>> }
>> });
>>
>> It may be helpful to look at the source for WizardPageSupport,
>> particularly in the handleStatusChanged() method to see how wizard pages
>> are supported (which are not too different from UI Forms as far as
>> setting error messages).
>>
>> Matthew
>>
>> Lars Vogel wrote:
>>> Hello,
>>>
>>> I'm using Eclipse Forms and Eclipse Databinding for the individual text
>>> elements.
>>>
>>> In Eclipse Forms I can display messages, e.g.
>>>
>>> form.setMessage("This is an error message", IMessageProvider.ERROR);
>>>
>>>
>>> Is there a simple way of connecting the message part of the form to the
>>> databinding?
>>>
>>> Currently I'm defining an label which I'm connecting to the error
>>> message of the databinding. I'm then registering a changeListener to
>>> this label and I'm updating then the message of the Form.
>>>
>>> errorLabel.setLayoutData(gridData);
>>>
>>> uiElement = SWTObservables.observeText(errorLabel);
>>>
>>> // Lets Change the color of the field
>>>
>>> uiElement.addChangeListener(new IChangeListener(){
>>>
>>> @Override
>>>
>>> public void handleChange(ChangeEvent event) {
>>>
>>> if (uiElement.getValue().equals("OK")){
>>>
>>> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_WHITE));
>>>
>>>
>>> } else{
>>>
>>> firstName.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_RED));
>>>
>>> }
>>>
>>> }
>>>
>>> });
>>>
>>> bindingContext.bindValue(uiElement, new
>>> AggregateValidationStatus(bindingContext.getBindings(),
>>> AggregateValidationStatus.MAX_SEVERITY), null, null);
>>>
>>>
>>> I believe that it must be possible to connect the message directly with
>>> the databinding validation but I cannot not find an example.
>>>
>>> Any advice?
>>>
>>> Best regards, Lars
>>
>
>
Previous Topic:[DataBinding] How to bind a List/ListViewer multi selection
Next Topic:How to navigate from StyledText to IEditorPart
Goto Forum:
  


Current Time: Fri Nov 08 21:57:31 GMT 2024

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

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

Back to the top