Search in sources :

Example 6 with PsiElementListCellRenderer

use of com.intellij.ide.util.PsiElementListCellRenderer in project intellij-community by JetBrains.

the class GrCreateFromUsageBaseFix method chooseClass.

private void chooseClass(List<PsiClass> classes, Editor editor) {
    final Project project = classes.get(0).getProject();
    final JList list = new JBList(classes);
    PsiElementListCellRenderer renderer = new PsiClassListCellRenderer();
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setCellRenderer(renderer);
    final PopupChooserBuilder builder = new PopupChooserBuilder(list);
    renderer.installSpeedSearch(builder);
    Runnable runnable = () -> {
        int index = list.getSelectedIndex();
        if (index < 0)
            return;
        final PsiClass aClass = (PsiClass) list.getSelectedValue();
        CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> invokeImpl(project, aClass)), getText(), null);
    };
    builder.setTitle(QuickFixBundle.message("target.class.chooser.title")).setItemChoosenCallback(runnable).createPopup().showInBestPositionFor(editor);
}
Also used : Project(com.intellij.openapi.project.Project) JBList(com.intellij.ui.components.JBList) PsiClassListCellRenderer(com.intellij.ide.util.PsiClassListCellRenderer) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder) PsiElementListCellRenderer(com.intellij.ide.util.PsiElementListCellRenderer)

Aggregations

PsiElementListCellRenderer (com.intellij.ide.util.PsiElementListCellRenderer)6 PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)5 JBList (com.intellij.ui.components.JBList)5 PsiClassListCellRenderer (com.intellij.ide.util.PsiClassListCellRenderer)3 Project (com.intellij.openapi.project.Project)3 JBPopup (com.intellij.openapi.ui.popup.JBPopup)2 Ref (com.intellij.openapi.util.Ref)2 PsiElement (com.intellij.psi.PsiElement)2 UsageView (com.intellij.usages.UsageView)2 Alarm (com.intellij.util.Alarm)2 ListBackgroundUpdaterTask (com.intellij.codeInsight.navigation.ListBackgroundUpdaterTask)1 FindUtil (com.intellij.find.FindUtil)1 PsiCopyPasteManager (com.intellij.ide.PsiCopyPasteManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Editor (com.intellij.openapi.editor.Editor)1 EditorUtil (com.intellij.openapi.editor.ex.util.EditorUtil)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)1