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;
}
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;
}
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;
}
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));
}
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;
}
Aggregations