Search in sources :

Example 1 with ProjectStructureProblemDescription

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription in project intellij-community by JetBrains.

the class ArtifactValidationManagerImpl method updateProblems.

public void updateProblems(@Nullable ProjectStructureProblemsHolderImpl holder) {
    myErrorPanel.clearError();
    myProblemsForNodes.clear();
    myProblems.clear();
    if (holder != null) {
        final List<ProjectStructureProblemDescription> problemDescriptions = holder.getProblemDescriptions();
        if (problemDescriptions != null) {
            for (ProjectStructureProblemDescription description : problemDescriptions) {
                final String message = description.getMessage(false);
                List<? extends ConfigurationErrorQuickFix> quickFixes = Collections.emptyList();
                if (description instanceof ArtifactProblemDescription) {
                    final ArtifactProblemDescription artifactProblem = (ArtifactProblemDescription) description;
                    quickFixes = artifactProblem.getFixes();
                    if (artifactProblem.getPathToPlace() != null) {
                        myProblems.add(artifactProblem);
                        showProblemInTree(artifactProblem);
                    }
                }
                myErrorPanel.showError(message, quickFixes);
            }
        }
    }
    myArtifactEditor.getLayoutTreeComponent().updateTreeNodesPresentation();
}
Also used : ProjectStructureProblemDescription(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription)

Example 2 with ProjectStructureProblemDescription

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription in project intellij-community by JetBrains.

the class ErrorPaneConfigurable method refresh.

public void refresh() {
    myAlarm.cancelAllRequests();
    myAlarm.addRequest(() -> {
        final String header = "<html>" + "<header><style type='text/css'>" + "body {" + "  color: #" + ColorUtil.toHex(new JBColor(Gray.x33, UIUtil.getLabelForeground())) + ";" + "  font-family: '" + UIUtil.getLabelFont().getName() + ",serif';" + "  font-size: " + UIUtil.getLabelFont().getSize() + ";" + "}" + "li {" + "  margin-bottom: 5;" + "}" + "ol {" + "}" + "a {" + " text-decoration: none;" + "}" + "</style>" + "</header>" + "<body>";
        final StringBuilder html = new StringBuilder(header);
        int i = 0;
        html.append("<ol>");
        ConfigurationError[] errors;
        int currentStamp;
        synchronized (myLock) {
            errors = myErrors.toArray(new ConfigurationError[0]);
            currentStamp = myComputedErrorsStamp;
        }
        for (ConfigurationError error : errors) {
            i++;
            if (i > 100)
                break;
            html.append("<li>");
            String description;
            if (error instanceof ProjectConfigurationProblem) {
                //todo[nik] pass ProjectStructureProblemDescription directly and get rid of ConfigurationError at all
                ProjectStructureProblemDescription problemDescription = ((ProjectConfigurationProblem) error).getProblemDescription();
                description = problemDescription.getDescription();
                if (description == null) {
                    ProjectStructureElement place = problemDescription.getPlace().getContainingElement();
                    description = XmlStringUtil.convertToHtmlContent(problemDescription.getMessage(false));
                    if (problemDescription.canShowPlace()) {
                        description = place.getTypeName() + " <a href='http://navigate/" + i + "'>" + XmlStringUtil.convertToHtmlContent(place.getPresentableName()) + "</a>: " + StringUtil.decapitalize(description);
                    }
                } else {
                    description = XmlStringUtil.convertToHtmlContent(description);
                }
            } else {
                description = XmlStringUtil.convertToHtmlContent(error.getDescription());
            }
            if (error.canBeFixed()) {
                description += " <a href='http://fix/" + i + "'>[Fix]</a>";
            }
            html.append(description).append("</li>");
        }
        html.append("</ol></body></html>");
        myContentUpdateQueue.queue(new ShowErrorsUpdate(currentStamp, html.toString()));
        if (myOnErrorsChanged != null) {
            myOnErrorsChanged.run();
        }
    }, 100);
}
Also used : ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) ProjectConfigurationProblem(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectConfigurationProblem) ProjectStructureProblemDescription(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription) RelativePoint(com.intellij.ui.awt.RelativePoint)

Aggregations

ProjectStructureProblemDescription (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription)2 ProjectConfigurationProblem (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectConfigurationProblem)1 ProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1