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.evosuite.intellij.EvoStartDialog.java

License:Open Source License

private void onSelectJavaHome() {

    String jdkStartLocation = getJDKStartLocation();

    JFileChooser fc = new JFileChooser(jdkStartLocation);
    fc.setAcceptAllFileFilterUsed(false);
    fc.setFileFilter(new FileFilter() {
        @Override/*from  www  .  j  a  va 2  s.c  o m*/
        public boolean accept(File file) {
            //return checkIfValidJavaHome(file);
            return true; //otherwise all folders will be greyed out
        }

        @Override
        public String getDescription() {
            return "Java Home (containing bin/javac)";
        }
    });
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    int returnVal = fc.showOpenDialog(null);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        String path = fc.getSelectedFile().getAbsolutePath();

        if (!checkIfValidJavaHome(new File(path))) {
            Messages.showMessageDialog(project,
                    "Invalid JDK home: choose a correct one that contains bin/javac", "EvoSuite Plugin",
                    Messages.getErrorIcon());
            return;
        }

        params.setJavaHome(path);
        javaHomeField.setText(path);
    }
}

From source file:org.evosuite.intellij.EvoStartDialog.java

License:Open Source License

private boolean saveParameters(boolean validate) {

    int cores = ((Number) coreField.getValue()).intValue();
    int memory = ((Number) memoryField.getValue()).intValue();
    int time = ((Number) timeField.getValue()).intValue();
    String dir = folderField.getText();
    String mvn = mavenField.getText();
    String javaHome = javaHomeField.getText();
    String evosuiteJar = evosuiteLocationTesxField.getText();

    List<String> errors = new ArrayList<>();

    if (cores < 1) {
        errors.add("Number of cores needs to be positive value");
    } else {//from   w  w w .j av a  2 s .  co  m
        params.setCores(cores);
    }

    if (memory < 1) {
        errors.add("Memory needs to be a positive value");
    } else {
        params.setMemory(memory);
    }

    if (time < 1) {
        errors.add("Duration needs to be a positive value");
    } else {
        params.setTime(time);
    }

    if (params.usesMaven() && !checkIfValidMaven(new File(mvn))) {
        errors.add("Invalid Maven executable: choose a correct one");
    } else {
        params.setMvnLocation(mvn);
    }

    if (!params.usesMaven() && !checkIfValidEvoSuiteJar(new File(evosuiteJar))) {
        errors.add("Invalid EvoSuite executable jar: choose a correct evosuite*.jar one");
    } else {
        params.setEvosuiteJarLocation(evosuiteJar);
    }

    if (!checkIfValidJavaHome(new File(javaHome))) {
        errors.add("Invalid JDK home: choose a correct one that contains bin/javac");
    } else {
        params.setJavaHome(javaHome);
    }

    params.setFolder(dir);
    params.setGuiWidth(this.getWidth());
    params.setGuiHeight(this.getHeight());

    if (validate && !errors.isEmpty()) {
        String title = "ERROR: EvoSuite Plugin";
        String msg = String.join("\n", errors);
        Messages.showMessageDialog(project, msg, title, Messages.getErrorIcon());
        return false;
    }

    return true;
}

From source file:org.intellij.images.editor.impl.ImageEditorUI.java

License:Apache License

