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:com.intellij.conversion.impl.ConversionServiceImpl.java
License:Apache License
@NotNull @Override// w w w . j a v a2 s .co m public ConversionResult convert(@NotNull String projectPath) { try { if (!new File(projectPath).exists() || ApplicationManager.getApplication().isHeadlessEnvironment() || !isConversionNeeded(projectPath)) { return ConversionResultImpl.CONVERSION_NOT_NEEDED; } final ConversionContextImpl context = new ConversionContextImpl(projectPath); final List<ConversionRunner> converters = getConversionRunners(context); ConvertProjectDialog dialog = new ConvertProjectDialog(context, converters); dialog.show(); if (dialog.isConverted()) { saveConversionResult(context); return new ConversionResultImpl(converters); } return ConversionResultImpl.CONVERSION_CANCELED; } catch (CannotConvertException e) { LOG.info(e); Messages.showErrorDialog(IdeBundle.message("error.cannot.convert.project", e.getMessage()), IdeBundle.message("title.cannot.convert.project")); return ConversionResultImpl.ERROR_OCCURRED; } }
From source file:com.intellij.debugger.impl.DebuggerSession.java
License:Apache License
public void runToCursor(Document document, int line, final boolean ignoreBreakpoints) { try {// w ww . ja va 2 s . co m DebugProcessImpl.ResumeCommand runToCursorCommand = myDebugProcess .createRunToCursorCommand(getSuspendContext(), document, line, ignoreBreakpoints); mySteppingThroughThreads.add(runToCursorCommand.getContextThread()); resumeAction(runToCursorCommand, EVENT_STEP); } catch (EvaluateException e) { Messages.showErrorDialog(e.getMessage(), ActionsBundle.actionText(XDebuggerActions.RUN_TO_CURSOR)); } }
From source file:com.intellij.debugger.ui.breakpoints.AddWildcardBreakpointDialog.java
License:Apache License
protected void doOKAction() { if (getClassPattern().length() == 0) { Messages.showErrorDialog(myPanel, "Class pattern not specified"); return;//from w w w. java2 s .co m } if (getMethodName().length() == 0) { Messages.showErrorDialog(myPanel, "Method name not specified"); return; } super.doOKAction(); }
From source file:com.intellij.diagnostic.TestMessageBoxAction.java
License:Apache License
@Override public void actionPerformed(final AnActionEvent e) { int r = myRandom.nextInt(10); if (r < 3) { String message = wrap("Test error message.", r); Messages.showErrorDialog(message, "Test"); } else if (r < 6) { String message = wrap("Test warning message.", r); Messages.showWarningDialog(message, "Test"); } else {//from w ww . j ava2 s .c o m String message = wrap("Test info message.", r); Messages.showInfoMessage(message, "Test"); } }
From source file:com.intellij.execution.ExecutionHelper.java
License:Apache License
public static void showExceptions(@NotNull final Project myProject, @NotNull final List<? extends Exception> errors, @NotNull final List<? extends Exception> warnings, @NotNull final String tabDisplayName, @Nullable final VirtualFile file) { if (ApplicationManager.getApplication().isUnitTestMode() && !errors.isEmpty()) { throw new RuntimeException(errors.get(0)); }//from w w w . ja va 2 s . c om ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; if (errors.isEmpty() && warnings.isEmpty()) { removeContents(null, myProject, tabDisplayName); return; } final ErrorViewPanel errorTreeView = new ErrorViewPanel(myProject); try { openMessagesView(errorTreeView, myProject, tabDisplayName); } catch (NullPointerException e) { final StringBuilder builder = new StringBuilder(); builder.append("Exceptions occurred:"); for (final Exception exception : errors) { builder.append("\n"); builder.append(exception.getMessage()); } builder.append("Warnings occurred:"); for (final Exception exception : warnings) { builder.append("\n"); builder.append(exception.getMessage()); } Messages.showErrorDialog(builder.toString(), "Execution Error"); return; } addMessages(MessageCategory.ERROR, errors, errorTreeView, file, "Unknown Error"); addMessages(MessageCategory.WARNING, warnings, errorTreeView, file, "Unknown Warning"); ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null); } }); }
From source file:com.intellij.execution.ExecutionHelper.java
License:Apache License
public static void showOutput(@NotNull final Project myProject, @NotNull final ProcessOutput output, @NotNull final String tabDisplayName, @Nullable final VirtualFile file, final boolean activateWindow) { final String stdout = output.getStdout(); final String stderr = output.getStderr(); if (ApplicationManager.getApplication().isUnitTestMode() && !(stdout.isEmpty() || stderr.isEmpty())) { throw new RuntimeException("STDOUT:\n" + stdout + "\nSTDERR:\n" + stderr); }/* w w w. ja v a 2 s .c o m*/ ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; final String stdOutTitle = "[Stdout]:"; final String stderrTitle = "[Stderr]:"; final ErrorViewPanel errorTreeView = new ErrorViewPanel(myProject); try { openMessagesView(errorTreeView, myProject, tabDisplayName); } catch (NullPointerException e) { final StringBuilder builder = new StringBuilder(); builder.append(stdOutTitle).append("\n").append(stdout != null ? stdout : "<empty>") .append("\n"); builder.append(stderrTitle).append("\n").append(stderr != null ? stderr : "<empty>"); Messages.showErrorDialog(builder.toString(), "Process Output"); return; } if (!StringUtil.isEmpty(stdout)) { final String[] stdoutLines = StringUtil.splitByLines(stdout); if (stdoutLines.length > 0) { if (StringUtil.isEmpty(stderr)) { // Only stdout available errorTreeView.addMessage(MessageCategory.SIMPLE, stdoutLines, file, -1, -1, null); } else { // both stdout and stderr available, show as groups if (file == null) { errorTreeView.addMessage(MessageCategory.SIMPLE, stdoutLines, stdOutTitle, new FakeNavigatable(), null, null, null); } else { errorTreeView.addMessage(MessageCategory.SIMPLE, new String[] { stdOutTitle }, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, new String[] { "" }, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, stdoutLines, file, -1, -1, null); } } } } if (!StringUtil.isEmpty(stderr)) { final String[] stderrLines = StringUtil.splitByLines(stderr); if (stderrLines.length > 0) { if (file == null) { errorTreeView.addMessage(MessageCategory.SIMPLE, stderrLines, stderrTitle, new FakeNavigatable(), null, null, null); } else { errorTreeView.addMessage(MessageCategory.SIMPLE, new String[] { stderrTitle }, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, ArrayUtil.EMPTY_STRING_ARRAY, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, stderrLines, file, -1, -1, null); } } } errorTreeView.addMessage(MessageCategory.SIMPLE, new String[] { "Process finished with exit code " + output.getExitCode() }, null, -1, -1, null); if (activateWindow) { ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW) .activate(null); } } }); }
From source file:com.intellij.help.impl.HelpManagerImpl.java
License:Apache License
public void invokeHelp(@Nullable String id) { if (MacHelpUtil.isApplicable()) { if (MacHelpUtil.invokeHelp(id)) return; }//w w w .j a va 2 s.com if (myHelpSet == null) { myHelpSet = createHelpSet(); } //if (Registry.is("ide.help.fxbrowser")) { // if (myFXHelpBrowser == null) { // myFXHelpBrowser = new FXHelpBrowser(myHelpSet); // } // // myFXHelpBrowser.showDocumentation(id); // return; //} if (myHelpSet == null) { BrowserUtil.launchBrowser(ApplicationInfoEx.getInstanceEx().getWebHelpUrl() + id); return; } if (myBroker == null) { myBroker = new IdeaHelpBroker(myHelpSet); } Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); myBroker.setActivationWindow(activeWindow); if (id != null) { try { myBroker.setCurrentID(id); } catch (BadIDException e) { Messages.showErrorDialog(IdeBundle.message("help.topic.not.found.error", id), CommonBundle.getErrorTitle()); return; } } myBroker.setDisplayed(true); }
From source file:com.intellij.ide.actions.ExportSettingsAction.java
License:Apache License
@Override public void actionPerformed(@Nullable AnActionEvent e) { ApplicationManager.getApplication().saveSettings(); ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog( getExportableComponentsMap(true, true), true, IdeBundle.message("title.select.components.to.export"), IdeBundle.message("prompt.please.check.all.components.to.export")); if (!dialog.showAndGet()) { return;// w ww . j av a 2 s . c o m } Set<ExportableComponent> markedComponents = dialog.getExportableComponents(); if (markedComponents.isEmpty()) { return; } Set<File> exportFiles = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY); for (ExportableComponent markedComponent : markedComponents) { ContainerUtil.addAll(exportFiles, markedComponent.getExportFiles()); } final File saveFile = dialog.getExportFile(); try { if (saveFile.exists()) { final int ret = Messages.showOkCancelDialog( IdeBundle.message("prompt.overwrite.settings.file", FileUtil.toSystemDependentName(saveFile.getPath())), IdeBundle.message("title.file.already.exists"), Messages.getWarningIcon()); if (ret != Messages.OK) return; } final JarOutputStream output = new JarOutputStream( new BufferedOutputStream(new FileOutputStream(saveFile))); try { final File configPath = new File(PathManager.getConfigPath()); final HashSet<String> writtenItemRelativePaths = new HashSet<String>(); for (File file : exportFiles) { final String rPath = FileUtil.getRelativePath(configPath, file); assert rPath != null; final String relativePath = FileUtil.toSystemIndependentName(rPath); if (file.exists()) { ZipUtil.addFileOrDirRecursively(output, saveFile, file, relativePath, null, writtenItemRelativePaths); } } exportInstalledPlugins(saveFile, output, writtenItemRelativePaths); final File magicFile = new File(FileUtil.getTempDirectory(), ImportSettingsFilenameFilter.SETTINGS_JAR_MARKER); FileUtil.createIfDoesntExist(magicFile); magicFile.deleteOnExit(); ZipUtil.addFileToZip(output, magicFile, ImportSettingsFilenameFilter.SETTINGS_JAR_MARKER, writtenItemRelativePaths, null); } finally { output.close(); } ShowFilePathAction.showDialog(getEventProject(e), IdeBundle.message("message.settings.exported.successfully"), IdeBundle.message("title.export.successful"), saveFile, null); } catch (IOException e1) { Messages.showErrorDialog(IdeBundle.message("error.writing.settings", e1.toString()), IdeBundle.message("title.error.writing.file")); } }
From source file:com.intellij.ide.actions.ImportSettingsAction.java
License:Apache License
private static void doImport(String path) { final File saveFile = new File(path); try {/*from ww w. j a v a 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; } @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final ZipEntry magicEntry = new ZipFile(saveFile) .getEntry(ImportSettingsFilenameFilter.SETTINGS_JAR_MARKER); if (magicEntry == null) { Messages.showErrorDialog( IdeBundle.message("error.file.contains.no.settings.to.import", presentableFileName(saveFile), promptLocationMessage()), IdeBundle.message("title.invalid.file")); return; } MultiMap<File, ExportableComponent> fileToComponents = ExportSettingsAction .getExportableComponentsMap(false, true); List<ExportableComponent> components = getComponentsStored(saveFile, fileToComponents.values()); fileToComponents.values().retainAll(components); final ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog(fileToComponents, false, IdeBundle.message("title.select.components.to.import"), IdeBundle.message("prompt.check.components.to.import")); if (!dialog.showAndGet()) { return; } final Set<ExportableComponent> chosenComponents = dialog.getExportableComponents(); Set<String> relativeNamesToExtract = new HashSet<String>(); for (final ExportableComponent chosenComponent : chosenComponents) { final File[] exportFiles = chosenComponent.getExportFiles(); for (File exportFile : exportFiles) { final File configPath = new File(PathManager.getConfigPath()); final String rPath = FileUtil.getRelativePath(configPath, exportFile); assert rPath != null; final String relativePath = FileUtil.toSystemIndependentName(rPath); relativeNamesToExtract.add(relativePath); } } relativeNamesToExtract.add(PluginManager.INSTALLED_TXT); final File tempFile = new File(PathManager.getPluginTempPath() + "/" + saveFile.getName()); FileUtil.copy(saveFile, tempFile); File outDir = new File(PathManager.getConfigPath()); final 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"; final 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:com.intellij.ide.actions.PruneEmptyDirectoriesAction.java
License:Apache License
private static void delete(final VirtualFile file) { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { try { file.delete(PruneEmptyDirectoriesAction.class); //noinspection UseOfSystemOutOrSystemErr System.out.println("Deleted: " + file.getPresentableUrl()); } catch (IOException e) { Messages.showErrorDialog( "Cannot delete '" + file.getPresentableUrl() + "', " + e.getLocalizedMessage(), "IOException"); }// w w w . j a v a 2 s. com } }); }