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

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

Introduction

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

Prototype

@NotNull
    public static Icon getErrorIcon() 

Source Link

Usage

From source file:org.wso2.wsf.idea.ws.util.PopupMessageUtil.java

License:Apache License

public static void popupErrorMessageBox(String errorMessage) {
    Messages.showMessageDialog(errorMessage, WSASMessageConstant.WARNING_WSAS_HEADING, Messages.getErrorIcon());
}

From source file:ru.artlebedev.idea.plugins.parser.refactoring.ParserIntroduceVariableHandler.java

License:Apache License

private String showDialog() {
    do {//from   w w w .  j a  v a2  s .c om
        String s = Messages.showInputDialog(ParserBundle.message("actions.introduceVariable.enterName"),
                ParserBundle.message("actions.introduceVariable.title"), Messages.getQuestionIcon());
        if (s == null)
            return "";
        if ("".equals(s.trim())) {
            Messages.showMessageDialog(ParserBundle.message("actions.createClass.emptyName"),
                    ParserBundle.message("actions.createClass.emptyNameTitle"), Messages.getErrorIcon());
        } else {
            return s;
        }
    } while (true);
}

From source file:wicketforge.util.WicketFileUtil.java

License:Apache License

/**
 * @param packageName   PackageName like 'com.foo.bar'
 * @param project       Project//  w  w w.  jav a2 s . co  m
 * @param module        Module
 * @return              Selected Directory or null if canceled/error
 */
@Nullable
public static PsiDirectory selectTargetDirectory(@NotNull final String packageName,
        @NotNull final Project project, @NotNull final Module module) {
    final PackageWrapper targetPackage = new PackageWrapper(PsiManager.getInstance(project), packageName);

    final VirtualFile selectedRoot = new ReadAction<VirtualFile>() {
        @Override
        protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
            VirtualFile[] roots = getResourceRoots(module);
            if (roots.length == 0)
                return;

            if (roots.length == 1) {
                result.setResult(roots[0]);
            } else {
                PsiDirectory defaultDir = PackageUtil.findPossiblePackageDirectoryInModule(module, packageName);
                result.setResult(MoveClassesOrPackagesUtil.chooseSourceRoot(targetPackage,
                        new SmartList<VirtualFile>(roots), defaultDir));
            }
        }
    }.execute().getResultObject();

    if (selectedRoot == null) {
        return null;
    }

    try {
        return new WriteCommandAction<PsiDirectory>(project,
                CodeInsightBundle.message("create.directory.command")) {
            @Override
            protected void run(@NotNull Result<PsiDirectory> result) throws Throwable {
                result.setResult(
                        RefactoringUtil.createPackageDirectoryInSourceRoot(targetPackage, selectedRoot));
            }
        }.execute().getResultObject();
    } catch (IncorrectOperationException e) {
        Messages.showMessageDialog(project, e.getMessage(), CommonBundle.getErrorTitle(),
                Messages.getErrorIcon());
        return null;
    }
}

From source file:wicketforge.util.WicketFileUtil.java

License:Apache License

/**
 * Creates and returns the file for the passed PsiClass.
 *
 * @param fileName     the name of the file to create
 * @param directory    the directory to create in
 * @param templateName the Markup Template name
 * @return the created Element from Template
 *//*from w w  w. j  a  va2  s .c  o m*/
@Nullable
public static PsiElement createFileFromTemplate(@NotNull String fileName, @NotNull PsiDirectory directory,
        @NotNull String templateName) {
    String errorMessage = RefactoringMessageUtil.checkCanCreateFile(directory, fileName);
    if (errorMessage != null) {
        Messages.showMessageDialog(directory.getProject(), errorMessage, CommonBundle.getErrorTitle(),
                Messages.getErrorIcon());
        return null;
    }

    final FileTemplate template = FileTemplateManager.getInstance().getJ2eeTemplate(templateName);

    Properties props = FileTemplateManager.getInstance().getDefaultProperties();
    props.put(Constants.PROP_WICKET_NS, WicketVersion.getVersion(directory).getNS());
    try {
        return FileTemplateUtil.createFromTemplate(template, fileName, props, directory);
    } catch (Exception e) {
        throw new RuntimeException("Unable to create template for '" + fileName + "'", e);
    }
}

From source file:wicketforge.WicketForgeUtil.java

License:Apache License

/**
 * @param packageName   PackageName like 'com.foo.bar'
 * @param project       Project// w ww .  ja v  a 2  s.  co  m
 * @param module        Module
 * @return              Selected Directory or null if canceled/error
 */
@Nullable
public static PsiDirectory selectTargetDirectory(@NotNull final String packageName,
        @NotNull final Project project, @NotNull final Module module) {
    final PackageWrapper targetPackage = new PackageWrapper(PsiManager.getInstance(project), packageName);

    final VirtualFile selectedRoot = new ReadAction<VirtualFile>() {
        protected void run(Result<VirtualFile> result) throws Throwable {
            VirtualFile[] roots = getResourceRoots(module);
            if (roots.length == 0)
                return;

            if (roots.length == 1) {
                result.setResult(roots[0]);
            } else {
                PsiDirectory defaultDir = PackageUtil.findPossiblePackageDirectoryInModule(module, packageName);
                result.setResult(MoveClassesOrPackagesUtil.chooseSourceRoot(targetPackage, roots, defaultDir));
            }
        }
    }.execute().getResultObject();

    if (selectedRoot == null) {
        return null;
    }

    try {
        return new WriteCommandAction<PsiDirectory>(project,
                CodeInsightBundle.message("create.directory.command")) {
            protected void run(Result<PsiDirectory> result) throws Throwable {
                result.setResult(
                        RefactoringUtil.createPackageDirectoryInSourceRoot(targetPackage, selectedRoot));
            }
        }.execute().getResultObject();
    } catch (IncorrectOperationException e) {
        Messages.showMessageDialog(project, e.getMessage(), CommonBundle.getErrorTitle(),
                Messages.getErrorIcon());
        return null;
    }
}

From source file:wicketforge.WicketForgeUtil.java

License:Apache License

/**
 * Creates and returns the file for the passed PsiClass.
 *
 * @param fileName     the name of the file to create
 * @param directory    the directory to create in
 * @param templateName the Markup Template name
 * @return the created Element from Template
 *//*from   w  w  w .j  a v  a  2s.c  o m*/
@Nullable
public static PsiElement createFileFromTemplate(@NotNull String fileName, @NotNull PsiDirectory directory,
        @NotNull String templateName) {
    String errorMessage = RefactoringMessageUtil.checkCanCreateFile(directory, fileName);
    if (errorMessage != null) {
        Messages.showMessageDialog(directory.getProject(), errorMessage, CommonBundle.getErrorTitle(),
                Messages.getErrorIcon());
        return null;
    }

    final FileTemplate template = FileTemplateManager.getInstance().getJ2eeTemplate(templateName);

    Properties props = FileTemplateManager.getInstance().getDefaultProperties();
    fillWicketProperties(directory, props);
    try {
        return FileTemplateUtil.createFromTemplate(template, fileName, props, directory);
    } catch (Exception e) {
        throw new RuntimeException("Unable to create template for '" + fileName + "'", e);
    }
}