Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to add a separator between two tree items
icon3.gif  How to add a separator between two tree items [message #740583] Tue, 18 October 2011 17:15 Go to next message
svic4ever is currently offline svic4everFriend
Messages: 7
Registered: October 2011
Junior Member
I have a Jface TreeViewer which contains two roots. I need to add a separator between the trees originated from these roots. A naive way is to implement a dummy treeitem as a separator but I'm looking for a better solution! Sad
Re: How to add a separator between two tree items [message #741355 is a reply to message #740583] Wed, 19 October 2011 13:00 Go to previous messageGo to next message
Thomas Singer is currently offline Thomas SingerFriend
Messages: 75
Registered: July 2009
Member
svic4ever wrote on Tue, 18 October 2011 13:15
I have a Jface TreeViewer which contains two roots. I need to add a separator between the trees originated from these roots. A naive way is to implement a dummy treeitem as a separator but I'm looking for a better solution! Sad

Hm, usually trees don't contain separators. Hence there is no direct way to do it. I'd try to avoid it or use your suggested naive way.
Re: How to add a separator between two tree items [message #741412 is a reply to message #740583] Wed, 19 October 2011 13:58 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Perhaps you could custom draw a separator line across the top of your
second root-level item. For info on using custom draw in Tables and
Trees see
http://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html
..

HTH,
Grant


On 10/18/2011 1:15 PM, svic4ever wrote:
> I have a Jface TreeViewer which contains two roots. I need to add a
> separator between the trees originated from these roots. A naive way is
> to implement a dummy treeitem as a separator but I'm looking for a
> better solution! :(
Re: How to add a separator between two tree items [message #741722 is a reply to message #741412] Wed, 19 October 2011 20:48 Go to previous messageGo to next message
svic4ever is currently offline svic4everFriend
Messages: 7
Registered: October 2011
Junior Member
Grant Gayed wrote on Wed, 19 October 2011 09:58
Perhaps you could custom draw a separator line across the top of your
second root-level item. For info on using custom draw in Tables and
Trees see
..

HTH,
Grant


On 10/18/2011 1:15 PM, svic4ever wrote:
> I have a Jface TreeViewer which contains two roots. I need to add a
> separator between the trees originated from these roots. A naive way is
> to implement a dummy treeitem as a separator but I'm looking for a
> better solution! Sad


Thank you for your advice. I use one of the snippets in the link to solve my other problem Very Happy About the separator problem, I settle with the naive method above.

Quote:
Hm, usually trees don't contain separators. Hence there is no direct way to do it. I'd try to avoid it or use your suggested naive way.

I wish I wouldn't have to use separator but using separator seems to be the easiest way to solve my problem.

Moreover, I don't know if I understand the Viewer framework exactly. This is an image I think that describes the framework :http: //i.imgur.com/wx1je.png. In my understanding, when we setInput on an object for a Tree, this object is feeded to the ContentProvider. The elements come out from the ContentProvider will be filtered by various filters. After that, the remaining elements will be sorted. Finally, the tree widget will take these elements and display them. Is it correct ?
Re: How to add a separator between two tree items [message #742184 is a reply to message #741722] Thu, 20 October 2011 09:01 Go to previous messageGo to next message
svic4ever is currently offline svic4everFriend
Messages: 7
Registered: October 2011
Junior Member
When I expand/collapse or change the size of the tree, the separator treeitem disappears. This is the reason why I ask about the Viewer framework. It seems that every time I expand the tree, the tree will reload the input object. I think that's why the separator disappears.
Tree tree = _viewer.getConceptFeedbackTree().getTree();
TreeItem selected = new TreeItem(tree, SWT.NONE, 0);
		selected.setText("Current cover");

Re: How to add a separator between two tree items [message #742190 is a reply to message #742184] Thu, 20 October 2011 09:08 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
why not incorporate the empty element in the model itself and write code in lableprovider and sorter for showing seperater element and keeping the seperater in the middle.

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Previous Topic:'No more handles' SWT Exception
Next Topic:Layout composite weird behaviour
Goto Forum:
  


Current Time: Thu Mar 28 16:36:16 GMT 2024

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

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

Back to the top