Search in sources :

Example 1 with PrintElementWithGraphElement

use of com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement in project intellij-community by JetBrains.

the class AbstractPrintElementGenerator method getPrintElements.

@NotNull
public Collection<PrintElementWithGraphElement> getPrintElements(int rowIndex) {
    Collection<PrintElementWithGraphElement> result = new ArrayList<>();
    Collection<SimpleRowElement> simpleRowElements = getSimpleRowElements(rowIndex);
    Map<GraphEdge, SimpleRowElement> arrows = ContainerUtil.newHashMap();
    for (SimpleRowElement rowElement : simpleRowElements) {
        if (!rowElement.myType.equals(RowElementType.NODE)) {
            arrows.put((GraphEdge) rowElement.myElement, rowElement);
        }
    }
    if (rowIndex < myLinearGraph.nodesCount() - 1) {
        for (ShortEdge shortEdge : getDownShortEdges(rowIndex)) {
            RowElementType rowElementType = RowElementType.NODE;
            if ((arrows.get(shortEdge.myEdge) != null) && RowElementType.DOWN_ARROW.equals(arrows.get(shortEdge.myEdge).myType)) {
                rowElementType = RowElementType.DOWN_ARROW;
                arrows.remove(shortEdge.myEdge);
            }
            result.add(createEdgePrintElement(rowIndex, shortEdge, EdgePrintElement.Type.DOWN, !rowElementType.equals(RowElementType.NODE)));
        }
    }
    if (rowIndex > 0) {
        for (ShortEdge shortEdge : getDownShortEdges(rowIndex - 1)) {
            RowElementType rowElementType = RowElementType.NODE;
            if ((arrows.get(shortEdge.myEdge) != null) && RowElementType.UP_ARROW.equals(arrows.get(shortEdge.myEdge).myType)) {
                rowElementType = RowElementType.UP_ARROW;
                arrows.remove(shortEdge.myEdge);
            }
            result.add(createEdgePrintElement(rowIndex, shortEdge, EdgePrintElement.Type.UP, !rowElementType.equals(RowElementType.NODE)));
        }
    }
    for (SimpleRowElement arrow : arrows.values()) {
        result.add(new TerminalEdgePrintElement(rowIndex, arrow.myPosition, arrow.myType == RowElementType.UP_ARROW ? EdgePrintElement.Type.UP : EdgePrintElement.Type.DOWN, (GraphEdge) arrow.myElement, myPrintElementManager));
    }
    for (SimpleRowElement rowElement : simpleRowElements) {
        if (rowElement.myType.equals(RowElementType.NODE)) {
            result.add(createSimplePrintElement(rowIndex, rowElement));
        }
    }
    return result;
}
Also used : PrintElementWithGraphElement(com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement) ArrayList(java.util.ArrayList) TerminalEdgePrintElement(com.intellij.vcs.log.graph.impl.print.elements.TerminalEdgePrintElement) GraphEdge(com.intellij.vcs.log.graph.api.elements.GraphEdge) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PrintElementWithGraphElement

use of com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement in project intellij-community by JetBrains.

the class PrintElementManagerImpl method isSelected.

@Override
public boolean isSelected(@NotNull PrintElementWithGraphElement printElement) {
    if (printElement.equals(mySelectedPrintElement))
        return true;
    GraphElement graphElement = printElement.getGraphElement();
    if (graphElement instanceof GraphNode) {
        int nodeId = myLinearGraph.getNodeId(((GraphNode) graphElement).getNodeIndex());
        return mySelectedNodeIds.contains(nodeId);
    }
    if (graphElement instanceof GraphEdge) {
        GraphEdge edge = (GraphEdge) graphElement;
        boolean selected = edge.getTargetId() == null || mySelectedNodeIds.contains(edge.getTargetId());
        selected &= edge.getUpNodeIndex() == null || mySelectedNodeIds.contains(myLinearGraph.getNodeId(edge.getUpNodeIndex()));
        selected &= edge.getDownNodeIndex() == null || mySelectedNodeIds.contains(myLinearGraph.getNodeId(edge.getDownNodeIndex()));
        return selected;
    }
    return false;
}
Also used : GraphElement(com.intellij.vcs.log.graph.api.elements.GraphElement) PrintElementWithGraphElement(com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement) GraphNode(com.intellij.vcs.log.graph.api.elements.GraphNode) GraphEdge(com.intellij.vcs.log.graph.api.elements.GraphEdge)

Aggregations

GraphEdge (com.intellij.vcs.log.graph.api.elements.GraphEdge)2 PrintElementWithGraphElement (com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement)2 GraphElement (com.intellij.vcs.log.graph.api.elements.GraphElement)1 GraphNode (com.intellij.vcs.log.graph.api.elements.GraphNode)1 TerminalEdgePrintElement (com.intellij.vcs.log.graph.impl.print.elements.TerminalEdgePrintElement)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1