Example usage for com.intellij.openapi.ui Messages showErrorDialog

List of usage examples for com.intellij.openapi.ui Messages showErrorDialog

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages showErrorDialog.

Prototype

public static void showErrorDialog(String message,
        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Document

Use this method only if you do not know project or component

Usage

From source file:com.android.tools.idea.wizard.NewProjectWizardDynamic.java

License:Apache License

@Override
public void init() {
    if (!AndroidSdkUtils.isAndroidSdkAvailable() || !TemplateManager.templatesAreValid()) {
        String title = "SDK problem";
        String msg = "<html>Your Android SDK is missing, out of date, or is missing templates.<br>"
                + "You can configure your SDK via <b>Configure | Project Defaults | Project Structure | SDKs</b></html>";
        Messages.showErrorDialog(msg, title);
        return;//ww w.java 2  s.com
    }
    addPaths();
    initState();
    super.init();
}

From source file:com.android.tools.idea.wizard.NewProjectWizardDynamic.java

License:Apache License

private void runFinish() {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;/*from   w w w.j av  a  2  s  .  c  om*/
    }
    GradleProjectImporter projectImporter = GradleProjectImporter.getInstance();
    String rootPath = getState().get(PROJECT_LOCATION_KEY);
    if (rootPath == null) {
        LOG.error("No root path specified for project");
        return;
    }
    File rootLocation = new File(rootPath);

    File wrapperPropertiesFilePath = GradleUtil.getGradleWrapperPropertiesFilePath(rootLocation);
    try {
        GradleUtil.updateGradleDistributionUrl(SdkConstants.GRADLE_LATEST_VERSION, wrapperPropertiesFilePath);
    } catch (IOException e) {
        // Unlikely to happen. Continue with import, the worst-case scenario is that sync fails and the error message has a "quick fix".
        LOG.warn("Failed to update Gradle wrapper file", e);
    }

    String projectName = getState().get(APPLICATION_NAME_KEY);
    if (projectName == null) {
        projectName = "Unnamed Project";
    }

    // Pick the highest language level of all the modules/form factors.
    // We have to pick the language level up front while creating the project rather than
    // just reacting to it during sync, because otherwise the user gets prompted with
    // a changing-language-level-requires-reopening modal dialog box and have to reload
    // the project
    LanguageLevel initialLanguageLevel = null;
    Iterator<FormFactor> iterator = FormFactor.iterator();
    while (iterator.hasNext()) {
        FormFactor factor = iterator.next();
        Object version = getState().get(FormFactorUtils.getLanguageLevelKey(factor));
        if (version != null) {
            LanguageLevel level = LanguageLevel.parse(version.toString());
            if (level != null && (initialLanguageLevel == null || level.isAtLeast(initialLanguageLevel))) {
                initialLanguageLevel = level;
            }
        }
    }

    try {
        projectImporter.importNewlyCreatedProject(projectName, rootLocation,
                new NewProjectImportGradleSyncListener() {
                    @Override
                    public void syncSucceeded(@NotNull final Project project) {
                        // Open files -- but wait until the Android facets are available, otherwise for example
                        // the layout editor won't add Design tabs to the file
                        StartupManagerEx manager = StartupManagerEx.getInstanceEx(project);
                        if (!manager.postStartupActivityPassed()) {
                            manager.registerPostStartupActivity(new Runnable() {
                                @Override
                                public void run() {
                                    openTemplateFiles(project);
                                }
                            });
                        } else {
                            openTemplateFiles(project);
                        }
                    }

                    private boolean openTemplateFiles(Project project) {
                        List<File> filesToOpen = myState.get(FILES_TO_OPEN_KEY);
                        assert filesToOpen != null; // Always initialized in initState
                        return TemplateUtils.openEditors(project, filesToOpen, true);
                    }
                }, null, initialLanguageLevel);
    } catch (IOException e) {
        Messages.showErrorDialog(e.getMessage(), ERROR_MSG_TITLE);
        LOG.error(e);
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(e.getMessage(), ERROR_MSG_TITLE);
        LOG.error(e);
    }
}

From source file:com.android.tools.idea.wizard.TemplateWizardModuleBuilder.java

License:Apache License

public void createModule() {
    try {/*from   w w  w  . jav a2s .  co  m*/
        myWizardState.populateDirectoryParameters();
        File projectRoot = new File(myProject.getBasePath());
        File moduleRoot = new File(projectRoot,
                (String) myWizardState.get(NewProjectWizardState.ATTR_MODULE_NAME));
        projectRoot.mkdirs();
        if (myLauncherIconStep.isStepVisible()
                && (Boolean) myWizardState.get(TemplateMetadata.ATTR_CREATE_ICONS)) {
            myWizardState.getLauncherIconState().outputImages(moduleRoot);
        }
        myWizardState.updateParameters();
        myWizardState.myTemplate.render(projectRoot, moduleRoot, myWizardState.myParameters);
        if (myActivityTemplateParameterStep.isStepVisible()
                && (Boolean) myWizardState.get(NewProjectWizardState.ATTR_CREATE_ACTIVITY)) {
            myWizardState.getActivityTemplateState().getTemplate().render(moduleRoot, moduleRoot,
                    myWizardState.getActivityTemplateState().myParameters);
        }
        GradleProjectImporter.getInstance().reImportProject(myProject);
    } catch (Exception e) {
        Messages.showErrorDialog(e.getMessage(), "New Module");
        LOG.error(e);
    }
}

