Search in sources :

Example 1 with Node

use of org.tigris.subversion.subclipse.graph.cache.Node in project subclipse by subclipse.

the class GraphEditPart method getModelChildren.

protected List getModelChildren() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    int showDeleted = store.getInt(RevisionGraphEditor.SHOW_DELETED_PREFERENCE);
    Graph graph = (Graph) getModel();
    List paths = graph.getPaths();
    List branches = new ArrayList();
    Iterator iter = paths.iterator();
    int i = 0;
    while (iter.hasNext()) {
        Branch branch = graph.getBranch((String) iter.next());
        if (branch.getNodes().size() == 1) {
            Node firstNode = (Node) branch.getNodes().iterator().next();
            if (firstNode.getSource() != null && firstNode.getChildCount() == 0) {
                // is not the root node and is not the target of any arrow
                // therefore is a tag
                branch.setView(null);
                continue;
            }
        }
        if (branch.getNodes().size() > 0) {
            Node lastNode = (Node) branch.getNodes().get(branch.getNodes().size() - 1);
            if (lastNode.getAction() == 'D' && Cache.isEqualsOrParent(lastNode.getPath(), branch.getPath())) {
                if (showDeleted == RevisionGraphEditor.SHOW_DELETED_NO || (showDeleted == RevisionGraphEditor.SHOW_DELETED_MODIFIED && !isModified(branch))) {
                    // into existence.
                    if (!graph.getRootPath().equals(branch.getPath())) {
                        branch.setView(null);
                        continue;
                    }
                }
            }
        }
        branch.setIndex(i++);
        branches.add(branch);
        int mod = branch.getIndex() % Activator.BG_COLORS.length;
        Color bgcolor = Activator.BG_COLORS[mod];
        Color fgcolor = Activator.FG_COLORS[mod];
        BranchFigure branchFigure = new BranchFigure(branch.getPath(), bgcolor, fgcolor);
        branchMap.put(branch.getPath(), branchFigure);
    }
    List nodeList = new ArrayList();
    iter = branches.iterator();
    while (iter.hasNext()) {
        Branch branch = (Branch) iter.next();
        Iterator nodeIter = branch.getNodes().iterator();
        while (nodeIter.hasNext()) {
            Node node = (Node) nodeIter.next();
            nodeList.add(node);
            int mod = branch.getIndex() % Activator.BG_COLORS.length;
            Color bgcolor = Activator.BG_COLORS[mod];
            Color fgcolor = Activator.FG_COLORS[mod];
            NodeFigure nodeFigure = new NodeFigure(node, bgcolor, fgcolor);
            nodeMap.put(node, nodeFigure);
        }
    }
    iter = branches.iterator();
    while (iter.hasNext()) {
        Branch branch = (Branch) iter.next();
        Iterator nodeIter = branch.getNodes().iterator();
        while (nodeIter.hasNext()) {
            Node node = (Node) nodeIter.next();
            NodeFigure nodeFigure = (NodeFigure) nodeMap.get(node);
            if (node.getParent() != null) {
                NodeFigure target = (NodeFigure) nodeMap.get(node.getParent());
                if (target != null) {
                    makeConnection(getFigure(), target, nodeFigure);
                }
            } else if (node.getSource() != null) {
                NodeFigure target = (NodeFigure) nodeMap.get(node.getSource());
                if (target != null) {
                    makeConnection(getFigure(), target, nodeFigure);
                }
            } else {
                BranchFigure branchFigure = (BranchFigure) branchMap.get(branch.getPath());
                makeConnection(getFigure(), branchFigure, nodeFigure);
            }
        }
    }
    // Merged Connections
    iter = branches.iterator();
    while (iter.hasNext()) {
        Branch branch = (Branch) iter.next();
        for (Iterator it = branch.getNodes().iterator(); it.hasNext(); ) {
            Node node = (Node) it.next();
            List mergedRevisions = node.getMergedRevisions();
            if (mergedRevisions == null)
                continue;
            NodeFigure nodeFigure = (NodeFigure) nodeMap.get(node);
            for (Iterator iterator = node.getMergedRevisions().iterator(); iterator.hasNext(); ) {
                Node merged = (Node) iterator.next();
                NodeFigure mergedView = (NodeFigure) nodeMap.get(merged);
                if (mergedView != null)
                    makeConnection(getFigure(), mergedView, nodeFigure, ColorConstants.red);
            }
        }
    }
    // TODO: Preserve selections
    // Branch selectedBranch = graph.getBranch(graph.getSelectedPath());
    // if (selectedBranch != null) {
    // Node n = selectedBranch.getSource(graph.getSelectedRevision());
    // NodeFigure nodeFigure = (NodeFigure)nodeMap.get(n);
    // if(nodeFigure != null) {
    // selectNode(nodeFigure);
    // // FIXME: it doesn't work
    // //				scrollTo((Rectangle) contentsLayout.getConstraint(nodeFigure));
    // }
    // }
    setConnectionVisibility();
    Node[] nodeArray = new Node[nodeList.size()];
    nodeList.toArray(nodeArray);
    Arrays.sort(nodeArray);
    for (int j = 0; j < nodeArray.length; j++) {
        nodeArray[j].setGraphIndex(j);
    }
    return branches;
}
Also used : Graph(org.tigris.subversion.subclipse.graph.cache.Graph) Branch(org.tigris.subversion.subclipse.graph.cache.Branch) Node(org.tigris.subversion.subclipse.graph.cache.Node) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with Node

use of org.tigris.subversion.subclipse.graph.cache.Node in project subclipse by subclipse.

the class GraphEditPart method isModified.

