List of usage examples for com.intellij.openapi.ui Messages showYesNoDialog
@YesNoResult public static int showYesNoDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String yesText, @NotNull String noText, @Nullable Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption)
From source file:net.andydvorak.intellij.lessc.ui.configurable.VfsLocationChangeDialog.java
License:Apache License
public synchronized boolean shouldCopyCssFile(final VirtualFileEvent virtualFileEvent) { DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { @Override// w w w . java 2 s.c om public boolean isToBeShown() { return myLessProjectState.isPromptOnCopy(); } @Override public void setToBeShown(boolean value, int exitCode) { myLessProjectState.setPromptOnCopy(value); } @Override public boolean canBeHidden() { return true; } @Override public boolean shouldSaveOptionsOnCancel() { return true; } @Override public String getDoNotShowMessage() { return UIBundle.message("do.not.ask.me.again"); } }; if (option.isToBeShown()) { if (System.currentTimeMillis() - lastPrompt > promptIntervalMillis) { result = Messages.showYesNoDialog( UIBundle.message("vfs.copy.message", virtualFileEvent.getFileName()), UIBundle.message("vfs.copy.title"), // Title UIBundle.message("vfs.copy.yes"), // "Yes" button text UIBundle.message("vfs.copy.no"), // "No" button text Messages.getQuestionIcon(), option); } } else { result = myLessProjectState.isCopyCssFiles() ? DialogWrapper.OK_EXIT_CODE : DialogWrapper.CANCEL_EXIT_CODE; } lastPrompt = System.currentTimeMillis(); final boolean shouldCopy = result == DialogWrapper.OK_EXIT_CODE; myLessProjectState.setCopyCssFiles(shouldCopy); return shouldCopy; }
From source file:net.andydvorak.intellij.lessc.ui.configurable.VfsLocationChangeDialog.java
License:Apache License
public synchronized boolean shouldDeleteCssFile(final VirtualFileEvent virtualFileEvent) { DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { @Override// w w w .j a v a 2 s .c om public boolean isToBeShown() { return myLessProjectState.isPromptOnDelete(); } @Override public void setToBeShown(boolean value, int exitCode) { myLessProjectState.setPromptOnDelete(value); } @Override public boolean canBeHidden() { return true; } @Override public boolean shouldSaveOptionsOnCancel() { return true; } @Override public String getDoNotShowMessage() { return UIBundle.message("do.not.ask.me.again"); } }; if (option.isToBeShown()) { if (System.currentTimeMillis() - lastPrompt > promptIntervalMillis) { result = Messages.showYesNoDialog( UIBundle.message("vfs.delete.message", virtualFileEvent.getFileName()), UIBundle.message("vfs.delete.title"), // Title UIBundle.message("vfs.delete.yes"), // "Yes" button text UIBundle.message("vfs.delete.no"), // "No" button text Messages.getQuestionIcon(), option); } } else { result = myLessProjectState.isDeleteCssFiles() ? DialogWrapper.OK_EXIT_CODE : DialogWrapper.CANCEL_EXIT_CODE; } lastPrompt = System.currentTimeMillis(); final boolean shouldDelete = result == DialogWrapper.OK_EXIT_CODE; myLessProjectState.setDeleteCssFiles(shouldDelete); return shouldDelete; }
From source file:net.groboclown.idea.p4ic.v2.ui.alerts.InvalidRootsHandler.java
License:Apache License
@Override public void handleError(@NotNull final Date when) { LOG.warn("Invalid client root", getException()); if (isInvalid()) { return;// w w w. j a va2 s . co m } final List<VirtualFile> vcsRoots = getVcs().getVcsRoots(); List<String> vcsPresentableRoots = new ArrayList<String>(vcsRoots.size()); for (VirtualFile vcsRoot : vcsRoots) { vcsPresentableRoots.add(vcsRoot.getPresentableName()); } int result; if (workspaceRoots.isEmpty()) { result = Messages.showYesNoDialog(getProject(), P4Bundle.message("error.config.no-workspace-roots"), P4Bundle.message("error.config.invalid-roots.title", clientServerId.getClientId()), P4Bundle.message("error.config.invalid-roots.yes"), P4Bundle.message("error.config.invalid-roots.no"), Messages.getErrorIcon()); } else { result = Messages.showYesNoDialog(getProject(), P4Bundle.message("error.config.invalid-roots", workspaceRoots, vcsPresentableRoots), P4Bundle.message("error.config.invalid-roots.title", clientServerId.getClientId()), P4Bundle.message("error.config.invalid-roots.yes"), P4Bundle.message("error.config.invalid-roots.no"), Messages.getErrorIcon()); } if (result == Messages.YES) { // Signal to the API to try again only if // the user selected "okay". tryConfigChange(false); } // Don't go offline if not changed. }
From source file:net.groboclown.idea.p4ic.v2.ui.alerts.SSLKeyStrengthProblemHandler.java
License:Apache License
@Override public void handleError(@NotNull final Date when) { LOG.warn("SSL key strength problem", getException()); if (isInvalid()) { return;/*from www . jav a 2 s. c o m*/ } int result = Messages.showYesNoDialog(getProject(), P4Bundle.message("exception.java.ssl.keystrength-ask", System.getProperty("java.version") == null ? "<unknown>" : System.getProperty("java.version"), System.getProperty("java.vendor") == null ? "<unknown>" : System.getProperty("java.vendor"), System.getProperty("java.vendor.url") == null ? "<unknown>" : System.getProperty("java.vendor.url"), System.getProperty("java.home") == null ? "<unknown>" : System.getProperty("java.home"), getExceptionMessage()), P4Bundle.message("exception.java.ssl.keystrength-ask.title"), P4Bundle.message("dialog.confirm.edit-config"), P4Bundle.message("dialog.confirm.work-offline"), Messages.getErrorIcon()); if (result == Messages.YES) { // Signal to the API to try again only if // the user selected "okay". tryConfigChange(); } else { // Work offline goOffline(); } }
From source file:org.jetbrains.jet.plugin.framework.ui.FileUIUtils.java
License:Apache License
@Nullable public static Map<File, File> copyWithOverwriteDialog(@NotNull String messagesTitle, @NotNull Map<File, String> filesWithDestinations) { Set<String> fileNames = new HashSet<String>(); Map<File, File> targetFiles = new LinkedHashMap<File, File>(filesWithDestinations.size()); for (Map.Entry<File, String> sourceToDestination : filesWithDestinations.entrySet()) { File file = sourceToDestination.getKey(); String destinationPath = sourceToDestination.getValue(); String fileName = file.getName(); if (!fileNames.add(fileName)) { throw new IllegalArgumentException("There are several files with the same name: " + fileName); }//w ww . jav a 2 s . c o m targetFiles.put(file, new File(destinationPath, fileName)); } Collection<Map.Entry<File, File>> existentFiles = Collections2.filter(targetFiles.entrySet(), new Predicate<Map.Entry<File, File>>() { @Override public boolean apply(@Nullable Map.Entry<File, File> sourceToTarget) { assert sourceToTarget != null; return sourceToTarget.getValue().exists(); } }); if (!existentFiles.isEmpty()) { String message; if (existentFiles.size() == 1) { File conflictingFile = existentFiles.iterator().next().getValue(); message = String.format("File \"%s\" already exists in %s.\nDo you want to overwrite it?", conflictingFile.getName(), conflictingFile.getParentFile().getAbsolutePath()); } else { Collection<File> conflictFiles = Collections2.transform(existentFiles, new Function<Map.Entry<File, File>, File>() { @Override public File apply(@Nullable Map.Entry<File, File> pair) { assert pair != null; return pair.getValue(); } }); message = String.format("Files already exist:\n%s\nDo you want to overwrite them?", StringUtil.join(conflictFiles, "\n")); } int replaceIfExist = Messages.showYesNoDialog(null, message, messagesTitle + ". Replace File", "Overwrite", "Cancel", Messages.getWarningIcon()); if (replaceIfExist != JOptionPane.YES_OPTION) { return null; } } for (Map.Entry<File, File> sourceToTarget : targetFiles.entrySet()) { try { String destinationPath = sourceToTarget.getValue().getParentFile().getAbsolutePath(); if (!ProjectWizardUtil.createDirectoryIfNotExists("Destination folder", destinationPath, false)) { Messages.showErrorDialog(String.format("Error during folder creating '%s'", destinationPath), messagesTitle + ". Error"); return null; } FileUtil.copy(sourceToTarget.getKey(), sourceToTarget.getValue()); LocalFileSystem.getInstance().refreshAndFindFileByIoFile(sourceToTarget.getValue()); } catch (IOException e) { Messages.showErrorDialog("Error with copy file " + sourceToTarget.getKey().getName(), messagesTitle + ". Error"); return null; } } return targetFiles; }
From source file:org.twodividedbyzero.idea.findbugs.core.AbstractSuggestionNotificationListener.java
License:Open Source License
@Override public final void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) { if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { final String desc = event.getDescription(); if (desc.equals(A_HREF_DISABLE_ANCHOR)) { final int result = Messages.showYesNoDialog(project, "Notification will be disabled for all projects.\n\n" + "Settings | Appearance & Behavior | Notifications | " + notificationGroupId + "\ncan be used to configure the notification.", "FindBugs Plugin Suggestion Notification", "Disable Notification", CommonBundle.getCancelButtonText(), Messages.getWarningIcon()); if (result == Messages.YES) { NotificationUtil.getNotificationsConfigurationImpl().changeSettings(notificationGroupId, NotificationDisplayType.NONE, false, false); notification.expire();/*from w ww .j a v a 2s. c o m*/ } else { notification.hideBalloon(); } } else { linkClicked(notification, desc); } } }
From source file:org.twodividedbyzero.idea.findbugs.core.PluginSuggestion.java
License:Open Source License
private static void showSuggestions(@NotNull final Project project, @NotNull final FindBugsPlugin findBugsPlugin, @NotNull final FindBugsPreferences preferences, @NotNull final Set<Suggestion> suggestions) { final StringBuilder sb = new StringBuilder(); for (final Suggestion suggestion : suggestions) { sb.append(" - <a href='").append(suggestion._pluginId).append("'>").append("Enable '") .append(suggestion._name).append("'</a><br>"); }//from w w w . j a va2 s . c o m sb.append("<br><a href='").append(A_HREF_DISABLE_ANCHOR).append("'>Disable Suggestion</a>"); FindBugsPluginImpl.NOTIFICATION_GROUP_PLUGIN_SUGGESTION.createNotification("FindBugs Plugin Suggestion", sb.toString(), NotificationType.INFORMATION, new NotificationListener() { @Override public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) { if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { final String desc = event.getDescription(); if (desc.equals(A_HREF_DISABLE_ANCHOR)) { final int result = Messages.showYesNoDialog(project, "Notification will be disabled for all projects.\n\n" + "Settings | Appearance & Behavior | Notifications | " + FindBugsPluginImpl.NOTIFICATION_GROUP_ID_PLUGIN_SUGGESTION + "\ncan be used to configure the notification.", "FindBugs Plugin Suggestion Notification", "Disable Notification", CommonBundle.getCancelButtonText(), Messages.getWarningIcon()); if (result == Messages.YES) { NotificationUtil.getNotificationsConfigurationImpl().changeSettings( FindBugsPluginImpl.NOTIFICATION_GROUP_ID_PLUGIN_SUGGESTION, NotificationDisplayType.NONE, false, false); notification.expire(); } else { notification.hideBalloon(); } } else { enablePlugin(project, findBugsPlugin, desc, preferences); notification.hideBalloon(); } } } }).setImportant(false).notify(project); }