Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r4102 - trunk/subclipse/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion/subclipse/graph: cache editors

subclipse
Discussion topic

Back to topic list

svn commit: r4102 - trunk/subclipse/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion/subclipse/graph: cache editors

Author selsemore
Full name Stephen Elsemore
Date 2008-11-19 08:37:57 PST
Message Author: selsemore
Date: 2008-11-19 08:37:57-0800
New Revision: 4102

Added:
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Path.java (contents, props changed)
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/BranchEditPart.j​ava (contents, props changed)
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphEditPart2.j​ava (contents, props changed)
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/PathEditPart.jav​a (contents, props changed)
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionEditPart​.java (contents, props changed)
Modified:
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Branch.java
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Cache.java
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Node.java
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphActionBarCo​ntributor.java
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphEditPartFac​tory.java
   trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionGraphMen​uProvider.java

Log:
Revision graph - Refactoring GEF. Rather than one edit part that encompasses
the entire graph, it is now broken down to graph, branch, path and revision
edit parts. This is to facilitate UI changes in the future, and to make it
easier to support multiple selection in the near time (not yet implemented).

Modified: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Branch.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/cache/Branch​.java?view=diff&​rev=4102&p1=trun​k/subclipse/org.tigr​is.subversion.subcli​pse.graph/src/org/ti​gris/subversion/subc​lipse/graph/cache/Br​anch.java&p2=tru​nk/subclipse/org.tig​ris.subversion.subcl​ipse.graph/src/org/t​igris/subversion/sub​clipse/graph/cache/B​ranch.java&r1=41​01&r2=4102
====================​====================​====================​==================
--- trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Branch.java (original)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Branch.java 2008-11-19 08:37:57-0800
@@ -6,7 +6,7 @@
 import java.util.Comparator;
 import java.util.List;
 
-public class Branch implements Serializable {
+public class Branch extends Path implements Serializable {
     
     private static final long serialVersionUID = -1236475833029223413L;
 
@@ -36,11 +36,10 @@
             return 0;
         }
     };
-
- private String path;
+
     private List nodes = new ArrayList();
     private Node lastNode;
-
+
     private transient Object view;
     
     public Object getView() {
@@ -52,7 +51,7 @@
     }
 
     public Branch(String path) {
- this.path = path;
+ super(path);
     }
     
     public void addNode(Node n) {
@@ -64,10 +63,6 @@
         return lastNode;
     }
 
- public String getPath() {
- return path;
- }
-
     public List getNodes() {
         return nodes;
     }

Modified: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Cache.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/cache/Cache.​java?view=diff&r​ev=4102&p1=trunk​/subclipse/org.tigri​s.subversion.subclip​se.graph/src/org/tig​ris/subversion/subcl​ipse/graph/cache/Cac​he.java&p2=trunk​/subclipse/org.tigri​s.subversion.subclip​se.graph/src/org/tig​ris/subversion/subcl​ipse/graph/cache/Cac​he.java&r1=4101​&r2=4102
====================​====================​====================​==================
--- trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Cache.java (original)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Cache.java 2008-11-19 08:37:57-0800
@@ -681,6 +681,25 @@
         } finally {
             closeFile(file);
         }
+
+ // Tags
+ List paths = graph.getPaths();
+ Iterator iter = paths.iterator();
+ while (iter.hasNext()) {
+ String path = (String) iter.next();
+ Branch branch = graph.getBranch(path);
+ if(branch.getNodes().size() == 1) {
+ Node firstNode = (Node) branch.getNodes().it​erator().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
+ if (firstNode.getSource() != null) {
+ firstNode.getSource(​).addTag(firstNode);​
+ }
+ }
+ }
+ }
+
         return graph;
     }
     

Modified: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Node.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/cache/Node.j​ava?view=diff&re​v=4102&p1=trunk/​subclipse/org.tigris​.subversion.subclips​e.graph/src/org/tigr​is/subversion/subcli​pse/graph/cache/Node​.java&p2=trunk/s​ubclipse/org.tigris.​subversion.subclipse​.graph/src/org/tigri​s/subversion/subclip​se/graph/cache/Node.​java&r1=4101​&r2=4102
====================​====================​====================​==================
--- trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Node.java (original)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Node.java 2008-11-19 08:37:57-0800
@@ -27,6 +27,10 @@
     private transient Object view;
     
     private List mergedRevisions;
