List of usage examples for com.intellij.openapi.ui Messages showOkCancelDialog
@OkCancelResult public static int showOkCancelDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String okText, @NotNull String cancelText, Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption)
From source file:com.intellij.usages.UsageLimitUtil.java
License:Apache License
@NotNull public static Result showTooManyUsagesWarning(@NotNull final Project project, @NotNull final String message, @NotNull final UsageViewPresentation usageViewPresentation) { final String[] buttons = { UsageViewBundle.message("button.text.continue"), UsageViewBundle.message("button.text.abort") }; int result = runOrInvokeAndWait(new Computable<Integer>() { @Override/* w w w. ja v a 2s.c o m*/ public Integer compute() { String title = UsageViewBundle.message("find.excessive.usages.title", StringUtil.capitalize(StringUtil.pluralize(usageViewPresentation.getUsagesWord()))); return Messages.showOkCancelDialog(project, message, title, buttons[0], buttons[1], Messages.getWarningIcon()); } }); return result == Messages.OK ? Result.CONTINUE : Result.ABORT; }
From source file:io.flutter.inspections.WrongModuleTypeNotificationProvider.java
License:Open Source License
@NotNull private static EditorNotificationPanel createPanel(@NotNull Project project, @NotNull Module module) { final EditorNotificationPanel panel = new EditorNotificationPanel().icon(FlutterIcons.Flutter); panel.setText(FlutterBundle.message("flutter.support.is.not.enabled.for.module.0", module.getName())); panel.createActionLabel(FlutterBundle.message("change.module.type.to.flutter.and.reload.project"), () -> { final int message = Messages.showOkCancelDialog(project, FlutterBundle.message("updating.module.type.requires.project.reload.proceed"), FlutterBundle.message("update.module.type"), FlutterBundle.message("reload.project"), CommonBundle.getCancelButtonText(), null); if (message == Messages.YES) { FlutterModuleUtils.setFlutterModuleAndReload(module, project); }/* w w w .j a v a 2 s.c om*/ }); panel.createActionLabel(FlutterBundle.message("don.t.show.again.for.this.module"), () -> { final Set<String> ignoredModules = getIgnoredModules(project); ignoredModules.add(module.getName()); PropertiesComponent.getInstance(project).setValue(DONT_ASK_TO_CHANGE_MODULE_TYPE_KEY, StringUtil.join(ignoredModules, ",")); EditorNotifications.getInstance(project).updateAllNotifications(); }); return panel; }
From source file:org.intellij.plugins.xpathView.XPathEvalAction.java
License:Apache License
private boolean evaluateExpression(EvalExpressionDialog.Context context, XmlElement contextNode, Editor editor, Config cfg) {//w ww . j av a 2 s . c o m final Project project = editor.getProject(); try { final XPathSupport support = XPathSupport.getInstance(); final XPath xpath = support.createXPath((XmlFile) contextNode.getContainingFile(), context.input.expression, context.input.namespaces); xpath.setVariableContext(new CachedVariableContext(context.input.variables, xpath, contextNode)); // evaluate the expression on the whole document final Object result = xpath.evaluate(contextNode); LOG.debug("result = " + result); LOG.assertTrue(result != null, "null result?"); if (result instanceof List<?>) { final List<?> list = (List<?>) result; if (!list.isEmpty()) { if (cfg.HIGHLIGHT_RESULTS) { highlightResult(contextNode, editor, list); } if (cfg.SHOW_USAGE_VIEW) { showUsageView(editor, xpath, contextNode, list); } if (!cfg.SHOW_USAGE_VIEW && !cfg.HIGHLIGHT_RESULTS) { final String s = StringUtil.pluralize("match", list.size()); Messages.showInfoMessage(project, "Expression produced " + list.size() + " " + s, "XPath Result"); } } else { return Messages.showOkCancelDialog(project, "Sorry, your expression did not return any result", "XPath Result", "OK", "Edit Expression", Messages.getInformationIcon()) == 1; } } else if (result instanceof String) { Messages.showMessageDialog("'" + result.toString() + "'", "XPath result (String)", Messages.getInformationIcon()); } else if (result instanceof Number) { Messages.showMessageDialog(result.toString(), "XPath result (Number)", Messages.getInformationIcon()); } else if (result instanceof Boolean) { Messages.showMessageDialog(result.toString(), "XPath result (Boolean)", Messages.getInformationIcon()); } else { LOG.error("Unknown XPath result: " + result); } } catch (XPathSyntaxException e) { LOG.debug(e); // TODO: Better layout of the error message with non-fixed size fonts return Messages.showOkCancelDialog(project, e.getMultilineMessage(), "XPath syntax error", "Edit Expression", "Cancel", Messages.getErrorIcon()) == 0; } catch (SAXPathException e) { LOG.debug(e); Messages.showMessageDialog(project, e.getMessage(), "XPath error", Messages.getErrorIcon()); } return false; }
From source file:org.jetbrains.android.exportSignedPackage.ExportSignedPackageWizard.java
License:Apache License
private void createAndAlignApk(final String apkPath) { AndroidPlatform platform = getFacet().getConfiguration().getAndroidPlatform(); assert platform != null; String sdkPath = platform.getSdkData().getLocation(); String zipAlignPath = sdkPath + File.separatorChar + AndroidCommonUtils.toolPath(SdkConstants.FN_ZIPALIGN); File zipalign = new File(zipAlignPath); final boolean runZipAlign = zipalign.isFile(); File destFile = null;//from w w w. j av a2 s.c om try { destFile = runZipAlign ? FileUtil.createTempFile("android", ".apk") : new File(apkPath); createApk(destFile); } catch (Exception e) { showErrorInDispatchThread(e.getMessage()); } if (destFile == null) return; if (runZipAlign) { File realDestFile = new File(apkPath); final String message = AndroidCommonUtils.executeZipAlign(zipAlignPath, destFile, realDestFile); if (message != null) { showErrorInDispatchThread(message); return; } } ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { String title = AndroidBundle.message("android.export.package.wizard.title"); final Project project = getProject(); final File apkFile = new File(apkPath); final VirtualFile vApkFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(apkFile); if (vApkFile != null) { vApkFile.refresh(true, false); } if (!runZipAlign) { Messages.showWarningDialog(project, AndroidCommonBundle.message("android.artifact.building.cannot.find.zip.align.error"), title); } if (ShowFilePathAction.isSupported()) { if (Messages.showOkCancelDialog(project, AndroidBundle.message("android.export.package.success.message", apkFile.getName()), title, RevealFileAction.getActionName(), IdeBundle.message("action.close"), Messages.getInformationIcon()) == Messages.OK) { ShowFilePathAction.openFile(apkFile); } } else { Messages.showInfoMessage(project, AndroidBundle.message("android.export.package.success.message", apkFile), title); } } }, ModalityState.NON_MODAL); }
From source file:org.jetbrains.tfsIntegration.ui.ApplyLabelDialog.java
License:Apache License
protected void doOKAction() { try {/* w ww .j av a2 s.c o m*/ List<VersionControlLabel> labels = myWorkspace.getServer().getVCS().queryLabels(getLabelName(), null, null, false, null, null, false, myApplyLabelForm.getContentPane(), TFSBundle.message("checking.existing.labels")); if (!labels.isEmpty()) { String message = MessageFormat.format("Label ''{0}'' already exists.\nDo you want to update it?", getLabelName()); if (Messages.showOkCancelDialog(myProject, message, getTitle(), "Update Label", "Cancel", Messages.getQuestionIcon()) != Messages.OK) { return; } } } catch (TfsException e) { Messages.showErrorDialog(myProject, e.getMessage(), getTitle()); return; } super.doOKAction(); }
From source file:org.zmlx.hg4idea.command.HgUpdateCommand.java
License:Apache License
public static int showDiscardChangesConfirmation(@NotNull final Project project, @NotNull final String confirmationMessage) { final AtomicInteger exitCode = new AtomicInteger(); UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override/*from w w w.j a v a 2 s .co m*/ public void run() { exitCode.set(Messages.showOkCancelDialog(project, confirmationMessage, "Uncommitted Changes Problem", "&Discard Changes", "&Cancel", Messages.getWarningIcon())); } }); return exitCode.get(); }
From source file:su.opencode.shuffler.ShuffleAction.java
License:Open Source License
@Override public void actionPerformed(AnActionEvent anActionEvent) { final Project project = anActionEvent.getProject(); final GlobalSearchScope scope; String scopeName;/*w ww .java2 s . com*/ PsiElement psiElement = DataKeys.TARGET_PSI_ELEMENT.getData(anActionEvent.getDataContext()); VirtualFile directory = DataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext()); Module module = DataKeys.TARGET_MODULE.getData(anActionEvent.getDataContext()); module = module != null ? module : DataKeys.MODULE.getData(anActionEvent.getDataContext()); module = module != null ? module : DataKeys.MODULE_CONTEXT.getData(anActionEvent.getDataContext()); if (psiElement != null && psiElement instanceof PsiDirectory) { directory = ((PsiDirectory) psiElement).getVirtualFile(); scope = GlobalSearchScopes.directoryScope(project, directory, true); scopeName = directory.getName(); } else if (directory != null) { scope = GlobalSearchScopes.directoryScope(project, directory, true); scopeName = directory.getName(); } else if (module != null) { scope = module.getModuleScope(); scopeName = module.getName(); } else { scope = GlobalSearchScopes.projectProductionScope(project); scopeName = project.getName(); } String warning = String .format("Varaiable, class, and method names will be shuffled in %s, comments will be removed. \n" + "It will block Idea and may take awhile. \n" + "Do you want to shuffle?", scopeName); int exitCode = Messages.showOkCancelDialog(project, warning, "Shuffle project?", "Shuffle", "Cancel", null); if (DialogWrapper.OK_EXIT_CODE != exitCode) return; Task task = new Task.Modal(project, "Shuffling", false) { @Override public void run(@NotNull ProgressIndicator indicator) { ShuffleRunner runner = new ShuffleRunner(indicator, project, scope); runner.run(); } }; ProgressManager.getInstance().run(task); }