Skip to main content



      Home
Home » Eclipse Projects » JFace » How to use Databinding to provide content and labels for editable viewers with calculated values?
How to use Databinding to provide content and labels for editable viewers with calculated values? [message #21864] Fri, 17 July 2009 04:26 Go to next message
Eclipse UserFriend
Originally posted by: TheRealHawk.Freenet.de

I know that I can do something like that:
IObservableMap[] labelMape = BeansObservables.observeMaps(
cp.getKnownElements(), new String[] { "name", "address", "phone" } );
viewer.setLabelProvider(new ObservableMapLabelProvider(labelMaps));

This works if I only want to display some properties of a list of beans.

But what should I do if I want to display calculated values in the viewer or
use an EditingSupport in the columns?

Markus
Re: How to use Databinding to provide content and labels for editable viewers with calculated values [message #21912 is a reply to message #21864] Fri, 17 July 2009 05:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Markus Koch schrieb:
> I know that I can do something like that:
> IObservableMap[] labelMape = BeansObservables.observeMaps(
> cp.getKnownElements(), new String[] { "name", "address", "phone" } );
> viewer.setLabelProvider(new ObservableMapLabelProvider(labelMaps));

I wrote a general purpose LabelProvider which uses Message.format() to
calculate Labels from different Attributes [1] including formatting.

>
> This works if I only want to display some properties of a list of beans.
>
> But what should I do if I want to display calculated values in the viewer or
> use an EditingSupport in the columns?
>

I'm not sure what you mean here? You want to edit calcuated values?

Tom

[1] http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-data binding-part-5/
Re: How to use Databinding to provide content and labels for editable viewers with calculated values [message #21956 is a reply to message #21912] Fri, 17 July 2009 06:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: TheRealHawk.Freenet.de

"Tom Schindl" <tom.schindl@bestsolution.at> schrieb im Newsbeitrag
news:h3pfop$ef7$1@build.eclipse.org...
> Hi,
>
> Markus Koch schrieb:
>> I know that I can do something like that:
>> IObservableMap[] labelMape = BeansObservables.observeMaps(
>> cp.getKnownElements(), new String[] { "name", "address",
>> "phone" } );
>> viewer.setLabelProvider(new ObservableMapLabelProvider(labelMaps));
>
> I wrote a general purpose LabelProvider which uses Message.format() to
> calculate Labels from different Attributes [1] including formatting.
>
>>
>> This works if I only want to display some properties of a list of beans.
>>
>> But what should I do if I want to display calculated values in the viewer
>> or
>> use an EditingSupport in the columns?
>>
>
> I'm not sure what you mean here? You want to edit calcuated values?

Of course not. :-)
Just an example: I have a list of persons with property name, surname,
dateOfBirth

If I only want to display the properties in a TableViewer I can use the
ObservableMapLabelProvider.
But what if:
1. I want to also display calculated values - e.g. age?
For this I don't can use the ObservableMapLabelProvider - I need an
ObservableValueLabelProvider for each TableViewerColumn, so that I also can
display CalculatedValues in the viewer.

2. I want to edit some properties?
For this I also have to create my own TableViewerColumn with an
ObservableValueEditingSupport.

Now my question is: Is there a eclipse-default-way like
ObservableValueLabelProvider or ObservableValueEditingSupport?

Markus

>
> Tom
>
> [1] http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-data binding-part-5/
Re: How to use Databinding to provide content and labels for editable viewers with calculated values [message #22000 is a reply to message #21956] Fri, 17 July 2009 06:36 Go to previous messageGo to next message
Eclipse UserFriend
No.

Markus Koch schrieb:
> "Tom Schindl" <tom.schindl@bestsolution.at> schrieb im Newsbeitrag
> news:h3pfop$ef7$1@build.eclipse.org...
>> Hi,
>>
>> Markus Koch schrieb:
>>> I know that I can do something like that:
>>> IObservableMap[] labelMape = BeansObservables.observeMaps(
>>> cp.getKnownElements(), new String[] { "name", "address",
>>> "phone" } );
>>> viewer.setLabelProvider(new ObservableMapLabelProvider(labelMaps));
>> I wrote a general purpose LabelProvider which uses Message.format() to
>> calculate Labels from different Attributes [1] including formatting.
>>
>>> This works if I only want to display some properties of a list of beans.
>>>
>>> But what should I do if I want to display calculated values in the viewer
>>> or
>>> use an EditingSupport in the columns?
>>>
>> I'm not sure what you mean here? You want to edit calcuated values?
>
> Of course not. :-)
> Just an example: I have a list of persons with property name, surname,
> dateOfBirth
>
> If I only want to display the properties in a TableViewer I can use the
> ObservableMapLabelProvider.
> But what if:
> 1. I want to also display calculated values - e.g. age?
> For this I don't can use the ObservableMapLabelProvider - I need an
> ObservableValueLabelProvider for each TableViewerColumn, so that I also can
> display CalculatedValues in the viewer.
>
> 2. I want to edit some properties?
> For this I also have to create my own TableViewerColumn with an
> ObservableValueEditingSupport.
>
> Now my question is: Is there a eclipse-default-way like
> ObservableValueLabelProvider or ObservableValueEditingSupport?
>
> Markus
>
>> Tom
>>
>> [1] http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-data binding-part-5/
>
>
Re: How to use Databinding to provide content and labels for editable viewers with calculated values [message #22044 is a reply to message #21956] Fri, 17 July 2009 13:27 Go to previous message
Eclipse UserFriend
Markus,

See answers below

Markus Koch wrote:
> Just an example: I have a list of persons with property name, surname,
> dateOfBirth
>
> If I only want to display the properties in a TableViewer I can use the
> ObservableMapLabelProvider.
> But what if:
> 1. I want to also display calculated values - e.g. age?
> For this I don't can use the ObservableMapLabelProvider - I need an
> ObservableValueLabelProvider for each TableViewerColumn, so that I also can
> display CalculatedValues in the viewer.

We do have ObservableMapCellLabelProvider if this is what you're
thinking about, but it won't help you with calculated values. And since
we don't yet have ComputedMap yet then that won't work either. Probably
the simplest route is to implement a SimpleValueProperty that converts a
birth date to an age:

public class DateAgeProperty extends SimpleValueProperty {
public INativePropertyListener adaptListener( ISimplePropertyListener
listener ) {
return null;
}

protected Object doGetValue( Object source ) {
Date date = (Date) source;
// convert date to age and return
}

protected void doSetValue( Object source, Object value ) {
throw new UnsupportedOperationException();
}

public Object getValueType() {
return Integer.class;
}
}

Then chain the dateOfBirth and age properties together:

IObservableMap ages = BeanProperties
.value("dateOfBirth")
.value(new DateAgeProperty())
.observeDetail(contentProvider.getKnownElements());

> 2. I want to edit some properties?
> For this I also have to create my own TableViewerColumn with an
> ObservableValueEditingSupport.
>
> Now my question is: Is there a eclipse-default-way like
> ObservableValueLabelProvider or ObservableValueEditingSupport?

I don't follow you here. Could you elaborate?

Matthew
Previous Topic:Form head client next to title like before 3.3 or replace title with StyledText?
Next Topic:ComboBoxPropertyDescriptor is not intended to be subclassed
Goto Forum:
  


Current Time: Sun May 11 19:38:01 EDT 2025

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

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

Back to the top