Search in sources :

Example 1 with ListChooseByNameModel

use of com.intellij.ide.util.gotoByName.ListChooseByNameModel 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);
}
Also used : Project(com.intellij.openapi.project.Project) ChooseByNamePopup(com.intellij.ide.util.gotoByName.ChooseByNamePopup) Module(com.intellij.openapi.module.Module) ListChooseByNameModel(com.intellij.ide.util.gotoByName.ListChooseByNameModel) ChooseByNamePopupComponent(com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent)

Aggregations

ChooseByNamePopup (com.intellij.ide.util.gotoByName.ChooseByNamePopup)1 ChooseByNamePopupComponent (com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent)1 ListChooseByNameModel (com.intellij.ide.util.gotoByName.ListChooseByNameModel)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1