use of com.intellij.ide.ui.search.BooleanOptionDescription in project intellij-community by JetBrains.
the class SearchEverywhereAction method doNavigate.
private void doNavigate(final int index) {
final DataManager dataManager = DataManager.getInstance();
if (dataManager == null)
return;
final Project project = CommonDataKeys.PROJECT.getData(dataManager.getDataContext(getField().getTextEditor()));
assert project != null;
final SearchListModel model = getModel();
if (isMoreItem(index)) {
final String pattern = myPopupField.getText();
WidgetID wid = null;
if (index == model.moreIndex.classes)
wid = WidgetID.CLASSES;
else if (index == model.moreIndex.files)
wid = WidgetID.FILES;
else if (index == model.moreIndex.settings)
wid = WidgetID.SETTINGS;
else if (index == model.moreIndex.actions)
wid = WidgetID.ACTIONS;
else if (index == model.moreIndex.symbols)
wid = WidgetID.SYMBOLS;
else if (index == model.moreIndex.runConfigurations)
wid = WidgetID.RUN_CONFIGURATIONS;
if (wid != null) {
final WidgetID widgetID = wid;
myCurrentWorker.doWhenProcessed(() -> {
myCalcThread = new CalcThread(project, pattern, true);
myPopupActualWidth = 0;
myCurrentWorker = myCalcThread.insert(index, widgetID);
});
return;
}
}
final String pattern = getField().getText();
final Object value = myList.getSelectedValue();
saveHistory(project, pattern, value);
IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(getField().getTextEditor());
if (myPopup != null && myPopup.isVisible()) {
myPopup.cancel();
}
if (value instanceof BooleanOptionDescription) {
final BooleanOptionDescription option = (BooleanOptionDescription) value;
option.setOptionState(!option.isOptionEnabled());
myList.revalidate();
myList.repaint();
getGlobalInstance().doWhenFocusSettlesDown(() -> {
getGlobalInstance().requestFocus(getField(), true);
});
return;
}
if (value instanceof OptionsTopHitProvider) {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> getField().setText("#" + ((OptionsTopHitProvider) value).getId() + " "));
return;
}
Runnable onDone = null;
AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
try {
if (value instanceof PsiElement) {
onDone = () -> NavigationUtil.activateFileWithPsiElement((PsiElement) value, true);
return;
} else if (isVirtualFile(value)) {
onDone = () -> OpenSourceUtil.navigate(true, new OpenFileDescriptor(project, (VirtualFile) value));
return;
} else if (isActionValue(value) || isSetting(value) || isRunConfiguration(value)) {
focusManager.requestDefaultFocus(true);
final Component comp = myContextComponent;
final AnActionEvent event = myActionEvent;
IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(() -> {
Component c = comp;
if (c == null) {
c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
}
if (isRunConfiguration(value)) {
ChooseRunConfigurationPopup.ItemWrapper itemWrapper = (ChooseRunConfigurationPopup.ItemWrapper) value;
RunnerAndConfigurationSettings settings = ObjectUtils.tryCast(itemWrapper.getValue(), RunnerAndConfigurationSettings.class);
if (settings != null) {
Executor executor = findExecutor(settings);
if (executor != null) {
itemWrapper.perform(project, executor, dataManager.getDataContext(c));
}
}
} else {
GotoActionAction.openOptionOrPerformAction(value, pattern, project, c, event);
if (isToolWindowAction(value))
return;
}
});
return;
} else if (value instanceof Navigatable) {
onDone = () -> OpenSourceUtil.navigate(true, (Navigatable) value);
return;
}
} finally {
token.finish();
final ActionCallback callback = onFocusLost();
if (onDone != null) {
callback.doWhenDone(onDone);
}
}
focusManager.requestDefaultFocus(true);
}
Aggregations