Search in sources :

Example 1 with AbstractNode

use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.

the class IssueTreeModelBuilder method getPreviousNode.

@CheckForNull
private static AbstractNode getPreviousNode(AbstractNode startNode) {
    AbstractNode parent = (AbstractNode) startNode.getParent();
    if (parent == null) {
        return null;
    }
    TreeNode previous = parent.getChildBefore(startNode);
    if (previous == null) {
        return getPreviousNode(parent);
    }
    return (AbstractNode) previous;
}
Also used : AbstractNode(org.sonarlint.intellij.ui.nodes.AbstractNode) TreeNode(javax.swing.tree.TreeNode) CheckForNull(javax.annotation.CheckForNull)

Example 2 with AbstractNode

use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.

the class IssueTreeModelBuilder method getNextNode.

/**
 * Next node, either the sibling if it exists, or the sibling of the parent
 */
@CheckForNull
private static AbstractNode getNextNode(AbstractNode startNode) {
    AbstractNode parent = (AbstractNode) startNode.getParent();
    if (parent == null) {
        return null;
    }
    TreeNode after = parent.getChildAfter(startNode);
    if (after == null) {
        return getNextNode(parent);
    }
    return (AbstractNode) after;
}
Also used : AbstractNode(org.sonarlint.intellij.ui.nodes.AbstractNode) TreeNode(javax.swing.tree.TreeNode) CheckForNull(javax.annotation.CheckForNull)

Example 3 with AbstractNode

use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.

the class IssueTreeModelBuilder method setFileIssues.

private void setFileIssues(VirtualFile file, Iterable<LiveIssue> issues) {
    if (!accept(file)) {
        removeFile(file);
        return;
    }
    List<LiveIssue> filtered = filter(issues);
    if (filtered.isEmpty()) {
        removeFile(file);
        return;
    }
    boolean newFile = false;
    FileNode fNode = index.getFileNode(file);
    if (fNode == null) {
        newFile = true;
        fNode = new FileNode(file);
        index.setFileNode(fNode);
    }
    setIssues(fNode, filtered);
    if (newFile) {
        AbstractNode parent = getFilesParent();
        int idx = parent.getInsertIdx(fNode, new FileNodeComparator());
        int[] newIdx = { idx };
        model.nodesWereInserted(parent, newIdx);
        model.nodeChanged(parent);
    } else {
        model.nodeStructureChanged(fNode);
    }
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) AbstractNode(org.sonarlint.intellij.ui.nodes.AbstractNode) FileNode(org.sonarlint.intellij.ui.nodes.FileNode)

Example 4 with AbstractNode

use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.

the class TreeCellRenderer method customizeCellRenderer.

@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    AbstractNode node = (AbstractNode) value;
    node.render(this);
}
Also used : AbstractNode(org.sonarlint.intellij.ui.nodes.AbstractNode)

Example 5 with AbstractNode

use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.

the class AbstractNodeTest method testFileCount.

@Test
public void testFileCount() {
    AbstractNode child1 = mock(AbstractNode.class);
    AbstractNode child2 = mock(AbstractNode.class);
    AbstractNode child3 = mock(AbstractNode.class);
    when(child1.getFileCount()).thenReturn(1);
    when(child1.getIssueCount()).thenReturn(1);
    when(child2.getFileCount()).thenReturn(2);
    when(child2.getIssueCount()).thenReturn(2);
    when(child3.getFileCount()).thenReturn(3);
    when(child3.getIssueCount()).thenReturn(3);
    testNode.add(child1);
    testNode.add(child2);
    testNode.add(child3);
    assertThat(testNode.getFileCount()).isEqualTo(6);
    assertThat(testNode.getIssueCount()).isEqualTo(6);
    assertThat(testNode.getFileCount()).isEqualTo(6);
    assertThat(testNode.getIssueCount()).isEqualTo(6);
    // second call should be from cache
    verify(child1, times(1)).getFileCount();
    verify(child1, times(1)).getIssueCount();
}
Also used : AbstractNode(org.sonarlint.intellij.ui.nodes.AbstractNode) Test(org.junit.Test)

Aggregations

AbstractNode (org.sonarlint.intellij.ui.nodes.AbstractNode)5 CheckForNull (javax.annotation.CheckForNull)2 TreeNode (javax.swing.tree.TreeNode)2 Test (org.junit.Test)1 LiveIssue (org.sonarlint.intellij.issue.LiveIssue)1 FileNode (org.sonarlint.intellij.ui.nodes.FileNode)1