+ private List tags;
+
+ private transient Branch branch;
+ private transient int index;
 
     public Node() {
     }
@@ -145,4 +149,31 @@
         mergedRevisions.add(node);
     }
     
+ public List getTags() {
+ return tags;
+ }
+
+ public void addTag(Node node) {
+ if(tags == null) {
+ tags = new ArrayList();
+ }
+ tags.add(node);
+ }
+
+ public void setBranch(Branch branch) {
+ this.branch = branch;
+ }
+
+ public Branch getBranch() {
+ return branch;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
 }

Added: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Path.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/cache/Path.j​ava?view=auto&re​v=4102
====================​====================​====================​==================
--- (empty file)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/cach​e/Path.java 2008-11-19 08:37:57-0800
@@ -0,0 +1,24 @@
+package org.tigris.subversio​n.subclipse.graph.ca​che;
+
+public class Path {
+ private String path;
+ private transient int index;
+
+ public Path(String path) {
+ super();
+ this.path = path;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+}

Added: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/BranchEditPart.j​ava
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Bran​chEditPart.java?view​=auto&rev=4102
====================​====================​====================​==================
--- (empty file)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/BranchEditPart.j​ava 2008-11-19 08:37:57-0800
@@ -0,0 +1,80 @@
+package org.tigris.subversio​n.subclipse.graph.ed​itors;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.C​olorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.draw2d.g​eometry.Rectangle;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.edit​parts.AbstractGraphi​calEditPart;
+import org.eclipse.gef.edit​policies.SelectionEd​itPolicy;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Branch;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Node;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Path;
+
+public class BranchEditPart extends AbstractGraphicalEditPart {
+ public final static int BRANCH_WIDTH = 220;
+ public final static int BRANCH_HEIGHT = 30;
+ public final static int BRANCH_OFFSET = BRANCH_WIDTH+20;
+
+ public BranchEditPart() {
+ super();
+ }
+
+ protected IFigure createFigure() {
+ Figure f = new Figure();
+ f.setBackgroundColor​(ColorConstants.whit​e);
+ f.setOpaque(true);
+
+ XYLayout layout = new XYLayout();
+ f.setLayoutManager(layout);
+
+ Branch branch = (Branch)getModel();
+ Rectangle rect = new Rectangle(10+branch.​getIndex()*BRANCH_OF​FSET, 10, BRANCH_WIDTH, -1);
+ ((AbstractGraphicalE​ditPart)getParent())​.getFigure().getLayo​utManager().setConst​raint(f, rect);
+
+ return f;
+ }
+
+ 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.setIndex(i++);
+ children.add(node);
+ }
+
+ return children;
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(Ed​itPolicy.SELECTION_F​EEDBACK_ROLE, new SelectionEditPolicy() {
+ protected void hideSelection() {
+// System.out.println("hide branch");
+ }
+
+ protected void showSelection() {
+// System.out.println("show branch");
+ }
+ });
+ }
+
+// public boolean isSelectable() {
+// System.out.println("​BranchEditPart.isSel​ectable");
+// return true;
+// }
+
+}

Modified: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphActionBarCo​ntributor.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Grap​hActionBarContributo​r.java?view=diff​&rev=4102&p1=tru​nk/subclipse/org.tig​ris.subversion.subcl​ipse.graph/src/org/t​igris/subversion/sub​clipse/graph/editors​/GraphActionBarContr​ibutor.java&p2=t​runk/subclipse/org.t​igris.subversion.sub​clipse.graph/src/org​/tigris/subversion/s​ubclipse/graph/edito​rs/GraphActionBarCon​tributor.java&r1​=4101&r2=4102
====================​====================​====================​==================
--- trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphActionBarCo​ntributor.java (original)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphActionBarCo​ntributor.java 2008-11-19 08:37:57-0800
@@ -68,7 +68,7 @@
         Action filterConnectionsAction = new Action() {
             public void run() {
                 store.setValue(Revis​ionGraphEditor.FILTE​R_CONNECTIONS, isChecked());
- GraphEditPart graphEditPart = (GraphEditPart)edito​r.getViewer().getCon​tents();
+ GraphEditPart2 graphEditPart = (GraphEditPart2)edit​or.getViewer().getCo​ntents();
                 graphEditPart.setCon​nectionVisibility(gr​aphEditPart.getSelec​tedNode());
             }
         };
