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 12:21  |
Eclipse User |
|
|
|
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 13:59   |
Eclipse User |
|
|
|
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 15:10   |
Eclipse User |
|
|
|
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 15:20   |
Eclipse User |
|
|
|
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] |
Mon, 09 June 2008 23:48  |
Eclipse User |
|
|
|
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
>>
>
>
|
|
|
Goto Forum:
Current Time: Wed Jul 02 02:30:46 EDT 2025
Powered by FUDForum. Page generated in 0.35223 seconds
|