Hide disabled and invisible actions from "Find Action..." result list

This commit is contained in:
Vassiliy.Kudryashov
2016-10-20 21:58:54 +03:00
parent 5cf2cf24e3
commit e0cfbf28db
2 changed files with 20 additions and 0 deletions
@@ -55,6 +55,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.*;
import java.util.Iterator;
import java.util.Set;
public class GotoActionAction extends GotoActionBase implements DumbAware {
@@ -97,6 +98,20 @@ public class GotoActionAction extends GotoActionBase implements DumbAware {
}
final Disposable disposable = Disposer.newDisposable();
final ChooseByNamePopup popup = new ChooseByNamePopup(project, model, new GotoActionItemProvider(model), oldPopup, initialText, false, initialIndex) {
@Override
protected void filterInEDT(Set<Object> elements) {
for (Iterator<Object> iterator = elements.iterator(); iterator.hasNext(); ) {
Object o = iterator.next();
if (o instanceof GotoActionModel.MatchedValue) {
Comparable value = ((GotoActionModel.MatchedValue)o).value;
if (value instanceof GotoActionModel.ActionWrapper) {
GotoActionModel.ActionWrapper wrapper = (GotoActionModel.ActionWrapper)value;
if (!wrapper.getPresentation().isEnabled() || !wrapper.getPresentation().isVisible()) iterator.remove();
}
}
}
}
@Override
protected void initUI(Callback callback, ModalityState modalityState, boolean allowMultipleSelection) {
super.initUI(callback, modalityState, allowMultipleSelection);
@@ -1467,6 +1467,9 @@ public abstract class ChooseByNameBase {
return panel;
}
protected void filterInEDT(Set<Object> elements) {
}
private class CalcElementsThread extends ReadTask {
private final String myPattern;
private final boolean myCheckboxState;
@@ -1518,6 +1521,8 @@ public abstract class ChooseByNameBase {
showCard(cardToShow, 0);
filterInEDT(filtered);
myCallback.consume(filtered);
}
}, myModalityState);