Search in sources :

Example 1 with PsIssue

use of com.android.tools.idea.gradle.structure.model.PsIssue in project android by JetBrains.

the class IssuesRenderer method render.

@NotNull
public String render(@NotNull Collection<PsIssue> issues) {
    StringBuilder buffer = new StringBuilder();
    buffer.append("<html><body><ol>");
    for (PsIssue issue : issues) {
        buffer.append("<li>").append(issue.getPath().toText(HTML)).append(": ").append(issue.getText());
        PsPath quickFixPath = issue.getQuickFixPath();
        if (quickFixPath != null) {
            buffer.append(" ").append(quickFixPath.toText(HTML));
        }
        buffer.append("</li>");
    }
    buffer.append("</ul></body></html>");
    return buffer.toString();
}
Also used : PsPath(com.android.tools.idea.gradle.structure.model.PsPath) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PsIssue

use of com.android.tools.idea.gradle.structure.model.PsIssue in project android by JetBrains.

the class IssuesViewer method display.

public void display(@NotNull Collection<PsIssue> issues) {
    if (issues.isEmpty()) {
        if (myShowEmptyText) {
            myEmptyIssuesLabel.setVisible(true);
        }
        myIssuesPanel1.setVisible(false);
        myIssuesPanel2.setVisible(false);
        myIssuesPanel3.setVisible(false);
        myIssuesPanel4.setVisible(false);
        revalidateAndRepaintPanels();
        return;
    } else {
        myEmptyIssuesLabel.setVisible(false);
        myIssuesPanel1.setVisible(true);
        myIssuesPanel2.setVisible(true);
        myIssuesPanel3.setVisible(true);
        myIssuesPanel4.setVisible(true);
    }
    Map<PsIssue.Severity, List<PsIssue>> issuesBySeverity = Maps.newHashMap();
    for (PsIssue issue : issues) {
        PsIssue.Severity severity = issue.getSeverity();
        List<PsIssue> currentIssues = issuesBySeverity.get(severity);
        if (currentIssues == null) {
            currentIssues = Lists.newArrayList();
            issuesBySeverity.put(severity, currentIssues);
        }
        currentIssues.add(issue);
    }
    List<PsIssue.Severity> severities = Lists.newArrayList(issuesBySeverity.keySet());
    Collections.sort(severities, (t1, t2) -> t1.getPriority() - t2.getPriority());
    int typeCount = severities.size();
    // There are only 4 types of issues
    assert typeCount < 5;
    // Start displaying from last to first
    int currentIssueIndex = typeCount - 1;
    PsIssue.Severity severity = severities.get(currentIssueIndex);
    List<PsIssue> group = issuesBySeverity.get(severity);
    updateTitle(((CollapsiblePanel) myIssuesPanel4), severity, group);
    renderIssues(group, myIssuesView4);
    currentIssueIndex--;
    if (currentIssueIndex < 0) {
        myIssuesPanel1.setVisible(false);
        myIssuesPanel2.setVisible(false);
        myIssuesPanel3.setVisible(false);
        revalidateAndRepaintPanels();
        return;
    }
    severity = severities.get(currentIssueIndex);
    group = issuesBySeverity.get(severity);
    updateTitle(((CollapsiblePanel) myIssuesPanel3), severity, group);
    renderIssues(group, myIssuesView3);
    currentIssueIndex--;
    if (currentIssueIndex < 0) {
        myIssuesPanel1.setVisible(false);
        myIssuesPanel2.setVisible(false);
        revalidateAndRepaintPanels();
        return;
    }
    severity = severities.get(currentIssueIndex);
    group = issuesBySeverity.get(severity);
    updateTitle(((CollapsiblePanel) myIssuesPanel2), severity, group);
    renderIssues(group, myIssuesView2);
    currentIssueIndex--;
    if (currentIssueIndex < 0) {
        myIssuesPanel1.setVisible(false);
        revalidateAndRepaintPanels();
        return;
    }
    severity = severities.get(currentIssueIndex);
    group = issuesBySeverity.get(severity);
    updateTitle(((CollapsiblePanel) myIssuesPanel1), severity, group);
    renderIssues(group, myIssuesView1);
    revalidateAndRepaintPanels();
}
Also used : List(java.util.List) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue) CollapsiblePanel(com.android.tools.idea.gradle.structure.configurables.ui.CollapsiblePanel) UiUtil.revalidateAndRepaint(com.android.tools.idea.gradle.structure.configurables.ui.UiUtil.revalidateAndRepaint)

