Merge branch 'master' of git@git.labs.intellij.net:idea/community
authorKirill Kalishev <kirill.kalishev@jetbrains.com>
Fri, 22 Jan 2010 10:37:25 +0000 (13:37 +0300)
committerKirill Kalishev <kirill.kalishev@jetbrains.com>
Fri, 22 Jan 2010 10:37:25 +0000 (13:37 +0300)
platform/platform-impl/src/com/intellij/ide/actions/WindowAction.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/platform-resources/src/idea/PlatformActions.xml

diff --git a/platform/platform-impl/src/com/intellij/ide/actions/WindowAction.java b/platform/platform-impl/src/com/intellij/ide/actions/WindowAction.java
new file mode 100644 (file)
index 0000000..688ece5
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.actions;
+
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.util.registry.Registry;
+import com.intellij.openapi.wm.IdeFrame;
+import com.intellij.openapi.wm.WindowManager;
+import com.intellij.openapi.wm.ex.WindowManagerEx;
+
+import javax.swing.*;
+import java.awt.*;
+
+public abstract class WindowAction extends AnAction {
+
+  public static final String NO_WINDOW_ACTIONS = "no.window.actions";
+
+  protected Window myWindow;
+  private static JLabel mySizeHelper = new JLabel("W");
+
+  {
+    setEnabledInModalContext(true);
+  }
+
+  @Override
+  public final void update(AnActionEvent e) {
+    Window wnd = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
+    e.getPresentation().setEnabled(wnd != null && !(wnd instanceof IdeFrame));
+
+    Object noActions = null;
+    if (wnd instanceof JDialog) {
+      noActions = ((JDialog)wnd).getRootPane().getClientProperty(NO_WINDOW_ACTIONS);
+    } else if (wnd instanceof JFrame) {
+      noActions = ((JFrame)wnd).getRootPane().getClientProperty(NO_WINDOW_ACTIONS);
+    }
+
+    if (noActions != null && "true".equalsIgnoreCase(noActions.toString())) {
+      e.getPresentation().setEnabled(false);
+    }
+
+    if (e.getPresentation().isEnabled()) {
+      myWindow = wnd;
+    } else {
+      myWindow = null;
+    }
+  }
+
+  public abstract static class BaseSizeAction extends WindowAction {
+
+    private boolean myHorizontal;
+    private boolean myPositive;
+
+    protected BaseSizeAction(boolean horizontal, boolean positive) {
+      myHorizontal = horizontal;
+      myPositive = positive;
+    }
+
+    @Override
+    public void actionPerformed(AnActionEvent e) {
+      int baseValue = myHorizontal ? mySizeHelper.getPreferredSize().width : mySizeHelper.getPreferredSize().height;
+
+      int inc = baseValue * (myHorizontal ? Registry.intValue("ide.windowSystem.hScrollChars") : Registry.intValue("ide.windowSystem.vScrollChars"));
+      if (!myPositive) {
+        inc = -inc;
+      }
+
+      Rectangle bounds = myWindow.getBounds();
+      if (myHorizontal) {
+        bounds.width += inc;
+      } else {
+        bounds.height += inc;
+      }
+
+      myWindow.setBounds(bounds);
+    }
+  }
+
+  public static class IncrementWidth extends BaseSizeAction {
+
+    public IncrementWidth() {
+      super(true, true);
+    }
+  }
+
+  public static class DecrementWidth extends BaseSizeAction {
+
+    public DecrementWidth() {
+      super(true, false);
+    }
+  }
+
+  public static class IncrementHeight extends BaseSizeAction {
+    public IncrementHeight() {
+      super(false, true);
+    }
+  }
+
+  public static class DecrementHeight extends BaseSizeAction {
+    public DecrementHeight() {
+      super(false, false);
+    }
+  }
+}
index a5205b9b9fd503fcaa4ff6346c6875cd52c84665..bcb93fb5a2b9da7ed2f110bb1390eb451542258b 100644 (file)
@@ -301,6 +301,8 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
   }
 
   private THashMap<KeyStroke,ArrayList<String>> getKeystroke2ListOfIds() {
+    myKeystroke2ListOfIds = null;
+
     if (myKeystroke2ListOfIds == null) {
       myKeystroke2ListOfIds = new THashMap<KeyStroke, ArrayList<String>>();
       fillKeystroke2ListOfIds(myKeystroke2ListOfIds, KeyboardShortcut.class);
index 930636b438709b056b90356e9ec81de587e549a8..fc94ef647fb4ec1f977ce3c18567d8b8adb75287 100644 (file)
@@ -708,6 +708,10 @@ action.ResizeToolWindowUp.text=Stretch to Top
 action.ResizeToolWindowUp.description=Resize active tool window to the top
 action.ResizeToolWindowDown.text=Stretch to Bottom
 action.ResizeToolWindowDown.description=Resize active tool window to the bottom
+action.IncrementWindowWidth.text=Increment Width
+action.DecrementWindowWidth.text=Decrement Width
+action.IncrementWindowHeight.text=Increment Height
+action.DecrementWindowHeight.text=Decrement Height
 action.NextTab.text=Select Ne_xt Tab
 action.NextTab.description=Activate next tab
 action.PreviousTab.text=Se_lect Previous Tab
index 4afbe0926e2b2ed1c7bcdea6db4e03903dc82470..fbed7287a14033810fc09b057a82f9031c005739 100644 (file)
     </group>
 
     <action id="Rerun" class="com.intellij.execution.runners.FakeRerunAction" text="Rerun"/>
+
+    <action id="IncrementWindowWidth" class="com.intellij.ide.actions.WindowAction$IncrementWidth" use-shortcut-of="ResizeToolWindowRight"/>
+    <action id="DecrementWindowWidth" class="com.intellij.ide.actions.WindowAction$DecrementWidth" use-shortcut-of="ResizeToolWindowLeft"/>
+    <action id="IncrementWindowHeight" class="com.intellij.ide.actions.WindowAction$IncrementHeight" use-shortcut-of="ResizeToolWindowDown"/>
+    <action id="DecrementWindowHeight" class="com.intellij.ide.actions.WindowAction$DecrementHeight" use-shortcut-of="ResizeToolWindowUp"/>
   </actions>
 </component>