Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r3910 - branches/GSoC2008/gimenete/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion: subclipse/graph/editors sublicpse/graph/cache

subclipse
Discussion topic

Back to topic list

svn commit: r3910 - branches/GSoC2008/gimenete/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion: subclipse/graph/editors sublicpse/graph/cache

Author gimenete
Full name Alberto Gimeno
Date 2008-07-11 08:27:06 PDT
Message Author: gimenete
Date: 2008-07-11 08:27:06-0700
New Revision: 3910

Modified:
   branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Branc​hFigure.java
   branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/NodeF​igure.java
   branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Revis​ionGraphEditor.java
   branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava

Log:
* UI changes: colours, tooltips, zoom
* cache update using threads

Modified: branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Branc​hFigure.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/branches​/GSoC2008/gimenete/o​rg.tigris.subversion​.subclipse.graph/src​/org/tigris/subversi​on/subclipse/graph/e​ditors/BranchFigure.​java?view=diff&r​ev=3910&p1=branc​hes/GSoC2008/gimenet​e/org.tigris.subvers​ion.subclipse.graph/​src/org/tigris/subve​rsion/subclipse/grap​h/editors/BranchFigu​re.java&p2=branc​hes/GSoC2008/gimenet​e/org.tigris.subvers​ion.subclipse.graph/​src/org/tigris/subve​rsion/subclipse/grap​h/editors/BranchFigu​re.java&r1=3909​&r2=3910
====================​====================​====================​==================
--- branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Branc​hFigure.java (original)
+++ branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Branc​hFigure.java 2008-07-11 08:27:06-0700
@@ -1,10 +1,10 @@
 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.Label;
 import org.eclipse.draw2d.LineBorder;
-import org.eclipse.draw2d.T​oolbarLayout;
 import org.eclipse.swt.graphics.Color;
 
 public class BranchFigure extends Figure {
@@ -12,13 +12,14 @@
     public static Color classColor = new Color(null,255,255,206);
     
     public BranchFigure(String path) {
- ToolbarLayout layout = new ToolbarLayout();
- setLayoutManager(layout);
+ setLayoutManager(new BorderLayout());
         setBorder(new LineBorder(ColorCons​tants.black,1));
         setBackgroundColor(classColor);
         setOpaque(true);
 
         Label label = new Label(path);
- add(label);
+ add(label, BorderLayout.CENTER);
+
+ setToolTip(new Label(path));
     }
 }

Modified: branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/NodeF​igure.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/branches​/GSoC2008/gimenete/o​rg.tigris.subversion​.subclipse.graph/src​/org/tigris/subversi​on/subclipse/graph/e​ditors/NodeFigure.ja​va?view=diff&rev​=3910&p1=branche​s/GSoC2008/gimenete/​org.tigris.subversio​n.subclipse.graph/sr​c/org/tigris/subvers​ion/subclipse/graph/​editors/NodeFigure.j​ava&p2=branches/​GSoC2008/gimenete/or​g.tigris.subversion.​subclipse.graph/src/​org/tigris/subversio​n/subclipse/graph/ed​itors/NodeFigure.jav​a&r1=3909&r2​=3910
====================​====================​====================​==================
--- branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/NodeF​igure.java (original)
+++ branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/NodeF​igure.java 2008-07-11 08:27:06-0700
@@ -1,41 +1,110 @@
 package org.tigris.subversio​n.subclipse.graph.ed​itors;
 
 import java.text.SimpleDateFormat;
-import java.util.Date;
 
-import org.eclipse.draw2d.C​olorConstants;
+import org.eclipse.draw2d.B​orderLayout;
 import org.eclipse.draw2d.Figure;
 import org.eclipse.draw2d.Label;
 import org.eclipse.draw2d.LineBorder;
+import org.eclipse.draw2d.P​ositionConstants;
 import org.eclipse.draw2d.T​oolbarLayout;
