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(@Nullable Component component, String message,
            @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Usage

From source file:org.jetbrains.plugins.groovy.intentions.declaration.GrCreateSubclassAction.java

License:Apache License

@Nullable
public static PsiClass createSubclassGroovy(final GrTypeDefinition psiClass, final PsiDirectory targetDirectory,
        final String className) {
    final Project project = psiClass.getProject();
    final Ref<GrTypeDefinition> targetClass = new Ref<GrTypeDefinition>();

    new WriteCommandAction(project, getTitle(psiClass), getTitle(psiClass)) {
        @Override/*from  ww w .  j  a v  a2s .  c  om*/
        protected void run(Result result) throws Throwable {
            IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();

            final GrTypeParameterList oldTypeParameterList = psiClass.getTypeParameterList();

            try {
                targetClass.set(CreateClassActionBase.createClassByType(targetDirectory, className,
                        PsiManager.getInstance(project), psiClass, GroovyTemplates.GROOVY_CLASS));
            } catch (final IncorrectOperationException e) {
                ApplicationManager.getApplication().invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        Messages.showErrorDialog(project,
                                CodeInsightBundle.message("intention.error.cannot.create.class.message",
                                        className) + "\n" + e.getLocalizedMessage(),
                                CodeInsightBundle.message("intention.error.cannot.create.class.title"));
                    }
                });
                return;
            }
            startTemplate(oldTypeParameterList, project, psiClass, targetClass.get(), false);
            JavaCodeStyleManager.getInstance(project).shortenClassReferences(targetClass.get());
        }
    }.execute();
    if (targetClass.get() == null)
        return null;
    if (!ApplicationManager.getApplication().isUnitTestMode() && !psiClass.hasTypeParameters()) {

        final Editor editor = CodeInsightUtil.positionCursor(project, targetClass.get().getContainingFile(),
                targetClass.get().getLBrace());
        if (editor == null)
            return targetClass.get();
        chooseAndImplement(psiClass, project, targetClass.get(), editor);
    }
    return targetClass.get();
}

From source file:org.jetbrains.plugins.ruby.rails.actions.execution.RunRailsScriptAction.java

License:Apache License

@Override
public void actionPerformed(@NotNull final AnActionEvent event) {
    final Module module = DataContextUtil.getModule(event.getDataContext());
    assert module != null;

    //Save all opened documents
    FileDocumentManager.getInstance().saveAllDocuments();

    //Show dialog
    final VirtualFile scriptsFolder = RailsUtil.getScriptsRoot(module);
    LOG.assertTrue(checkScriptsDir(module), "./script directory doesn't exist!");

    //noinspection ConstantConditions
    final RunRailsScriptDialog dialog = new RunRailsScriptDialog(module.getProject(), module.getName(),
            scriptsFolder);//  w  w w. j a v  a  2s.co m
    dialog.setTitle(RBundle.message("rails.actions.execution.run.rails.script.title"));
    dialog.show();
    if (dialog.isOK()) {
        final String scriptName = dialog.getScriptName();
        final String arguments = dialog.getArguments();

        if (!checkScriptsDir(module)) {
            final String errorMsg = RBundle.message(
                    "rails.actions.execution.run.rails.script.error.no.scripts.folder", module.getName());
            final String errorTitle = RBundle.message("rails.actions.execution.run.rails.script.error.title");
            Messages.showErrorDialog(module.getProject(), errorMsg, errorTitle);
        }

        final String scriptFolderPath = scriptsFolder.getPath();
        File scriptFile = FileLinksFilterUtil.getFileByRubyLink(scriptFolderPath + File.separator + scriptName);
        if (scriptFile == null) {
            scriptFile = FileLinksFilterUtil.getFileByRubyLink(scriptName);
        }
        if (scriptFile == null) {
            final String errorMsg = RBundle
                    .message("rails.actions.execution.run.rails.script.error.script.want.found", scriptName);
            final String errorTitle = RBundle.message("rails.actions.execution.run.rails.script.error.title");
            Messages.showErrorDialog(module.getProject(), errorMsg, errorTitle);
            return;
        }

        runRailsScript(module, scriptFile.getPath(), arguments);
    }
}

From source file:org.jetbrains.plugins.ruby.rails.actions.generators.actions.SimpleGeneratorAction.java

License:Apache License

@Override
protected boolean validateBeforeInvokeDialog(final Module module) {
    if (!RailsUtil.hasRailsSupportInSDK(RModuleUtil.getModuleOrJRubyFacetSdk(module))) {
        Messages.showErrorDialog(module.getProject(), RBundle.message("new.generate.common.error.no.rails"),
                RBundle.message("action.registered.shortcut.execute.disabled.title"));
        return false;
    }//from  w  ww  . j a v  a 2  s.  c  o  m
    return true;
}

From source file:org.jetbrains.plugins.ruby.rails.actions.generators.actions.SimpleGeneratorInputValidator.java

License:Apache License

protected void showErrorDialog(final String message) {
    Messages.showErrorDialog(myProject, message, myGeneratorAction.getErrorTitle());
}

From source file:org.jetbrains.plugins.ruby.rails.actions.generators.ReloadGeneratorsAction.java

License:Apache License

