Boolean (@NotNull Project project, @NotNull Path file) { Boolean[] ref = new Boolean[1]; DoNotAskOption option = new DoNotAskOption() { @Override public boolean isToBeShown() { return true; } @Override public void setToBeShown(boolean value, int exitCode) { if (!value) { ref[0] = exitCode == 0; } } @Override public boolean canBeHidden() { return true; } @Override public boolean shouldSaveOptionsOnCancel() { return true; } @NotNull @Override public String getDoNotShowMessage() { return IdeCoreBundle.message("dialog.options.do.not.ask"); } }; boolean confirmed = MessageDialogBuilder.okCancel( VcsBundle.message("create.patch.commit.action.title"), VcsBundle.message("create.patch.success.confirmation", file.toString()) ) .yesText(RevealFileAction.getActionName(null)) .noText(IdeBundle.message("action.close")) .icon(Messages.getInformationIcon()) .doNotAsk(option) .ask(project); if (confirmed) { RevealFileAction.openFile(file.toFile()); } return ref[0]; }