From source file:com.arcbees.plugin.idea.wizards.createpresenter.CreatePresenterAction.java

License:Apache License

private void error(String message) {
    Messages.showErrorDialog(message, "Error");
}

From source file:com.atlassian.theplugin.idea.autoupdate.PluginDownloader.java

License:Apache License

public void run() {
    try {/*from  w  w w .ja v  a 2s . c o  m*/
        final File tmpDownloadFile = downloadPluginFromServer(this.newVersion.getDownloadUrl(),
                new File(PathManager.getPluginsPath()));

        // add startup actions

        // todo lguminski/jjaroczynski to find a better way of getting plugin descriptor
        // theoritically openapi should provide a method so the plugin could get info on itself

        IdeaPluginDescriptor pluginDescr = PluginManager
                .getPlugin(PluginId.getId(PluginUtil.getInstance().getPluginId()));
        /* todo lguminsk when you debug the plugin it appears in registry as attlassian-idea-plugin, but when
            you rinstall it notmally it appears as Atlassian. Thats why it is double checked here
            */
        if (pluginDescr == null) {
            pluginDescr = PluginManager.getPlugin(PluginId.getId(PluginUtil.getInstance().getName()));
        }

        if (pluginDescr == null) {
            IdeaActionScheduler.getInstance().invokeLater(new Runnable() {
                public void run() {
                    // todo add project or parent to the below window
                    Messages.showErrorDialog("Cannot retrieve plugin descriptor", "Error installing plugin");
                }
            });
            return;
        }
        addActions(pluginDescr, tmpDownloadFile);

        // restart IDEA
        promptShutdownAndShutdown();

    } catch (final IOException e) {
        PluginUtil.getLogger().warn(e.getMessage(), e);
        IdeaActionScheduler.getInstance().invokeLater(new Runnable() {
            public void run() {
                Messages.showErrorDialog(e.getMessage(), "Error downloading and installing plugin");
            }
        });

    }
}

From source file:com.boxysystems.libraryfinder.view.intellij.actions.OpenHelpAction.java

License:Apache License

public void actionPerformed(AnActionEvent anActionEvent) {
    try {// www .  j  av a 2s  . c om
        BrowserUtil.launchBrowser(Constants.PLUGIN_HOME_PAGE);
    } catch (Exception e) {
        Messages.showErrorDialog(
                "Error launching browser! " + Constants.NEW_LINE + "Exception: " + e.getMessage(), "Error");
    }
}

From source file:com.eightbitmage.moonscript.debugger.MoonDebugProcess.java

License:Apache License

public void sessionInitialized() {
    super.sessionInitialized();
    ProgressManager.getInstance().run(new Task.Backgroundable(null, "Connecting to debugger", false) {

        public void run(@NotNull ProgressIndicator indicator) {
            indicator.setText("Connecting to debugger...");
            log.debug("connecting");
            try {
                controller.waitForConnect();

                log.debug("connected");
                indicator.setText("... Debugger connected");

                getSession().rebuildViews();

                registerBreakpoints();/*from  w  w w. j  a  v a2  s .  co  m*/

                controller.resume();
            } catch (final Exception e) {

                if (executionResult != null && executionResult.getProcessHandler() != null)
                    executionResult.getProcessHandler().destroyProcess();

                if (!myClosing)
                    SwingUtilities.invokeLater(new Runnable() {

                        public void run() {
                            Messages.showErrorDialog((new StringBuilder())
                                    .append("Unable to establish connection with debugger:\n")
                                    .append(e.getMessage()).toString(), "Connecting to debugger");
                        }
                    });
            }
        }
    });
}

From source file:com.facebook.buck.plugin.intellij.ui.BuckUI.java

License:Apache License

public void showErrorMessage(String message) {
    Preconditions.checkNotNull(message);
    Messages.showErrorDialog(message, "Buck");
}

From source file:com.github.cssxfire.CssXFireConnector.java

License:Apache License

public void initComponent() {
    // start web server
    try {//from w  w  w. j  ava2  s.  co m
        webServer = new SimpleWebServer();
        new Thread(webServer).start();
        initialized = true;
    } catch (BindException e) {
        LOG.error("Unable to start web server - address in use: ", e);
        Messages.showErrorDialog(
                "Unable to start SimpleWebServer on localhost:6776 - address is in use.\n\nCSS-X-Fire will be disabled until restart of "
                        + ApplicationNamesInfo.getInstance().getFullProductName(),
                "CSS-X-Fire Error");
    } catch (IOException e) {
        LOG.error("Unable to start web server: ", e);
        Messages.showErrorDialog("Unable to start SimpleWebServer on localhost:6776 - " + e.getMessage()
                + "\n\nCSS-X-Fire will be disabled until restart of "
                + ApplicationNamesInfo.getInstance().getFullProductName(), "CSS-X-Fire Error");
    }
}

From source file:com.google.cloud.tools.intellij.debugger.CloudDebugProcess.java

License:Apache License

@Override
public boolean checkCanPerformCommands() {
    Messages.showErrorDialog(
            "The Cloud Debugger does not pause execution. Therefore, this feature is unavailable.",
            "Not Supported");
    return false;
}