Search in sources :

Example 1 with GraphElement

use of com.intellij.vcs.log.graph.api.elements.GraphElement in project intellij-community by JetBrains.

the class CollapsedActionManager method isForDelegateGraph.

private static boolean isForDelegateGraph(@NotNull ActionContext context) {
    GraphElement affectedGraphElement = context.getAffectedGraphElement();
    if (affectedGraphElement == null)
        return false;
    GraphEdge dottedEdge = getDottedEdge(context.getAffectedGraphElement(), context.getCompiledGraph());
    if (dottedEdge != null) {
        int upNodeIndex = context.convertToDelegateNodeIndex(assertInt(dottedEdge.getUpNodeIndex()));
        int downNodeIndex = context.convertToDelegateNodeIndex(assertInt(dottedEdge.getDownNodeIndex()));
        if (!context.myCollapsedGraph.isMyCollapsedEdge(upNodeIndex, downNodeIndex))
            return true;
    }
    return false;
}
Also used : GraphElement(com.intellij.vcs.log.graph.api.elements.GraphElement) GraphEdge(com.intellij.vcs.log.graph.api.elements.GraphEdge)

Example 2 with GraphElement

use of com.intellij.vcs.log.graph.api.elements.GraphElement 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)

Example 3 with GraphElement

use of com.intellij.vcs.log.graph.api.elements.GraphElement in project intellij-community by JetBrains.

the class PrintElementGeneratorImpl method getDownShortEdges.

@NotNull
@Override
protected List<ShortEdge> getDownShortEdges(int rowIndex) {
    NullableFunction<GraphEdge, Integer> endPosition = createEndPositionFunction(rowIndex);
    List<ShortEdge> result = new ArrayList<>();
    List<GraphElement> visibleElements = getSortedVisibleElementsInRow(rowIndex);
    for (int startPosition = 0; startPosition < visibleElements.size(); startPosition++) {
        GraphElement element = visibleElements.get(startPosition);
        if (element instanceof GraphNode) {
            int nodeIndex = ((GraphNode) element).getNodeIndex();
            for (GraphEdge edge : myLinearGraph.getAdjacentEdges(nodeIndex, EdgeFilter.ALL)) {
                if (isEdgeDown(edge, nodeIndex)) {
                    Integer endPos = endPosition.fun(edge);
                    if (endPos != null)
                        result.add(new ShortEdge(edge, startPosition, endPos));
                }
            }
        }
        if (element instanceof GraphEdge) {
            GraphEdge edge = (GraphEdge) element;
            Integer endPos = endPosition.fun(edge);
            if (endPos != null)
                result.add(new ShortEdge(edge, startPosition, endPos));
        }
    }
    return result;
}
Also used : GraphElement(com.intellij.vcs.log.graph.api.elements.GraphElement) GraphNode(com.intellij.vcs.log.graph.api.elements.GraphNode) GraphEdge(com.intellij.vcs.log.graph.api.elements.GraphEdge) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with GraphElement

use of com.intellij.vcs.log.graph.api.elements.GraphElement in project intellij-community by JetBrains.

the class PrintElementGeneratorImpl method getSimpleRowElements.

@NotNull
@Override
protected List<SimpleRowElement> getSimpleRowElements(int visibleRowIndex) {
    List<SimpleRowElement> result = new SmartList<>();
    List<GraphElement> sortedVisibleElementsInRow = getSortedVisibleElementsInRow(visibleRowIndex);
    for (int position = 0; position < sortedVisibleElementsInRow.size(); position++) {
        GraphElement element = sortedVisibleElementsInRow.get(position);
        if (element instanceof GraphNode) {
            result.add(new SimpleRowElement(element, RowElementType.NODE, position));
        }
        if (element instanceof GraphEdge) {
            GraphEdge edge = (GraphEdge) element;
            RowElementType arrowType = getArrowType(edge, visibleRowIndex);
            if (arrowType != null) {
                result.add(new SimpleRowElement(edge, arrowType, position));
            }
        }
    }
    return result;
}
Also used : GraphElement(com.intellij.vcs.log.graph.api.elements.GraphElement) GraphNode(com.intellij.vcs.log.graph.api.elements.GraphNode) SmartList(com.intellij.util.SmartList) GraphEdge(com.intellij.vcs.log.graph.api.elements.GraphEdge) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with GraphElement

use of com.intellij.vcs.log.graph.api.elements.GraphElement in project intellij-community by JetBrains.

the class PrintElementGeneratorImpl method getSortedVisibleElementsInRow.

@NotNull
private List<GraphElement> getSortedVisibleElementsInRow(int rowIndex) {
    List<GraphElement> graphElements = myCache.get(rowIndex);
    if (graphElements != null) {
        return graphElements;
    }
    List<GraphElement> result = new ArrayList<>();
    result.add(myLinearGraph.getGraphNode(rowIndex));
    for (GraphEdge edge : myEdgesInRowGenerator.getEdgesInRow(rowIndex)) {
        if (isEdgeVisibleInRow(edge, rowIndex))
            result.add(edge);
    }
    addSpecialEdges(result, rowIndex);
    Collections.sort(result, myGraphElementComparator);
    myCache.put(rowIndex, result);
    return result;
}
Also used : GraphElement(com.intellij.vcs.log.graph.api.elements.GraphElement) GraphEdge(com.intellij.vcs.log.graph.api.elements.GraphEdge) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GraphEdge (com.intellij.vcs.log.graph.api.elements.GraphEdge)5 GraphElement (com.intellij.vcs.log.graph.api.elements.GraphElement)5 GraphNode (com.intellij.vcs.log.graph.api.elements.GraphNode)3 NotNull (org.jetbrains.annotations.NotNull)3 SmartList (com.intellij.util.SmartList)1 PrintElementWithGraphElement (com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement)1