JBPopup (@NotNull DataContext context, @NotNull JComponent component, @Nullable Runnable disposeCallback) { Project project = Objects.requireNonNull(context.getData(CommonDataKeys.PROJECT)); GitRepository repo = Objects.requireNonNull(GitBranchUtil.guessWidgetRepository(project, context)); JBPopup popup = GitBranchesTreePopup.create(project, repo); popup.addListener(new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { if (disposeCallback != null) { disposeCallback.run(); } } }); return popup; }