use of com.intellij.ide.util.gotoByName.ChooseByNamePopup in project intellij-community by JetBrains.
the class GotoActionAction method gotoActionPerformed.
@Override
public void gotoActionPerformed(@NotNull final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
Editor editor = e.getData(CommonDataKeys.EDITOR);
PsiFile file = e.getData(CommonDataKeys.PSI_FILE);
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.action");
GotoActionModel model = new GotoActionModel(project, component, editor, file);
GotoActionCallback<Object> callback = new GotoActionCallback<Object>() {
@Override
public void elementChosen(@NotNull ChooseByNamePopup popup, @NotNull Object element) {
if (project != null) {
// if the chosen action displays another popup, don't populate it automatically with the text from this popup
project.putUserData(ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY, null);
}
String enteredText = popup.getTrimmedText();
openOptionOrPerformAction(((GotoActionModel.MatchedValue) element).value, enteredText, project, component, e);
}
};
Pair<String, Integer> start = getInitialText(false, e);
showNavigationPopup(callback, null, createPopup(project, model, start.first, start.second, component, e), false);
}
use of com.intellij.ide.util.gotoByName.ChooseByNamePopup in project intellij-community by JetBrains.
the class SetupTaskChooserAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Module module = e.getData(LangDataKeys.MODULE);
if (module == null)
return;
final Project project = module.getProject();
final ListChooseByNameModel<SetupTask> model = new ListChooseByNameModel<>(project, "Enter setup.py task name", "No tasks found", SetupTaskIntrospector.getTaskList(module));
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, GotoActionBase.getPsiContext(e));
popup.setShowListForEmptyPattern(true);
popup.invoke(new ChooseByNamePopupComponent.Callback() {
public void onClose() {
}
public void elementChosen(Object element) {
if (element != null) {
final SetupTask task = (SetupTask) element;
ApplicationManager.getApplication().invokeLater(() -> runSetupTask(task.getName(), module), ModalityState.NON_MODAL);
}
}
}, ModalityState.current(), false);
}
Aggregations