0

I would like to set focus to a specifc row in a TableViewer.

The focus and input handing is defined like this:

ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE);

FocusCellOwnerDrawHighlighter fch = new FocusCellOwnerDrawHighlighter(viewer);
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, fch);

ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) {
            protected boolean isEditorActivationEvent(final 
                   ColumnViewerEditorActivationEvent event) {
                return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                        || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION
                        || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.F2)
                        || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
            }
};

TableViewerEditor.create(viewer, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
                | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
                 ColumnViewerEditor.TABBING_VERTICAL
                | ColumnViewerEditor.KEYBOARD_ACTIVATION);

The code to select a row is:

getViewer().setSelection(new StructuredSelection(parameterTable.getViewer().getElementAt(selection)), false);

The problem is, that as soon as I use the FocusCellOwnerDrawHighlighter, setSelection no longer works, meaning that no row is selected.

Any ideas what I'm doing wrong ?

Regards Roger

flavio.donze
  • 6,077
  • 9
  • 41
  • 69
rogergl
  • 2,993
  • 2
  • 22
  • 46

1 Answers1

0

This is not a solution. Just elaborating what could be an issue. I see a problem in

FocusCellOwnerDrawHighlighter:110 line


                    ViewerCell cell = row.getCell(event.index);

                    if (focusCell == null || !cell.equals(focusCell)) {
                        removeSelectionInformation(event, cell);
                    } else {
                        markFocusedCell(event, cell);
                    }

initial focus cell will be default top index of Table. focus cell and selection cell will not be equal so it is removing selection background on the selected cell.

sambi reddy
  • 2,997
  • 1
  • 11
  • 10