mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ui: TreeTable's underlying tree should synchronize selection with table when left/right arrow was pressed (IDEA-168531)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user