if (this.row == row && this.column == column) { return; } if (this.row != row && this.row != -1) { table.getItem(this.row).removeListener(SWT.Dispose, disposeItemListener); this.row = -1; } if (this.column != column && this.column != -1) { TableColumn col = table.getColumn(this.column); col.removeListener(SWT.Dispose, disposeColumnListener); col.removeListener(SWT.Move, resizeListener); col.removeListener(SWT.Resize, resizeListener); this.column = -1; } int itemCount = table.getItemCount(); int columnCount = table.getColumnCount(); if (0 <= row && row < itemCount) { if ((columnCount == 0 && column == 0) || (column < columnCount && column >= 0)) { TableItem item = table.getItem(row); if (this.row != row) { item.addListener(SWT.Dispose, disposeItemListener); this.row = row; table.showItem(item); } if (this.column  != column) { this.column = column; if (columnCount > 0) { TableColumn col = table.getColumn(column); col.addListener(SWT.Dispose, disposeColumnListener); col.addListener(SWT.Move, resizeListener); col.addListener(SWT.Resize, resizeListener); table.showColumn(col); } } setBounds(item.getBounds(column)); redraw(); if (notify) { notifyListeners(SWT.Selection, new Event()); } } }
TableItem item = row == -1 ? null : table.getItem(row); TableColumn col = column == -1 || table.getColumnCount() == 0 ? null : table.getColumn(column); setRowColumn(item, col, notify);
void setRowColumn(int row, int column, boolean notify) {	if (this.row == row && this.column == column) {		return;	}	if (this.row != row && this.row != -1) {		table.getItem(this.row).removeListener(SWT.Dispose, disposeItemListener);		this.row = -1;	}	if (this.column != column && this.column != -1) {		TableColumn col = table.getColumn(this.column);		col.removeListener(SWT.Dispose, disposeColumnListener);		col.removeListener(SWT.Move, resizeListener);		col.removeListener(SWT.Resize, resizeListener);		this.column = -1;	}	int itemCount = table.getItemCount();	int columnCount = table.getColumnCount();	if (0 <= row && row < itemCount) {		if ((columnCount == 0 && column == 0) || (column < columnCount && column >= 0)) {			TableItem item = table.getItem(row);			if (this.row != row) {				item.addListener(SWT.Dispose, disposeItemListener);				this.row = row;				table.showItem(item);			}			if (this.column  != column) {				this.column = column;				if (columnCount > 0) {					TableColumn col = table.getColumn(column);					col.addListener(SWT.Dispose, disposeColumnListener);					col.addListener(SWT.Move, resizeListener);					col.addListener(SWT.Resize, resizeListener);					table.showColumn(col);				}			}			setBounds(item.getBounds(column));			redraw();			if (notify) {				notifyListeners(SWT.Selection, new Event());			}		}	}}