Search in sources :

Example 31 with PopupChooserBuilder

use of com.intellij.openapi.ui.popup.PopupChooserBuilder in project intellij-plugins by StepicOrg.

the class DownloadSubmission method showPopup.

private void showPopup(@NotNull Project project, @NotNull StepNode stepNode, @NotNull List<Submission> submissions) {
    JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    PopupChooserBuilder builder;
    if (!submissions.isEmpty()) {
        JList<SubmissionDecorator> list;
        List<SubmissionDecorator> submissionDecorators = submissions.stream().map(SubmissionDecorator::new).collect(Collectors.toList());
        list = new JBList<>(submissionDecorators);
        builder = popupFactory.createListPopupBuilder(list).addListener(new Listener(list, project, stepNode));
    } else {
        JList<String> emptyList = new JBList<>("Empty");
        builder = popupFactory.createListPopupBuilder(emptyList);
    }
    builder = builder.setTitle("Choose submission");
    JBPopup popup = builder.createPopup();
    popup.showCenteredInCurrentWindow(project);
}
Also used : JBPopupListener(com.intellij.openapi.ui.popup.JBPopupListener) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) JBList(com.intellij.ui.components.JBList) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder) JBPopup(com.intellij.openapi.ui.popup.JBPopup)

Aggregations

PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)31 JBList (com.intellij.ui.components.JBList)24 JBPopup (com.intellij.openapi.ui.popup.JBPopup)15 PsiElementListCellRenderer (com.intellij.ide.util.PsiElementListCellRenderer)5 Project (com.intellij.openapi.project.Project)4 Ref (com.intellij.openapi.util.Ref)4 RelativePoint (com.intellij.ui.awt.RelativePoint)4 NotNull (org.jetbrains.annotations.NotNull)4 MethodCellRenderer (com.intellij.ide.util.MethodCellRenderer)3 PsiClassListCellRenderer (com.intellij.ide.util.PsiClassListCellRenderer)3 PsiElement (com.intellij.psi.PsiElement)3 JBLabel (com.intellij.ui.components.JBLabel)3 Editor (com.intellij.openapi.editor.Editor)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ColoredListCellRenderer (com.intellij.ui.ColoredListCellRenderer)2 TreeTableView (com.intellij.ui.dualView.TreeTableView)2 UsageView (com.intellij.usages.UsageView)2 Alarm (com.intellij.util.Alarm)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 ColumnInfo (com.intellij.util.ui.ColumnInfo)2