ui: TreeTable's underlying tree should synchronize selection with table when left/right arrow was pressed (IDEA-168531)

This commit is contained in:
Dmitry Batkovich
2017-02-21 15:35:32 +03:00
parent a8346fefbe
commit 5a6b5ada5a
@@ -15,7 +15,9 @@
*/
package com.intellij.ui.treeStructure.treetable;
import com.intellij.ui.TableUtil;
import com.intellij.ui.table.JBTable;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.accessibility.ScreenReader;
@@ -178,30 +180,15 @@ public class TreeTable extends JBTable {
final int selColumn = columnModel.getSelectionModel().getAnchorSelectionIndex();
boolean treeHasFocus = selColumn == -1 || selColumn >= 0 && isTreeColumn(selColumn);
boolean oneRowSelected = getSelectedRowCount() == 1;
int rowToSelect = -1;
if(treeHasFocus && oneRowSelected && ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT))){
TreePath selectionPath = myTree.getSelectionPath();
myTree._processKeyEvent(e);
if (myTree.isExpanded(selectionPath)) {
myTree.setSelectionPath(selectionPath);
} else if (keyCode == KeyEvent.VK_LEFT) {
rowToSelect = myTree.getRowForPath(myTree.getSelectionPath());
if (!getScrollableTracksViewportHeight()) {
int visibleYPosition = getVisibleRect().y;
final Rectangle cellRect = getCellRect(rowToSelect, 0, false);
int selectedRowYPosition = cellRect.y;
if (selectedRowYPosition < visibleYPosition) {
scrollRectToVisible(cellRect);
}
}
}
int rowToSelect = ObjectUtils.notNull(myTree.getSelectionRows())[0];
getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
TableUtil.scrollSelectionToVisible(this);
}
else{
super.processKeyEvent(e);
}
if (rowToSelect > -1) {
getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
}
}
/**