Search in sources :

Example 6 with ChooseByNamePopup

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);
}
Also used : GotoActionModel(com.intellij.ide.util.gotoByName.GotoActionModel) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) ChooseByNamePopup(com.intellij.ide.util.gotoByName.ChooseByNamePopup) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Example 7 with ChooseByNamePopup

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);
}
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)7 Project (com.intellij.openapi.project.Project)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 NotNull (org.jetbrains.annotations.NotNull)3 GotoActionModel (com.intellij.ide.util.gotoByName.GotoActionModel)2 PsiFile (com.intellij.psi.PsiFile)2 ChooseTargetItem (com.facebook.buck.intellij.ideabuck.actions.choosetargets.ChooseTargetItem)1 ChooseTargetModel (com.facebook.buck.intellij.ideabuck.actions.choosetargets.ChooseTargetModel)1 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 Function (com.google.common.base.Function)1 BooleanOptionDescription (com.intellij.ide.ui.search.BooleanOptionDescription)1 ChooseByNameFilter (com.intellij.ide.util.gotoByName.ChooseByNameFilter)1 ChooseByNamePopupComponent (com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent)1 GotoActionItemProvider (com.intellij.ide.util.gotoByName.GotoActionItemProvider)1 GotoFileModel (com.intellij.ide.util.gotoByName.GotoFileModel)1 ListChooseByNameModel (com.intellij.ide.util.gotoByName.ListChooseByNameModel)1 Disposable (com.intellij.openapi.Disposable)1 ModalityState (com.intellij.openapi.application.ModalityState)1 Editor (com.intellij.openapi.editor.Editor)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1