Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Reset row height on table resize
Reset row height on table resize [message #484049] Fri, 04 September 2009 05:26
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
Hello,

I have a tableviewer where row size get dynamically changed based on the
content of a cell in a row.

I have listeners for the table as below

table.addListener(SWT.MeasureItem, paintListener);
table.addListener(SWT.PaintItem, paintListener);
table.addListener(SWT.EraseItem, paintListener);

where paintListener is

Listener paintListener = new Listener() {
public void handleEvent(Event event) {
switch (event.type) {
case SWT.MeasureItem: {
TableItem item = (TableItem) event.item;
String text = getText(item, event.index);
Point size = event.gc.textExtent(text);
event.width = size.x;
int height = Math.max(25, Math.max(event.height,
size.y));
// If the size of the row is greater than 1/3d of the
// table height, then set the height to 1/3rd of the table
height
if (height > table.getBounds().height)
height = (table.getBounds().height)/3;
event.height = height;
break;
}
case SWT.PaintItem: {
TableItem item = (TableItem) event.item;
String text = getText(item, event.index);
Point size = event.gc.textExtent(text);
int offset2 = event.index == 0 ? Math.max(0,(event.height - size.y) / 2)
: 0;
event.gc.drawText(text, event.x, event.y + offset2,true);
break;
}
case SWT.EraseItem: {
event.detail &= ~SWT.FOREGROUND;
break;
}
}
}

String getText(TableItem item, int column) {
String text = item.getText(column);
return text;
}
};

I have this table in a view and my problem is that I am unable to call
this listener to reset the row height when my view is resized.

Please help me out here.

Thanks,
Bhat
Previous Topic:SourceViewer + Annotations with IDrawingStrategy
Next Topic:How to Undo changeTextPresentation in TextViewer
Goto Forum:
  


Current Time: Fri Apr 19 03:36:14 GMT 2024

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

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

Back to the top