ImageEditorUI(@Nullable ImageEditor editor) {
    this.editor = editor;

    imageComponent.addPropertyChangeListener(ZOOM_FACTOR_PROP,
            e -> imageComponent.setZoomFactor(getZoomModel().getZoomFactor()));
    Options options = OptionsManager.getInstance().getOptions();
    EditorOptions editorOptions = options.getEditorOptions();
    options.addPropertyChangeListener(optionsChangeListener);

    copyPasteSupport = editor != null ? new CopyPasteDelegator(editor.getProject(), this) {
        @Nonnull/*w  w w. j a v  a  2  s . c  om*/
        @Override
        protected PsiElement[] getSelectedElements() {
            DataContext dataContext = DataManager.getInstance().getDataContext(ImageEditorUI.this);
            return ObjectUtils.notNull(dataContext.getData(LangDataKeys.PSI_ELEMENT_ARRAY),
                    PsiElement.EMPTY_ARRAY);
        }
    } : null;
    deleteProvider = new DeleteHandler.DefaultDeleteProvider();

    ImageDocument document = imageComponent.getDocument();
    document.addChangeListener(changeListener);

    // Set options
    TransparencyChessboardOptions chessboardOptions = editorOptions.getTransparencyChessboardOptions();
    GridOptions gridOptions = editorOptions.getGridOptions();
    imageComponent.setTransparencyChessboardCellSize(chessboardOptions.getCellSize());
    imageComponent.setTransparencyChessboardWhiteColor(chessboardOptions.getWhiteColor());
    imageComponent.setTransparencyChessboardBlankColor(chessboardOptions.getBlackColor());
    imageComponent.setGridLineZoomFactor(gridOptions.getLineZoomFactor());
    imageComponent.setGridLineSpan(gridOptions.getLineSpan());
    imageComponent.setGridLineColor(gridOptions.getLineColor());

    // Create layout
    ImageContainerPane view = new ImageContainerPane(imageComponent);
    view.addMouseListener(new EditorMouseAdapter());
    view.addMouseListener(new FocusRequester());

    myScrollPane = ScrollPaneFactory.createScrollPane(view, true);
    myScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Zoom by wheel listener
    myScrollPane.addMouseWheelListener(wheelAdapter);

    // Construct UI
    setLayout(new BorderLayout());

    ActionManager actionManager = ActionManager.getInstance();
    ActionGroup actionGroup = (ActionGroup) actionManager.getAction(ImageEditorActions.GROUP_TOOLBAR);
    ActionToolbar actionToolbar = actionManager.createActionToolbar(ImageEditorActions.ACTION_PLACE,
            actionGroup, true);

    // Make sure toolbar is 'ready' before it's added to component hierarchy
    // to prevent ActionToolbarImpl.updateActionsImpl(boolean, boolean) from increasing popup size unnecessarily
    actionToolbar.updateActionsImmediately();

    actionToolbar.setTargetComponent(this);

    JComponent toolbarPanel = actionToolbar.getComponent();
    toolbarPanel.addMouseListener(new FocusRequester());

    JLabel errorLabel = new JLabel(ImagesBundle.message("error.broken.image.file.format"),
            Messages.getErrorIcon(), SwingConstants.CENTER);

    JPanel errorPanel = new JPanel(new BorderLayout());
    errorPanel.add(errorLabel, BorderLayout.CENTER);

    contentPanel = new JPanel(new CardLayout());
    contentPanel.add(myScrollPane, IMAGE_PANEL);
    contentPanel.add(errorPanel, ERROR_PANEL);

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(toolbarPanel, BorderLayout.WEST);
    infoLabel = new JLabel((String) null, SwingConstants.RIGHT);
    infoLabel.setBorder(JBUI.Borders.emptyRight(2));
    topPanel.add(infoLabel, BorderLayout.EAST);

    add(topPanel, BorderLayout.NORTH);
    add(contentPanel, BorderLayout.CENTER);

    myScrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            updateZoomFactor();
        }
    });

    updateInfo();
}

From source file:org.intellij.images.ui.ThumbnailComponentUI.java

License:Apache License

private void paintError(Graphics g, ThumbnailComponent tc) {
    Font font = getSmallFont();/* w  w  w . j  a  va2s .  co m*/
    FontMetrics fontMetrics = g.getFontMetrics(font);

    Messages.getErrorIcon().paintIcon(tc, g,
            5 + (ImagesIcons.ThumbnailBlank.getIconWidth() - Messages.getErrorIcon().getIconWidth()) / 2,
            5 + (ImagesIcons.ThumbnailBlank.getIconHeight() - Messages.getErrorIcon().getIconHeight()) / 2);

    // Error
    String error = getSubmnailComponentErrorString();
    g.setColor(JBColor.RED);
    g.setFont(font);
    g.drawString(error, 8, 8 + fontMetrics.getAscent());
}

From source file:org.intellij.lang.xpath.xslt.refactoring.XsltExtractFunctionAction.java

License:Apache License

protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) {
    final String name = Messages.showInputDialog(expression.getProject(), "Function Name: ",
            getRefactoringName(), Messages.getQuestionIcon());
    final boolean[] b = new boolean[] { false };
    if (name != null) {
        final String[] parts = name.split(":", 2);
        if (parts.length < 2) {
            Messages.showMessageDialog(expression.getProject(), "Custom functions require a prefixed name",
                    "Error", Messages.getErrorIcon());
            b[0] = true;/*from   ww  w .  j  a va  2s  . c  om*/
        }
        final XmlElement context = PsiTreeUtil.getContextOfType(expression, XmlElement.class);
        final NamespaceContext namespaceContext = expression.getXPathContext().getNamespaceContext();
        if (namespaceContext != null && context != null
                && namespaceContext.resolve(parts[0], context) == null) {
            Messages.showMessageDialog(expression.getProject(), "Prefix '" + parts[0] + "' is not defined",
                    "Error", Messages.getErrorIcon());
            b[0] = true;
        }
    }
    return new RefactoringOptions() {
        @Override
        public boolean isCanceled() {
            return b[0];
        }

        @Override
        public String getName() {
            return name;
        }
    };
}

