@Override public void setFocusCell(Object element, int column) { final ViewerCell oldCell = getFocusCell(); if (oldCell != null && (column == oldCell.getColumnIndex()) && (element == oldCell.getElement())) return; final ColumnViewer viewer = getViewer(); final TableItem item = (TableItem) viewer.findItem(element); if (item == null) return; final ViewerRow row = viewer.getViewerRowFromItem(item); final ViewerCell cell = row.getCell(column); if (cell == null) return; setFocusCell(cell); }
/* * (non-Javadoc) * * @see org.eclipse.jface.viewers.IA#updateFocusCell() */ @Override public void updateFocusCell() { final ViewerCell cell = getFocusCell(); if (cell == null || cell.getViewerRow() == null) return; cell.update( cell.getViewerRow(), cell.getColumnIndex(), ((TableItem) cell.getViewerRow().getItem()).getData()); }
@Override protected void doUpdateItem(Widget widget, Object element, boolean fullMap) { boolean oldBusy = isBusy(); setBusy(true); try { if (widget instanceof Item) { final Item item = (Item) widget; // remember element we are showing if (fullMap) { associate(element, item); } else { Object data = item.getData(); if (data != null) { unmapElement(data, item); } item.setData(element); mapElement(element, item); } int columnCount = doGetColumnCount(); if (columnCount == 0) columnCount = 1; // If there are no columns do the first one ViewerRow viewerRowFromItem = getViewerRowFromItem(item); boolean isVirtual = (getControl().getStyle() & SWT.VIRTUAL) != 0; // If the control is virtual, we cannot use the cached viewer row object. See bug 188663. if (isVirtual) { viewerRowFromItem = (ViewerRow) viewerRowFromItem.clone(); } // Also enter loop if no columns added. See 1G9WWGZ: JFUIF:WINNT - // TableViewer with 0 columns does not work for (int column = 0; column < columnCount || column == 0; column++) { ViewerColumn columnViewer = getViewerColumn(column); ViewerCell cellToUpdate = updateCell(viewerRowFromItem, column, element); // If the control is virtual, we cannot use the cached cell object. See bug 188663. if (isVirtual) { cellToUpdate = new ViewerCell(cellToUpdate.getViewerRow(), cellToUpdate.getColumnIndex(), element); } columnViewer.refresh(cellToUpdate); // clear cell (see bug 201280) updateCell(null, 0, null); // As it is possible for user code to run the event // loop check here. if (item.isDisposed()) { unmapElement(element, item); return; } } } } finally { setBusy(oldBusy); } }