threads / patch / 20094

patch, 3 partsRequest for help: graph-based UI

Subject: [JGIT PATCH 0/3] Request for help: graph-based UI

## tl;dr

8 messages between Jul 12, 2009 and Jul 25, 2009. Diffs are folded; open one to read it.

replies: 7people: 4as markdown or json

Johannes Schindelin· Jul 12, 2009, 14:46 UTC · lore
Hi,
unfortunately, the GSoC project for the graph-based UI failed.

Unwilling to give up on the idea, I ask you for help to make it become a reality, though.

The basic concept is this: show the user a graph instead of a list of objects. This should make things much more intuitive, especially when the user can not only see the history, but "make" it in this UI, too!

Just imagine being able to drag 'n drop a commit onto HEAD, and it is cherry-picked. Or drag 'n drop files or directories onto the window, and you see the history filtered to see only commits touching those files or directories.

Things like that are as near in the future as you make it.

Don't be intimidated by the size of the overall patch; almost half of it are license boiler-plates.

Now, as for some low-hanging fruits I can think of, here is a short list:
- I am crap at annotation, so that is lacking.
- I am crap at documentation, so that is lacking.
- It should be possible to read the commits on demand (maybe in the 
  background, too, with a MIN_PRIORITY thread).
- At the moment, only (part of) the commit subject is shown.  It would be 
  nice to have tooltips for the full subject, maybe a panel that shows the 
  full commit metadata, and maybe make it configurable what is to be shown 
  in the boxes to begin with.
- The boxes could be resizable, automatically resizing the graph.
- Coloring commits provides a very nice way to convey additional 
  information; I could imagine that it would be nice to have a color 
  coding of authors, for example.
- It should be possible to reinitialize the GraphWalk with different 
  options/refs.
- I am developing using vi and bash, but that is not the way most Java 
  developers work; Eclipse seems to be the most popular development 
  platform.  There should be a little how-to for people wanting to hack on 
  JGit GUI.
- The commits are shown in a rigid grid.  Maybe it would be nice to be 
  able to rearrange them interactively.  Or to make that grid less rigid?  
  (Well, the latter is not so low-hanging anymore...)
- Nothing in the GUI let's you access the file revisions of the commits 
  yet.  What would be the most intuitive interface for that?
- I have a rudimentary diff implementation in my repository 
  (http://repo.or.cz/w/jgit/dscho.git where you can find the "gui"  
  branch, too) which could be used to show the diffs corresponding to the 
  commits.
Interested?

Ciao, Dscho

Johannes Schindelin (3):
  Add a rudimentary graph-based user interface
  Add license boiler-plates
  Introduce the command 'jgit gui'
 .../services/org.spearce.jgit.pgm.TextBuiltin      |    1 +
 .../src/org/spearce/jgit/pgm/Gui.java              |  100 +++++++++++
 .../src/org/spearce/jgit/gui/CommitGraph.java      |   64 +++++++
 .../src/org/spearce/jgit/gui/CommitGrid.java       |  184 ++++++++++++++++++++
 .../src/org/spearce/jgit/gui/CommitPainter.java    |   80 +++++++++
 .../src/org/spearce/jgit/gui/CommitRow.java        |   69 ++++++++
 .../src/org/spearce/jgit/gui/GraphCommit.java      |   78 ++++++++
 .../src/org/spearce/jgit/gui/GraphWalk.java        |   73 ++++++++
 8 files changed, 649 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java
Johannes Schindelin· Jul 12, 2009, 14:46 UTC · re: Johannes Schindelin · lore

[JGIT PATCH 1/3] Add a rudimentary graph-based user interface

The idea for a graph-based user interface cropped up during the Google Summer of Code 2009. Unfortunately, the project failed, but the idea is too good to let it go to waste.

This commit introduces a very basic Swing component which shows a graph of the commits in the repository, newest on top, older on the bottom.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .../src/org/spearce/jgit/gui/CommitGraph.java      |   27 ++++
 .../src/org/spearce/jgit/gui/CommitGrid.java       |  147 ++++++++++++++++++++
 .../src/org/spearce/jgit/gui/CommitPainter.java    |   43 ++++++
 .../src/org/spearce/jgit/gui/CommitRow.java        |   32 +++++
 .../src/org/spearce/jgit/gui/GraphCommit.java      |   41 ++++++
 .../src/org/spearce/jgit/gui/GraphWalk.java        |   36 +++++
 6 files changed, 326 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java
Show changes to 6 files +326 −0

org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java, org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java, org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java, org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java, org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java, org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java

diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java
new file mode 100644
index 0000000..0d94865
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java
@@ -0,0 +1,27 @@
+package org.spearce.jgit.gui;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+
+import java.io.IOException;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.errors.MissingObjectException;
+
+public class CommitGraph extends JScrollPane {
+
+	protected GraphWalk walk;
+	protected CommitGrid grid;
+
+	public CommitGraph(GraphWalk walk)
+			throws IOException, MissingObjectException {
+		super(new CommitGrid(walk));
+	}
+
+	public Dimension getPreferredSize() {
+		return new Dimension(300, 600);
+	}
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java
new file mode 100644
index 0000000..77f56f6
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java
@@ -0,0 +1,147 @@
+package org.spearce.jgit.gui;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.JComponent;
+
+import org.spearce.jgit.lib.Repository;
+
+import org.spearce.jgit.revwalk.RevSort;
+
+public class CommitGrid extends JComponent {
+	protected GraphWalk walk;
+	protected List<CommitRow> rows;
+	protected CommitPainter painter;
+	protected Rectangle clip;
+
+	protected Dimension size;
+	protected int minColumn = 0, maxColumn = 0;
+
+	// commit dimensions
+	protected int w = 200;
+	protected int h = 30;
+	protected int spacing = 20;
+
+	public CommitGrid(GraphWalk walk) {
+		this.walk = walk;
+		rows = new ArrayList<CommitRow>();
+		painter = new CommitPainter();
+		clip = new Rectangle();
+		size = new Dimension(0, 0);
+	}
+
+	public Dimension getMinimumSize() {
+		return new Dimension((maxColumn - minColumn) * (w + spacing),
+			rows.size() * (h + spacing));
+	}
+
+	public Dimension getPreferredSize() {
+		return new Dimension((maxColumn - minColumn) * (w + spacing),
+			rows.size() * (h + spacing));
+	}
+
+	// TODO: public void resetWalk(Graphwalk walk)
+
+	protected void readCommits(int maxRow) {
+		if (rows.size() > maxRow)
+			return;
+		for (;;) {
+			GraphCommit commit;
+			try {
+				commit = (GraphCommit)walk.next();
+				if (commit == null)
+					return;
+			} catch (IOException e) {
+				// TODO: show error
+				continue;
+			}
+			commit.calculateColumn();
+			int row = commit.getRow();
+			while (row >= rows.size()) {
+				rows.add(new CommitRow());
+				size.height += h + spacing;
+				resize(getMinimumSize());
+				revalidate();
+			}
+			commit.column =
+				rows.get(row).add(commit, commit.getColumn());
+			commit.childrenCount = -1;
+			maxColumn = Math.max(maxColumn, commit.column);
+			minColumn = Math.min(minColumn, commit.column);
+		}
+	}
+
+	int x2column(int x) { return x / (w + spacing); }
+	int y2row(int y) { return y / (h + spacing); }
+	int column2x(int column) { return column * (w + spacing); }
+	int row2y(int row) { return row * (h + spacing); }
+
+	class CommitsInRectangle implements Iterator<GraphCommit> {
+		int minRow, maxRow, minColumn, maxColumn;
+		int row, column;
+
+		CommitsInRectangle(int minRow, int maxRow,
+				int minColumn, int maxColumn) {
+			this.minRow = minRow;
+			this.maxRow = maxRow;
+			this.minColumn = minColumn;
+			this.maxColumn = maxColumn;
+			row = minRow;
+			column = minColumn - 1;
+
+			readCommits(maxRow);
+			maxRow = Math.min(maxRow, rows.size());
+		}
+
+		CommitsInRectangle(Rectangle r) {
+			this(y2row(r.y), y2row(r.y + r.height - 1),
+				x2column(r.x), x2column(r.x + r.width - 1));
+		}
+
+		public boolean hasNext() {
+			for (; row <= maxRow; row++, column = minColumn - 1)
+				while (++column <= maxColumn)
+					if (rows.get(row).get(column) != null)
+						return true;
+			return false;
+		}
+
+		public GraphCommit next() {
+			return rows.get(row).get(column);
+		}
+
+		public void remove() throws UnsupportedOperationException {
+			throw new UnsupportedOperationException();
+		}
+	}
+
+	public void paintComponent(Graphics g) {
+		g.getClipBounds(clip);
+		CommitsInRectangle iter = new CommitsInRectangle(clip);
+		while (iter.hasNext()) {
+			GraphCommit commit = iter.next();
+			painter.paint((Graphics2D)g, commit,
+					column2x(iter.column), row2y(iter.row),
+					w, h);
+			for (int i = 0; i < commit.getParentCount(); i++) {
+				GraphCommit parent =
+					(GraphCommit)commit.getParent(i);
+				parent.calculateColumn();
+				g.setColor(painter.foreground);
+				g.drawLine(column2x(commit.column) + w / 2,
+					row2y(commit.row) + h,
+					column2x(parent.column) + w / 2,
+					row2y(parent.row));
+			}
+		}
+	}
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java
new file mode 100644
index 0000000..061cd2f
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java
@@ -0,0 +1,43 @@
+package org.spearce.jgit.gui;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.GradientPaint;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+import java.awt.geom.Area;
+
+class CommitPainter {
+
+	protected Color background1, background2, foreground;
+	protected int margin = 2;
+
+	public CommitPainter() {
+		background1 = Color.LIGHT_GRAY;
+		background2 = background1.darker();
+		foreground = Color.BLACK;
+	}
+
+	public void paint(Graphics2D g, GraphCommit commit,
+			int x, int y, int w, int h) {
+
+		GradientPaint gradient = new GradientPaint(x, y, background1,
+				x + w, y + h, background2);
+
+		g.setPaint(gradient);
+		g.fillRect(x, y, w, h);
+		g.setColor(foreground);
+		g.drawRect(x, y, w, h);
+
+		Shape clip = g.getClip();
+		Area area = new Area(new Rectangle(x + margin, y + margin,
+					w - 2 * margin, h - 2 * margin));
+		area.intersect(new Area(clip));
+		g.setClip(area);
+		g.drawString(commit.getShortMessage(),
+				x + margin, y + margin + h / 2);
+		g.setClip(clip);
+	}
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java
new file mode 100644
index 0000000..d110e89
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java
@@ -0,0 +1,32 @@
+package org.spearce.jgit.gui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CommitRow {
+	protected List<GraphCommit> left, right;
+
+	public CommitRow() {
+		left = new ArrayList<GraphCommit>();
+		right = new ArrayList<GraphCommit>();
+	}
+
+	public GraphCommit get(int index) {
+		if (index < 0) {
+			index = -1 - index;
+			return index < left.size() ? left.get(index) : null;
+		}
+		return index < right.size() ? right.get(index) : null;
+	}
+
+	public int add(GraphCommit commit, int desiredColumn) {
+		int leftIndex = -1 - desiredColumn;
+		if (Math.abs(-1 - desiredColumn - left.size()) <
+				Math.abs(desiredColumn - right.size())) {
+			left.add(commit);
+			return -left.size();
+		}
+		right.add(commit);
+		return right.size() - 1;
+	}
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java
new file mode 100644
index 0000000..13a5936
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java
@@ -0,0 +1,41 @@
+package org.spearce.jgit.gui;
+
+import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.revwalk.RevCommit;
+
+public class GraphCommit extends RevCommit {
+
+	protected int column = 0, row = 0;
+
+	protected int childrenCount = 0;
+	protected int cumulatedChildColumn = 0;
+
+	protected GraphCommit(final AnyObjectId id) {
+		super(id);
+	}
+
+	public void addChild(GraphCommit child) {
+		cumulatedChildColumn += child.column;
+		this.row = Math.max(this.row, child.row + 1);
+		childrenCount++;
+	}
+
+	// TODO: CommitLayout argument
+	public void calculateColumn() {
+		if (childrenCount < 0)
+			return; // already assigned
+		if (childrenCount > 0)
+			column = cumulatedChildColumn / childrenCount;
+		else
+			column = 0;
+		// TODO: ask the layout for the position
+	}
+
+	public int getColumn() {
+		return column;
+	}
+
+	public int getRow() {
+		return row;
+	}
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java
new file mode 100644
index 0000000..fe98df3
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java
@@ -0,0 +1,36 @@
+package org.spearce.jgit.gui;
+
+import java.io.IOException;
+
+import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.revwalk.RevSort;
+import org.spearce.jgit.revwalk.RevWalk;
+import org.spearce.jgit.revwalk.RevCommit;
+import org.spearce.jgit.errors.IncorrectObjectTypeException;
+import org.spearce.jgit.errors.MissingObjectException;
+
+public class GraphWalk extends RevWalk {
+	public GraphWalk(final Repository repo)
+			/* throws IOException, MissingObjectException */ {
+		super(repo);
+		sort(RevSort.COMMIT_TIME_DESC, true);
+	}
+	
+	protected RevCommit createCommit(final AnyObjectId id) {
+		return new GraphCommit(id);
+	}
+
+	public RevCommit next() throws MissingObjectException,
+			IncorrectObjectTypeException, IOException {
+		GraphCommit commit = (GraphCommit)super.next();
+		if (commit == null)
+			return null;
+
+		// Update all parents
+		for (int i = 0; i < commit.getParentCount(); i++)
+			((GraphCommit)commit.getParent(i)).addChild(commit);
+
+		return commit;
+	}
+}
-- 
1.6.3.3.644.g82c56
Johannes Schindelin· Jul 12, 2009, 14:47 UTC · re: Johannes Schindelin · lore

[JGIT PATCH 2/3] Add license boiler-plates

Add some legalese so that sue-happy people get not that happy. This patch is separate from the code part to help reviewers in getting less distracted.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .../src/org/spearce/jgit/gui/CommitGraph.java      |   37 ++++++++++++++++++++
 .../src/org/spearce/jgit/gui/CommitGrid.java       |   37 ++++++++++++++++++++
 .../src/org/spearce/jgit/gui/CommitPainter.java    |   37 ++++++++++++++++++++
 .../src/org/spearce/jgit/gui/CommitRow.java        |   37 ++++++++++++++++++++
 .../src/org/spearce/jgit/gui/GraphCommit.java      |   37 ++++++++++++++++++++
 .../src/org/spearce/jgit/gui/GraphWalk.java        |   37 ++++++++++++++++++++
 6 files changed, 222 insertions(+), 0 deletions(-)
Show changes to 6 files +222 −0

org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java, org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java, org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java, org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java, org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java, org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java

diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java
index 0d94865..7c77c9b 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGraph.java
@@ -1,3 +1,40 @@
+/*
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.spearce.jgit.gui;
 
 import java.awt.Dimension;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java
index 77f56f6..379bdf3 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitGrid.java
@@ -1,3 +1,40 @@
+/*
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.spearce.jgit.gui;
 
 import java.awt.Dimension;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java
index 061cd2f..e67e6ab 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitPainter.java
@@ -1,3 +1,40 @@
+/*
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.spearce.jgit.gui;
 
 import java.awt.Color;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java
index d110e89..e3ec75f 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/CommitRow.java
@@ -1,3 +1,40 @@
+/*
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.spearce.jgit.gui;
 
 import java.util.ArrayList;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java
index 13a5936..6c99a4f 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphCommit.java
@@ -1,3 +1,40 @@
+/*
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.spearce.jgit.gui;
 
 import org.spearce.jgit.lib.AnyObjectId;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java
index fe98df3..8297b57 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/gui/GraphWalk.java
@@ -1,3 +1,40 @@
+/*
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.spearce.jgit.gui;
 
 import java.io.IOException;
-- 
1.6.3.3.644.g82c56
Johannes Schindelin· Jul 12, 2009, 14:47 UTC · re: Johannes Schindelin · lore

[JGIT PATCH 3/3] Introduce the command 'jgit gui'

Expose the graph-based user interface to the user. This command takes the same arguments as 'jgit log'.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .../services/org.spearce.jgit.pgm.TextBuiltin      |    1 +
 .../src/org/spearce/jgit/pgm/Gui.java              |  100 ++++++++++++++++++++
 2 files changed, 101 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java
Show changes to 2 files +101 −0

org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin, org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java

diff --git a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
index 3a8cc09..335a643 100644
--- a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
+++ b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
@@ -4,6 +4,7 @@ org.spearce.jgit.pgm.Daemon
 org.spearce.jgit.pgm.DiffTree
 org.spearce.jgit.pgm.Fetch
 org.spearce.jgit.pgm.Glog
+org.spearce.jgit.pgm.Gui
 org.spearce.jgit.pgm.IndexPack
 org.spearce.jgit.pgm.Init
 org.spearce.jgit.pgm.Log
diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java
new file mode 100644
index 0000000..59904a7
--- /dev/null
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2009, Shawn O. Pearce <spearce@spearce.org>,
+ *                     Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.pgm;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import java.io.File;
+
+import javax.swing.JFrame;
+
+import org.spearce.jgit.gui.CommitGraph;
+import org.spearce.jgit.gui.GraphWalk;
+
+import org.spearce.jgit.revwalk.RevCommit;
+import org.spearce.jgit.revwalk.RevWalk;
+
+class Gui extends RevWalkTextBuiltin {
+	final JFrame frame;
+
+	CommitGraph graph;
+
+	Gui() {
+		frame = new JFrame();
+		frame.addWindowListener(new WindowAdapter() {
+			@Override
+			public void windowClosing(final WindowEvent e) {
+				frame.dispose();
+			}
+		});
+	}
+
+	@Override
+	protected int walkLoop() throws Exception {
+		graph = new CommitGraph((GraphWalk)walk);
+		frame.getContentPane().add(graph);
+
+		frame.setTitle("[" + repoName() + "]");
+		frame.pack();
+		frame.setVisible(true);
+		return 0;
+	}
+
+	@Override
+	protected void show(final RevCommit c) throws Exception {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	protected RevWalk createWalk() {
+		if (objects)
+			throw die("Cannot use --objects with gui");
+		final GraphWalk w = new GraphWalk(db);
+		return w;
+	}
+
+	private String repoName() {
+		final File f = db.getDirectory();
+		String n = f.getName();
+		if (".git".equals(n))
+			n = f.getParentFile().getName();
+		return n;
+	}
+}
-- 
1.6.3.3.644.g82c56
Robin Rosenberg· Jul 21, 2009, 19:40 UTC · re: Johannes Schindelin · lore

Re: [JGIT PATCH 0/3] Request for help: graph-based UI

Diff yes, absolutely.

As for the graph, have you considered using JGraph (LGPL) or some other graph toolkit.

I'm not sure jgit gui in any advanced version belong in jgit itself, but should probably be a project on its' own and let jgit stay as building blocks for more advanced stuff, such as EGit, NbGit, Gerrit and others, and of course the gui of yours.

I'm not likely to have much time for much non-Eclipse GUI stuff, but I do think this is a sensible project.

-- robin
Douglas Campos· Jul 25, 2009, 20:54 UTC · re: Robin Rosenberg · lore

Re: [JGIT PATCH 0/3] Request for help: graph-based UI

Just a question.. all graphic things that we implement in swing aren't usable inside eclipse with swt-awt bridge?

On Tue, Jul 21, 2009 at 4:40 PM, Robin Rosenberg<robin.rosenberg@dewire.com> wrote:

Show 19 quoted lines
> Diff yes, absolutely.
>
> As for the graph, have you considered using JGraph (LGPL) or some
> other  graph toolkit.
>
> I'm not sure jgit gui in any advanced version belong in jgit itself, but should
> probably be a project on its' own and let jgit stay as building blocks for more
> advanced stuff, such as EGit, NbGit, Gerrit and others, and of course the gui
> of yours.
>
> I'm not likely to have much time for much non-Eclipse GUI stuff, but I do
> think this is a sensible project.
>
> -- robin
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
-- 
Douglas Campos
Theros Consulting
+55 11 7626 5959
+55 11 3020 8168
Shawn O. Pearce· Jul 25, 2009, 20:59 UTC · re: Douglas Campos · lore

Re: [JGIT PATCH 0/3] Request for help: graph-based UI

Douglas Campos <douglas@theros.info> wrote:
> Just a question.. all graphic things that we implement in swing aren't
> usable inside eclipse with swt-awt bridge?

They should be usuable inside the SWT-AWT bridge, but that bridge is really dicey to get working right sometimes. I had a lot of trouble with it at my prior day-job and am happy I no longer have to deal with it.

For the most part, SWT and AWT are similar enough in their rendering that its possible to build most of a layout algorithm to be rendering API agnostic, and then permit implementation of AWT and SWT backends. But that still is duplicated effort, vs. straightforward code reuse.

-- 
Shawn.
Johannes Schindelin· Jul 25, 2009, 23:20 UTC · re: Shawn O. Pearce · lore

Re: [JGIT PATCH 0/3] Request for help: graph-based UI

Hi,
On Sat, 25 Jul 2009, Shawn O. Pearce wrote:
Show 13 quoted lines
> Douglas Campos <douglas@theros.info> wrote:
> > Just a question.. all graphic things that we implement in swing aren't 
> > usable inside eclipse with swt-awt bridge?
> 
> They should be usuable inside the SWT-AWT bridge, but that bridge is 
> really dicey to get working right sometimes.  I had a lot of trouble 
> with it at my prior day-job and am happy I no longer have to deal with 
> it.
> 
> For the most part, SWT and AWT are similar enough in their rendering 
> that its possible to build most of a layout algorithm to be rendering 
> API agnostic, and then permit implementation of AWT and SWT backends. 
> But that still is duplicated effort, vs. straightforward code reuse.
Of course, the Graph GUI is Swing...

But I would definitely welcome if somebody made the rendering more modular, to allow for an SWT backend.

In fact, I think I welcome almost everything people contribute to the Graph GUI project.

Ciao, Dscho

← back to recent threads