Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to bind a list-size to a label
How to bind a list-size to a label [message #1006843] Sat, 02 February 2013 18:57 Go to next message
Jens Mayer is currently offline Jens Mayer
Messages: 19
Registered: September 2009
Location: Hamburg
Junior Member
Hi,

maybe this is a dumb question but I am stuck:

i want to bind the size of a WritableList to a label to show how many entries the list actually has.

The label-sided part of the Binding is easy, but I wonder how to create the IObservableValue for the size of the list...

Can anyone help me please?

Thanks in advance,

Jens
Re: How to bind a list-size to a label [message #1008408 is a reply to message #1006843] Tue, 12 February 2013 11:15 Go to previous messageGo to next message
Nigel Westbury is currently offline Nigel Westbury
Messages: 16
Registered: July 2009
Junior Member
Use a computed value. The model side of the binding would be:

new ComputedValue() {
protected Object calculate() {
return myWritableList.size();
}
};

Note that ObservableList.size() is a tracked getter (annotated with
@TrackedGetter and if you look at the implementation you will see it
calls getterCalled method).

Nigel Westbury

On 02/02/2013 18:57, Jens Mayer wrote:
> Hi,
>
> maybe this is a dumb question but I am stuck:
>
> i want to bind the size of a WritableList to a label to show how many
> entries the list actually has.
>
> The label-sided part of the Binding is easy, but I wonder how to create
> the IObservableValue for the size of the list...
>
> Can anyone help me please?
>
> Thanks in advance,
>
> Jens
Re: How to bind a list-size to a label [message #1008547 is a reply to message #1006843] Tue, 12 February 2013 22:30 Go to previous message
Jens Mayer is currently offline Jens Mayer
Messages: 19
Registered: September 2009
Location: Hamburg
Junior Member
Hi Nigel,

works like a charm.

Thank you!

Jens
Previous Topic:Tabbed text field using Jface databinding
Next Topic:Performance Problems with an IObservableMap and TreeViewer
Goto Forum:
  


Current Time: Sun Sep 21 16:20:47 GMT 2014

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

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