@@ -174,7 +174,6 @@
         public ToggleShowDeletedAction(String text, int show) {
             super(text, AS_RADIO_BUTTON);
             this.show = show;
-// IPreferenceStore store = Activator.getDefault​().getPreferenceStor​e();
             setChecked(show == store.getInt(Revisio​nGraphEditor.SHOW_DE​LETED_PREFERENCE));
         }
         
@@ -185,8 +184,7 @@
         public void run() {
             if (isChecked()) {
                 Activator.getDefault​().getPreferenceStor​e().setValue(Revisio​nGraphEditor.SHOW_DE​LETED_PREFERENCE, show);
-// editor.refresh();
- GraphEditPart graphEditPart = (GraphEditPart)edito​r.getViewer().getCon​tents();
+ GraphEditPart2 graphEditPart = (GraphEditPart2)edit​or.getViewer().getCo​ntents();
                 Graph graph = (Graph)graphEditPart​.getModel();
                 editor.getViewer().s​etContents("Redrawin​g graph...");
                 editor.getViewer().s​etContents(graph);
@@ -212,7 +210,7 @@
             Node[] nodes = null;
             if (type == TYPE_NODES || type == TYPE_BOTH) {
                 List refreshList = new ArrayList();
- GraphEditPart graphEditPart = (GraphEditPart)edito​r.getViewer().getCon​tents();
+ GraphEditPart2 graphEditPart = (GraphEditPart2)edit​or.getViewer().getCo​ntents();
                 Graph graph = (Graph)graphEditPart​.getModel();
                 nodes = graph.getNodes();
                 for (int i = 0; i < nodes.length; i++) {
@@ -234,7 +232,6 @@
             } catch (Exception e) {
                 MessageDialog.openEr​ror(Display.getDefau​lt().getActiveShell(​), "Refresh " + getText(), e.getMessage()); //$NON-NLS-1$
             }
- // editor.refresh();
         }
     }
 

Added: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphEditPart2.j​ava
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Grap​hEditPart2.java?view​=auto&rev=4102
====================​====================​====================​==================
--- (empty file)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphEditPart2.j​ava 2008-11-19 08:37:57-0800
@@ -0,0 +1,391 @@
+package org.tigris.subversio​n.subclipse.graph.ed​itors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.draw2d.C​hopboxAnchor;
+import org.eclipse.draw2d.C​olorConstants;
+import org.eclipse.draw2d.C​onnectionAnchor;
+import org.eclipse.draw2d.Cursors;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.F​igureCanvas;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MouseEvent;
+import org.eclipse.draw2d.M​ouseListener;
+import org.eclipse.draw2d.M​ouseMotionListener;
+import org.eclipse.draw2d.P​olygonDecoration;
+import org.eclipse.draw2d.P​olylineConnection;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.XYAnchor;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.draw2d.g​eometry.Point;
+import org.eclipse.draw2d.g​eometry.Rectangle;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.edit​parts.AbstractGraphi​calEditPart;
+import org.eclipse.gef.edit​policies.SelectionEd​itPolicy;
+import org.eclipse.gef.ui.p​arts.ScrollingGraphi​calViewer;
+import org.eclipse.jface.pr​eference.IPreference​Store;
+import org.eclipse.jface.vi​ewers.IStructuredSel​ection;
+import org.eclipse.swt.graphics.Color;
+import org.tigris.subversio​n.subclipse.graph.Ac​tivator;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Branch;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Cache;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Graph;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Node;
+
+public class GraphEditPart2 extends AbstractGraphicalEditPart implements MouseListener {
+ private Graph graph;
+ private NodeFigure selected;
+ private ScrollingGraphicalViewer viewer;
+ private Map branchMap = new HashMap();
+ private Map nodeMap = new HashMap();
+ private List connections = new ArrayList();
+ private IPreferenceStore store = Activator.getDefault​().getPreferenceStor​e();
+
+ public GraphEditPart2(Graph graph, ScrollingGraphicalViewer viewer) {
+ super();
+ this.graph = graph;
+ this.viewer = viewer;
+ }
+
+ protected IFigure createFigure() {
+ Figure f = new Figure();
+ f.setBackgroundColor​(ColorConstants.whit​e);
+ f.setOpaque(true);
+
+ XYLayout layout = new XYLayout();
+ f.setLayoutManager(layout);
+
+ return f;
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(Ed​itPolicy.SELECTION_F​EEDBACK_ROLE, new SelectionEditPolicy() {
+ protected void hideSelection() {
+// System.out.println("hide graph");
+ }
+
+ protected void showSelection() {
+// System.out.println("show graph");
+ }
+ });
+ }
+
+ protected List getModelChildren() {
+ IPreferenceStore store = Activator.getDefault​().getPreferenceStor​e();
+ int showDeleted = store.getInt(Revisio​nGraphEditor.SHOW_DE​LETED_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((Str​ing)iter.next());
+
+ if(branch.getNodes().size() == 1) {
+ Node firstNode = (Node) branch.getNodes().it​erator().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.getNode​s().get(branch.getNo​des().size() - 1);
+ if (lastNode.getAction() == 'D' && Cache.isEqualsOrPare​nt(lastNode.getPath(​), branch.getPath())) {
+ if (showDeleted == RevisionGraphEditor.​SHOW_DELETED_NO || (showDeleted == RevisionGraphEditor.​SHOW_DELETED_MODIFIE​D && !isModified(branch))) {
+ // branch has been deleted and item was not modified in that location.
+ // do not show this branch, unless it is the location where the item came
+ // into existence.
+ if (!graph.getRootPath(​).equals(branch.getP​ath())) {
+ 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);
+ }
+
+ iter = branches.iterator();
+ while (iter.hasNext()) {
+ Branch branch = (Branch)iter.next();
+ Iterator nodeIter = branch.getNodes().iterator();
+ while (nodeIter.hasNext()) {
+ Node node = (Node)nodeIter.next();
+ 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);
+ nodeFigure.addMouseL​istener(this);
+ 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)branch​Map.get(branch.getPa​th());
+ 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.getMergedRevisi​ons().iterator(); iterator
+ .hasNext();) {
+ Node merged = (Node) iterator.next();
+ NodeFigure mergedView = (NodeFigure)nodeMap.​get(merged);
+ if(mergedView != null)
+ makeConnection(getFigure(), mergedView, nodeFigure, ColorConstants.red);
+ }
+ }
+ }
+
+ Branch selectedBranch = graph.getBranch(grap​h.getSelectedPath())​;
+ if (selectedBranch != null) {
+ Node n = selectedBranch.getSo​urce(graph.getSelect​edRevision());
+ NodeFigure nodeFigure = (NodeFigure)nodeMap.get(n);
+ if(nodeFigure != null) {
+ selectNode(nodeFigure);
+ // FIXME: it doesn't work
+// scrollTo((Rectangle) contentsLayout.getCo​nstraint(nodeFigure)​);
+ }
+ }
+
+ setConnectionVisibil​ity(selected);
+
+ return branches;
+ }
+
+ public BranchFigure getBranchFigure(String path) {
+ return (BranchFigure)branch​Map.get(path);
+ }
+
+ public NodeFigure getNodeFigure(Node node) {
+ return (NodeFigure)nodeMap.get(node);
+ }
+
+ public List getNodes(Branch branch) {
+ return (List)nodeMap.get(branch);
+ }
+
+ private boolean isModified(Branch branch) {
+ List nodes = branch.getNodes();
+ Iterator iter = nodes.iterator();
+ while (iter.hasNext()) {
+ Node node = (Node)iter.next();
+ if (node.getPath().equa​ls(branch.getPath())​ && node.getAction() == 'M') return true;
+ }
+ return false;
+ }
+
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ }
+
+ public void setConnectionVisibil​ity(NodeFigure figure) {
+ Iterator iter = connections.iterator();
+ while (iter.hasNext()) {
+ PolylineConnection con = (PolylineConnection)​iter.next();
+ boolean show = !store.getBoolean(Re​visionGraphEditor.FI​LTER_CONNECTIONS) || (con.getSourceAnchor​().getOwner() == figure || con.getTargetAnchor(​).getOwner() == figure);
+ con.setVisible(show);
+ }
+ }
+
+ private void selectNode(NodeFigure figure) {
+ setConnectionVisibil​ity(figure);
+
+ if(selected != null)
+ selected.setSelected(false);
+ figure.setSelected(true);
+ selected = figure;
+ if (figure == null) graph.setSelectedNode(null);
+ else graph.setSelectedNod​e(figure.getNode());​
+ getViewer().setSelection(new IStructuredSelection() {
+
+ public Object getFirstElement() {
+ return GraphEditPart2.this;
+ }
+
+ public Iterator iterator() {
+ return toList().iterator();
+ }
+
+ public int size() {
+ return toArray().length;
+ }
+
+ public Object[] toArray() {
+ Object[] selectedObjects = { GraphEditPart2.this };
+ return selectedObjects;
+ }
+
+ public List toList() {
+ List list = new ArrayList();
+ list.add(GraphEditPart2.this);
+ return list;
+ }
+
+ public boolean isEmpty() {
+ return false;
+ }
+
+ });
+ }
+
+ public NodeFigure getSelectedNode() {
+ return selected;
+ }
+
+ private PolylineConnection makeConnection(IFigure contents, IFigure source, NodeFigure target) {
+ return makeConnection(contents, source, target, Activator.CONNECTION_COLOR);
+ }
+
+ private PolylineConnection makeConnection(IFigure contents, IFigure source, NodeFigure target, Color color) {
+ PolylineConnection c = new PolylineConnection();
+ ConnectionAnchor targetAnchor = new ChopboxAnchor(target);
+ c.setTargetAnchor(ta​rgetAnchor);
+ c.setSourceAnchor(new ChopboxAnchor(source));
+ PolygonDecoration decoration = new PolygonDecoration();
+ decoration.setTempla​te(PolygonDecoration​.TRIANGLE_TIP);
+ c.setTargetDecoratio​n(decoration);
+ c.setForegroundColor(color);
+ ConnectionMouseListener listener = new ConnectionMouseListener(c);
+ c.addMouseMotionList​ener(listener);
+ c.addMouseListener(listener);
+ c.setCursor(Cursors.HAND);
+ contents.add(c);
+ connections.add(c);
+ return c;
+ }
+
+ private void scrollTo(Rectangle fbounds) {
+ scrollTo(fbounds.x+f​bounds.width/2, fbounds.y+fbounds.height/2);
+ }
+
+ private void scrollTo(int ax, int ay) {
+ Viewport viewport = ((FigureCanvas)viewe​r.getControl()).getV​iewport();
+ Rectangle vbounds = viewport.getBounds();
+ Point p = new Point(ax, ay);
+// target.translateToAbsolute(p); // TODO
+ int x = p.x-vbounds.width/2;
+ int y = p.y-vbounds.height/2;
+ viewport.setHorizont​alLocation(x);
+ viewport.setVertical​Location(y);
+ }
+
+ private void scrollTo(IFigure target) {
+ scrollTo(target.getBounds());
+ }
+
+ public void mouseDoubleClicked(MouseEvent event) {
+ }
+
+ public void mousePressed(MouseEvent event) {
+ }
+
+ public void mouseReleased(MouseEvent event) {
+ Object source = event.getSource();
+ if (source instanceof NodeFigure) {
+ selectNode((NodeFigure) source);
+ }
+ }
+
+ class ConnectionMouseListener implements MouseMotionListener, MouseListener {
+
+ private PolylineConnection connection;
+
+ public ConnectionMouseListe​ner(PolylineConnecti​on connection) {
+ this.connection = connection;
+ }
+
+ public void mouseDragged(MouseEvent event) {
+ }
+
+ public void mouseEntered(MouseEvent event) {
+ }
+
+ public void mouseExited(MouseEvent event) {
+ connection.setLineWidth(1);
+ }
+
+ public void mouseHover(MouseEvent event) {
+ connection.setLineWidth(2);
+ }
+
+ public void mouseMoved(MouseEvent event) {
+ }
+
+ public void mouseDoubleClicked(MouseEvent event) {
+ }
+
+ public void mousePressed(MouseEvent event) {
+ }
+
+ public void mouseReleased(MouseEvent event) {
+ NodeFigure nodeFigure = (NodeFigure) connection.getTarget​Anchor().getOwner();​
+ scrollTo(nodeFigure);
+ selectNode(nodeFigure);
+ }
+
+ } class MyXYAnchor extends XYAnchor {
+
+ private IFigure f;
+
+ public MyXYAnchor(Point point, IFigure f) {
+ super(point);
+ this.f = f;
+ }
+
+ public Point getLocation(Point reference) {
+ Point p = super.getLocation(re​ference).getCopy();
+ f.translateToAbsolute(p);
+ return p;
+ }
+
+ public IFigure getOwner() {
+ return f;
+ }
+
+ }
+
+}

