List of usage examples for com.intellij.openapi.ui Messages showErrorDialog
public static void showErrorDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:io.ballerina.plugins.idea.completion.inserthandlers.AutoImportInsertHandler.java
License:Open Source License
@Override public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item) { ApplicationManager.getApplication().invokeLater(() -> { CommandProcessor.getInstance().runUndoTransparentAction(() -> { PsiElement element = item.getPsiElement(); if (element == null) { return; }/*w ww. jav a2 s . co m*/ String organizationName = element.getUserData(BallerinaCompletionUtils.ORGANIZATION_NAME); if (!(element instanceof PsiDirectory)) { return; } String packageName = ((PsiDirectory) element).getName(); PsiFile file = context.getFile(); if (!(file instanceof BallerinaFile)) { return; } Editor editor = context.getEditor(); Project project = editor.getProject(); if (suggestAlias) { alias = Messages.showInputDialog(project, "Package '" + ((PsiDirectory) element).getName() + "' already imported. Please enter an alias:", "Enter Alias", Messages.getInformationIcon()); if (alias == null || alias.isEmpty()) { Messages.showErrorDialog("Alias cannot be null or empty.", "Error"); return; } } // Import the package. autoImport(context, organizationName, packageName, alias); if (project == null) { return; } if (!isCompletionCharAtSpace(editor)) { if (suggestAlias) { // InsertHandler inserts the old package name. So we need to change it to the new alias. PsiElement currentPackageName = file.findElementAt(context.getStartOffset()); if (currentPackageName != null) { if (alias == null || alias.isEmpty()) { return; } ApplicationManager.getApplication().runWriteAction(() -> { // Add a new identifier node. PsiElement identifier = BallerinaElementFactory.createIdentifierFromText(project, alias); currentPackageName.getParent().addBefore(identifier, currentPackageName); // Delete the current identifier node. currentPackageName.delete(); }); } } if (myTriggerAutoPopup) { ApplicationManager.getApplication().runWriteAction(() -> { PsiDocumentManager.getInstance(project) .doPostponedOperationsAndUnblockDocument(editor.getDocument()); EditorModificationUtil.insertStringAtCaret(editor, ":"); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); }); } } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + 1); } // Invoke the popup. if (myTriggerAutoPopup) { // We need to invoke the popup with a delay. Otherwise it might not show. ApplicationManager.getApplication().invokeLater( () -> AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)); } }); }); }
From source file:io.flutter.actions.OpenInAndroidStudioAction.java
License:Open Source License
@Nullable private static String findAndroidStudio(@Nullable Project project) { if (project == null) { return null; }//from ww w. j a va2s . c o m final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(project); if (flutterSdk != null) { String androidSdkLocation = flutterSdk.queryFlutterConfig("android-studio-dir", true); if (androidSdkLocation != null) { if (androidSdkLocation.contains("/Android Studio 2")) { Messages.showErrorDialog(FlutterBundle.message("old.android.studio.message", File.separator), FlutterBundle.message("old.android.studio.title")); return null; } if (androidSdkLocation.endsWith("/")) { androidSdkLocation = androidSdkLocation.substring(0, androidSdkLocation.length() - 1); } final String contents = "/Contents"; // On a mac, trim off "/Contents". if (SystemInfo.isMac && androidSdkLocation.endsWith(contents)) { return androidSdkLocation.substring(0, androidSdkLocation.length() - contents.length()); } return androidSdkLocation; } } return null; }
From source file:io.flutter.FlutterStudioInitializer.java
License:Open Source License
private static void reportVersionIncompatibility(ApplicationInfo info) { Messages.showErrorDialog("The Flutter plugin requires a more recent version of Android Studio.", "Version Mismatch"); }
From source file:io.flutter.project.FlutterProjectCreator.java
License:Open Source License
public static boolean finalValidityCheckPassed(@NotNull String projectLocation) { // See AS NewProjectModel.ProjectTemplateRenderer.doDryRun() for why this is necessary. boolean couldEnsureLocationExists = WriteCommandAction.runWriteCommandAction(null, (Computable<Boolean>) () -> { try { if (VfsUtil.createDirectoryIfMissing(projectLocation) != null && FileOpUtils.create().canWrite(new File(projectLocation))) { return true; }//ww w .java2s. com } catch (Exception e) { LOG.error(String.format("Exception thrown when creating target project location: %1$s", projectLocation), e); } return false; }); if (!couldEnsureLocationExists) { String msg = "Could not ensure the target project location exists and is accessible:\n\n%1$s\n\nPlease try to specify another path."; Messages.showErrorDialog(String.format(msg, projectLocation), "Error Creating Project"); return false; } return true; }
From source file:manuylov.maxim.ocaml.toolWindow.OCamlToolWindowOpenCloseAction.java
License:Open Source License
@Override public void actionPerformed(final AnActionEvent e) { if (myOpenConsole) { final Sdk topLevelSdk = OCamlSettings.getInstance(e.getProject()).getTopLevelSdk(); if (topLevelSdk == null) { Messages.showErrorDialog( "Please select OCaml SDK to run top level interactive console (project default SDK is not a valid OCaml SDK).", "Error"); final OCamlToolWindowSettingsAction settingsAction = new OCamlToolWindowSettingsAction(myProject, new Runnable() { public void run() { Sdk choosenSdk = OCamlSettings.getInstance(e.getProject()).getTopLevelSdk(); if (choosenSdk != null) { OCamlToolWindowUtil.addAndSelectTopLevelConsoleContent(myProject, myContentManager, choosenSdk); }//from w w w. j a va 2 s . c o m } }); settingsAction.showSettingsDialog(); } else { OCamlToolWindowUtil.addAndSelectTopLevelConsoleContent(myProject, myContentManager, topLevelSdk); } } if (myCloseView && myContentManager.isSingleSelection()) { final Content selectedContent = myContentManager.getSelectedContent(); if (selectedContent != null) { myContentManager.removeContent(selectedContent, true); } } }
From source file:manuylov.maxim.ocaml.toolWindow.OCamlToolWindowUtil.java
License:Open Source License
public static void addAndSelectTopLevelConsoleContent(@Nonnull final Project project, @Nonnull final ContentManager contentManager, @Nonnull final Sdk topLevelSdk) { final OCamlTopLevelConsoleView view; try {//from w w w. j ava 2 s .c o m view = new OCamlTopLevelConsoleView(project, contentManager, topLevelSdk); } catch (final ExecutionException e) { Messages.showErrorDialog(e.getLocalizedMessage(), "Error"); return; } addAndSelectContent(contentManager, view, "Top Level #" + view.getConsoleNumber(), true); }
From source file:net.sf.logsupport.ui.util.Dialogs.java
License:Apache License
/** * Shows an info message without blocking the calling thread. * * @param message the message to show./*from w ww.jav a2 s .c o m*/ * @param title the window title. */ public static void showErrorDialog(final String message, final String title) { SwingUtilities.invokeLater(new Runnable() { public void run() { Messages.showErrorDialog(message, title); } }); }
From source file:nieldw.plugins.idea.ImportSettings.java
License:Apache License
public static void doImport(String path) { File saveFile = new File(path); try {// w w w . j a va 2 s. c o m if (!saveFile.exists()) { Messages.showErrorDialog(IdeBundle.message("error.cannot.find.file", presentableFileName(saveFile)), IdeBundle.message("title.file.not.found")); return; } ZipEntry magicEntry = new ZipFile(saveFile).getEntry("IntelliJ IDEA Global Settings"); if (magicEntry == null) { Messages.showErrorDialog( IdeBundle.message("error.file.contains.no.settings.to.import", presentableFileName(saveFile), promptLocationMessage()), IdeBundle.message("title.invalid.file")); return; } ArrayList<ExportableComponent> registeredComponents = new ArrayList<ExportableComponent>(); Map<File, Set<ExportableComponent>> filesToComponents = ExportSettingsAction .getRegisteredComponentsAndFiles(registeredComponents); List<ExportableComponent> components = getComponentsStored(saveFile, registeredComponents); ChooseComponentsToImportDialog dialog = new ChooseComponentsToImportDialog(components, filesToComponents, IdeBundle.message("title.select.components.to.import"), IdeBundle.message("prompt.check.components.to.import")); dialog.show(); if (!dialog.isOK()) return; Set<ExportableComponent> chosenComponents = dialog.getExportableComponents(); Set<String> relativeNamesToExtract = new HashSet<String>(); for (ExportableComponent chosenComponent : chosenComponents) { File[] exportFiles = chosenComponent.getExportFiles(); for (File exportFile : exportFiles) { File configPath = new File(PathManager.getConfigPath()); String rPath = FileUtil.getRelativePath(configPath, exportFile); assert rPath != null; String relativePath = FileUtil.toSystemIndependentName(rPath); relativeNamesToExtract.add(relativePath); } } relativeNamesToExtract.add(PluginManager.INSTALLED_TXT); File tempFile = new File(PathManager.getPluginTempPath() + "/" + saveFile.getName()); FileUtil.copy(saveFile, tempFile); File outDir = new File(PathManager.getConfigPath()); ImportSettingsFilenameFilter filenameFilter = new ImportSettingsFilenameFilter(relativeNamesToExtract); StartupActionScriptManager.ActionCommand unzip = new StartupActionScriptManager.UnzipCommand(tempFile, outDir, filenameFilter); StartupActionScriptManager.addActionCommand(unzip); // remove temp file StartupActionScriptManager.ActionCommand deleteTemp = new StartupActionScriptManager.DeleteCommand( tempFile); StartupActionScriptManager.addActionCommand(deleteTemp); UpdateSettings.getInstance().forceCheckForUpdateAfterRestart(); String key = ApplicationManager.getApplication().isRestartCapable() ? "message.settings.imported.successfully.restart" : "message.settings.imported.successfully"; int ret = Messages.showOkCancelDialog( IdeBundle.message(key, ApplicationNamesInfo.getInstance().getProductName(), ApplicationNamesInfo.getInstance().getFullProductName()), IdeBundle.message("title.restart.needed"), Messages.getQuestionIcon()); if (ret == Messages.OK) { ((ApplicationEx) ApplicationManager.getApplication()).restart(true); } } catch (ZipException e1) { Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file", presentableFileName(saveFile), e1.getMessage(), promptLocationMessage()), IdeBundle.message("title.invalid.file")); } catch (IOException e1) { Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file.2", presentableFileName(saveFile), e1.getMessage()), IdeBundle.message("title.error.reading.file")); } }
From source file:org.ballerinalang.plugins.idea.completion.AutoImportInsertHandler.java
License:Open Source License
@Override public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item) { ApplicationManager.getApplication().invokeLater(() -> { CommandProcessor.getInstance().runUndoTransparentAction(() -> { PsiElement element = item.getPsiElement(); if (element == null || !(element instanceof PsiDirectory)) { return; }/*from w w w . j a v a 2 s.com*/ Editor editor = context.getEditor(); Project project = editor.getProject(); if (suggestAlias) { alias = Messages.showInputDialog(project, "Package '" + ((PsiDirectory) element).getName() + "' already imported. Please enter an alias:", "Enter Alias", Messages.getInformationIcon()); if (alias == null || alias.isEmpty()) { Messages.showErrorDialog("Alias cannot be null or empty.", "Error"); return; } } // Import the package. autoImport(context, element, alias); if (project == null) { return; } if (!isCompletionCharAtSpace(editor)) { if (suggestAlias) { // InsertHandler inserts the old package name. So we need to change it to the new alias. PsiFile file = context.getFile(); PsiElement currentPackageName = file.findElementAt(context.getStartOffset()); if (currentPackageName != null) { if (alias == null || alias.isEmpty()) { return; } ApplicationManager.getApplication().runWriteAction(() -> { // Add a new identifier node. PsiElement identifier = BallerinaElementFactory.createIdentifier(project, alias); currentPackageName.getParent().addBefore(identifier, currentPackageName); // Delete the current identifier node. currentPackageName.delete(); }); } } if (myTriggerAutoPopup) { ApplicationManager.getApplication().runWriteAction(() -> { PsiDocumentManager.getInstance(project) .doPostponedOperationsAndUnblockDocument(editor.getDocument()); EditorModificationUtil.insertStringAtCaret(editor, ":"); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); }); } } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + 1); } // Invoke the popup. if (myTriggerAutoPopup) { // We need to invoke the popup with a delay. Otherwise it might not show. ApplicationManager.getApplication().invokeLater( () -> AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)); } }); }); }
From source file:org.codehaus.cargo.intellijidea.CargoDeploymentProvider.java
License:Apache License
/** * Start undeploying./* ww w . j av a 2s. c om*/ * * @param activeInstance server instance * @param deploymentModel deployment model */ public void startUndeploy(final J2EEServerInstance activeInstance, final DeploymentModel deploymentModel) { // currently we do not support this, so we don't change the status final Module module = deploymentModel.getModuleProperties().getModule(); Messages.showErrorDialog("Undeploy is not supported, yet.", "Error undeploying module '" + module.getName() + "'"); //setDeploymentStatus(activeInstance, model, DeploymentStatus.NOT_DEPLOYED); }