Пример #1
0
 @NotNull
 public Set<Node> getUpRefNodes(@NotNull GraphElement graphElement) {
   Set<Node> nodes = new HashSet<Node>();
   for (Node node : getGraphModel().getFragmentManager().getUpNodes(graphElement)) {
     if (getRefsModel().isBranchRef(node.getCommitHash())) {
       nodes.add(node);
     }
   }
   return nodes;
 }
Пример #2
0
 @Nullable
 public Node getNodeByHash(Hash hash) {
   Graph graph = getGraphModel().getGraph();
   for (int i = 0; i < graph.getNodeRows().size(); i++) {
     Node node = graph.getCommitNodeInRow(i);
     if (node != null && node.getCommitHash().equals(hash)) {
       return node;
     }
   }
   return null;
 }
Пример #3
0
 public boolean isSameBranch(@NotNull Node nodeA, @NotNull Node nodeB) {
   Node up, down;
   if (nodeA.getRowIndex() > nodeB.getRowIndex()) {
     up = nodeB;
     down = nodeA;
   } else {
     up = nodeA;
     down = nodeB;
   }
   return getGraphModel().getFragmentManager().getUpNodes(down).contains(up);
 }
Пример #4
0
 public List<Node> getCommitsInBranchAboveBase(Node base, Node branchHead) {
   List<Node> result = new ArrayList<Node>();
   Node node = branchHead;
   while (node != base) {
     result.add(node);
     // TODO: multiple edges must not appear
     // TODO: if there are no edges, we are in the wrong branch
     node = node.getDownEdges().get(0).getDownNode();
   }
   // Collections.reverse(result);
   return result;
 }
Пример #5
0
 private List<Node> getAllAncestors(Node a, Predicate<Node> stop) {
   Set<Node> all = new LinkedHashSet<Node>();
   Queue<Node> queue = new ArrayDeque<Node>();
   queue.add(a);
   while (!queue.isEmpty()) {
     Node aNode = queue.remove();
     all.add(aNode);
     if (stop.apply(aNode)) {
       return new ArrayList<Node>(all);
     }
     for (Edge edge : aNode.getDownEdges()) {
       queue.add(edge.getDownNode());
     }
   }
   return new ArrayList<Node>(all);
 }
 @Override
 public void mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 1) {
     Node jumpToNode = arrowToNode(e);
     if (jumpToNode != null) {
       jumpToRow(jumpToNode.getRowIndex());
       return;
     }
     GraphElement graphElement = overCell(e);
     myUI.click(graphElement);
     if (graphElement == null) {
       myUI.click(PositionUtil.getRowIndex(e));
     }
   }
   myTableListener.onClick(e, e.getClickCount());
 }
Пример #7
0
 public int getRowByHash(Hash commitHash) {
   Node node = getNodeByHash(commitHash);
   return node == null ? -1 : node.getRowIndex();
 }