mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-63021 maven: Artifact Search dialog: up/down keys should work without focusing the list.
This commit is contained in:
+24
-1
@@ -74,7 +74,6 @@ public class MavenArtifactSearchPanel extends JPanel {
|
||||
}
|
||||
|
||||
private void initComponents(String initialText) {
|
||||
mySearchField = new JTextField(initialText);
|
||||
myResultList = new Tree();
|
||||
myResultList.getExpandableItemsHandler().setEnabled(false);
|
||||
myResultList.getEmptyText().setText("Loading...");
|
||||
@@ -86,6 +85,30 @@ public class MavenArtifactSearchPanel extends JPanel {
|
||||
myResultList.setCellRenderer(renderer);
|
||||
myResultList.setRowHeight(renderer.getPreferredSize().height);
|
||||
|
||||
mySearchField = new JTextField(initialText);
|
||||
mySearchField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
int d;
|
||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
d = 1;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
d = -1;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
int row = myResultList.getSelectionModel().getLeadSelectionRow();
|
||||
row += d;
|
||||
|
||||
if (row >=0 && row < myResultList.getRowCount()) {
|
||||
myResultList.setSelectionRow(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(mySearchField, BorderLayout.NORTH);
|
||||
JScrollPane pane = ScrollPaneFactory.createScrollPane(myResultList);
|
||||
|
||||
Reference in New Issue
Block a user