Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [Databinding] Converted values not seen in Text
[Databinding] Converted values not seen in Text [message #329295] Wed, 18 June 2008 14:32 Go to next message
Christoph Jäger is currently offline Christoph JägerFriend
Messages: 14
Registered: July 2009
Junior Member
Hi,

I am using Eclipse 3.4RC3.

I have a Text field, which is connected to a String property via data
binding like this:

--
IObservable observable = ... ; // bound to my String property
Text name=new Text(parent, SWT.NONE);

UpdateValueStrategy targetToModelStrategy=new UpdateValueStrategy();
targetToModelStrategy.setConverter(new TrimWhiteSpaceConverter());

IObservableValue textObserveWidget=SWTObservables.observeText(name,
SWT.FocusOut);

dataBindingContext.bindValue(textObserveWidget, observable,
targetToModelStrategy, null);
--

This should trim whitespace (leading and trailing) from the value
entered into the Text field.

Now, this works fine for updating the model, when I enter " Test " into
the Text field, the model gets updated with "Test" (note: whitespace
removed).

What does not work: the value in the Text field stays " Test ".

There must be a simple way to make the Text field also be updated with
the value after conversion. Can anyone point me in the right direction?

Thanks,

Christoph Jäger
Re: [Databinding] Converted values not seen in Text [message #329298 is a reply to message #329295] Wed, 18 June 2008 14:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You'll need to call do this manually after your model is updated by calling:

Binding#updateModelToTarget()

Tom

Christoph Jaeger schrieb:
> Hi,
>
> I am using Eclipse 3.4RC3.
>
> I have a Text field, which is connected to a String property via data
> binding like this:
>
> --
> IObservable observable = ... ; // bound to my String property
> Text name=new Text(parent, SWT.NONE);
>
> UpdateValueStrategy targetToModelStrategy=new UpdateValueStrategy();
> targetToModelStrategy.setConverter(new TrimWhiteSpaceConverter());
>
> IObservableValue textObserveWidget=SWTObservables.observeText(name,
> SWT.FocusOut);
>
> dataBindingContext.bindValue(textObserveWidget, observable,
> targetToModelStrategy, null);
> --
>
> This should trim whitespace (leading and trailing) from the value
> entered into the Text field.
>
> Now, this works fine for updating the model, when I enter " Test " into
> the Text field, the model gets updated with "Test" (note: whitespace
> removed).
>
> What does not work: the value in the Text field stays " Test ".
>
> There must be a simple way to make the Text field also be updated with
> the value after conversion. Can anyone point me in the right direction?
>
> Thanks,
>
> Christoph Jäger


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: [Databinding] Converted values not seen in Text [message #329302 is a reply to message #329298] Wed, 18 June 2008 15:25 Go to previous messageGo to next message
Christoph Jäger is currently offline Christoph JägerFriend
Messages: 14
Registered: July 2009
Junior Member
Tom Schindl wrote:
> You'll need to call do this manually after your model is updated by
> calling:
>
> Binding#updateModelToTarget()
>

Thanks for your hint. So I extended UpdateValueStrategy to override

@Override
protected IStatus doSet(IObservableValue observableValue, Object value)
{
IStatus status=super.doSet(observableValue, value);
if (binding!=null) binding.updateModelToTarget();
return status;
}

and make sure I set the binding (see last line):

--
UpdateValueStrategyWithFeedback targetToModelStrategy=new
UpdateValueStrategyWithFeedback();
targetToModelStrategy.setConverter(new TrimWhiteSpaceConverter());

Binding binding=dataBindingContext.bindValue(textObserveWidget,
observable, targetToModelStrategy, null);

targetToModelStrategy.setBinding(binding);
--

Looks a bit strange (first I use the targetModelStrategy to create a
binding, and then I feed the resulting binding to the
targetModelStrategy), but seems to work. Do I need to worry about
disposing the binding instance I pass into targetModelStrategy?

Or is there an easier way to achieve the same?

Thanks,

Christoph
Re: [Databinding] Converted values not seen in Text [message #329365 is a reply to message #329302] Sat, 21 June 2008 10:35 Go to previous messageGo to next message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Could you please file an enhancement request in Bugzilla? This seems to be a
common feature request that we should support. We could also use the
Bugzilla to discuss possible workarounds.

Boris

"Christoph Jaeger" <christoph.jaeger@cargodata.at> wrote in message
news:g3b9dr$pm7$1@build.eclipse.org...
> Tom Schindl wrote:
>> You'll need to call do this manually after your model is updated by
>> calling:
>>
>> Binding#updateModelToTarget()
>>
>
> Thanks for your hint. So I extended UpdateValueStrategy to override
>
> @Override
> protected IStatus doSet(IObservableValue observableValue, Object value)
> {
> IStatus status=super.doSet(observableValue, value);
> if (binding!=null) binding.updateModelToTarget();
> return status;
> }
>
> and make sure I set the binding (see last line):
>
> --
> UpdateValueStrategyWithFeedback targetToModelStrategy=new
> UpdateValueStrategyWithFeedback();
> targetToModelStrategy.setConverter(new TrimWhiteSpaceConverter());
>
> Binding binding=dataBindingContext.bindValue(textObserveWidget,
> observable, targetToModelStrategy, null);
>
> targetToModelStrategy.setBinding(binding);
> --
>
> Looks a bit strange (first I use the targetModelStrategy to create a
> binding, and then I feed the resulting binding to the
> targetModelStrategy), but seems to work. Do I need to worry about
> disposing the binding instance I pass into targetModelStrategy?
>
> Or is there an easier way to achieve the same?
>
> Thanks,
>
> Christoph
Re: [Databinding] Converted values not seen in Text [message #329406 is a reply to message #329365] Mon, 23 June 2008 12:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Boris Bokowski wrote:
> Could you please file an enhancement request in Bugzilla? This seems to be a
> common feature request that we should support. We could also use the
> Bugzilla to discuss possible workarounds.

Please post the Bugzilla number or link here so other interested readers
can follow the progress.

Eric


> "Christoph Jaeger" <christoph.jaeger@cargodata.at> wrote in message
> news:g3b9dr$pm7$1@build.eclipse.org...
>> Tom Schindl wrote:
>>> You'll need to call do this manually after your model is updated by
>>> calling:
>>>
>>> Binding#updateModelToTarget()
>>>
>> Thanks for your hint. So I extended UpdateValueStrategy to override
>>
>> @Override
>> protected IStatus doSet(IObservableValue observableValue, Object value)
>> {
>> IStatus status=super.doSet(observableValue, value);
>> if (binding!=null) binding.updateModelToTarget();
>> return status;
>> }
>>
>> and make sure I set the binding (see last line):
>>
>> --
>> UpdateValueStrategyWithFeedback targetToModelStrategy=new
>> UpdateValueStrategyWithFeedback();
>> targetToModelStrategy.setConverter(new TrimWhiteSpaceConverter());
>>
>> Binding binding=dataBindingContext.bindValue(textObserveWidget,
>> observable, targetToModelStrategy, null);
>>
>> targetToModelStrategy.setBinding(binding);
>> --
>>
>> Looks a bit strange (first I use the targetModelStrategy to create a
>> binding, and then I feed the resulting binding to the
>> targetModelStrategy), but seems to work. Do I need to worry about
>> disposing the binding instance I pass into targetModelStrategy?
>>
>> Or is there an easier way to achieve the same?
>>
>> Thanks,
>>
>> Christoph
>
>
Re: [Databinding] Converted values not seen in Text [message #329438 is a reply to message #329406] Tue, 24 June 2008 10:03 Go to previous message
Christoph Jäger is currently offline Christoph JägerFriend
Messages: 14
Registered: July 2009
Junior Member
Filed an enhancement request 238222

https://bugs.eclipse.org/bugs/show_bug.cgi?id=238222

Christoph

Eric Rizzo wrote:
> Boris Bokowski wrote:
>> Could you please file an enhancement request in Bugzilla? This seems
>> to be a common feature request that we should support. We could also
>> use the Bugzilla to discuss possible workarounds.
>
> Please post the Bugzilla number or link here so other interested readers
> can follow the progress.
>
> Eric
>
>
>> "Christoph Jaeger" <christoph.jaeger@cargodata.at> wrote in message
>> news:g3b9dr$pm7$1@build.eclipse.org...
>>> Tom Schindl wrote:
>>>> You'll need to call do this manually after your model is updated by
>>>> calling:
>>>>
>>>> Binding#updateModelToTarget()
>>>>
>>> Thanks for your hint. So I extended UpdateValueStrategy to override
>>>
>>> @Override
>>> protected IStatus doSet(IObservableValue observableValue, Object value)
>>> {
>>> IStatus status=super.doSet(observableValue, value);
>>> if (binding!=null) binding.updateModelToTarget();
>>> return status;
>>> }
>>>
>>> and make sure I set the binding (see last line):
>>>
>>> --
>>> UpdateValueStrategyWithFeedback targetToModelStrategy=new
>>> UpdateValueStrategyWithFeedback();
>>> targetToModelStrategy.setConverter(new TrimWhiteSpaceConverter());
>>>
>>> Binding binding=dataBindingContext.bindValue(textObserveWidget,
>>> observable, targetToModelStrategy, null);
>>>
>>> targetToModelStrategy.setBinding(binding);
>>> --
>>>
>>> Looks a bit strange (first I use the targetModelStrategy to create a
>>> binding, and then I feed the resulting binding to the
>>> targetModelStrategy), but seems to work. Do I need to worry about
>>> disposing the binding instance I pass into targetModelStrategy?
>>>
>>> Or is there an easier way to achieve the same?
>>>
>>> Thanks,
>>>
>>> Christoph
>>
>>
Previous Topic:New plugin for Run>Run...
Next Topic:i feel overwhelmled!!!
Goto Forum:
  


Current Time: Sat Jul 27 12:23:32 GMT 2024

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

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

Back to the top