I would like to find a way to set focus to a cell in a multi-column table
by an internal Process other than the activation events listed in the code
below. One would expect that the setFocusCell(viewerCell) from
TableViewerFocusCellManager from SWTFocusCellManager would get the job
done, but it is not visible.
Suggestions for setting focus and highlighting a cell based on an internal
event?
Here's the set-up code for the TableViewer and related entities:
tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL |
SWT.V_SCROLL
| SWT.BORDER | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
final TableViewerFocusCellManager mgr = new
TableViewerFocusCellManager(tableViewer, new
FocusCellOwnerDrawHighlighter(tableViewer));
final ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(tableViewer) {
@Override
protected boolean isEditorActivationEvent
(ColumnViewerEditorActivationEvent event) {
return event.eventType ==
ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION
|| event.eventType ==
ColumnViewerEditorActivationEvent.KEY_PRESSED
&& (event.keyCode == SWT.CR || event.character == ' ')
|| event.eventType ==
ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
TableViewerEditor.create(tableViewer, mgr, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
ColumnViewerEditor.TABBING_VERTICAL
| ColumnViewerEditor.KEYBOARD_ACTIVATION);
TableViewerColumn column;
final int[] styles = { SWT.LEAD, SWT.LEAD, SWT.LEAD, SWT.LEAD, SWT.LEAD,
SWT.LEAD, SWT.LEAD};
for (int columnIndex = 0; columnIndex columnIndex++) {
column = new TableViewerColumn(tableViewer, styles[columnIndex]);
// etc. for each column, specifying setLabelProvider and
setEditingSupport