List of usage examples for com.intellij.openapi.ui Messages showOkCancelDialog
@OkCancelResult @Deprecated public static int showOkCancelDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, Icon icon)
From source file:com.intellij.refactoring.memberPushDown.PushDownProcessor.java
License:Apache License
protected boolean preprocessUsages(final Ref<UsageInfo[]> refUsages) { final UsageInfo[] usagesIn = refUsages.get(); final PushDownConflicts pushDownConflicts = new PushDownConflicts(myClass, myMemberInfos); pushDownConflicts.checkSourceClassConflicts(); if (usagesIn.length == 0) { if (myClass.isEnum() || myClass.hasModifierProperty(PsiModifier.FINAL)) { if (Messages.showOkCancelDialog( (myClass.isEnum()//from w ww .j ava2s. c o m ? "Enum " + myClass.getQualifiedName() + " doesn't have constants to inline to. " : "Final class " + myClass.getQualifiedName() + "does not have inheritors. ") + "Pushing members down will result in them being deleted. " + "Would you like to proceed?", JavaPushDownHandler.REFACTORING_NAME, Messages.getWarningIcon()) != DialogWrapper.OK_EXIT_CODE) { return false; } } else { String noInheritors = myClass.isInterface() ? RefactoringBundle.message("interface.0.does.not.have.inheritors", myClass.getQualifiedName()) : RefactoringBundle.message("class.0.does.not.have.inheritors", myClass.getQualifiedName()); final String message = noInheritors + "\n" + RefactoringBundle.message("push.down.will.delete.members"); final int answer = Messages.showYesNoCancelDialog(message, JavaPushDownHandler.REFACTORING_NAME, Messages.getWarningIcon()); if (answer == DialogWrapper.OK_EXIT_CODE) { myCreateClassDlg = CreateSubclassAction.chooseSubclassToCreate(myClass); if (myCreateClassDlg != null) { pushDownConflicts.checkTargetClassConflicts(null, false, myCreateClassDlg.getTargetDirectory()); return showConflicts(pushDownConflicts.getConflicts(), usagesIn); } else { return false; } } else if (answer != 1) return false; } } Runnable runnable = new Runnable() { public void run() { for (UsageInfo usage : usagesIn) { final PsiElement element = usage.getElement(); if (element instanceof PsiClass) { pushDownConflicts.checkTargetClassConflicts((PsiClass) element, usagesIn.length > 1, element); } } } }; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, RefactoringBundle.message("detecting.possible.conflicts"), true, myProject)) { return false; } return showConflicts(pushDownConflicts.getConflicts(), usagesIn); }
From source file:com.intellij.util.xml.tree.actions.DeleteDomElement.java
License:Apache License
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) { final SimpleNode selectedNode = treeView.getTree().getSelectedNode(); if (selectedNode instanceof BaseDomElementNode) { if (selectedNode instanceof DomFileElementNode) { e.getPresentation().setVisible(false); return; }/*from www. j a v a 2 s . co m*/ final DomElement domElement = ((BaseDomElementNode) selectedNode).getDomElement(); final int ret = Messages.showOkCancelDialog(getPresentationText(selectedNode) + "?", ApplicationBundle.message("action.remove"), Messages.getQuestionIcon()); if (ret == 0) { new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) { protected void run(final Result result) throws Throwable { domElement.undefine(); } }.execute(); } } }
From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.InstalledPluginsTableModel.java
License:Apache License
private void warnAboutMissedDependencies(final Boolean newVal, final IdeaPluginDescriptor... ideaPluginDescriptors) { final Set<PluginId> deps = new HashSet<PluginId>(); final List<IdeaPluginDescriptor> descriptorsToCheckDependencies = new ArrayList<IdeaPluginDescriptor>(); if (newVal) { Collections.addAll(descriptorsToCheckDependencies, ideaPluginDescriptors); } else {//from ww w. j a v a 2 s .c o m descriptorsToCheckDependencies.addAll(getAllPlugins()); descriptorsToCheckDependencies.removeAll(Arrays.asList(ideaPluginDescriptors)); for (Iterator<IdeaPluginDescriptor> iterator = descriptorsToCheckDependencies.iterator(); iterator .hasNext();) { IdeaPluginDescriptor descriptor = iterator.next(); final Boolean enabled = myEnabled.get(descriptor.getPluginId()); if (enabled == null || !enabled.booleanValue()) { iterator.remove(); } } } for (final IdeaPluginDescriptor ideaPluginDescriptor : descriptorsToCheckDependencies) { PluginManagerCore.checkDependants(ideaPluginDescriptor, new Function<PluginId, IdeaPluginDescriptor>() { @Override @Nullable public IdeaPluginDescriptor fun(final PluginId pluginId) { return PluginManager.getPlugin(pluginId); } }, new Condition<PluginId>() { @Override public boolean value(final PluginId pluginId) { Boolean enabled = myEnabled.get(pluginId); if (enabled == null) { return false; } if (newVal && !enabled.booleanValue()) { deps.add(pluginId); } if (!newVal) { if (ideaPluginDescriptor instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl) ideaPluginDescriptor).isDeleted()) { return true; } final PluginId pluginDescriptorId = ideaPluginDescriptor.getPluginId(); for (IdeaPluginDescriptor descriptor : ideaPluginDescriptors) { if (pluginId.equals(descriptor.getPluginId())) { deps.add(pluginDescriptorId); break; } } } return true; } }); } if (!deps.isEmpty()) { final String listOfSelectedPlugins = StringUtil.join(ideaPluginDescriptors, new Function<IdeaPluginDescriptor, String>() { @Override public String fun(IdeaPluginDescriptor pluginDescriptor) { return pluginDescriptor.getName(); } }, ", "); final Set<IdeaPluginDescriptor> pluginDependencies = new HashSet<IdeaPluginDescriptor>(); final String listOfDependencies = StringUtil.join(deps, new Function<PluginId, String>() { @Override public String fun(final PluginId pluginId) { final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId); assert pluginDescriptor != null; pluginDependencies.add(pluginDescriptor); return pluginDescriptor.getName(); } }, "<br>"); final String message = !newVal ? "<html>The following plugins <br>" + listOfDependencies + "<br>are enabled and depend" + (deps.size() == 1 ? "s" : "") + " on selected plugins. " + "<br>Would you like to disable them too?</html>" : "<html>The following plugins on which " + listOfSelectedPlugins + " depend" + (ideaPluginDescriptors.length == 1 ? "s" : "") + " are disabled:<br>" + listOfDependencies + "<br>Would you like to enable them?</html>"; if (Messages.showOkCancelDialog(message, newVal ? "Enable Dependant Plugins" : "Disable Plugins with Dependency on this", Messages.getQuestionIcon()) == Messages.OK) { for (PluginId pluginId : deps) { myEnabled.put(pluginId, newVal); } updatePluginDependencies(); hideNotApplicablePlugins(newVal, pluginDependencies.toArray(new IdeaPluginDescriptor[pluginDependencies.size()])); } } }
From source file:com.mediaworx.intellij.opencmsplugin.listeners.OpenCmsModuleFileChangeListener.java
License:Open Source License
/** * Presents a dialog asking the user if files are to be deleted from the VFS and handles the deletions if the user * chooses to do so//from ww w.ja v a2s . c om * @return <code>true</code> if the user elected to delete files, <code>false</code> if the user cancelled the * deletion * @throws CmsConnectionException if the connection to OpenCms failed */ private boolean deleteFiles() throws CmsConnectionException { StringBuilder msg = new StringBuilder( "Do you want to delete the following files/folders from the OpenCms VFS?"); for (VfsFileDeleteInfo vfsFileToBeDeleted : vfsFilesToBeDeleted) { msg.append("\n").append(vfsFileToBeDeleted.vfsPath); } int dlgStatus = Messages.showOkCancelDialog(msg.toString(), "Delete Files/Folders?", Messages.getQuestionIcon()); if (dlgStatus == 0) { console.clear(); plugin.showConsole(); for (VfsFileDeleteInfo deleteInfo : vfsFilesToBeDeleted) { console.info("DELETE: " + deleteInfo.vfsPath); getVfsAdapter().deleteResource(deleteInfo.vfsPath); // check export points deleteExportedFileIfNecessary(deleteInfo.vfsPath); // handle meta data files boolean isDirectory = deleteInfo.isDirectory; String metaDataFilePath = getMetaDataFilePath(deleteInfo.ocmsModule, deleteInfo.vfsPath, isDirectory); console.info("Remove meta data file " + metaDataFilePath); File metaDataFile = new File(metaDataFilePath); FileUtils.deleteQuietly(metaDataFile); refreshFiles.add(metaDataFile); if (isDirectory) { String metaFolderPath = getMetaDataFilePathWithoutSuffix(deleteInfo.ocmsModule, deleteInfo.vfsPath); console.info("Remove meta data folder " + metaFolderPath); File metaFolder = new File(metaFolderPath); FileUtils.deleteQuietly(metaFolder); refreshFiles.add(metaFolder); } } return true; } return false; }
From source file:com.mediaworx.intellij.opencmsplugin.listeners.OpenCmsModuleFileChangeListener.java
License:Open Source License
/** * Presents a dialog asking the user if files are to be moved in the VFS and handles the moves if the user * chooses to do so// w w w . j av a 2s.c o m * @return <code>true</code> if the user elected to move files, <code>false</code> if the user cancelled the * move * @throws CmsConnectionException if the connection to OpenCms failed */ private boolean moveFiles() throws CmsConnectionException { StringBuilder msg = new StringBuilder( "Do you want to move the following files/folders in the OpenCms VFS as well?"); for (VfsFileMoveInfo vfsFileToBeMoved : vfsFilesToBeMoved) { msg.append("\n").append(vfsFileToBeMoved.oldVfsPath); } int dlgStatus = Messages.showOkCancelDialog(msg.toString(), "Move Files/Folders?", Messages.getQuestionIcon()); if (dlgStatus == 0) { console.clear(); plugin.showConsole(); for (VfsFileMoveInfo moveInfo : vfsFilesToBeMoved) { try { console.info("MOVE: " + moveInfo.oldVfsPath + " to " + moveInfo.newParentPath); Folder oldParent = (Folder) getVfsAdapter().getVfsObject(moveInfo.oldParentPath); Folder newParent = (Folder) getVfsAdapter().getVfsObject(moveInfo.newParentPath); if (newParent == null) { newParent = getVfsAdapter().createFolder(moveInfo.newParentPath); } FileableCmisObject resource = (FileableCmisObject) getVfsAdapter() .getVfsObject(moveInfo.oldVfsPath); resource.move(oldParent, newParent); // handle export points handleExportPointsForMovedResources(moveInfo.oldVfsPath, moveInfo.newVfsPath, moveInfo.newIdeaVFile.getPath()); // handle meta data files handleMetaDataForMovedResources(moveInfo.oldOcmsModule, moveInfo.newOcmsModule, moveInfo.oldVfsPath, moveInfo.newVfsPath, moveInfo.newIdeaVFile.isDirectory()); } catch (CmsPermissionDeniedException e) { Messages.showDialog("Error moving files/folders." + e.getMessage(), "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); } } return true; } return false; }
From source file:com.mediaworx.intellij.opencmsplugin.listeners.OpenCmsModuleFileChangeListener.java
License:Open Source License
/** * Presents a dialog asking the user if files are to be renamed in the VFS and handles the renames if the user * chooses to do so/*from w ww . ja v a2s.c o m*/ * @return <code>true</code> if the user elected to rename files, <code>false</code> if the user cancelled the * rename * @throws CmsConnectionException if the connection to OpenCms failed */ private boolean renameFiles() throws CmsConnectionException { StringBuilder msg = new StringBuilder( "Do you want to rename the following files/folders in the OpenCms VFS as well?"); for (VfsFileRenameInfo vfsFileToBeRenamed : vfsFilesToBeRenamed) { msg.append("\n").append(vfsFileToBeRenamed.oldVfsPath).append(" -> ") .append(vfsFileToBeRenamed.newName); } int dlgStatus = Messages.showOkCancelDialog(msg.toString(), "Move Files/Folders?", Messages.getQuestionIcon()); if (dlgStatus == 0) { console.clear(); plugin.showConsole(); for (VfsFileRenameInfo renameInfo : vfsFilesToBeRenamed) { console.info("RENAME: " + renameInfo.oldVfsPath + " to " + renameInfo.newName); try { CmisObject file = getVfsAdapter().getVfsObject(renameInfo.oldVfsPath); if (file == null) { LOG.warn("Error renaming " + renameInfo.oldVfsPath + ": the resource could not be loaded through CMIS"); continue; } HashMap<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.NAME, renameInfo.newName); file.updateProperties(properties); // handle export points handleExportPointsForMovedResources(renameInfo.oldVfsPath, renameInfo.newVfsPath, renameInfo.newIdeaVFile.getPath()); // handle meta data files handleMetaDataForMovedResources(renameInfo.ocmsModule, renameInfo.ocmsModule, renameInfo.oldVfsPath, renameInfo.newVfsPath, renameInfo.newIdeaVFile.isDirectory()); } catch (CmsPermissionDeniedException e) { LOG.warn("Exception moving files - permission denied", e); Messages.showDialog("Error moving files/folders. " + e.getMessage(), "Error", new String[] { "Ok" }, 0, Messages.getErrorIcon()); } } return true; } return false; }
From source file:com.microsoft.intellij.actions.PackageAction.java
License:Open Source License
private boolean checkSdk() { String sdkPath = null;/*from w ww .j a v a 2 s . co m*/ if (AzurePlugin.IS_WINDOWS) { try { sdkPath = WindowsAzureProjectManager.getLatestAzureSdkDir(); } catch (IOException e) { log(message("error"), e); } try { if (sdkPath == null) { int choice = Messages.showOkCancelDialog(message("sdkInsErrMsg"), message("sdkInsErrTtl"), Messages.getQuestionIcon()); if (choice == Messages.OK) { Desktop.getDesktop().browse(URI.create(message("sdkInsUrl"))); } return false; } } catch (Exception ex) { // only logging the error in log file not showing anything to // end user log(message("error"), ex); return false; } } else { log("Not Windows OS, skipping getSDK"); } return true; }
From source file:com.microsoft.intellij.forms.WebSiteDeployForm.java
License:Open Source License
void deleteWebApp() { if (selectedWebSite != null) { String name = selectedWebSite.getName(); int choice = Messages.showOkCancelDialog(String.format(message("delMsg"), name), message("delTtl"), Messages.getQuestionIcon()); if (choice == Messages.OK) { try { AzureManagerImpl.getManager().deleteWebSite(selectedWebSite.getSubscriptionId(), selectedWebSite.getWebSpaceName(), name); webSiteList.remove(webSiteJList.getSelectedIndex()); webSiteConfigMap.remove(selectedWebSite); AzureSettings.getSafeInstance(AzurePlugin.project).saveWebApps(webSiteConfigMap); selectedWebSite = null;/* w w w.java 2 s . c om*/ if (webSiteConfigMap.isEmpty()) { setMessages("There are no Azure web apps in the imported subscriptions."); } else { setWebApps(webSiteConfigMap); } } catch (AzureCmdException e) { String msg = message("delWebErr") + "\n" + String.format(message("webappExpMsg"), e.getMessage()); PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e); } } } else { PluginUtil.displayErrorDialog(message("errTtl"), "Select a web app container to delete."); } }
From source file:com.microsoft.intellij.ui.AppInsightsMngmtPanel.java
License:Open Source License
private ActionListener removeButtonListener() { return new ActionListener() { public void actionPerformed(ActionEvent e) { int curSelIndex = insightsTable.getSelectedRow(); if (curSelIndex > -1) { String keyToRemove = ApplicationInsightsResourceRegistry.getKeyAsPerIndex(curSelIndex); String moduleName = MethodUtils.getModuleNameAsPerKey(myProject, keyToRemove); if (moduleName != null && !moduleName.isEmpty()) { PluginUtil.displayErrorDialog(message("aiErrTtl"), String.format(message("rsrcUseMsg"), moduleName)); } else { int choice = Messages.showOkCancelDialog(message("rsrcRmvMsg"), message("aiErrTtl"), Messages.getQuestionIcon()); if (choice == Messages.OK) { ApplicationInsightsResourceRegistry.getAppInsightsResrcList().remove(curSelIndex); AzureSettings.getSafeInstance(myProject).saveAppInsights(); ((InsightsTableModel) insightsTable.getModel()).setResources(getTableContent()); ((InsightsTableModel) insightsTable.getModel()).fireTableDataChanged(); }// ww w . j a v a 2 s . com } } } }; }
From source file:com.microsoft.intellij.ui.azureroles.AzureRolePanel.java
License:Open Source License
/** * Method checks if number of instances are equal to 1 * and caching is enabled as well as high availability * feature is on then ask input from user, * whether to turn off high availability feature * or he wants to edit instances.// w w w. ja v a 2s . co m * * @param val * @return boolean */ private boolean handleHighAvailabilityFeature(boolean val) { boolean isBackupSet = false; boolean okToProceed = val; try { /* * checks if number of instances are equal to 1 * and caching is enabled */ if (txtNoOfInstances.getText().trim().equalsIgnoreCase("1") && windowsAzureRole.getCacheMemoryPercent() > 0) { /* * Check high availability feature of any of the cache is on */ Map<String, WindowsAzureNamedCache> mapCache = windowsAzureRole.getNamedCaches(); for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator .hasNext();) { WindowsAzureNamedCache cache = (WindowsAzureNamedCache) iterator.next(); if (cache.getBackups()) { isBackupSet = true; } } /* * High availability feature of any of the cache is on. */ if (isBackupSet) { int choice = Messages.showOkCancelDialog(message("highAvailMsg"), message("highAvailTtl"), Messages.getQuestionIcon()); /* * Set High availability feature to No. */ if (choice == Messages.OK) { for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator .hasNext();) { WindowsAzureNamedCache cache = iterator.next(); if (cache.getBackups()) { cache.setBackups(false); } } okToProceed = true; waProjManager.save(); } else { /* * Stay on Role properties page. */ okToProceed = false; txtNoOfInstances.requestFocus(); } } } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog(message("cachErrTtl"), message("cachGetErMsg"), e); okToProceed = false; } return okToProceed; }