List of usage examples for com.intellij.openapi.ui Messages showYesNoCancelDialog
@YesNoCancelResult public static int showYesNoCancelDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String yes, @NotNull String no, @NotNull String cancel, Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption)
From source file:com.intellij.util.ui.tree.AbstractFileTreeTable.java
License:Apache License
public boolean clearSubdirectoriesOnDemandOrCancel(final VirtualFile parent, final String message, final String title) { Map<VirtualFile, T> mappings = myModel.myCurrentMapping; Map<VirtualFile, T> subdirectoryMappings = new THashMap<VirtualFile, T>(); for (VirtualFile file : mappings.keySet()) { if (file != null && (parent == null || VfsUtilCore.isAncestor(parent, file, true))) { subdirectoryMappings.put(file, mappings.get(file)); }/*from w ww .j a v a 2 s .c o m*/ } if (subdirectoryMappings.isEmpty()) { return true; } int ret = Messages.showYesNoCancelDialog(myProject, message, title, "Override", "Do Not Override", "Cancel", Messages.getWarningIcon()); if (ret == 0) { for (VirtualFile file : subdirectoryMappings.keySet()) { myModel.setValueAt(null, new DefaultMutableTreeNode(file), 1); } } return ret != 2; }
From source file:org.sonarlint.intellij.trigger.SonarLintCheckinHandler.java
License:Open Source License
private ReturnResult showYesNoCancel(String resultStr) { final int answer = Messages.showYesNoCancelDialog(project, resultStr, "SonarLint Analysis Results", "Review Issues", "Commit Anyway", "Close", UIUtil.getWarningIcon()); if (answer == Messages.YES) { showChangedFilesTab();//from w w w.j ava 2s.com return ReturnResult.CLOSE_WINDOW; } else if (answer == Messages.CANCEL) { return ReturnResult.CANCEL; } else { return ReturnResult.COMMIT; } }
From source file:org.twodividedbyzero.idea.findbugs.core.CheckinHandlerFactoryImpl.java
License:Open Source License
@NotNull @Override//from w w w . j av a 2 s. c o m public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull final CommitContext commitContext) { return new CheckinHandler() { @Override public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox run = new JCheckBox(ResourcesLoader.getString("checkin.text")); return new RefreshableOnComponent() { public JComponent getComponent() { return JBUI.Panels.simplePanel().addToLeft(run); } @Override public void refresh() { } @Override public void saveState() { WorkspaceSettings.getInstance(panel.getProject()).analyzeBeforeCheckIn = run.isSelected(); } @Override public void restoreState() { run.setSelected(WorkspaceSettings.getInstance(panel.getProject()).analyzeBeforeCheckIn); } }; } @Override public ReturnResult beforeCheckin(@Nullable final CommitExecutor executor, final PairConsumer<Object, Object> additionalDataConsumer) { if (!WorkspaceSettings.getInstance(panel.getProject()).analyzeBeforeCheckIn) { return super.beforeCheckin(executor, additionalDataConsumer); } new FindBugsStarter(panel.getProject(), "Running FindBugs analysis for affected files...", ProgressStartType.Modal) { @Override protected boolean isCompileBeforeAnalyze() { return false; // CompilerManager#make start asynchronous task } @Override protected void createCompileScope(@NotNull final CompilerManager compilerManager, @NotNull final Consumer<CompileScope> consumer) { throw new UnsupportedOperationException(); } @Override protected boolean configure(@NotNull final ProgressIndicator indicator, @NotNull final FindBugsProjects projects, final boolean justCompiled) { final Collection<VirtualFile> virtualFiles = panel.getVirtualFiles(); projects.addFiles(virtualFiles, false, hasTests(virtualFiles)); return true; } }.start(); final ToolWindowPanel toolWindowPanel = ToolWindowPanel.getInstance(panel.getProject()); if (toolWindowPanel != null && toolWindowPanel.getResult() != null) { if (!toolWindowPanel.getResult().isBugCollectionEmpty()) { // Based on com.intellij.openapi.vcs.checkin.CodeAnalysisBeforeCheckinHandler#processFoundCodeSmells String commitButtonText = executor != null ? executor.getActionText() : panel.getCommitActionName(); commitButtonText = StringUtil.trimEnd(commitButtonText, "..."); final int answer = Messages.showYesNoCancelDialog(panel.getProject(), ResourcesLoader.getString("checkin.problem.text"), StringUtil.capitalizeWords(ResourcesLoader.getString("checkin.problem.title"), true), ResourcesLoader.getString("checkin.problem.review"), commitButtonText, CommonBundle.getCancelButtonText(), UIUtil.getWarningIcon()); if (answer == Messages.YES) { ToolWindowPanel.showWindow(panel.getProject()); return ReturnResult.CLOSE_WINDOW; } else if (answer == Messages.CANCEL) { return ReturnResult.CANCEL; } } } return super.beforeCheckin(executor, additionalDataConsumer); } }; }