From 6d09764a020e99658b8cba30ab7037e695a2ee9d Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Thu, 9 Jul 2015 14:46:10 +0300 Subject: [PATCH] IDEA-142244 Context menu on Find tool window tabs doesn't work correctly +Hide disabled Close Tab / Close All / Close Other / Select Next / Select Previous --- .../intellij/ide/actions/ShowContentAction.java | 2 +- .../ui/content/tabs/TabbedContentAction.java | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowContentAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowContentAction.java index 62ebac620e60..60b4902e6b79 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowContentAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowContentAction.java @@ -48,7 +48,7 @@ public class ShowContentAction extends AnAction implements DumbAware { @Override public void update(AnActionEvent e) { final ToolWindow window = getWindow(e); - e.getPresentation().setEnabled(window != null && window.getContentManager().getContentCount() > 1); + e.getPresentation().setEnabledAndVisible(window != null && window.getContentManager().getContentCount() > 1); e.getPresentation().setText(window == null || window.getContentUiType() == ToolWindowContentUiType.TABBED ? "Show List of Tabs" : "Show List of Views"); diff --git a/platform/platform-impl/src/com/intellij/ui/content/tabs/TabbedContentAction.java b/platform/platform-impl/src/com/intellij/ui/content/tabs/TabbedContentAction.java index be7edec759d8..e7066a682c94 100644 --- a/platform/platform-impl/src/com/intellij/ui/content/tabs/TabbedContentAction.java +++ b/platform/platform-impl/src/com/intellij/ui/content/tabs/TabbedContentAction.java @@ -76,15 +76,14 @@ public abstract class TabbedContentAction extends AnAction implements DumbAware public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); - presentation.setEnabled(myContent != null && myManager.canCloseContents() && myContent.isCloseable() && myManager.isSelected(myContent)); - presentation.setVisible(myManager.canCloseContents() && myContent.isCloseable()); + presentation.setEnabledAndVisible(myManager.canCloseContents() && myContent.isCloseable()); presentation.setText(myManager.getCloseActionName()); } } public static class CloseAllButThisAction extends ForContent { - public CloseAllButThisAction(Content content) { + public CloseAllButThisAction(@NotNull Content content) { super(content, ActionManager.getInstance().getAction(IdeActions.ACTION_CLOSE_ALL_EDITORS_BUT_THIS), UIBundle.message("tabbed.pane.close.all.but.this.action.name")); } @@ -101,11 +100,10 @@ public abstract class TabbedContentAction extends AnAction implements DumbAware public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setText(myManager.getCloseAllButThisActionName()); - presentation.setEnabled(myContent != null && myManager.canCloseContents() && myManager.getContentCount() > 1); - presentation.setVisible(myManager.canCloseContents() && hasCloseableContents()); + presentation.setEnabledAndVisible(myManager.canCloseContents() && hasOtherCloseableContents()); } - private boolean hasCloseableContents() { + private boolean hasOtherCloseableContents() { Content[] contents = myManager.getContents(); for (Content content : contents) { if (myContent != content && content.isCloseable()) { @@ -132,8 +130,7 @@ public abstract class TabbedContentAction extends AnAction implements DumbAware public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); - presentation.setEnabled(myManager.canCloseAllContents()); - presentation.setVisible(myManager.canCloseAllContents()); + presentation.setEnabledAndVisible(myManager.getContentCount() > 1 && myManager.canCloseAllContents()); } } public static class MyNextTabAction extends TabbedContentAction { @@ -146,7 +143,7 @@ public abstract class TabbedContentAction extends AnAction implements DumbAware } public void update(AnActionEvent e) { - e.getPresentation().setEnabled(myManager.getContentCount() > 1); + e.getPresentation().setEnabledAndVisible(myManager.getContentCount() > 1); e.getPresentation().setText(myManager.getNextContentActionName()); } } @@ -161,7 +158,7 @@ public abstract class TabbedContentAction extends AnAction implements DumbAware } public void update(AnActionEvent e) { - e.getPresentation().setEnabled(myManager.getContentCount() > 1); + e.getPresentation().setEnabledAndVisible(myManager.getContentCount() > 1); e.getPresentation().setText(myManager.getPreviousContentActionName()); } }