From caf4cea3406c3be5524baf1231a054e691c4aa3d Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 21 Jan 2010 16:14:11 +0300 Subject: [PATCH] toolwindows: stretching for undocked mode --- .../src/com/intellij/idea/ActionsBundle.java | 5 ++ .../ide/actions/ResizeToolWindowAction.java | 95 +++++++++++++++++++++- .../openapi/wm/impl/InternalDecorator.java | 10 +++ .../src/messages/ActionsBundle.properties | 9 ++ .../src/idea/PlatformActions.xml | 11 +-- 5 files changed, 121 insertions(+), 9 deletions(-) diff --git a/platform/platform-api/src/com/intellij/idea/ActionsBundle.java b/platform/platform-api/src/com/intellij/idea/ActionsBundle.java index 8c17fd7bbe..43318d0010 100644 --- a/platform/platform-api/src/com/intellij/idea/ActionsBundle.java +++ b/platform/platform-api/src/com/intellij/idea/ActionsBundle.java @@ -38,6 +38,11 @@ public class ActionsBundle { } @SuppressWarnings({"HardCodedStringLiteral", "UnresolvedPropertyKey"}) + public static String groupText(@NonNls String actionId) { + return message("group." + actionId + ".text"); + } + + @SuppressWarnings({"HardCodedStringLiteral", "UnresolvedPropertyKey"}) public static String actionDescription(@NonNls String actionId) { return message("action." + actionId + ".description"); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ResizeToolWindowAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ResizeToolWindowAction.java index d2992168de..7c3a0a87f1 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ResizeToolWindowAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ResizeToolWindowAction.java @@ -15,11 +15,13 @@ */ package com.intellij.ide.actions; +import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.ShadowAction; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.*; import com.intellij.openapi.wm.ex.ToolWindowEx; @@ -35,6 +37,24 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa protected JLabel myScrollHelper = new JLabel("W"); + private ToolWindow myToolWindow; + + protected ResizeToolWindowAction() { + } + + protected ResizeToolWindowAction(String text) { + super(text); + } + + protected ResizeToolWindowAction(String text, String description, Icon icon) { + super(text, description, icon); + } + + protected ResizeToolWindowAction(ToolWindow toolWindow, String originalAction, JComponent c) { + myToolWindow = toolWindow; + new ShadowAction(this, ActionManager.getInstance().getAction(originalAction), c); + } + @Override public final void update(AnActionEvent e) { Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); @@ -45,11 +65,14 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa ToolWindowManager mgr = ToolWindowManager.getInstance(project); - String active = mgr.getActiveToolWindowId(); - if (active != null) { - ToolWindow window = mgr.getToolWindow(active); + ToolWindow window = myToolWindow; - if (!window.isAvailable() || !window.isVisible() || window.getType() == ToolWindowType.FLOATING) { + if (window != null || mgr.getActiveToolWindowId() != null) { + if (window == null) { + window = mgr.getToolWindow(mgr.getActiveToolWindowId()); + } + + if (window == null || !window.isAvailable() || !window.isVisible() || window.getType() == ToolWindowType.FLOATING) { setDisabled(e); return; } @@ -141,6 +164,22 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa } public static class Left extends ResizeToolWindowAction { + + public Left() { + } + + public Left(String text) { + super(text); + } + + public Left(String text, String description, Icon icon) { + super(text, description, icon); + } + + public Left(ToolWindow toolWindow, JComponent c) { + super(toolWindow, "ResizeToolWindowLeft", c); + } + @Override protected void update(AnActionEvent event, ToolWindow window, ToolWindowManager mgr) { event.getPresentation().setEnabled(!window.getAnchor().isHorizontal()); @@ -153,6 +192,22 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa } public static class Right extends ResizeToolWindowAction { + + public Right() { + } + + public Right(String text) { + super(text); + } + + public Right(String text, String description, Icon icon) { + super(text, description, icon); + } + + public Right(ToolWindow toolWindow, JComponent c) { + super(toolWindow, "ResizeToolWindowRight", c); + } + @Override protected void update(AnActionEvent event, ToolWindow window, ToolWindowManager mgr) { event.getPresentation().setEnabled(!window.getAnchor().isHorizontal()); @@ -165,6 +220,22 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa } public static class Up extends ResizeToolWindowAction { + + public Up() { + } + + public Up(String text) { + super(text); + } + + public Up(String text, String description, Icon icon) { + super(text, description, icon); + } + + public Up(ToolWindow toolWindow, JComponent c) { + super(toolWindow, "ResizeToolWindowUp", c); + } + @Override protected void update(AnActionEvent event, ToolWindow window, ToolWindowManager mgr) { event.getPresentation().setEnabled(window.getAnchor().isHorizontal()); @@ -177,6 +248,22 @@ public abstract class ResizeToolWindowAction extends AnAction implements DumbAwa } public static class Down extends ResizeToolWindowAction { + + public Down() { + } + + public Down(String text) { + super(text); + } + + public Down(String text, String description, Icon icon) { + super(text, description, icon); + } + + public Down(ToolWindow toolWindow, JComponent c) { + super(toolWindow, "ResizeToolWindowDown", c); + } + @Override protected void update(AnActionEvent event, ToolWindow window, ToolWindowManager mgr) { event.getPresentation().setEnabled(window.getAnchor().isHorizontal()); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java index 42d5ba42a9..6e07ab8b7e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java @@ -16,6 +16,8 @@ package com.intellij.openapi.wm.impl; import com.intellij.ide.DataManager; +import com.intellij.ide.actions.ResizeToolWindowAction; +import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; import com.intellij.openapi.diagnostic.Logger; @@ -498,6 +500,14 @@ public final class InternalDecorator extends JPanel implements TestableUi, TypeS } group.add(moveGroup); + DefaultActionGroup resize = new DefaultActionGroup(ActionsBundle.groupText("ResizeToolWindowGroup"), true); + resize.add(new ResizeToolWindowAction.Left(myToolWindow, this)); + resize.add(new ResizeToolWindowAction.Right(myToolWindow, this)); + resize.add(new ResizeToolWindowAction.Up(myToolWindow, this)); + resize.add(new ResizeToolWindowAction.Down(myToolWindow, this)); + + group.add(resize); + group.addSeparator(); group.add(myHideAction); return group; diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 7a54e63746..930636b438 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -699,6 +699,15 @@ action.ToggleContentUiTypeMode.text=Tabbed Content action.ToggleContentUiTypeMode.description=Toggle between tabbed/combo presentation of contents action.ShowContent.text=Show Content action.ShowContent.description=Show tool window content popup +group.ResizeToolWindowGroup.text=Resize +action.ResizeToolWindowLeft.text=Stretch to Left +action.ResizeToolWindowLeft.description=Resize active tool window to the left +action.ResizeToolWindowRight.text=Stretch to Right +action.ResizeToolWindowRight.description=Resize active tool window to the right +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.NextTab.text=Select Ne_xt Tab action.NextTab.description=Activate next tab action.PreviousTab.text=Se_lect Previous Tab diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index a069617f72..4afbe0926e 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -94,11 +94,6 @@ - - - - - @@ -234,6 +229,12 @@ + + + + + + -- 2.11.4.GIT