+import org.eclipse.draw2d.g​eometry.Dimension;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
+import org.tigris.subversio​n.sublicpse.graph.ca​che.Node;
 
 public class NodeFigure extends Figure {
     
- public static Color classColor = new Color(null,255,255,206);
+ public static final Color BGCOLOR = new Color(null, 255, 255, 206);
+ public static final Color RED = new Color(null, 247, 92, 61);
+ public static final Color GREEN = new Color(null, 153, 231, 51);
+ public static final Color BLUE = new Color(null, 54, 175, 245);
     
- public NodeFigure(long revision, String author, Date date) {
+ public NodeFigure(Node node) {
+ setLayoutManager(new BorderLayout());
+ switch(node.getAction()) {
+ case 'A':
+ setBorder(new LineBorder(GREEN, 2));
+ break;
+ case 'M':
+ setBorder(new LineBorder(BLUE, 2));
+ break;
+ case 'D':
+ setBorder(new LineBorder(RED, 2));
+ }
+ setBackgroundColor(BGCOLOR);
+ setOpaque(true);
+
+ Font revisionFont = new Font(null, "Arial", 12, SWT.BOLD);
+
+ setToolTip(new ToolTipFigure(node));
+
+ add(createLabel(Long​.toString(node.getRe​vision()), revisionFont), BorderLayout.CENTER);
+ }
+
+ public static Label createLabel(String text, Font font) {
+ Label label = new Label(text);
+ label.setFont(font);
+ return label;
+ }
+
+} class ToolTipFigure extends Figure {
+
+ private static final int BORDER_WIDTH = 5;
+ private static final int BORDER_WIDTH2 = BORDER_WIDTH*2;
+ private static SimpleDateFormat dateFormat;
+ private static Font info = null;
+ private static Font authorFont = null;
+ private static Font dateFont = null;
+
+ public ToolTipFigure(Node node) {
         ToolbarLayout layout = new ToolbarLayout();
+ layout.setStretchMin​orAxis(false);
         setLayoutManager(layout);
- setBorder(new LineBorder(ColorCons​tants.black,1));
- setBackgroundColor(classColor);
+// setBorder(new LineBorder(ColorCons​tants.black,1));
+ setBackgroundColor(N​odeFigure.BGCOLOR);
         setOpaque(true);
+ layout.setSpacing(5);
+
+ // lazy loading and reuse
+ if(dateFormat == null) {
+ dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+ info = new Font(null, "Arial", 12, SWT.BOLD);
+ authorFont = new Font(null, "Arial", 10, SWT.BOLD);
+ dateFont = new Font(null, "Arial", 10, SWT.ITALIC);
+ }
+
+ Figure tooltip = new Figure();
+ setToolTip(tooltip);
 
- Font revisionFont = new Font(null, "Arial", 10, SWT.BOLD);
- Font authorFont = new Font(null, "Arial", 10, SWT.BOLD);
- Font dateFont = new Font(null, "Arial", 10, SWT.ITALIC);
-
- add(createLabel(Long​.toString(revision),​ revisionFont));
- add(createLabel(author, authorFont));
- add(createLabel(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(date), dateFont));
+ add(createLabel("Author", info, NodeFigure.BLUE));
+ add(createLabel(node​.getAuthor(), authorFont));
+ add(createLabel("Date", info, NodeFigure.BLUE));
+ add(createLabel(date​Format.format(node.g​etRevisionDate()), dateFont));
+ add(createLabel("Message", info, NodeFigure.BLUE));
+ add(createLabel(node​.getMessage(), dateFont));
+
+ Dimension d = getPreferredSize();
+
+ setPreferredSize(d.w​idth+BORDER_WIDTH2, d.height+BORDER_WIDTH2);
+ setBorder(new LineBorder(NodeFigure.BGCOLOR, BORDER_WIDTH));
     }
     
- private Label createLabel(String text, Font font) {
+ public static Label createLabel(String text, Font font) {
         Label label = new Label(text);
         label.setFont(font);
+ label.setTextAlignme​nt(PositionConstants​.LEFT);
         return label;
     }
     
+ public static Label createLabel(String text, Font font, Color c) {
+ Label label = new Label(text);
+ label.setFont(font);
+ label.setTextAlignme​nt(PositionConstants​.LEFT);
+ label.setForegroundColor(c);
+ return label;
+ }
+
+
 }

Modified: branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Revis​ionGraphEditor.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/branches​/GSoC2008/gimenete/o​rg.tigris.subversion​.subclipse.graph/src​/org/tigris/subversi​on/subclipse/graph/e​ditors/RevisionGraph​Editor.java?view=dif​f&rev=3910&p​1=branches/GSoC2008/​gimenete/org.tigris.​subversion.subclipse​.graph/src/org/tigri​s/subversion/subclip​se/graph/editors/Rev​isionGraphEditor.jav​a&p2=branches/GS​oC2008/gimenete/org.​tigris.subversion.su​bclipse.graph/src/or​g/tigris/subversion/​subclipse/graph/edit​ors/RevisionGraphEdi​tor.java&r1=3909​&r2=3910
====================​====================​====================​==================
--- branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Revis​ionGraphEditor.java (original)
+++ branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/subclipse​/graph/editors/Revis​ionGraphEditor.java 2008-07-11 08:27:06-0700
@@ -12,16 +12,22 @@
 import org.eclipse.draw2d.Figure;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.M​anhattanConnectionRo​uter;
+import org.eclipse.draw2d.P​olygonDecoration;
 import org.eclipse.draw2d.P​olylineConnection;
 import org.eclipse.draw2d.XYLayout;
 import org.eclipse.draw2d.g​eometry.Rectangle;
 import org.eclipse.gef.EditPart;
 import org.eclipse.gef.Edit​PartFactory;
+import org.eclipse.gef.EditPartViewer;
 import org.eclipse.gef.Grap​hicalViewer;
 import org.eclipse.gef.edit​parts.AbstractGraphi​calEditPart;
 import org.eclipse.gef.edit​parts.ScalableRootEd​itPart;
+import org.eclipse.gef.edit​parts.ZoomManager;
+import org.eclipse.gef.ui.a​ctions.ZoomComboCont​ributionItem;
 import org.eclipse.gef.ui.p​arts.ScrollingGraphi​calViewer;
+import org.eclipse.jface.ac​tion.IToolBarManager​;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.widg​ets.Composite;
 import org.eclipse.swt.widg​ets.Display;
 import org.eclipse.ui.IEditorInput;
@@ -47,20 +53,6 @@
     public void setFocus() {
     }
     
-// public void selectionChanged(IWorkbenchPart part,
-// ISelection selection) {
-// if(selection instanceof IStructuredSelection) {
-// Object first = ((IStructuredSelection) selection).getFirstElement();
-// if(first instanceof IResource) {
-// IResource resource = (IResource) first;
-// showGraphFor(resource);
-// }
-// } else if(selection instanceof IResource) {
-// IResource resource = (IResource) selection; // TODO: not tested. This is ok?
-// showGraphFor(resource);
-// }
-// }
-
     public void showGraphFor(IResource resource) {
         ShowGraphBackgroundTask task =
             new ShowGraphBackgroundT​ask(getSite().getPar​t(), viewer, resource);
@@ -72,12 +64,24 @@
         }
     }
     
+ public Object getAdapter(Class adapter) {
+ if(adapter == GraphicalViewer.class || adapter == EditPartViewer.class) {
+ return viewer;
+ } else if(adapter == ZoomManager.class) {
+ return ((ScalableRootEditPart) viewer.getRootEditPa​rt()).getZoomManager​();
+ }
+ return super.getAdapter(adapter);
+ }
+
     public void createPartControl(Composite parent) {
+ IToolBarManager mgr = getEditorSite().getA​ctionBars().getToolB​arManager();
+ mgr.add(new ZoomComboContributio​nItem(getSite().getP​age()));
+
         viewer = new ScrollingGraphicalViewer();
+ GC gc = new GC(parent);
+ gc.setAntialias(SWT.ON);
         viewer.createControl(parent);
         ScalableRootEditPart root = new ScalableRootEditPart();
-// root.getZoomManager(​).zoomOut();
-// root.getZoomManager(​).zoomOut();
         viewer.setRootEditPart(root);
         viewer.setEditPartFactory(new GraphEditPartFactory());
         viewer.setContents("Nothing to show");
@@ -147,21 +151,29 @@
                     
                     try {
                         monitor.setTaskName("Retrieving revision history");
- monitor.beginTask("Asking the repository for updates", 100);
- int workedUnit = (int) (100 / ((latestRevisionInRepository - latestRevisionStored) / (float) MAGIC_NUMBER));
+ monitor.beginTask("Asking the repository for updates", 50*2);
+ int workedUnit = (int) (50 / ((latestRevisionInRepository - latestRevisionStored) / (float) MAGIC_NUMBER));
+ CacheUpdaterThread cacheUpdater = null;
                         while(latestRevision​InRepository > latestRevisionStored) {
                             latestRevisionStored += MAGIC_NUMBER;
                             if(latestRevisionStored > latestRevisionInRepository) {
                                 latestRevisionStored = latestRevisionInRepository;
                             }
-
                             ISVNLogMessage[] messages = client.getLogMessage​s(info.getRepository​(),
                                     latest, new SVNRevision.Number(l​atestRevisionStored)​);
                             monitor.worked(workedUnit);
 // printLogMessages(messages);
- cache.update(messages);
+ if(cacheUpdater != null) {
+ cacheUpdater.join();
+ monitor.worked(workedUnit);
+ }
+ cacheUpdater = new CacheUpdaterThread(cache, messages);
+ cacheUpdater.start();
                             latest = new SVNRevision.Number(l​atestRevisionStored+​1);
                         }
+ if(cacheUpdater != null) {
+ cacheUpdater.join();
+ }
                         monitor.done();
                     } catch(Exception e) {
                         e.printStackTrace();
@@ -176,8 +188,8 @@
             e.printStackTrace();
             return;
         } finally {
- if(cache != null)
- cache.close();
+// if(cache != null)
+// cache.close();
             // TODO: clean up ISVNClientAdapter ?
         }
     }
@@ -206,6 +218,22 @@
         return "Calculating graph information";
     }
 
