visual switcher - painting fixes
authorKirill Kalishev <kirill.kalishev@jetbrains.com>
Fri, 23 Apr 2010 13:47:00 +0000 (17:47 +0400)
committerKirill Kalishev <kirill.kalishev@jetbrains.com>
Fri, 23 Apr 2010 13:47:00 +0000 (17:47 +0400)
13 files changed:
platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java
platform/platform-api/src/com/intellij/ui/switcher/SwitchAction.java
platform/platform-api/src/com/intellij/ui/switcher/SwitchManager.java
platform/platform-api/src/com/intellij/ui/switcher/SwitchTarget.java
platform/platform-api/src/com/intellij/ui/switcher/SwitchingSession.java
platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentLayout.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabContentLayout.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ToolWindowContentUi.java
platform/platform-resources/src/idea/Keymap_Mac.xml
platform/platform-resources/src/idea/Keymap_MacClassic.xml

index 88ff067e2eb31c11718f259d57cee6489f5a1090..d4240ba68797c5069bebe0455cb5bf3df5fb1649 100644 (file)
@@ -1141,18 +1141,4 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
 
     return result;
   }
-
-  private class LayoutTarget implements SwitchTarget {
-    public ActionCallback switchTo(boolean requestFocus) {
-      return null;
-    }
-
-    public boolean isVisible() {
-      return false;
-    }
-
-    public RelativeRectangle getRectangle() {
-      return null;
-    }
-  }
 }
