private static boolean showConfirmation() { final boolean hasUnsafeBgTasks = ProgressManager.getInstance().hasUnsafeProgressIndicator(); DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { @Override public boolean isToBeShown() { return GeneralSettings.getInstance().isConfirmExit(); } @Override public void setToBeShown(boolean value, int exitCode) { GeneralSettings.getInstance().setConfirmExit(value); } @Override public boolean canBeHidden() { return !hasUnsafeBgTasks; } @Override public boolean shouldSaveOptionsOnCancel() { return false; } @Override public String getDoNotShowMessage() { return "Do not ask me again"; } }; if (hasUnsafeBgTasks || option.isToBeShown()) { String message = ApplicationBundle.message( hasUnsafeBgTasks ? "exit.confirm.prompt.tasks" : "exit.confirm.prompt", ApplicationNamesInfo.getInstance().getFullProductName()); if (DialogWrapper.OK_EXIT_CODE != Messages.showYesNoDialog( message, ApplicationBundle.message("exit.confirm.title"), ApplicationBundle.message("command.exit"), "Cancel", Messages.getQuestionIcon(), option)) { return false; } } return true; }
private boolean disposeSelf() { myDisposeInProgress = true; final CommandProcessor commandProcessor = CommandProcessor.getInstance(); final Ref<Boolean> canClose = new Ref<Boolean>(Boolean.TRUE); for (final Project project : ProjectManagerEx.getInstanceEx().getOpenProjects()) { try { commandProcessor.executeCommand( project, new Runnable() { public void run() { canClose.set(ProjectUtil.closeAndDispose(project)); } }, ApplicationBundle.message("command.exit"), null); } catch (Throwable e) { LOG.error(e); } if (!canClose.get()) { myDisposeInProgress = false; return false; } } Disposer.dispose(this); Disposer.assertIsEmpty(); return true; }