Source:
<code>private static Rectangle getBounds(final Widget widget) { return UIThreadRunnable.syncExec(widget.getDisplay(), new Result<Rectangle>() { public Rectangle run() { Control parent; Rectangle widgetBounds; if (widget instanceof Control) { parent = ((Control) widget).getParent(); widgetBounds = ((Control) widget).getBounds(); } else if (widget instanceof TableItem) { TableItem tableItem = (TableItem) widget; parent = tableItem.getParent(); widgetBounds = getTableItemBounds(tableItem); } else if (widget instanceof TreeItem) { TreeItem treeItem = (TreeItem) widget; parent = treeItem.getParent(); widgetBounds = getTreeItemBounds(treeItem); } else { return null; } Point location = new Point(widgetBounds.x, widgetBounds.y); if (parent != null) { location = parent.toDisplay(location); } return new Rectangle(location.x, location.y, widgetBounds.width, widgetBounds.height); } private Rectangle getTableItemBounds(TableItem tableItem) { Table table = tableItem.getParent(); int[] columnOrder = table.getColumnOrder(); Rectangle itemBounds; if (columnOrder.length > 0) { int lastColumnIndex = columnOrder[columnOrder.length - 1]; itemBounds = tableItem.getBounds(lastColumnIndex); itemBounds.width = itemBounds.x + itemBounds.width; } else { Rectangle tableBounds = table.getBounds(); itemBounds = tableItem.getBounds(); itemBounds.width = tableBounds.width; <START> } <END> return new Rectangle(0, itemBounds.y, itemBounds.width, itemBounds.height); } private Rectangle getTreeItemBounds(TreeItem treeItem) { Tree tree = treeItem.getParent(); int[] columnOrder = tree.getColumnOrder(); Rectangle itemBounds; if (columnOrder.length > 0) { int lastColumnIndex = columnOrder[columnOrder.length - 1]; itemBounds = treeItem.getBounds(lastColumnIndex); itemBounds.width = itemBounds.x + itemBounds.width; } else { Rectangle treeBounds = tree.getBounds(); itemBounds = treeItem.getBounds(); itemBounds.width = treeBounds.width; } return new Rectangle(0, itemBounds.y, itemBounds.width, itemBounds.height); } }); }</code><technical_language>a thought, if set itemBounds.x = 0 return itemBounds directly</technical_language>

Target:
private static Rectangle getBounds(final Widget widget) { return UIThreadRunnable.syncExec(widget.getDisplay(), new Result<Rectangle>() { public Rectangle run() { Control parent; Rectangle widgetBounds; if (widget instanceof Control) { parent = ((Control) widget).getParent(); widgetBounds = ((Control) widget).getBounds(); } else if (widget instanceof TableItem) { TableItem tableItem = (TableItem) widget; parent = tableItem.getParent(); widgetBounds = getTableItemBounds(tableItem); } else if (widget instanceof TreeItem) { TreeItem treeItem = (TreeItem) widget; parent = treeItem.getParent(); widgetBounds = getTreeItemBounds(treeItem); } else { return null; } Point location = new Point(widgetBounds.x, widgetBounds.y); if (parent != null) { location = parent.toDisplay(location); } return new Rectangle(location.x, location.y, widgetBounds.width, widgetBounds.height); } private Rectangle getTableItemBounds(TableItem tableItem) { Table table = tableItem.getParent(); int[] columnOrder = table.getColumnOrder(); Rectangle itemBounds; if (columnOrder.length > 0) { int lastColumnIndex = columnOrder[columnOrder.length - 1]; itemBounds = tableItem.getBounds(lastColumnIndex); itemBounds.width = itemBounds.x + itemBounds.width; } else { Rectangle tableBounds = table.getBounds(); itemBounds = tableItem.getBounds(); itemBounds.width = tableBounds.width; } itemBounds.x = 0; return itemBounds; } private Rectangle getTreeItemBounds(TreeItem treeItem) { Tree tree = treeItem.getParent(); int[] columnOrder = tree.getColumnOrder(); Rectangle itemBounds; if (columnOrder.length > 0) { int lastColumnIndex = columnOrder[columnOrder.length - 1]; itemBounds = treeItem.getBounds(lastColumnIndex); itemBounds.width = itemBounds.x + itemBounds.width; } else { Rectangle treeBounds = tree.getBounds(); itemBounds = treeItem.getBounds(); itemBounds.width = treeBounds.width; } itemBounds.x = 0; return itemBounds; } }); }