Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » how to change and add TableViewer's columns dynamically
icon5.gif  how to change and add TableViewer's columns dynamically [message #637583] Sun, 07 November 2010 11:18 Go to next message
Ping Luo is currently offline Ping LuoFriend
Messages: 8
Registered: January 2010
Location: Beijing
Junior Member
hi guys,

I have created a TableViewer, now it can add and delete rows dynamically using context menu, but how to add a new column? when add the new column, we can set the default column header text, is there a way to edit this column header like cellEditor? can someone give me some sample code for this?

thanks,
Ping
Re: how to change and add TableViewer's columns dynamically [message #637891 is a reply to message #637583] Tue, 09 November 2010 09:35 Go to previous messageGo to next message
T. Wilhelm is currently offline T. WilhelmFriend
Messages: 129
Registered: July 2009
Senior Member
Hi Ping Luo,

i think you can simple create a new Column with:

TreeViewerColumn viewerColumn = new TreeViewerColumn( myTreeViewer, SWT.NONE );


Maybe you have to call this afterwards to make the changes visible

tree.layout()


Afterwards you can call:

 column.setText( columnTitle );


to set the header text. A CellEditor is not possible for a column header, maybe you provide an extra dialog with textfields where you can rename the column headers.

Greetz
Thomas
Re: how to change and add TableViewer's columns dynamically [message #637906 is a reply to message #637891] Tue, 09 November 2010 10:10 Go to previous messageGo to next message
Ping Luo is currently offline Ping LuoFriend
Messages: 8
Registered: January 2010
Location: Beijing
Junior Member
Thomas,

thanks for your reply, now I can use extra dialog to rename header through right click menu.

thanks,
Ping
Re: how to change and add TableViewer's columns dynamically [message #637918 is a reply to message #637906] Tue, 09 November 2010 11:08 Go to previous message
T. Wilhelm is currently offline T. WilhelmFriend
Messages: 129
Registered: July 2009
Senior Member
Maybe it would be nice for you to have a dialog where you can select which columns should be visible, define the headers and maybe the width. In addition you can save the configuration, and load it on startup.

Greetz
Thomas
Previous Topic:TreeViewer with multiple columns
Next Topic:TableViewer: 'Enter' key default behaviour?
Goto Forum:
  


Current Time: Fri Nov 28 13:53:25 GMT 2014

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

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