Modified: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphEditPartFac​tory.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Grap​hEditPartFactory.jav​a?view=diff&rev=​4102&p1=trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Grap​hEditPartFactory.jav​a&p2=trunk/subcl​ipse/org.tigris.subv​ersion.subclipse.gra​ph/src/org/tigris/su​bversion/subclipse/g​raph/editors/GraphEd​itPartFactory.java​&r1=4101&r2=41​02
====================​====================​====================​==================
--- trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphEditPartFac​tory.java (original)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/GraphEditPartFac​tory.java 2008-11-19 08:37:57-0800
@@ -6,7 +6,10 @@
 import org.eclipse.gef.Edit​PartFactory;
 import org.eclipse.gef.edit​parts.AbstractGraphi​calEditPart;
 import org.eclipse.gef.ui.p​arts.ScrollingGraphi​calViewer;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Branch;
 import org.tigris.subversio​n.subclipse.graph.ca​che.Graph;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Node;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Path;
 
 public class GraphEditPartFactory implements EditPartFactory {
     
@@ -16,9 +19,10 @@
         this.viewer = viewer;
     }
 
- public EditPart createEditPart(EditPart editPart, Object node) {
- if (node instanceof String) {
- final String s = (String) node;
+ public EditPart createEditPart(EditPart context, Object model) {
+ EditPart editPart = null;
+ if (model instanceof String) {
+ final String s = (String) model;
             return new AbstractGraphicalEditPart() {
                 protected IFigure createFigure() {
                     return new Label(s);
@@ -27,10 +31,20 @@
                 protected void createEditPolicies() {
                 }
             };
- } else if (node instanceof Graph) {
- return new GraphEditPart((Graph) node, viewer);
+ } else if (model instanceof Graph) {
+ editPart = new GraphEditPart2((Graph) model, viewer);
+ } else if (model instanceof Branch) {
+ editPart = new BranchEditPart();
+ } else if (model instanceof Path) {
+ editPart = new PathEditPart();
+ } else if (model instanceof Node) {
+ editPart = new RevisionEditPart();
         }
- throw new RuntimeException("cannot create EditPart for "+node.getClass().getName()+" class");
+ if (editPart == null)
+ throw new RuntimeException("cannot create EditPart for "+model.getClass().getName()+" class");
+ else
+ editPart.setModel(model);
+ return editPart;
     }
 
 }

Added: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/PathEditPart.jav​a
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Path​EditPart.java?view=a​uto&rev=4102
====================​====================​====================​==================
--- (empty file)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/PathEditPart.jav​a 2008-11-19 08:37:57-0800
@@ -0,0 +1,55 @@
+package org.tigris.subversio​n.subclipse.graph.ed​itors;
+
+import org.eclipse.draw2d.B​orderLayout;
+import org.eclipse.draw2d.C​olorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.edit​parts.AbstractGraphi​calEditPart;
+import org.eclipse.gef.edit​policies.SelectionEd​itPolicy;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Path;
+
+public class PathEditPart extends AbstractGraphicalEditPart {
+ private BranchFigure branchFigure;
+
+ public PathEditPart() {
+ super();
+ }
+
+ protected IFigure createFigure() {
+ Figure f = new Figure();
+ f.setBackgroundColor​(ColorConstants.whit​e);
+ f.setOpaque(true);
+ BorderLayout layout = new BorderLayout();
+ f.setLayoutManager(layout);
+
+ Path path = (Path)getModel();
+ GraphEditPart2 graphEditPart = (GraphEditPart2)getP​arent().getParent();​
+ branchFigure = graphEditPart.getBra​nchFigure(path.getPa​th());
+
+ f.add(branchFigure, BorderLayout.CENTER);
+
+ return f;
+ }
+
+
+
+ protected void refreshVisuals() {
+ getFigure().setSize(220, 30);
+
+ super.refreshVisuals();
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(Ed​itPolicy.SELECTION_F​EEDBACK_ROLE, new SelectionEditPolicy() {
+ protected void hideSelection() {
+// System.out.println("hide path");
+ }
+
+ protected void showSelection() {
+// System.out.println("show path");
+ }
+ });
+ }
+
+}

Added: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionEditPart​.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Revi​sionEditPart.java?vi​ew=auto&rev=4102​
====================​====================​====================​==================
--- (empty file)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionEditPart​.java 2008-11-19 08:37:57-0800
@@ -0,0 +1,74 @@
+package org.tigris.subversio​n.subclipse.graph.ed​itors;
+
+import java.util.Iterator;
+
+import org.eclipse.draw2d.B​orderLayout;
+import org.eclipse.draw2d.C​olorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.g​eometry.Rectangle;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.edit​parts.AbstractGraphi​calEditPart;
+import org.eclipse.gef.edit​policies.SelectionEd​itPolicy;
+import org.tigris.subversio​n.subclipse.graph.ca​che.Node;
+
+public class RevisionEditPart extends AbstractGraphicalEditPart {
+ private final static int NODE_WIDTH = 50;
+ private final static int NODE_HEIGHT = 30;
+ private final static int NODE_OFFSET_Y = NODE_HEIGHT + 10;
+ private final static int NODE_OFFSET_X = (BranchEditPart.BRANCH_WIDTH - NODE_WIDTH) / 2;
+
+ public RevisionEditPart() {
+ super();
+ }
+
+ protected IFigure createFigure() {
+ Figure f = new Figure();
+ f.setBackgroundColor​(ColorConstants.whit​e);
+ f.setOpaque(true);
+ BorderLayout layout = new BorderLayout();
+ f.setLayoutManager(layout);
+
+ Node node = (Node)getModel();
+ GraphEditPart2 graphEditPart = (GraphEditPart2)getP​arent().getParent();​
+ NodeFigure nodeFigure = graphEditPart.getNod​eFigure(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();
+
+ f.add(nodeFigure, BorderLayout.CENTER);
+
+ Rectangle rect = new Rectangle(NODE_OFFSET_X, 10+BranchEditPart.BR​ANCH_HEIGHT+node.get​Index()*NODE_OFFSET_​Y, NODE_WIDTH, NODE_HEIGHT);
+ ((AbstractGraphicalE​ditPart)getParent())​.getFigure().getLayo​utManager().setConst​raint(f, rect);
+
+
+ return f;
+ }
+
+ public boolean isSelectable() {
+// System.out.println("​RevisionEditPart.isS​electable");
+ return true;
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(Ed​itPolicy.SELECTION_F​EEDBACK_ROLE, new SelectionEditPolicy() {
+ protected void hideSelection() {
+// System.out.println("hide revision");
+ }
+
+ protected void showSelection() {
+// System.out.println("show revision");
+ }
+ });
+ }
+
+}

Modified: trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionGraphMen​uProvider.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/org.tigris.s​ubversion.subclipse.​graph/src/org/tigris​/subversion/subclips​e/graph/editors/Revi​sionGraphMenuProvide​r.java?view=diff​&rev=4102&p1=tru​nk/subclipse/org.tig​ris.subversion.subcl​ipse.graph/src/org/t​igris/subversion/sub​clipse/graph/editors​/RevisionGraphMenuPr​ovider.java&p2=t​runk/subclipse/org.t​igris.subversion.sub​clipse.graph/src/org​/tigris/subversion/s​ubclipse/graph/edito​rs/RevisionGraphMenu​Provider.java&r1​=4101&r2=4102
====================​====================​====================​==================
--- trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionGraphMen​uProvider.java (original)
+++ trunk/subclipse/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionGraphMen​uProvider.java 2008-11-19 08:37:57-0800
@@ -19,7 +19,7 @@
     }
 
     public void buildContextMenu(IMenuManager menu) {
- GraphEditPart graphEditPart = (GraphEditPart)getVi​ewer().getContents()​;
+ GraphEditPart2 graphEditPart = (GraphEditPart2)getV​iewer().getContents(​);
         NodeFigure nodeFigure = graphEditPart.getSel​ectedNode();
         if (nodeFigure != null) {
             menu.add(new RevisionDetailsActio​n(nodeFigure, editor));

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r4102 - trunk/subclipse/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion/subclipse/graph: cache editors selsemore Stephen Elsemore 2008-11-19 08:37:57 PST
Messages per page: