Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2014-11-18 13:25:11 +0000
committerMatthias Sohn2014-12-01 14:18:31 +0000
commit0c4bf7ab1a71230e1a8a6d6eda7cd6d3aef2d31f (patch)
treec793fde3443afc6f30776bbbe9527ed95254c7ff
parent5fca74d2c026dfe1531af587ccb759426386504c (diff)
downloadegit-0c4bf7ab1a71230e1a8a6d6eda7cd6d3aef2d31f.tar.gz
egit-0c4bf7ab1a71230e1a8a6d6eda7cd6d3aef2d31f.tar.xz
egit-0c4bf7ab1a71230e1a8a6d6eda7cd6d3aef2d31f.zip
[historyView] Show date columns in local time zone, original on hover
The local time zone makes sense to the user as they can compare the different commit dates much easier, and it is what is shown in other places of the UI as well. On hover, the full date in original time zone is shown in ISO format. Bug: 369802 Change-Id: I4b0b19dfa8e3c51efc21ff394a84f891c6f72113 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitLabelProvider.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTableHoverManager.java96
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java5
3 files changed, 75 insertions, 30 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitLabelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitLabelProvider.java
index b0a600b22b..b8f65f79b5 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitLabelProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitLabelProvider.java
@@ -35,7 +35,7 @@ public class CommitLabelProvider extends BaseLabelProvider implements
private PersonIdent lastCommitter;
- private Format format = Format.LOCALE;
+ private Format format = Format.LOCALELOCAL;
/**
* Default constructor
@@ -117,7 +117,7 @@ public class CommitLabelProvider extends BaseLabelProvider implements
if (relative)
format = Format.RELATIVE;
else
- format = Format.LOCALE;
+ format = Format.LOCALELOCAL;
}
/**
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTableHoverManager.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTableHoverManager.java
index eb2fc41681..283b8b249d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTableHoverManager.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTableHoverManager.java
@@ -15,13 +15,16 @@ import org.eclipse.jface.text.AbstractReusableInformationControlCreator;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.util.GitDateFormatter;
+import org.eclipse.jgit.util.GitDateFormatter.Format;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableItem;
/**
* For showing tool tips when hovering over cells in the commit graph table.
@@ -29,6 +32,9 @@ import org.eclipse.swt.widgets.TableItem;
class CommitGraphTableHoverManager extends
AbstractHoverInformationControlManager {
+ private final GitDateFormatter dateFormatter = new GitDateFormatter(
+ Format.ISO);
+
private final TableViewer tableViewer;
private final SWTPlotRenderer renderer;
@@ -44,34 +50,62 @@ class CommitGraphTableHoverManager extends
protected void computeInformation() {
MouseEvent e = getHoverEvent();
- TableItem item = tableViewer.getTable().getItem(new Point(e.x, e.y));
- if (item != null) {
- SWTCommit commit = (SWTCommit) item.getData();
- if (commit != null && commit.getRefCount() > 0) {
- Rectangle itemBounds = item.getBounds();
- int firstColumnWidth = tableViewer.getTable().getColumn(0)
- .getWidth();
- int relativeX = e.x - firstColumnWidth - itemBounds.x;
- for (int i = 0; i < commit.getRefCount(); i++) {
- Ref ref = commit.getRef(i);
- Point textSpan = renderer.getRefHSpan(ref);
- if ((textSpan != null)
- && (relativeX >= textSpan.x && relativeX <= textSpan.y)) {
-
- String hoverText = getHoverText(ref, i, commit);
- int width = textSpan.y - textSpan.x;
- Rectangle rectangle = new Rectangle(firstColumnWidth
- + itemBounds.x + textSpan.x, itemBounds.y,
- width, itemBounds.height);
- setInformation(hoverText, rectangle);
- return;
- }
- }
- }
+ Information information = null;
+ ViewerCell cell = tableViewer.getCell(new Point(e.x, e.y));
+ if (cell != null) {
+ SWTCommit commit = (SWTCommit) cell.getElement();
+ if (commit != null)
+ information = computeInformationForCommit(commit, cell, e);
}
// computeInformation must setInformation in all cases
- setInformation(null, null);
+ if (information != null)
+ setInformation(information.information, information.subjectArea);
+ else
+ setInformation(null, null);
+ }
+
+ private Information computeInformationForCommit(SWTCommit commit,
+ ViewerCell cell, MouseEvent e) {
+ final int columnIndex = cell.getColumnIndex();
+ switch (columnIndex) {
+ case 1:
+ return computeInformationForRef(commit, cell, e);
+ case 3:
+ return computeInformationForDate(commit.getAuthorIdent(), cell);
+ case 5:
+ return computeInformationForDate(commit.getCommitterIdent(), cell);
+ }
+ return null;
+ }
+
+ private Information computeInformationForRef(SWTCommit commit,
+ ViewerCell cell, MouseEvent e) {
+ if (commit.getRefCount() == 0)
+ return null;
+ Rectangle itemBounds = cell.getBounds();
+ int relativeX = e.x - itemBounds.x;
+ for (int i = 0; i < commit.getRefCount(); i++) {
+ Ref ref = commit.getRef(i);
+ Point textSpan = renderer.getRefHSpan(ref);
+ if ((textSpan != null)
+ && (relativeX >= textSpan.x && relativeX <= textSpan.y)) {
+
+ String hoverText = getHoverText(ref, i, commit);
+ int x = itemBounds.x + textSpan.x;
+ int width = textSpan.y - textSpan.x;
+ Rectangle rectangle = new Rectangle(x, itemBounds.y, width,
+ itemBounds.height);
+ return new Information(hoverText, rectangle);
+ }
+ }
+ return null;
+ }
+
+ private Information computeInformationForDate(PersonIdent ident,
+ ViewerCell cell) {
+ String formattedDate = dateFormatter.formatDate(ident);
+ return new Information(formattedDate, cell.getBounds());
}
private String getHoverText(Ref ref, int refIndex, SWTCommit commit) {
@@ -116,4 +150,14 @@ class CommitGraphTableHoverManager extends
return new DefaultInformationControl(parent);
}
}
+
+ private static class Information {
+ final Object information;
+ final Rectangle subjectArea;
+
+ private Information(Object information, Rectangle subjectArea) {
+ this.information = information;
+ this.subjectArea = subjectArea;
+ }
+ }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java
index a837345c6f..02b027d782 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTPlotRenderer.java
@@ -252,6 +252,7 @@ class SWTPlotRenderer extends AbstractPlotRenderer<SWTLane, Color> {
Point textsz = g.stringExtent(txt);
int arc = textsz.y / 2;
final int texty = (y * 2 - textsz.y) / 2;
+ final int outerWidth = textsz.x + 7;
// Draw backgrounds
g.setLineWidth(1);
@@ -265,7 +266,7 @@ class SWTPlotRenderer extends AbstractPlotRenderer<SWTLane, Color> {
textsz.y - 2, arc - 1, arc - 1);
g.setForeground(resources.createColor(labelOuter));
- g.drawRoundRectangle(cellX + x, cellY + texty - 1, textsz.x + 7,
+ g.drawRoundRectangle(cellX + x, cellY + texty - 1, outerWidth,
textsz.y + 1, arc, arc);
g.setForeground(sys_black);
@@ -276,7 +277,7 @@ class SWTPlotRenderer extends AbstractPlotRenderer<SWTLane, Color> {
if (isHead)
g.setFont(oldFont);
- labelCoordinates.put(name, new Point(x, x + textsz.x));
+ labelCoordinates.put(name, new Point(x, x + outerWidth));
return 10 + textsz.x;
}

Back to the top