Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TreeViewer with only one TreeViewerColumn(How to have it resize automatically?)
TreeViewer with only one TreeViewerColumn [message #731675] Sun, 02 October 2011 12:13 Go to next message
sielver Mising name is currently offline sielver Mising nameFriend
Messages: 42
Registered: September 2011
Member
Hello,

So I have a TreeViewer and I want to add editing support to it.

I used to use the setCellEditors/setCellModifier methods directly on my TreeViewer instance but I noticed the setEditingSupport was the new, preferred way of doing this (and it seems more handy):

// In my TreeViewer constructor
TreeViewerColumn column = new TreeViewerColumn(this, SWT.NONE);
column.setEditingSupport(new EditingSupport(this));
column.setLabelProvider(new LabelProvider());
column.getColumn().setText("Column 1");
column.getColumn().setWidth(???); // Here's the question


So I have to specify a witdh for the column to be visible. Is there an easy way to have it take the full size of the tree all the time? I heard about adding some listeners and calling pack() on the TreeColumn but I'm not sure how to do that, and I wonder if there's anything handier.

Any idea?

Thanks,

-Jérémy

[Updated on: Sun, 02 October 2011 12:13]

Report message to a moderator

Re: TreeViewer with only one TreeViewerColumn [message #731680 is a reply to message #731675] Sun, 02 October 2011 12:52 Go to previous messageGo to next message
sielver Mising name is currently offline sielver Mising nameFriend
Messages: 42
Registered: September 2011
Member
OK, answering myself as I found the solution:

ViewerColumn column = new ViewerColumn(this, getTree()) {};
column.setLabelProvider(labelProvider);
column.setEditingSupport(new EditingSupport(this));


Basically, using a ViewerColumn instance directly doesn't create a TreeColumn behind, i.e. no need to specify a size or whatever.
Re: TreeViewer with only one TreeViewerColumn [message #731843 is a reply to message #731680] Mon, 03 October 2011 09:29 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Though this works it this is not how we intended to use ViewerColumn, i
think we simply missed ColumnViewer#setEditingSupport(). So please file
a bugzilla to request this API.

Tom

Am 02.10.11 14:52, schrieb sielver:
> OK, answering myself as I found the solution:
>
>
> ViewerColumn column = new ViewerColumn(this, getTree()) {};
> column.setLabelProvider(labelProvider);
> column.setEditingSupport(new EditingSupport(this));
>
>
> Basically, using a ViewerColumn instance directly doesn't create a
> TreeColumn behind, i.e. no need to specify a size or whatever.
Re: TreeViewer with only one TreeViewerColumn [message #731919 is a reply to message #731843] Mon, 03 October 2011 13:48 Go to previous messageGo to next message
sielver Mising name is currently offline sielver Mising nameFriend
Messages: 42
Registered: September 2011
Member
Done:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359708
Re: TreeViewer with only one TreeViewerColumn [message #738495 is a reply to message #731919] Sun, 16 October 2011 10:01 Go to previous message
sielver Mising name is currently offline sielver Mising nameFriend
Messages: 42
Registered: September 2011
Member
Expanding on this:

Still using a simple one-column TreeViewer with no explicit TreeColumn, I would like the whole row's background to be painted when overriding the getBackground() method of my LabelProvider. Is there any easy way to achieve this?

Jérémy
Previous Topic:huge polyline performance
Next Topic:Custom Tree Selection mechanism
Goto Forum:
  


Current Time: Thu Apr 25 00:48:10 GMT 2024

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

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

Back to the top