Make goto action's "change goto check box" and toolbar buttons dumb aware

This commit is contained in:
Bas Leijdekkers
2015-11-27 14:54:49 +01:00
parent be09ce6743
commit 28b2e73480
2 changed files with 27 additions and 19 deletions
@@ -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);
}
@@ -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<T> {
@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<T> {
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();
}
}
}
}