From source file:org.intellij.plugins.junit.actions.GoToTestedClassProcessor.java

License:Open Source License

public boolean isTestClass(PsiClass originClass) {
    if (!classLocator.isTestClassConform(originClass)) {
        messageHandler.showMessageDialog(
                "Current test class " + classLocator.getTestClassPath(originClass)
                        + " does not conform to the defined test organization",
                "Test Class not Conform", Messages.getErrorIcon());
        return false;
    }// w w w .  jav a 2s  .c o  m
    return true;
}

From source file:org.intellij.plugins.junit.actions.GoToUnitTestProcessor.java

License:Open Source License

public boolean isOriginClassConform() {
    if (!classLocator.isTestedClassConform(originClass)) {
        messageHandler.showMessageDialog(
                "Current class " + classLocator.getTestedClassPath(originClass)
                        + " does not comform to the defined test organization",
                "Tested Class not Conform", Messages.getErrorIcon());
        return false;
    }//from   w  ww.j  a va2s .  c o  m
    return true;
}

From source file:org.intellij.plugins.junit.JUnitHelper.java

License:Open Source License

public static boolean checkProjectCorrectlySetup(Project project) {
    if (!isJUnitInClassPath(project)) {
        Messages.showMessageDialog(project, "JUnit is not in the class path. Please add it first",
                "JUnit Test Plugin Prerequisite Not Met", Messages.getErrorIcon());
        return false;
    }//from  ww  w .  j  av  a2s.com
    return true;
}

From source file:org.intellij.plugins.xpathView.XPathEvalAction.java

License:Apache License

private boolean evaluateExpression(EvalExpressionDialog.Context context, XmlElement contextNode, Editor editor,
        Config cfg) {/* w  w  w .  j  ava  2 s . com*/
    final Project project = editor.getProject();

    try {
        final XPathSupport support = XPathSupport.getInstance();
        final XPath xpath = support.createXPath((XmlFile) contextNode.getContainingFile(),
                context.input.expression, context.input.namespaces);

        xpath.setVariableContext(new CachedVariableContext(context.input.variables, xpath, contextNode));

        // evaluate the expression on the whole document
        final Object result = xpath.evaluate(contextNode);
        LOG.debug("result = " + result);
        LOG.assertTrue(result != null, "null result?");

        if (result instanceof List<?>) {
            final List<?> list = (List<?>) result;
            if (!list.isEmpty()) {
                if (cfg.HIGHLIGHT_RESULTS) {
                    highlightResult(contextNode, editor, list);
                }
                if (cfg.SHOW_USAGE_VIEW) {
                    showUsageView(editor, xpath, contextNode, list);
                }
                if (!cfg.SHOW_USAGE_VIEW && !cfg.HIGHLIGHT_RESULTS) {
                    final String s = StringUtil.pluralize("match", list.size());
                    Messages.showInfoMessage(project, "Expression produced " + list.size() + " " + s,
                            "XPath Result");
                }
            } else {
                return Messages.showOkCancelDialog(project, "Sorry, your expression did not return any result",
                        "XPath Result", "OK", "Edit Expression", Messages.getInformationIcon()) == 1;
            }
        } else if (result instanceof String) {
            Messages.showMessageDialog("'" + result.toString() + "'", "XPath result (String)",
                    Messages.getInformationIcon());
        } else if (result instanceof Number) {
            Messages.showMessageDialog(result.toString(), "XPath result (Number)",
                    Messages.getInformationIcon());
        } else if (result instanceof Boolean) {
            Messages.showMessageDialog(result.toString(), "XPath result (Boolean)",
                    Messages.getInformationIcon());
        } else {
            LOG.error("Unknown XPath result: " + result);
        }
    } catch (XPathSyntaxException e) {
        LOG.debug(e);
        // TODO: Better layout of the error message with non-fixed size fonts
        return Messages.showOkCancelDialog(project, e.getMultilineMessage(), "XPath syntax error",
                "Edit Expression", "Cancel", Messages.getErrorIcon()) == 0;
    } catch (SAXPathException e) {
        LOG.debug(e);
        Messages.showMessageDialog(project, e.getMessage(), "XPath error", Messages.getErrorIcon());
    }
    return false;
}

From source file:org.jetbrains.android.exportSignedPackage.CheckModulePanel.java

License:Apache License

public void addError(String message) {
    JLabel label = new JLabel();
    label.setIcon(Messages.getErrorIcon());
    label.setText("<html><body><b>Error: " + message + "</b></body></html>");
    add(label);/*from   w ww . j a  va  2  s . com*/
    myHasError = true;
}