Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » JFace Viewer
JFace Viewer [message #336259] Thu, 04 June 2009 02:48 Go to next message
Andy Czerwonka is currently offline Andy CzerwonkaFriend
Messages: 42
Registered: July 2009
Member
Is there any way I can stop my TreeViewer from completely collapsing on
a setInput()?
Re: JFace Viewer [message #336260 is a reply to message #336259] Thu, 04 June 2009 05:26 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
Andy Czerwonka wrote:
> Is there any way I can stop my TreeViewer from completely collapsing on
> a setInput()?

I think that its not a good idea for TreeViewer to expand all when
setting the input. It would have severe performance impact if the tree
depth is more or if fetching of each element is time consuming.

However, if you really need to do that for your app, you can call
treeViewer.expandAll() or treeViewer.expandToLevel() methods

- Prakash
---
http://blog.eclipse-tips.com
Re: JFace Viewer [message #336277 is a reply to message #336260] Thu, 04 June 2009 22:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wim.jongman.gmail.com

Hi Andy,

Alternatively you can get the current expanded nodes before setinput and
expand exactly that after setinput. Stop the tree from drawing in between and
show a nice progress dialog if it takes longer.

Best Regards,

Wim Jongman



> Andy Czerwonka wrote:
>> Is there any way I can stop my TreeViewer from completely collapsing on
>> a setInput()?
>
> I think that its not a good idea for TreeViewer to expand all when
> setting the input. It would have severe performance impact if the tree
> depth is more or if fetching of each element is time consuming.
>
> However, if you really need to do that for your app, you can call
> treeViewer.expandAll() or treeViewer.expandToLevel() methods
>
> - Prakash
> ---
> http://blog.eclipse-tips.com
Re: JFace Viewer [message #336454 is a reply to message #336259] Sat, 13 June 2009 04:19 Go to previous messageGo to next message
Jon Buck is currently offline Jon BuckFriend
Messages: 29
Registered: July 2009
Junior Member
Andy Czerwonka wrote:
> Is there any way I can stop my TreeViewer from completely collapsing on
> a setInput()?

In order to stop this from happening your domain objects that are being
displayed in the TreeView have to correctly implement compareTo, equals
and HasCode. Once you have done this it should stop happening.

An additional thing I do is that after I add an item to the list backing
the tree viewer I create a TreeSelection object and call the
setSelection method on the TreeViewer passing it the selection object,
If the TreeSelection object is created correctly the item you just added
should be the selected item in the tree with the branch it is in expanded.

Hope this helps, good luck.
Re: JFace Viewer [message #336455 is a reply to message #336454] Sat, 13 June 2009 07:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
As an alternative you can also set an IElementComparer on the viewer.

Tom

exquisitus schrieb:
> Andy Czerwonka wrote:
>> Is there any way I can stop my TreeViewer from completely collapsing
>> on a setInput()?
>
> In order to stop this from happening your domain objects that are being
> displayed in the TreeView have to correctly implement compareTo, equals
> and HasCode. Once you have done this it should stop happening.
>
> An additional thing I do is that after I add an item to the list backing
> the tree viewer I create a TreeSelection object and call the
> setSelection method on the TreeViewer passing it the selection object,
> If the TreeSelection object is created correctly the item you just added
> should be the selected item in the tree with the branch it is in expanded.
>
> Hope this helps, good luck.
Re: JFace Viewer [message #336471 is a reply to message #336455] Tue, 16 June 2009 01:50 Go to previous message
Allen D. McDonald is currently offline Allen D. McDonaldFriend
Messages: 13
Registered: July 2009
Junior Member
Interesting information on the domain objects needing to be Comparable.
That accents a behavior change I noted in my TreeViewer when I changed my
top level object to implement Comparable and overrode compareTo().
For not collapsing the TreeViewer on setInput(), however, would it be Ok
if it reset to a default expand level? I believe setAutoExpandLevel()
will do that for you...
Previous Topic:Workspace ADDED distinguished from file system ADDED
Next Topic:Was "Delete project contents on disk (cannot be undone)" selected
Goto Forum:
  


Current Time: Fri Aug 16 14:30:17 GMT 2024

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

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

Back to the top