index ad8ea02a340dca907d0107d7c3fc95151dae92cc..f92e483ec84aae26960ddef36180d9f910f65f88 100644 (file)
@@ -25,6 +25,10 @@ import java.awt.event.KeyEvent;
 
 public abstract class SwitchAction extends AnAction implements DumbAware {
 
+  protected SwitchAction() {
+    setEnabledInModalContext(true);
+  }
+
   @Override
   public void update(AnActionEvent e) {
     SwitchingSession session = getSession(e);
index 3b2c3c0197f366d0b99a72b4d9bd390305b160cc..959e84706dde8b95b5699cf41b1788e6a8ba62c2 100644 (file)
@@ -25,7 +25,9 @@ import com.intellij.openapi.keymap.KeymapManagerListener;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.wm.IdeFocusManager;
+import com.intellij.openapi.wm.IdeFrame;
 import com.intellij.util.Alarm;
+import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
@@ -56,6 +58,13 @@ public class SwitchManager implements ProjectComponent, KeyEventDispatcher, Keym
 
   public boolean dispatchKeyEvent(KeyEvent e) {
     if (mySession != null && !mySession.isFinished()) return false;
+
+    Component c = e.getComponent();
+    Component frame = UIUtil.findUltimateParent(c);
+    if (frame instanceof IdeFrame) {
+      if (((IdeFrame)frame).getProject() != myProject) return false;
+    }
+
     if (e.getID() != KeyEvent.KEY_PRESSED) {
       if (myWaitingForAutoInitSession) {
         cancelWaitingForAutoInit();
index 876cd3193f1934fd961ec005a0d56cb11b6549f1..bb410b2d247ca40d717f491910d6fd1d16cc38b9 100644 (file)
@@ -18,6 +18,8 @@ package com.intellij.ui.switcher;
 import com.intellij.openapi.util.ActionCallback;
 import com.intellij.ui.awt.RelativeRectangle;
 
+import java.awt.*;
+
 public interface SwitchTarget {
 
   ActionCallback switchTo(boolean requestFocus);
@@ -25,4 +27,5 @@ public interface SwitchTarget {
   boolean isVisible();
   RelativeRectangle getRectangle();
 
+  Component getComponent();
 }
index 5435dc84193777a4961ac9a9c96cc068b287ed1e..b642fc30bbbb0e11417960cae1e33d01aad5e96a 100644 (file)
@@ -86,7 +86,7 @@ public class SwitchingSession implements KeyEventDispatcher, Disposable {
       Disposer.register(this, eachPainter);
 
       myRootComponent = myProvider.getComponent();
-      myGlassPane.addPainter(myRootComponent, eachPainter, this);
+      myGlassPane.addPainter(each.getComponent(), eachPainter, this);
       myPainters.put(each, eachPainter);
     }
 
@@ -188,6 +188,10 @@ public class SwitchingSession implements KeyEventDispatcher, Disposable {
   }
 
   private SwitchTarget getNextTarget(Direction direction) {
+    if (myTargets.size() == 1) {
+      return getSelection();
+    }
+
     List<Point> points = new ArrayList<Point>();
     Point selected = null;
     Map<SwitchTarget, Point> target2Point = new HashMap<SwitchTarget, Point>();
index edf5f9a4ef250c4fcedd9ef64ffebc37a57587d5..0896ca332f87c83edcd6892831c9d1ffd4a0c532 100644 (file)
@@ -2784,6 +2784,10 @@ public class JBTabsImpl extends JComponent
       return new RelativeRectangle(label.getParent(), b);
     }
 
+    public Component getComponent() {
+      return myInfo2Label.get(myInfo);
+    }
+
     @Override
     public Object[] getEqualityObjects() {
       return new Object[] {myInfo};
index 619fbc7b540c7f3a8fc9a4d5ebe4bb386996f51c..403a8e037f3623e2d4faed3d8ec25821faaa266e 100644 (file)
@@ -1024,6 +1024,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
     public RelativeRectangle getRectangle() {
       return new RelativeRectangle(myButton.getParent(), myButton.getBounds());
     }
+
+    public Component getComponent() {
+      return myButton;
+    }
   }
 
   public SwitchTarget getCurrentTarget() {
index f16f251f971e90431444002eb6d45d6bd2ca0105..54b2ff8654cfc02601ac0ac982f7078953c14666 100644 (file)
@@ -168,4 +168,9 @@ class ComboContentLayout extends ContentLayout {
   public RelativeRectangle getRectangleFor(Content content) {
     return null;
   }
+
+  @Override
+  public Component getComponentFor(Content content) {
+    return null;
+  }
 }
index 1b2d826bd2407c06fe504108bfd1871b6b346d79..eb9ceedab31bbaf7ea8f5ea7d45cf67155bdf636 100644 (file)
@@ -96,4 +96,7 @@ abstract class ContentLayout {
   public abstract void showContentPopup(ListPopup listPopup);
 
   public abstract RelativeRectangle getRectangleFor(Content content);
+
+  public abstract Component getComponentFor(Content content);
+
 }
index 9cc0eeba95141d65560721eb5aa2e5bc87a348a5..8454e870860a8218cd0e306aeae1d4ac08b43e46 100644 (file)
@@ -407,4 +407,8 @@ class TabContentLayout extends ContentLayout {
     ContentTabLabel label = myContent2Tabs.get(content);
     return new RelativeRectangle(label.getParent(), label.getBounds());
   }
+
+  public Component getComponentFor(Content content) {
+    return myContent2Tabs.get(content);
+  }
 }
index 603a46ee5c0d32f49e009ff490b54c80e216d1f5..5eb14263bd1fc1da5e343f151e96307a579b8474 100644 (file)
@@ -478,6 +478,10 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
       return myTabsLayout.getRectangleFor(myContent);
     }
 
+    public Component getComponent() {
+      return myManager.getComponent();
+    }
+
     @Override
     public Object[] getEqualityObjects() {
       return new Object[] {myContent};
index 4720e0248836f884bbd5ab54c0151eb92d537cc6..81886a2caa0fce9a67bd1761b35b660e0da3c111 100644 (file)
@@ -4,6 +4,21 @@
       <keyboard-shortcut first-keystroke="meta P"/>
     </action>
 
+    <action id="SwitchUp">
+      <keyboard-shortcut first-keystroke="control alt UP"/>
+    </action>
+
+    <action id="SwitchDown">
+      <keyboard-shortcut first-keystroke="control alt DOWN"/>
+    </action>
+
+    <action id="SwitchLeft">
+      <keyboard-shortcut first-keystroke="control alt LEFT"/>
+    </action>
+
+    <action id="SwitchRight">
+      <keyboard-shortcut first-keystroke="control alt RIGHT"/>
+    </action>
 
     <action id="NextSplitter">
       <keyboard-shortcut first-keystroke="alt TAB"/>
     <action id="PreviousEditorTab">
       <keyboard-shortcut first-keystroke="control shift LEFT"/>
     </action>
-
-    <action id="SwitchUp">
-      <keyboard-shortcut first-keystroke="control alt UP"/>
-    </action>
-
-    <action id="SwitchDown">
-      <keyboard-shortcut first-keystroke="control alt DOWN"/>
-    </action>
-
-    <action id="SwitchLeft">
-      <keyboard-shortcut first-keystroke="control alt LEFT"/>
-    </action>
-
-    <action id="SwitchRight">
-      <keyboard-shortcut first-keystroke="control alt RIGHT"/>
-    </action>
-
     <action id="EditorPreviousWord">
       <keyboard-shortcut first-keystroke="alt LEFT"/>
     </action>
index 3b4b8c3e1c1e75a84979f2bf3ba98a0d86cc05fc..09746c8664f9c6cc51af656dd3c3fde6ea8f54d8 100644 (file)
@@ -5,6 +5,23 @@
     </action>
 
 
+    <action id="SwitchUp">
+      <keyboard-shortcut first-keystroke="control alt UP"/>
+    </action>
+
+    <action id="SwitchDown">
+      <keyboard-shortcut first-keystroke="control alt DOWN"/>
+    </action>
+
+    <action id="SwitchLeft">
+      <keyboard-shortcut first-keystroke="control alt LEFT"/>
+    </action>
+
+    <action id="SwitchRight">
+      <keyboard-shortcut first-keystroke="control alt RIGHT"/>
+    </action>
+
+
     <action id="NextSplitter">
       <keyboard-shortcut first-keystroke="alt TAB"/>
     </action>