Search in sources :

Example 76 with JBPopup

use of com.intellij.openapi.ui.popup.JBPopup 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 JList<>(submissionDecorators.toArray(new SubmissionDecorator[submissionDecorators.size()]));
        builder = popupFactory.createListPopupBuilder(list).addListener(new Listener(list, project, stepNode));
    } else {
        JList<String> emptyList = new JList<>(new String[] { "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) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder) JBPopup(com.intellij.openapi.ui.popup.JBPopup)

Aggregations

JBPopup (com.intellij.openapi.ui.popup.JBPopup)76 Project (com.intellij.openapi.project.Project)21 NotNull (org.jetbrains.annotations.NotNull)20 RelativePoint (com.intellij.ui.awt.RelativePoint)19 JBList (com.intellij.ui.components.JBList)18 PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)15 Editor (com.intellij.openapi.editor.Editor)13 PsiElement (com.intellij.psi.PsiElement)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Nullable (org.jetbrains.annotations.Nullable)8 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)7 Ref (com.intellij.openapi.util.Ref)7 DocumentationManager (com.intellij.codeInsight.documentation.DocumentationManager)6 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)6 AbstractPopup (com.intellij.ui.popup.AbstractPopup)6 ActionEvent (java.awt.event.ActionEvent)6 List (java.util.List)6 javax.swing (javax.swing)6 Disposable (com.intellij.openapi.Disposable)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)5