List of usage examples for com.intellij.openapi.ui Messages CANCEL
int CANCEL
To view the source code for com.intellij.openapi.ui Messages CANCEL.
Click Source Link
From source file:com.intellij.ui.mac.MacMessagesImpl.java
License:Apache License
@Messages.YesNoCancelResult public static int showAlertDialog(@NotNull String title, @NotNull String defaultText, @Nullable final String alternateText, @Nullable final String otherText, final String message, @Nullable Window window, final boolean errorStyle, @Nullable final DialogWrapper.DoNotAskOption doNotAskDialogOption) { Map<Enum, Object> params = new HashMap<Enum, Object>(); ID pool = invoke(invoke("NSAutoreleasePool", "alloc"), "init"); try {// w w w .java 2 s.com params.put(COMMON_DIALOG_PARAM_TYPE.title, nsString(title)); params.put(ALERT_DIALOG_PARAM_TYPE.defaultText, nsString(UIUtil.removeMnemonic(defaultText))); params.put(ALERT_DIALOG_PARAM_TYPE.alternateText, nsString(otherText == null ? "-1" : UIUtil.removeMnemonic(otherText))); params.put(ALERT_DIALOG_PARAM_TYPE.otherText, nsString(alternateText == null ? "-1" : UIUtil.removeMnemonic(alternateText))); // replace % -> %% to avoid formatted parameters (causes SIGTERM) params.put(COMMON_DIALOG_PARAM_TYPE.message, nsString(StringUtil.stripHtml(message == null ? "" : message, true).replace("%", "%%"))); params.put(COMMON_DIALOG_PARAM_TYPE.errorStyle, nsString(errorStyle ? "error" : "-1")); params.put(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption1, nsString(doNotAskDialogOption == null || !doNotAskDialogOption.canBeHidden() // TODO: state=!doNotAsk.shouldBeShown() ? "-1" : doNotAskDialogOption.getDoNotShowMessage())); params.put(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption2, nsString( doNotAskDialogOption != null && !doNotAskDialogOption.isToBeShown() ? "checked" : "-1")); MessageResult result = resultsFromDocumentRoot.remove(showDialog(window, "showSheet:", new DialogParamsWrapper(DialogParamsWrapper.DialogType.alert, params))); int convertedResult = convertReturnCodeFromNativeAlertDialog(result.myReturnCode, alternateText); if (doNotAskDialogOption != null && doNotAskDialogOption.canBeHidden()) { boolean operationCanceled = convertedResult == Messages.CANCEL; if (!operationCanceled || doNotAskDialogOption.shouldSaveOptionsOnCancel()) { doNotAskDialogOption.setToBeShown(!result.mySuppress, convertedResult); } } return convertedResult; } finally { invoke(pool, "release"); } }
From source file:com.intellij.ui.mac.MacMessagesImpl.java
License:Apache License
@Messages.YesNoCancelResult private static int convertReturnCodeFromNativeAlertDialog(int returnCode, String alternateText) { // DEFAULT = 1 // ALTERNATE = 0 // OTHER = -1 (cancel) int cancelCode; int code;//from ww w .ja v a 2 s . co m if (alternateText != null) { // DEFAULT = 0 // ALTERNATE = 1 // CANCEL = 2 cancelCode = Messages.CANCEL; switch (returnCode) { case 1: code = Messages.YES; break; case 0: code = Messages.NO; break; case -1: // cancel default: code = Messages.CANCEL; break; } } else { // DEFAULT = 0 // CANCEL = 1 cancelCode = 1; switch (returnCode) { case 1: code = Messages.YES; break; case -1: // cancel default: code = Messages.NO; break; } } if (cancelCode == code) { code = Messages.CANCEL; } LOG.assertTrue(code == Messages.YES || code == Messages.NO || code == Messages.CANCEL, code); return code; }
From source file:com.intellij.ui.messages.JBMacMessages.java
License:Apache License
@Override public int showYesNoCancelDialog(@NotNull String title, String message, @NotNull String defaultButton, String alternateButton, String otherButton, @Nullable Window window, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) { if (window == null) { window = getForemostWindow(null); }/* w w w . ja v a 2 s . co m*/ SheetMessage sheetMessage = new SheetMessage(window, title, message, UIUtil.getQuestionIcon(), new String[] { defaultButton, alternateButton, otherButton }, null, defaultButton, alternateButton); String resultString = sheetMessage.getResult(); int result = resultString.equals(defaultButton) ? Messages.YES : resultString.equals(alternateButton) ? Messages.NO : Messages.CANCEL; if (doNotAskOption != null) { doNotAskOption.setToBeShown(sheetMessage.toBeShown(), result); } return result; }
From source file:com.intellij.uiDesigner.designSurface.InsertComponentProcessor.java
License:Apache License
private boolean checkAddModuleDependency(final ComponentItem item, final ModuleSourceOrderEntry moduleSourceOrderEntry) { final Module ownerModule = moduleSourceOrderEntry.getOwnerModule(); int rc = Messages.showYesNoCancelDialog(myEditor, UIDesignerBundle.message("add.module.dependency.prompt", item.getClassName(), ownerModule.getName(), myEditor.getModule().getName()), UIDesignerBundle.message("add.module.dependency.title"), Messages.getQuestionIcon()); if (rc == Messages.CANCEL) { return false; }/* ww w .ja va 2 s . co m*/ if (rc == Messages.YES) { ModuleRootModificationUtil.addDependency(myEditor.getModule(), ownerModule); } return true; }
From source file:com.intellij.uiDesigner.designSurface.InsertComponentProcessor.java
License:Apache License
private boolean checkAddLibraryDependency(final ComponentItem item, final LibraryOrderEntry libraryOrderEntry) { int rc = Messages.showYesNoCancelDialog(myEditor, UIDesignerBundle.message("add.library.dependency.prompt", item.getClassName(), libraryOrderEntry.getPresentableName(), myEditor.getModule().getName()), UIDesignerBundle.message("add.library.dependency.title"), Messages.getQuestionIcon()); if (rc == Messages.CANCEL) { return false; }/*w w w. ja v a 2 s . com*/ if (rc == Messages.YES) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { final ModifiableRootModel model = ModuleRootManager.getInstance(myEditor.getModule()) .getModifiableModel(); if (libraryOrderEntry.isModuleLevel()) { copyModuleLevelLibrary(libraryOrderEntry.getLibrary(), model); } else { model.addLibraryEntry(libraryOrderEntry.getLibrary()); } model.commit(); } }); } return true; }
From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.InstallPluginAction.java
License:Apache License
private static boolean suggestToEnableInstalledPlugins(InstalledPluginsTableModel pluginsModel, Set<IdeaPluginDescriptor> disabled, Set<IdeaPluginDescriptor> disabledDependants, List<PluginNode> list) { if (!disabled.isEmpty() || !disabledDependants.isEmpty()) { String message = ""; if (disabled.size() == 1) { message += "Updated plugin '" + disabled.iterator().next().getName() + "' is disabled."; } else if (!disabled.isEmpty()) { message += "Updated plugins " + StringUtil.join(disabled, new Function<IdeaPluginDescriptor, String>() { @Override public String fun(IdeaPluginDescriptor pluginDescriptor) { return pluginDescriptor.getName(); }//from w ww .j a v a2 s . c om }, ", ") + " are disabled."; } if (!disabledDependants.isEmpty()) { message += "<br>"; message += "Updated plugin" + (list.size() > 1 ? "s depend " : " depends ") + "on disabled"; if (disabledDependants.size() == 1) { message += " plugin '" + disabledDependants.iterator().next().getName() + "'."; } else { message += " plugins " + StringUtil.join(disabledDependants, new Function<IdeaPluginDescriptor, String>() { @Override public String fun(IdeaPluginDescriptor pluginDescriptor) { return pluginDescriptor.getName(); } }, ", ") + "."; } } message += " Disabled plugins " + (disabled.isEmpty() ? "and plugins which depend on disabled " : "") + "won't be activated after restart."; int result; if (!disabled.isEmpty() && !disabledDependants.isEmpty()) { result = Messages.showYesNoCancelDialog(XmlStringUtil.wrapInHtml(message), CommonBundle.getWarningTitle(), "Enable all", "Enable updated plugin" + (disabled.size() > 1 ? "s" : ""), CommonBundle.getCancelButtonText(), Messages.getQuestionIcon()); if (result == Messages.CANCEL) return false; } else { message += "<br>Would you like to enable "; if (!disabled.isEmpty()) { message += "updated plugin" + (disabled.size() > 1 ? "s" : ""); } else { //noinspection SpellCheckingInspection message += "plugin dependenc" + (disabledDependants.size() > 1 ? "ies" : "y"); } message += "?"; result = Messages.showYesNoDialog(XmlStringUtil.wrapInHtml(message), CommonBundle.getWarningTitle(), Messages.getQuestionIcon()); if (result == Messages.NO) return false; } if (result == Messages.YES) { disabled.addAll(disabledDependants); pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true); } else if (result == Messages.NO && !disabled.isEmpty()) { pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true); } return true; } return false; }
From source file:com.microsoft.intellij.ui.azureroles.ComponentsPanel.java
License:Open Source License
/** * Listener method for remove button which * deletes the selected component./*from w w w.j av a2 s . c om*/ */ private void removeComponent() { WindowsAzureRoleComponent component = tblComponents.getSelectedObject(); // IWorkspace workspace = ResourcesPlugin.getWorkspace(); // IWorkspaceRoot root = workspace.getRoot(); // WindowsAzureRoleComponent component = listComponents.get(selIndex); try { /* First condition: Checks component is part of a JDK, * server configuration * Second condition: For not showing error message * "Disable Server JDK Configuration" * while removing server application * when server or JDK is already disabled. */ if (component.getIsPreconfigured() && (!(component.getType().equals(message("typeSrvApp")) && windowsAzureRole.getServerName() == null))) { PluginUtil.displayErrorDialog(message("jdkDsblErrTtl"), message("jdkDsblErrMsg")); } else { int choice = Messages.showYesNoDialog(message("cmpntRmvMsg"), message("cmpntRmvTtl"), Messages.getQuestionIcon()); if (choice == Messages.YES) { String cmpntPath = String.format("%s%s%s%s%s", PluginUtil.getModulePath(ModuleManager.getInstance(project) .findModuleByName(waProjManager.getProjectName())), File.separator, windowsAzureRole.getName(), message("approot"), component.getDeployName()); File file = new File(cmpntPath); // Check import source is equal to approot if (component.getImportPath().isEmpty() && file.exists()) { int selected = Messages.showYesNoCancelDialog(message("cmpntSrcRmvMsg"), message("cmpntSrcRmvTtl"), Messages.getQuestionIcon()); switch (selected) { case Messages.YES: //yes component.delete(); // tblViewer.refresh(); fileToDel.add(file); break; case Messages.NO: //no component.delete(); // tblViewer.refresh(); break; case Messages.CANCEL: //cancel break; default: break; } } else { component.delete(); // tblViewer.refresh(); fileToDel.add(file); } myModified = true; } } // if (tblComponents.getItemCount() == 0) { // // table is empty i.e. number of rows = 0 // btnRemove.setEnabled(false); // btnEdit.setEnabled(false); // } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(message("cmpntSetErrTtl"), message("cmpntRmvErrMsg"), e); } }
From source file:com.microsoftopentechnologies.intellij.ui.azureroles.ComponentsPanel.java
License:Apache License
/** * Listener method for remove button which * deletes the selected component.//from w ww . j av a 2s. co m */ private void removeComponent() { WindowsAzureRoleComponent component = tblComponents.getSelectedObject(); // IWorkspace workspace = ResourcesPlugin.getWorkspace(); // IWorkspaceRoot root = workspace.getRoot(); // WindowsAzureRoleComponent component = listComponents.get(selIndex); try { /* First condition: Checks component is part of a JDK, * server configuration * Second condition: For not showing error message * "Disable Server JDK Configuration" * while removing server application * when server or JDK is already disabled. */ if (component.getIsPreconfigured() && (!(component.getType().equals(message("typeSrvApp")) && windowsAzureRole.getServerName() == null))) { PluginUtil.displayErrorDialog(message("jdkDsblErrTtl"), message("jdkDsblErrMsg")); } else { int choice = Messages.showYesNoDialog(message("cmpntRmvMsg"), message("cmpntRmvTtl"), Messages.getQuestionIcon()); if (choice == Messages.YES) { String cmpntPath = String.format("%s%s%s%s%s", PluginUtil.getModulePath(ModuleManager.getInstance(project) .findModuleByName(waProjManager.getProjectName())), File.separator, windowsAzureRole.getName(), message("approot"), component.getDeployName()); File file = new File(cmpntPath); // Check import source is equal to approot if (component.getImportPath().isEmpty() && file.exists()) { int selected = Messages.showYesNoCancelDialog(message("cmpntSrcRmvMsg"), message("cmpntSrcRmvTtl"), Messages.getQuestionIcon()); switch (selected) { case Messages.YES: //yes component.delete(); // tblViewer.refresh(); fileToDel.add(file); break; case Messages.NO: //no component.delete(); // tblViewer.refresh(); break; case Messages.CANCEL: //cancel break; default: break; } } else { component.delete(); // tblViewer.refresh(); fileToDel.add(file); } myModified = true; } } // if (tblComponents.getItemCount() == 0) { // // table is empty i.e. number of rows = 0 // btnRemove.setEnabled(false); // btnEdit.setEnabled(false); // } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(message("cmpntSetErrTtl"), message("cmpntRmvErrMsg"), e); } }
From source file:net.groboclown.idea.p4ic.actions.P4WorkOfflineAction.java
License:Apache License
@Override public void actionPerformed(@NotNull AnActionEvent e) { Project project = getProject(e);/*from ww w . ja va 2s . c o m*/ if (project == null) { return; } final P4Vcs vcs = P4Vcs.getInstance(getProject(e)); List<P4Server> onlineServers = new ArrayList<P4Server>(); for (P4Server server : vcs.getP4Servers()) { if (server.isWorkingOnline()) { onlineServers.add(server); } } if (!onlineServers.isEmpty()) { if (Messages.showOkCancelDialog(e.getProject(), P4Bundle.message("dialog.go-offline.message", P4Bundle.applicationName()), P4Bundle.message("dialog.go-offline.title"), Messages.getQuestionIcon()) == Messages.CANCEL) { return; } for (P4Server server : onlineServers) { server.workOffline(); } } }
From source file:org.jboss.forge.plugin.idea.runtime.UIPromptImpl.java
License:Open Source License
@Override public boolean promptBoolean(final String message, final boolean defaultValue) { ApplicationManager.getApplication().invokeAndWait(new Runnable() { @Override//from ww w . j a v a 2 s .c o m public void run() { int result = Messages.showYesNoCancelDialog(message, "", Messages.getQuestionIcon()); booleanValue = result == Messages.CANCEL ? defaultValue : result == Messages.YES; } }, ModalityState.any()); return booleanValue; }