@Override ViewerCell getInitialFocusCell() { Tree tree = (Tree) getViewer().getControl(); if (! tree.isDisposed() && tree.getItemCount() > 0 && ! tree.getTopItem().isDisposed()) { ViewerRow aViewerRow = getViewer().getViewerRowFromItem(tree.getTopItem()); if (tree.getColumnCount() == 0) { return aViewerRow.getCell(0); } Rectangle clientArea = tree.getClientArea(); for (int i = 0; i < tree.getColumnCount(); i++) { if (aViewerRow.getWidth(i) > 0 && columnInVisibleArea(clientArea,aViewerRow,i)) return aViewerRow.getCell(i); } } return null; }
@Override public ViewerCell getFocusCell() { ViewerCell cell = super.getFocusCell(); Tree t = (Tree) getViewer().getControl(); // It is possible that the selection has changed under the hood if (cell != null) { if (t.getSelection().length == 1 && t.getSelection()[0] != cell.getItem()) { setFocusCell(getViewer().getViewerRowFromItem( t.getSelection()[0]).getCell(cell.getColumnIndex())); } } return super.getFocusCell(); } }
TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(getViewer(), new FocusCellOwnerDrawHighlighter(getViewer())); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(getViewer()) { protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(getViewer(), new FocusCellOwnerDrawHighlighter(getViewer())); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(getViewer()) { @Override
@Override ViewerCell getInitialFocusCell() { Tree tree = (Tree) getViewer().getControl(); if (! tree.isDisposed() && tree.getItemCount() > 0 && ! tree.getTopItem().isDisposed()) { ViewerRow aViewerRow = getViewer().getViewerRowFromItem(tree.getTopItem()); if (tree.getColumnCount() == 0) { return aViewerRow.getCell(0); } Rectangle clientArea = tree.getClientArea(); for (int i = 0; i < tree.getColumnCount(); i++) { if (aViewerRow.getWidth(i) > 0 && columnInVisibleArea(clientArea,aViewerRow,i)) return aViewerRow.getCell(i); } } return null; }
@Override public ViewerCell getFocusCell() { ViewerCell cell = super.getFocusCell(); Tree t = (Tree) getViewer().getControl(); // It is possible that the selection has changed under the hood if (cell != null) { if (t.getSelection().length == 1 && t.getSelection()[0] != cell.getItem()) { setFocusCell(getViewer().getViewerRowFromItem( t.getSelection()[0]).getCell(cell.getColumnIndex())); } } return super.getFocusCell(); } }