IDEA-58308 SQL console: IAE at com.intellij.ui.SwingActionWrapper.<init>()
authorGregory Shrago <Gregory.Shrago@jetbrains.com>
Thu, 2 Sep 2010 16:37:43 +0000 (20:37 +0400)
committerGregory Shrago <Gregory.Shrago@jetbrains.com>
Thu, 2 Sep 2010 16:41:29 +0000 (20:41 +0400)
platform/util/src/com/intellij/ui/SwingActionWrapper.java
platform/util/src/com/intellij/ui/TableUtil.java

index 8f02d95f00009b5186bebf137762d6d21d949d68..111857ce454edad477079eb2088f6f3bb188ec7d 100644 (file)
@@ -41,7 +41,7 @@ public abstract class SwingActionWrapper<T extends JComponent> implements Action
   }
 
   @Nullable
-  private static Object getKeyForActionMap(JComponent component, KeyStroke keyStroke) {
+  public static Object getKeyForActionMap(JComponent component, KeyStroke keyStroke) {
     for (int i = 0; i < 3; i++) {
       final InputMap inputMap = component.getInputMap(i);
       if (inputMap == null) continue;
index 48e5989f12513390d6e76a2eff23510cc913f372..2c8edb83718840bd3f1f78aa8f2bdbfc52596bcc 100644 (file)
@@ -196,21 +196,20 @@ public class TableUtil {
   }
 
   public static void configureAllowedCellSelection(final JTable table, final Condition<Point> cellCondition) {
-    new MyFocusAction(table, cellCondition, KeyStroke.getKeyStroke("ENTER"));
-    new MyFocusAction(table, cellCondition, KeyStroke.getKeyStroke("TAB"));
-    new MyFocusAction(table, cellCondition, KeyStroke.getKeyStroke("shift TAB"));
-    new MyFocusAction(table, cellCondition, KeyStroke.getKeyStroke("RIGHT"));
-    new MyFocusAction(table, cellCondition, KeyStroke.getKeyStroke("LEFT"));
-    new MyFocusAction(table, cellCondition, KeyStroke.getKeyStroke("UP"));
-    new MyFocusAction(table, cellCondition, KeyStroke.getKeyStroke("DOWN"));
+    for (String keyStroke : new String[]{"ENTER","TAB","shift TAB","RIGHT","LEFT","UP","DOWN"}) {
+      final Object key = SwingActionWrapper.getKeyForActionMap(table, KeyStroke.getKeyStroke(keyStroke));
+      if (key != null) {
+        new MyFocusAction(table, cellCondition, key);
+      }
+    }
   }
 
   public static class MyFocusAction extends SwingActionWrapper<JTable> {
 
     private final Condition<Point> myCellCondition;
 
-    public MyFocusAction(JTable table, Condition<Point> cellCondition, KeyStroke keyStroke) {
-      super(table, keyStroke);
+    public MyFocusAction(JTable table, Condition<Point> cellCondition, Object key) {
+      super(table, key);
       myCellCondition = cellCondition;
     }