From 82cdd82ebd092f4cf71ef305140db8714d58ec21 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 10 Mar 2011 19:27:53 +0300 Subject: [PATCH] client can have actions mapped to LEFT/RIGHT keys. So, use maybeInstall to register actions by default --- .../com/intellij/ui/ListScrollingUtil.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java b/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java index 9694bcc20b5f..5c4899f977a9 100644 --- a/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java +++ b/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java @@ -16,9 +16,6 @@ package com.intellij.ui; import com.intellij.ide.ui.UISettings; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CustomShortcutSet; import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; @@ -44,6 +41,10 @@ public class ListScrollingUtil { protected static final String SELECT_LAST_ROW_ACTION_ID = "selectLastRow"; @NonNls protected static final String SELECT_FIRST_ROW_ACTION_ID = "selectFirstRow"; + @NonNls + protected static final String MOVE_HOME_ID = "MOVE_HOME"; + @NonNls + protected static final String MOVE_END_ID = "MOVE_END"; public static final int ROW_PADDING = 2; @@ -267,17 +268,18 @@ public class ListScrollingUtil { moveHome(list); } }); - new AnAction() { - public void actionPerformed(AnActionEvent e) { + actionMap.put(MOVE_HOME_ID, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { moveHome(list); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)), list); - new AnAction() { - public void actionPerformed(AnActionEvent e) { + }); + actionMap.put(MOVE_END_ID, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { moveEnd(list); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)), list); - + }); InputMap map = list.getInputMap(JComponent.WHEN_FOCUSED); UIUtil.maybeInstall(map, SCROLLUP_ACTION_ID, KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0)); @@ -286,6 +288,7 @@ public class ListScrollingUtil { UIUtil.maybeInstall(map, SELECT_NEXT_ROW_ACTION_ID, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)); UIUtil.maybeInstall(map, SELECT_FIRST_ROW_ACTION_ID, KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0)); UIUtil.maybeInstall(map, SELECT_LAST_ROW_ACTION_ID, KeyStroke.getKeyStroke(KeyEvent.VK_END, 0)); - + UIUtil.maybeInstall(map, MOVE_HOME_ID, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)); + UIUtil.maybeInstall(map, MOVE_END_ID, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)); } }