colDetails.setWidth(300);
colDetails.setResizable(false);
activityTable.setHeaderVisible(true);
Listener computeLastRowWidthListener = new Listener() {
// inUse flag to prevent a SWT stack overflow. For some reason
// the setWidth call was triggering a resize.
boolean inUse = false;
public void handleEvent(Event event) {
if (inUse) {
return;
}
inUse = true;
try {
if(activityTable == null || activityTable.isDisposed()) return;
int totalWidth = activityTable.getClientArea().width;
int remainingWidth = totalWidth
- colStatus.getWidth()
- colType.getWidth()
- colName.getWidth();
if(remainingWidth > 0)
colDetails.setWidth(remainingWidth);
} finally {
inUse = false;
}
}
};
activityTable.addListener(SWT.Resize, computeLastRowWidthListener);
colStatus.addListener(SWT.Resize,computeLastRowWidthListener);
colType.addListener(SWT.Resize,computeLastRowWidthListener);
colName.addListener(SWT.Resize,computeLastRowWidthListener);
activityTable.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem) event.item;
int index = activityTable.indexOf (item);
item.setText (0,MessageText.getString("DHTView.activity.status." + activities[index].isQueued()));
item.setText (1,MessageText.getString("DHTView.activity.type." + activities[index].getType()));