@Override
public void actionPerformed(@NotNull final AnActionEvent event) {
    final Module module = DataContextUtil.getModule(event.getDataContext());
    assert module != null;

    //Save all opened documents
    FileDocumentManager.getInstance().saveAllDocuments();

    final BaseRailsFacetConfiguration conf = RailsFacetUtil.getRailsFacetConfiguration(module);
    assert conf != null;

    if (RModuleUtil.getModuleOrJRubyFacetSdk(module) == null) {
        final String msg = RBundle.message("rails.facet.action.regenerate.generators.error.wrong.sdk");
        final String title = RBundle.message("action.registered.shortcut.execute.disabled.title");
        Messages.showErrorDialog(module.getProject(), msg, title);

        return;/*from  ww  w  .  j ava  2  s .  c  om*/
    }
    conf.reloadGenerators();
}

From source file:org.jetbrains.plugins.ruby.rails.actions.rake.RakeUtil.java

License:Apache License

/**
 * Saves all opened documents and runs rake task
 *
 * @param dataContext DataContext/* w  w  w . j a va 2  s  . c  om*/
 * @param task        RakeTask
 */
public static void runRakeTask(@NotNull final DataContext dataContext, @NotNull final RakeTask task) {
    //Save all opened documents
    FileDocumentManager.getInstance().saveAllDocuments();

    final Module module = DataContextUtil.getModule(dataContext);
    if (module == null || !RailsFacetUtil.hasRailsSupport(module)) {
        return;
    }
    final VirtualFile moduleRoot = RailsFacetUtil.getRailsAppHomeDir(module);
    if (moduleRoot == null) {
        final String msg = RBundle.message("rails.facet.action.rake.run.error.home.dir.not.found");
        Messages.showErrorDialog(module.getProject(), msg,
                RBundle.message("action.registered.shortcut.execute.disabled.title"));
        return;
    }

    final String workingDir = moduleRoot.getPath();

    // rake command
    final String rakeCmd = task.getFullCommand();
    final String title = RBundle.message("module.rails.generateapp.rake.result", rakeCmd);

    final RakeArgumentsProvider provider = new RakeArgumentsProvider(new String[0], new String[] { rakeCmd });
    final Filter[] filters = { new RFileLinksFilter(module, workingDir) };

    final Sdk sdk = RModuleUtil.getModuleOrJRubyFacetSdk(module);
    if (sdk != null) {
        GemsRunner.runGemScriptInConsoleAndRefreshModule(module, sdk, title, provider.getActions(), true, RAKE,
                workingDir, provider, null, filters, null);
        RailsFacetUtil.refreshRailsAppHomeContent(module);
    } else {
        final String msg = RBundle.message("action.registered.shortcut.execute.disabled.raketasks.msg",
                task.getFullCommand(), module.getName()) + " " + RBundle.message("sdk.no.specified");
        Messages.showErrorDialog(module.getProject(), msg,
                RBundle.message("action.registered.shortcut.execute.disabled.title"));
    }
}

From source file:org.jetbrains.plugins.ruby.rails.actions.rake.ReloadRakeTasksAction.java

License:Apache License

@Override
public void actionPerformed(@NotNull final AnActionEvent event) {
    final Module module = DataContextUtil.getModule(event.getDataContext());
    assert module != null;

    //Save all opened documents
    FileDocumentManager.getInstance().saveAllDocuments();

    final BaseRailsFacetConfiguration conf = RailsFacetUtil.getRailsFacetConfiguration(module);
    assert conf != null;

    if (RModuleUtil.getModuleOrJRubyFacetSdk(module) == null) {
        final String msg = RBundle.message("rails.facet.action.regenerate.rakeTasks.error.wrong.sdk");
        final String title = RBundle.message("action.registered.shortcut.execute.disabled.title");
        Messages.showErrorDialog(module.getProject(), msg, title);

        return;/*from   ww w . ja  v  a2s.  c o m*/
    }
    conf.reloadRakeTasks();
}

From source file:org.jetbrains.plugins.ruby.rails.actions.templates.CreateFileFromTemplateDialog.java

License:Apache License

@Override
protected void doOKAction() {
    String fileName = myAttrPanel.getFileName();
    if (fileName != null && fileName.length() == 0) {
        Messages.showErrorDialog(myAttrComponent, RBundle.message("error.please.enter.a.file.name"),
                CommonBundle.getErrorTitle());
        return;/*from   ww w  .  j a  v  a2 s  . c o m*/
    }
    doCreate(fileName);
    if (myCreatedElement != null) {
        super.doOKAction();
    }
}

From source file:org.jetbrains.plugins.ruby.rails.actions.templates.CreateFileFromTemplateDialog.java

License:Apache License

private void showErrorDialog(final Exception e) {
    Messages.showErrorDialog(myProject, filterMessage(e.getMessage()),
            RBundle.message("title.cannot.create.file"));
}

From source file:org.jetbrains.plugins.ruby.rails.facet.ui.wizard.ui.AddFacetWizard.java

License:Apache License

private boolean commitStepData(final FacetWizardStep step) {
    try {//www  .  j a va 2s.  c  om
        if (!step.validate()) {
            return false;
        }
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(myCurrentProject, e.getMessage(), e.getTitle());
        return false;
    }
    step.updateDataModel();
    return true;
}