Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Re: Simple Jface ListViewer
Re: Simple Jface ListViewer [message #330994] Wed, 20 August 2008 17:10 Go to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Zardosht Hodaie wrote:
> Hi all,
> i'm not sure if this post belongs to this group. if not sorry.
> Here is my problem. I want to have a simple ListViewer to show some
> elements. The SWT List shows only Strings and does not contains the
> unerlying Objects. JFace ListViewer needs a model. I thought ok, i make
> a list of elements, and set it as the input to my Jface listViewer. And
> i thought every time a change the input list, the changes should also be
> reflected in viewer. But i don't know what kind of list should i use for
> this. And if i have to write a ContentProvider myself?
>
> thanks in advance for your help,
> Zardosht.

Note: copying this to the eclipse.platform newsgroup.

I think you can use an ArrayContentProvider to do what you want; it
should handle any array or Collection as input.

Hope this helps,
Eric
Re: Simple Jface ListViewer [message #330997 is a reply to message #330994] Wed, 20 August 2008 18:54 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
The viewer won't update themselves when the underlying list changes
(because Java-List don't inform about changes). To make this possible

a) ArrayContentProvider:
List l = ...
viewer.setContentProvider(new ArrayContentProvider());
viewer.setInput(l);

....
l.add(new ...)
viewer.refresh();

b) Databinding with ObservableListContentProvider

IObservableList l = ...
viewer.setContentProvider(new ObservableListContentProvider());
viewer.setInput(l);

l.add(new ...);

Tom

Eric Rizzo schrieb:
> Zardosht Hodaie wrote:
>> Hi all,
>> i'm not sure if this post belongs to this group. if not sorry.
>> Here is my problem. I want to have a simple ListViewer to show some
>> elements. The SWT List shows only Strings and does not contains the
>> unerlying Objects. JFace ListViewer needs a model. I thought ok, i
>> make a list of elements, and set it as the input to my Jface
>> listViewer. And i thought every time a change the input list, the
>> changes should also be reflected in viewer. But i don't know what kind
>> of list should i use for this. And if i have to write a
>> ContentProvider myself?
>>
>> thanks in advance for your help,
>> Zardosht.
>
> Note: copying this to the eclipse.platform newsgroup.
>
> I think you can use an ArrayContentProvider to do what you want; it
> should handle any array or Collection as input.
>
> Hope this helps,
> Eric


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Simple Jface ListViewer [message #330998 is a reply to message #330997] Wed, 20 August 2008 19:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zhodaie.gmail.com

Tom Schindl schrieb:
> The viewer won't update themselves when the underlying list changes
> (because Java-List don't inform about changes). To make this possible
>
> a) ArrayContentProvider:
> List l = ...
> viewer.setContentProvider(new ArrayContentProvider());
> viewer.setInput(l);
>
> ...
> l.add(new ...)
> viewer.refresh();
>
> b) Databinding with ObservableListContentProvider
>
> IObservableList l = ...
> viewer.setContentProvider(new ObservableListContentProvider());
> viewer.setInput(l);
>
> l.add(new ...);
>
> Tom
>
> Eric Rizzo schrieb:
>> Zardosht Hodaie wrote:
>>> Hi all,
>>> i'm not sure if this post belongs to this group. if not sorry.
>>> Here is my problem. I want to have a simple ListViewer to show some
>>> elements. The SWT List shows only Strings and does not contains the
>>> unerlying Objects. JFace ListViewer needs a model. I thought ok, i
>>> make a list of elements, and set it as the input to my Jface
>>> listViewer. And i thought every time a change the input list, the
>>> changes should also be reflected in viewer. But i don't know what
>>> kind of list should i use for this. And if i have to write a
>>> ContentProvider myself?
>>>
>>> thanks in advance for your help,
>>> Zardosht.
>>
>> Note: copying this to the eclipse.platform newsgroup.
>>
>> I think you can use an ArrayContentProvider to do what you want; it
>> should handle any array or Collection as input.
>>
>> Hope this helps,
>> Eric
>
>
Thank you for your help. I got it working. Thank you.
Re: Simple Jface ListViewer [message #834439 is a reply to message #330994] Mon, 02 April 2012 00:22 Go to previous message
Phaedrus The Greek is currently offline Phaedrus The GreekFriend
Messages: 17
Registered: August 2011
Junior Member
If you refresh manually don't forget to use listviewer.refresh(true) to update labels as well.
Previous Topic:Eclipse freezes/hangs before Workspace selection
Next Topic:[org.eclipse.ui.navigator.viewer] doesn't work in PackageExplorer
Goto Forum:
  


Current Time: Thu Dec 26 20:37:09 GMT 2024

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

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

Back to the top