+} class CacheUpdaterThread extends Thread {
+
+ private Cache cache;
+ private ISVNLogMessage[] messages;
+
+ public CacheUpdaterThread(Cache cache,
+ ISVNLogMessage[] messages) {
+ this.cache = cache;
+ this.messages = messages;
+ }
+
+ public void run() {
+ cache.update(messages); // TODO: handle exceptions
+ }
+
+
 } class Graph {
     
     private List nodes;
@@ -240,6 +268,14 @@
 } class GraphEditPart extends AbstractGraphicalEditPart {
     
     private Graph graph;
+
+ private final static int NODE_WIDTH = 70;
+ private final static int NODE_HEIGHT = 30;
+ private final static int BRANCH_WIDTH = 150;
+ private final static int BRANCH_HEIGHT = 30;
+ private final static int BRANCH_OFFSET = 170;
+ private final static int NODE_OFFSET_Y = 40;
+ private final static int NODE_OFFSET_X = (BRANCH_WIDTH - NODE_WIDTH) / 2;
     
     public GraphEditPart(Graph graph) {
         this.graph = graph;
@@ -254,24 +290,33 @@
         Map branches = new HashMap();
         Map figures = new HashMap();
         Map previousFigure = new HashMap();
+ Map nodesCount = new HashMap();
 
         int i=0;
         for (Iterator iterator = nodes.iterator(); iterator
                 .hasNext();) {
             Node node = (Node) iterator.next();
- NodeFigure figure = new NodeFigure(node.getRevision(), node.getAuthor(), node.getRevisionDate());
+ NodeFigure figure = new NodeFigure(node);
             figures.put(node.get​Revision()+"@"+node.​getPath(), figure);
             
+ int branchNodesCount = 0;
+
             BranchFigure branch = (BranchFigure) branches.get(node.getPath());
             if(branch == null) {
                 branch = new BranchFigure(node.getPath());
- contentsLayout.setCo​nstraint(branch, new Rectangle(10+branche​s.keySet().size()*17​0, 10, 150, 30));
+ contentsLayout.setCo​nstraint(branch,
+ new Rectangle(10+branche​s.keySet().size()*BR​ANCH_OFFSET, 10, BRANCH_WIDTH, BRANCH_HEIGHT));
                 branches.put(node.getPath(), branch);
                 contents.add(branch);
                 previousFigure.put(n​ode.getPath(), branch);
+ nodesCount.put(node.getPath(), new Integer(0));
+ } else {
+ branchNodesCount = ((Integer) nodesCount.get(node.​getPath())).intValue​() + 1;
+ nodesCount.put(node.getPath(), new Integer(branchNodesCount));
             }
             Rectangle r = (Rectangle) contentsLayout.getCo​nstraint(branch);
- contentsLayout.setCo​nstraint(figure, new Rectangle(r.x, 50+60*i, 150, 50));
+ contentsLayout.setCo​nstraint(figure,
+ new Rectangle(NODE_OFFSET_X+r.x, 50+NODE_OFFSET_Y*bra​nchNodesCount, NODE_WIDTH, NODE_HEIGHT));
             contents.add(figure);
 
             ChopboxAnchor sourceAnchor = null;
@@ -296,10 +341,14 @@
             }
             if(sourceAnchor != null) {
                 PolylineConnection c = new PolylineConnection();
- c.setConnectionRouter(new ManhattanConnectionRouter());
+// c.setLineWidth(2);
+// c.setConnectionRouter(new ManhattanConnectionRouter());
                 ChopboxAnchor targetAnchor = new ChopboxAnchor(figure);
                 c.setSourceAnchor(so​urceAnchor);
                 c.setTargetAnchor(ta​rgetAnchor);
+ PolygonDecoration decoration = new PolygonDecoration();
+ decoration.setTempla​te(PolygonDecoration​.TRIANGLE_TIP);
+ c.setSourceDecoratio​n(decoration);
                 contents.add(c);
             }
             
@@ -314,4 +363,4 @@
     protected void createEditPolicies() {
     }
     
-}
+}
\ No newline at end of file