Example 3 with PsIssue

use of com.android.tools.idea.gradle.structure.model.PsIssue in project android by JetBrains.

the class SingleModuleIssuesRenderer method render.

@Override
@NotNull
public String render(@NotNull Collection<PsIssue> issues) {
    StringBuilder buffer = new StringBuilder();
    buffer.append("<html><body><ol>");
    for (PsIssue issue : issues) {
        buffer.append("<li>").append(issue.getText());
        PsPath quickFixPath = issue.getQuickFixPath();
        if (quickFixPath != null) {
            buffer.append(" ").append(quickFixPath.toText(HTML));
        }
        String description = issue.getDescription();
        if (isNotEmpty(description)) {
            buffer.append("<br/><br/>").append(description);
        }
        buffer.append("</li>");
    }
    buffer.append("</ol></body></html>");
    return buffer.toString();
}
Also used : PsPath(com.android.tools.idea.gradle.structure.model.PsPath) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with PsIssue

use of com.android.tools.idea.gradle.structure.model.PsIssue in project android by JetBrains.

the class DependencyGraphPanel method updateIssues.

private void updateIssues(@NotNull List<AbstractDependencyNode<? extends PsAndroidDependency>> selection) {
    List<PsIssue> issues = Lists.newArrayList();
    for (AbstractDependencyNode<? extends PsAndroidDependency> node : selection) {
        for (PsAndroidDependency dependency : node.getModels()) {
            issues.addAll(myContext.getAnalyzerDaemon().getIssues().findIssues(dependency, null));
        }
    }
    displayIssues(issues);
}
Also used : PsAndroidDependency(com.android.tools.idea.gradle.structure.model.android.PsAndroidDependency) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue)

Example 5 with PsIssue

use of com.android.tools.idea.gradle.structure.model.PsIssue in project android by JetBrains.

the class PsModuleCellRenderer method customizeCellRenderer.

@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value instanceof MasterDetailsComponent.MyNode) {
        MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode) value;
        NamedConfigurable namedConfigurable = node.getConfigurable();
        if (namedConfigurable == null) {
            return;
        }
        setIcon(namedConfigurable.getIcon(expanded));
        setToolTipText(null);
        setFont(getTreeFont());
        SimpleTextAttributes textAttributes = REGULAR_ATTRIBUTES;
        if (node.isDisplayInBold()) {
            textAttributes = REGULAR_BOLD_ATTRIBUTES;
        } else if (namedConfigurable instanceof BaseNamedConfigurable) {
            PsModule module = ((BaseNamedConfigurable) namedConfigurable).getEditableObject();
            List<PsIssue> issues = myContext.getAnalyzerDaemon().getIssues().findIssues(module, IssuesByTypeAndTextComparator.INSTANCE);
            setToolTipText(getTooltipText(issues, true));
            if (!issues.isEmpty()) {
                PsIssue issue = issues.get(0);
                Color waveColor = issue.getSeverity().getColor();
                textAttributes = textAttributes.derive(STYLE_WAVED, null, null, waveColor);
            }
        }
        append(node.getDisplayName(), textAttributes);
    }
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent) List(java.util.List) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue)

Aggregations

PsIssue (com.android.tools.idea.gradle.structure.model.PsIssue)9 NotNull (org.jetbrains.annotations.NotNull)4 PsPath (com.android.tools.idea.gradle.structure.model.PsPath)3 List (java.util.List)3 PsModel (com.android.tools.idea.gradle.structure.model.PsModel)2 PsAndroidDependency (com.android.tools.idea.gradle.structure.model.android.PsAndroidDependency)2 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)2 SyncIssue (com.android.builder.model.SyncIssue)1 CollapsiblePanel (com.android.tools.idea.gradle.structure.configurables.ui.CollapsiblePanel)1 UiUtil.revalidateAndRepaint (com.android.tools.idea.gradle.structure.configurables.ui.UiUtil.revalidateAndRepaint)1 PsIssueCollection (com.android.tools.idea.gradle.structure.model.PsIssueCollection)1 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)1 PresentationData (com.intellij.ide.projectView.PresentationData)1 NodeRenderer (com.intellij.ide.util.treeView.NodeRenderer)1 CellAppearanceEx (com.intellij.openapi.roots.ui.CellAppearanceEx)1 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)1 NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)1 Cursor (java.awt.Cursor)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1