diff options
author | Thomas Wolf | 2018-06-04 12:29:35 +0000 |
---|---|---|
committer | Thomas Wolf | 2018-06-04 12:38:35 +0000 |
commit | cdda987e0ddfbb0ef3b617c5b78fc08cd80888d5 (patch) | |
tree | 919b68b8c40ca817f57bd5e662b1efbfe60ee953 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal | |
parent | 0f70f1475f1959ccc0189eb1113a0f9674b3ad88 (diff) | |
download | egit-cdda987e0ddfbb0ef3b617c5b78fc08cd80888d5.tar.gz egit-cdda987e0ddfbb0ef3b617c5b78fc08cd80888d5.tar.xz egit-cdda987e0ddfbb0ef3b617c5b78fc08cd80888d5.zip |
Complete the hovers in the CommitGraphTable
Add the missing hovers:
* On the commit ID column, display the full SHA1 and the short commit
message.
* On the message column, display the short message if not over a ref.
Especially the latter is useful when there are so many lanes that
the short commit message cannot be displayed in full (or in extreme
cases, at all) or is very far away from the corresponding node on a
lane.
Change-Id: I76a2536b3972683a9e85260ecff62f472f874f2f
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal')
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTableHoverManager.java | 64 |
1 files changed, 52 insertions, 12 deletions
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 1b7ed4f9f3..177fb03269 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 @@ -71,6 +71,8 @@ class CommitGraphTableHoverManager extends ViewerCell cell, MouseEvent e) { final int columnIndex = cell.getColumnIndex(); switch (columnIndex) { + case 0: + return computeInformationForHash(commit, cell); case 1: return computeInformationForRef(commit, cell, e); case 2: @@ -81,29 +83,67 @@ class CommitGraphTableHoverManager extends return computeInformationForName(commit.getCommitterIdent(), cell); case 5: return computeInformationForDate(commit.getCommitterIdent(), cell); + default: + return null; } - return null; + } + + private Information computeInformationForHash(SWTCommit commit, + ViewerCell cell) { + return new Information( + commit.getName() + '\n' + commit.getShortMessage(), + cell.getBounds()); } private Information computeInformationForRef(SWTCommit commit, ViewerCell cell, MouseEvent e) { - if (commit.getRefCount() == 0) - return null; Rectangle itemBounds = cell.getBounds(); + int minRefX = -1; + int maxRefX = itemBounds.x; 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); + if (textSpan != null) { + if (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); + } else { + if (minRefX < 0) { + minRefX = itemBounds.x + textSpan.x; + } else { + minRefX = Math.min(minRefX, itemBounds.x + textSpan.x); + } + maxRefX = Math.max(maxRefX, itemBounds.x + textSpan.y); + } + } + } + if (minRefX < 0) { + if (relativeX > itemBounds.width / 2) { + return new Information(commit.getShortMessage(), + new Rectangle(itemBounds.x + itemBounds.width / 2, + itemBounds.y, itemBounds.width / 2, + itemBounds.height)); + } else { + int left = Math.max(itemBounds.x, e.x - 10); + return new Information(commit.getShortMessage(), + new Rectangle(left, itemBounds.y, + itemBounds.x + itemBounds.width - left, + itemBounds.height)); } + } else if (e.x > maxRefX) { + return new Information(commit.getShortMessage(), + new Rectangle(maxRefX, itemBounds.y, + itemBounds.x + itemBounds.width - maxRefX, + itemBounds.height)); + } else if (e.x < minRefX) { + return new Information(commit.getShortMessage(), + new Rectangle(itemBounds.x, itemBounds.y, + minRefX - itemBounds.x, itemBounds.height)); } return null; } |