private boolean isModified(Branch branch) {
    List nodes = branch.getNodes();
    Iterator iter = nodes.iterator();
    while (iter.hasNext()) {
        Node node = (Node) iter.next();
        if (node.getPath().equals(branch.getPath()) && node.getAction() == 'M')
            return true;
    }
    return false;
}
Also used : Node(org.tigris.subversion.subclipse.graph.cache.Node) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with Node

use of org.tigris.subversion.subclipse.graph.cache.Node in project subclipse by subclipse.

the class RevisionEditPart method createFigure.

protected IFigure createFigure() {
    Node node = (Node) getModel();
    GraphEditPart graphEditPart = (GraphEditPart) getParent().getParent();
    NodeFigure nodeFigure = graphEditPart.getNodeFigure(node);
    node.setView(nodeFigure);
    if (node.getTags() != null) {
        Iterator iter = node.getTags().iterator();
        while (iter.hasNext()) {
            Node tag = (Node) iter.next();
            nodeFigure.addTag(tag);
        }
    }
    nodeFigure.endLayout();
    int index;
    if (graphEditPart.isChronologicalMode())
        index = node.getGraphIndex();
    else
        index = node.getBranchIndex();
    Rectangle rect = new Rectangle(NODE_OFFSET_X, 10 + BranchEditPart.BRANCH_HEIGHT + index * NODE_OFFSET_Y, NODE_WIDTH, NODE_HEIGHT);
    ((AbstractGraphicalEditPart) getParent()).getFigure().getLayoutManager().setConstraint(nodeFigure, rect);
    return nodeFigure;
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) Node(org.tigris.subversion.subclipse.graph.cache.Node) Iterator(java.util.Iterator) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 4 with Node

use of org.tigris.subversion.subclipse.graph.cache.Node in project subclipse by subclipse.

the class RevisionGraphMenuProvider method buildContextMenu.

public void buildContextMenu(IMenuManager menu) {
    List selectedRevisions = getSelectedRevisions();
    if (selectedRevisions.size() == 1) {
        RevisionEditPart revision = (RevisionEditPart) selectedRevisions.get(0);
        Node node = (Node) revision.getModel();
        NodeFigure nodeFigure = (NodeFigure) revision.getFigure();
        menu.add(new RevisionDetailsAction(node, editor));
        menu.add(new SetCommitPropertiesAction(nodeFigure, editor));
        menu.add(new BranchTagAction("Create Branch/Tag from Revision " + node.getRevision() + "...", editor, node));
    }
    if (selectedRevisions.size() > 0) {
        menu.add(new RefreshNodeAction(selectedRevisions, editor));
    }
    menu.add(new Separator());
    if (selectedRevisions.size() == 2) {
        RevisionEditPart revision1 = (RevisionEditPart) selectedRevisions.get(0);
        Node node1 = (Node) revision1.getModel();
        RevisionEditPart revision2 = (RevisionEditPart) selectedRevisions.get(1);
        Node node2 = (Node) revision2.getModel();
        menu.add(new CompareRevisionsAction(node1, node2, editor));
    }
    menu.add(new Separator());
    menu.add(new ImageAction(editor));
}
Also used : Node(org.tigris.subversion.subclipse.graph.cache.Node) SetCommitPropertiesAction(org.tigris.subversion.subclipse.graph.popup.actions.SetCommitPropertiesAction) CompareRevisionsAction(org.tigris.subversion.subclipse.graph.popup.actions.CompareRevisionsAction) ArrayList(java.util.ArrayList) List(java.util.List) RefreshNodeAction(org.tigris.subversion.subclipse.graph.popup.actions.RefreshNodeAction) ImageAction(org.tigris.subversion.subclipse.graph.popup.actions.ImageAction) BranchTagAction(org.tigris.subversion.subclipse.graph.popup.actions.BranchTagAction) RevisionDetailsAction(org.tigris.subversion.subclipse.graph.popup.actions.RevisionDetailsAction) Separator(org.eclipse.jface.action.Separator)

Example 5 with Node

use of org.tigris.subversion.subclipse.graph.cache.Node in project subclipse by subclipse.

the class BranchEditPart method getModelChildren.

protected List getModelChildren() {
    Branch branch = (Branch) getModel();
    List children = new ArrayList();
    Path path = new Path(branch.getPath());
    path.setIndex(branch.getIndex());
    children.add(path);
    List nodes = branch.getNodes();
    Iterator iter = nodes.iterator();
    int i = 0;
    while (iter.hasNext()) {
        Node node = (Node) iter.next();
        node.setBranch(branch);
        node.setBranchIndex(i++);
        children.add(node);
    }
    return children;
}
Also used : Path(org.tigris.subversion.subclipse.graph.cache.Path) Branch(org.tigris.subversion.subclipse.graph.cache.Branch) Node(org.tigris.subversion.subclipse.graph.cache.Node) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Node (org.tigris.subversion.subclipse.graph.cache.Node)8 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 List (java.util.List)4 Branch (org.tigris.subversion.subclipse.graph.cache.Branch)2 IResource (org.eclipse.core.resources.IResource)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)1 Separator (org.eclipse.jface.action.Separator)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Color (org.eclipse.swt.graphics.Color)1 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)1 Graph (org.tigris.subversion.subclipse.graph.cache.Graph)1 Path (org.tigris.subversion.subclipse.graph.cache.Path)1 GraphBackgroundTask (org.tigris.subversion.subclipse.graph.editors.GraphBackgroundTask)1 RevisionEditPart (org.tigris.subversion.subclipse.graph.editors.RevisionEditPart)1 RevisionGraphEditorInput (org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput)1 BranchTagAction (org.tigris.subversion.subclipse.graph.popup.actions.BranchTagAction)1 CompareRevisionsAction (org.tigris.subversion.subclipse.graph.popup.actions.CompareRevisionsAction)1