From 5a6b5ada5a809f8a97860283fb8e981654248403 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 21 Feb 2017 15:34:46 +0300 Subject: [PATCH] ui: TreeTable's underlying tree should synchronize selection with table when left/right arrow was pressed (IDEA-168531) --- .../ui/treeStructure/treetable/TreeTable.java | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java b/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java index 04692e10a85a..209fb51d5dbc 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java @@ -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); - } } /**