Modified: branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/branches​/GSoC2008/gimenete/o​rg.tigris.subversion​.subclipse.graph/src​/org/tigris/subversi​on/sublicpse/graph/c​ache/Cache.java?view​=diff&rev=3910​&p1=branches/GSoC2​008/gimenete/org.tig​ris.subversion.subcl​ipse.graph/src/org/t​igris/subversion/sub​licpse/graph/cache/C​ache.java&p2=bra​nches/GSoC2008/gimen​ete/org.tigris.subve​rsion.subclipse.grap​h/src/org/tigris/sub​version/sublicpse/gr​aph/cache/Cache.java​&r1=3909&r2=​3910
====================​====================​====================​==================
--- branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava (original)
+++ branches/GSoC2008/gi​menete/org.tigris.su​bversion.subclipse.g​raph/src/org/tigris/​subversion/sublicpse​/graph/cache/Cache.j​ava 2008-07-11 08:27:06-0700
@@ -388,6 +388,13 @@
     public void update(ISVNLogMessage[] messages) {
         Map fileIds = new HashMap();
         
+ try {
+ connection.setAutoCo​mmit(false);
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
         for (int i = 0; i < messages.length; i++) {
             ISVNLogMessage logMessage = messages[i];
             long revision = logMessage.getRevisi​on().getNumber();
@@ -424,6 +431,14 @@
                 }
             }
         }
+
+ try {
+ connection.commit();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
     }
     
     private void addedAction(ISVNLogM​essageChangePath changePath, Map fileIds, long revision, Long copySrcRevision) {

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

Messages

Show all messages in topic

svn commit: r3910 - branches/GSoC2008/gimenete/org.tigris.subversion.subclipse.graph/src/org/tigris/subversion: subclipse/graph/editors sublicpse/graph/cache gimenete Alberto Gimeno 2008-07-11 08:27:06 PDT
Messages per page: