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);
}
Aggregations