From 28b2e734804c6287bc5b4782e543ca27093ef5be Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 27 Nov 2015 14:28:17 +0100 Subject: [PATCH] Make goto action's "change goto check box" and toolbar buttons dumb aware --- .../ide/util/gotoByName/ChooseByNameBase.java | 5 ++- .../util/gotoByName/ChooseByNameFilter.java | 41 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java index ed2be858950a..9dcc72110d80 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java @@ -49,6 +49,7 @@ import com.intellij.openapi.progress.util.ProgressIndicatorBase; import com.intellij.openapi.progress.util.ProgressIndicatorUtils; import com.intellij.openapi.progress.util.ReadTask; import com.intellij.openapi.progress.util.TooManyUsagesStatus; +import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.*; @@ -495,7 +496,7 @@ public abstract class ChooseByNameBase { if (checkBoxName != null) { if (myCheckBox != null && myCheckBoxShortcut != null) { - new AnAction("change goto check box", null, null) { + new DumbAwareAction("change goto check box", null, null) { @Override public void actionPerformed(@NotNull AnActionEvent e) { myCheckBox.setSelected(!myCheckBox.isSelected()); @@ -1681,7 +1682,7 @@ public abstract class ChooseByNameBase { private static final String ACTION_NAME = "Show All in View"; - private abstract class ShowFindUsagesAction extends AnAction { + private abstract class ShowFindUsagesAction extends DumbAwareAction { public ShowFindUsagesAction() { super(ACTION_NAME, ACTION_NAME, AllIcons.General.AutohideOff); } diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java index a9043c649291..75b755ae14f0 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -18,6 +18,7 @@ package com.intellij.ide.util.gotoByName; import com.intellij.icons.AllIcons; import com.intellij.ide.util.ElementsChooser; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopup; @@ -79,22 +80,7 @@ public abstract class ChooseByNameFilter { @NotNull Project project) { myParentPopup = popup; DefaultActionGroup actionGroup = new DefaultActionGroup("go.to.file.filter", false); - ToggleAction action = new ToggleAction("Filter", "Filter files by type", AllIcons.General.Filter) { - @Override - public boolean isSelected(final AnActionEvent e) { - return myPopup != null; - } - - @Override - public void setSelected(final AnActionEvent e, final boolean state) { - if (state) { - createPopup(); - } - else { - close(); - } - } - }; + ToggleAction action = new FilterAction(); actionGroup.add(action); myToolbar = ActionManager.getInstance().createActionToolbar("gotfile.filter", actionGroup, true); myToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY); @@ -232,4 +218,25 @@ public abstract class ChooseByNameFilter { Disposer.dispose(myPopup); } } + + private class FilterAction extends ToggleAction implements DumbAware { + public FilterAction() { + super("Filter", "Filter files by type", AllIcons.General.Filter); + } + + @Override + public boolean isSelected(final AnActionEvent e) { + return myPopup != null; + } + + @Override + public void setSelected(final AnActionEvent e, final boolean state) { + if (state) { + createPopup(); + } + else { + close(); + } + } + } }