Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » SWT TableColumn.pack doesn't make columns wider
SWT TableColumn.pack doesn't make columns wider [message #326400] Tue, 18 March 2008 19:02 Go to next message
Carolyn Duby is currently offline Carolyn Duby
Messages: 30
Registered: July 2009
Member
I am running on Windows XP Professional 2002 Service Pack 2.

I have an SWT table that is populated by a TableViewer. The table has one
column. After the contents of the column is updated, the code calls
TableColumn.pack to resize the column so the entire text of the item
appears in the column. The first time the column is packed everything
works mostly ok. The column size is a bit too short to accommodate the
entire text of the longest item. (I would like to know how to fix this one
but my other problem is more pressing.)

However, when a new wider item is added to the top of the table where a
narrower item used to be, pack doesn't make the column any wider. The
column stays the same width. I tried adding a header and double clicking
on the header would only make the column smaller. It would not increase
the width.

I stepped into the TableColumn.pack method and saw that when it went to
Windows to get the width of the new item, it returned the narrower width
of the item that used to be there.

It seems as if the underlying windows GUI widget still thinks it has the
old text. Is there any method that I can call before pack to refresh the
widths of the underlying windows GUI widgets before I call pack.

Here's the code to create the table and viewers.

/*
* Table for editing this path.
*/
Table pathTable;
/*
* Viewer that populate the path table.
*/
TableViewer pathTableViewer;
/*
* Column containing directories in the path.
*/
TableColumn dirColumn;
pathTable = toolkit.createTable(tableComp, SWT.SINGLE);
pathTable.setLinesVisible(true);

pathTableViewer = new TableViewer(pathTable);
pathTableViewer.setContentProvider(new
ResolvedPathContentProvider(resolver));
pathTableViewer.setLabelProvider(new LabelProvider());

dirColumn = new TableColumn(pathTable,SWT.LEFT);
dirColumn.setText("Directory");
dirColumn.setResizable(true);

Thanks very much for your help!

Carolyn
Re: SWT TableColumn.pack doesn't make columns wider [message #515181 is a reply to message #326400] Thu, 18 February 2010 01:39 Go to previous message
Kevin Hand is currently offline Kevin Hand
Messages: 3
Registered: July 2009
Junior Member
add ((Table)event.widget).getGridLineWidth(); to event.width in your MeasureItem.
Previous Topic:Prompt for target in Ant launch config
Next Topic:Common Navigator Key Bindings
Goto Forum:
  


Current Time: Tue Sep 30 22:11:13 GMT 2014

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

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