2013-02-11 27 views
0

我想將焦點設置到TableViewer中的特定行。getViewer()。setSelection()不適用於FocusCellOwnerDrawHighlighter

聚焦和輸入切換的定義如下:

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); 

的代碼來選擇的行是:

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

的問題是,只要我使用FocusCellOwnerDrawHighlightersetSelection不再有效,意味着沒有行被選中。

任何想法我做錯了什麼?

問候 羅傑

回答

0

這不是一個解決方案。只是闡述可能是一個問題。 我看到

FocusCellOwnerDrawHighlighter:110 line 


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

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

初始焦點單元出現問題將是Table默認最高指數。聚焦單元格和選擇單元格將不相同,因此它將移除選定單元格上的選擇背景。

相關問題