Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [jface.databinding] empty-selection state not supported by SingleSelectionObservableValue?
[jface.databinding] empty-selection state not supported by SingleSelectionObservableValue? [message #484082] Fri, 04 September 2009 08:41 Go to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
Hi,

I'm just studying the code of ComboSingleSelectionObservableValue,
because I need a better data binding framework than I currently
use (JGoodies Databinding). An important use-case for me are SWT
combos and SWT lists for our application and also important is the
capability to get *and* set an empty selection.

Now I see that the setter doSetSelectionIndex for combos is defined
as:

getCombo().select(index)

which wouldn't accept an empty selection (e.g. -1), even though
this could have been the original state or a future state. On a first
quick view I see no predefined factory I could use for my scenarios to
support. Interestingly the seemingly alternative factory
observeSelection doesn't satisfy my requirements as well, because
this would try to the set an unknown value as combo text,
which is not what I want: In this case I need an empty selection,
because of the mismatch.

Am I correct that I have to define this empty-selection capable
on my own? I ask, because I expected that empty selections are
very popular in tables, lists, and combos.

Thanks in advance,

Daniel Krügler
Re: [jface.databinding] empty-selection state not supported by SingleSelectionObservableValue? [message #484184 is a reply to message #484082] Fri, 04 September 2009 14:08 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Daniel Krügler wrote:
> I'm just studying the code of ComboSingleSelectionObservableValue,

You're using an old version of DataBinding. That class was internal and
no longer exists in the 1.3 version of the JFace databinding bundle.

> because I need a better data binding framework than I currently
> use (JGoodies Databinding). An important use-case for me are SWT
> combos and SWT lists for our application and also important is the
> capability to get *and* set an empty selection.
>
> Now I see that the setter doSetSelectionIndex for combos is defined
> as:
>
> getCombo().select(index)
>
> which wouldn't accept an empty selection (e.g. -1), even though
> this could have been the original state or a future state.

You are correct, we should call Combo.deselectAll() when the index is
set to -1. Would you file a bug against Platform - UI for this? Please
preface the subject line with [DataBinding] to make it easy to triage.

> On a first
> quick view I see no predefined factory I could use for my scenarios to
> support. Interestingly the seemingly alternative factory
> observeSelection doesn't satisfy my requirements as well, because
> this would try to the set an unknown value as combo text,
> which is not what I want: In this case I need an empty selection,
> because of the mismatch.

You will probably have to create your WidgetValueProperty subclass and
implement the fix yourself until the next release. You can (mostly)
copy the doGetValue and doSetValue implementations from
ComboSingleSelectionIndexProperty.java, then update the doSet to check
for -1 and call deselectAll() instead in that case.

> Am I correct that I have to define this empty-selection capable
> on my own? I ask, because I expected that empty selections are
> very popular in tables, lists, and combos.

For the moment, yes. If you file a bug and name all the cases where
this error was made, then we can issue a fix for the next release.

Matthew
Re: [jface.databinding] empty-selection state not supported by SingleSelectionObservableValue? [message #484215 is a reply to message #484184] Fri, 04 September 2009 15:15 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
Matthew Hall wrote:
> Daniel Krügler wrote:
>> I'm just studying the code of ComboSingleSelectionObservableValue,
>
> You're using an old version of DataBinding. That class was internal and
> no longer exists in the 1.3 version of the JFace databinding bundle.

OK, thanks for correction. Nevertheless my target platform will be
Eclipse 3.4.2 for our product. I'm aware that I should not use internal
classes of Eclipse but it was more explicit to name the implementing
class for the sake of this report.

>> because I need a better data binding framework than I currently
>> use (JGoodies Databinding). An important use-case for me are SWT
>> combos and SWT lists for our application and also important is the
>> capability to get *and* set an empty selection.
>>
>> Now I see that the setter doSetSelectionIndex for combos is defined
>> as:
>>
>> getCombo().select(index)
>>
>> which wouldn't accept an empty selection (e.g. -1), even though
>> this could have been the original state or a future state.
>
> You are correct, we should call Combo.deselectAll() when the index is
> set to -1. Would you file a bug against Platform - UI for this? Please
> preface the subject line with [DataBinding] to make it easy to triage.

I did so, see:

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

[Sorry for the wrong name of the factory function in my first comment,
the second comment has corrected that]

>> On a first
>> quick view I see no predefined factory I could use for my scenarios to
>> support. Interestingly the seemingly alternative factory
>> observeSelection doesn't satisfy my requirements as well, because
>> this would try to the set an unknown value as combo text,
>> which is not what I want: In this case I need an empty selection,
>> because of the mismatch.
>
> You will probably have to create your WidgetValueProperty subclass and
> implement the fix yourself until the next release. You can (mostly)
> copy the doGetValue and doSetValue implementations from
> ComboSingleSelectionIndexProperty.java, then update the doSet to check
> for -1 and call deselectAll() instead in that case.

Thanks, this seems like a simple way to go.

>> Am I correct that I have to define this empty-selection capable
>> on my own? I ask, because I expected that empty selections are
>> very popular in tables, lists, and combos.
>
> For the moment, yes. If you file a bug and name all the cases where
> this error was made, then we can issue a fix for the next release.

This would be sufficient for me, because it will be simple to provide
the value property implementation in this case.

Let me add that one of the most impressing features of jface databinding
over jgoodies databinding is to me the fact, that the former also
non-intrusively supports simple Pojo classes and that it properly
handles vetoing.

A final point: It would be great, if jface databinding could add in the
future bean reflection of *generic* classes (in a special project that
requires Java 1.5), e.g. for classes like

public class PojoValueHolder<T> {

private T value;

public PojoValueHolder() {
}

public PojoValueHolder(T value) {
this.value = value;
}

public final T getValue() {
return value;
}

public final void setValue(T value) {
this.value = value;
}

}

In this case PojoObservables.observeValue will return a property
descriptor that evaluates a property type java.lang.Object for
e.g. PojoValueHolder<Integer>. But given some additional class-Type
information of the property provided by the user it should be
possible to define a property descriptor (I think) that effectively
has a return type of Integer. IMO such a helper class exists in
the Spring sources (GenericTypeAwarePropertyDescriptor).

Above example is of-course not the best example, because for this
simple case WritableValue would be appropriate, but there are more
complex classes were this isn't the case.

Thanks for your help,

Daniel
Re: [jface.databinding] empty-selection state not supported by SingleSelectionObservableValue? [message #484262 is a reply to message #484215] Fri, 04 September 2009 22:19 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Daniel Krügler wrote:
>> You are correct, we should call Combo.deselectAll() when the index is
>> set to -1. Would you file a bug against Platform - UI for this?
>> Please preface the subject line with [DataBinding] to make it easy to
>> triage.
>
> I did so, see:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=288642

Thanks, I'll take a look.

> A final point: It would be great, if jface databinding could add in the
> future bean reflection of *generic* classes (in a special project that
> requires Java 1.5), e.g. for classes like

This might be possible down the road. Would you file a bug for this too
so it stays on my radar?

Matthew
Previous Topic:Need help Exporting Perspective (saving opening etc)
Next Topic:RCP updated through Update Manager does not uninstall old plug-ins
Goto Forum:
  


Current Time: Wed Feb 05 10:48:35 GMT 2025

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

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

Back to the top