aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Pfeifer2013-01-24 12:09:42 (EST)
committerTobias Pfeifer2013-01-25 06:10:06 (EST)
commitf9733c0dfad825aeac7ec4fe14137868f67f678a (patch)
treeddb7881ad3b5a898249744440066f253be3f2962
parent799aa1922db473e9734d3745f5952405a8860d53 (diff)
downloadegit-f9733c0dfad825aeac7ec4fe14137868f67f678a.zip
egit-f9733c0dfad825aeac7ec4fe14137868f67f678a.tar.gz
egit-f9733c0dfad825aeac7ec4fe14137868f67f678a.tar.bz2
Conditional label of context menu item for checkout in GitHistoryViewerrefs/changes/89/9889/2
Shows "checkout..." when a dialog will open, "checkout" otherwise Bug: 397950 Change-Id: I14ea1dffb68443f61b44fa7aca953e503a748aa8 Signed-off-by: Tobias Pfeifer <to.pfeifer@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java33
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties1
3 files changed, 34 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index 72dabe4..2a4c24e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -426,6 +426,9 @@ public class UIText extends NLS {
public static String GitHistoryPage_CheckoutMenuLabel;
/** */
+ public static String GitHistoryPage_CheckoutMenuLabel2;
+
+ /** */
public static String GitHistoryPage_CompareModeMenuLabel;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java
index 11f8af7..0ce9aa6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java
@@ -62,6 +62,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revplot.PlotCommit;
@@ -764,9 +765,16 @@ class CommitGraphTable {
if (selectionSize == 1) {
popupMgr.add(new Separator());
- popupMgr.add(getCommandContributionItem(
- HistoryViewCommands.CHECKOUT,
- UIText.GitHistoryPage_CheckoutMenuLabel));
+ if (hasMultipleRefNodes()) {
+ popupMgr.add(getCommandContributionItem(
+ HistoryViewCommands.CHECKOUT,
+ UIText.GitHistoryPage_CheckoutMenuLabel2));
+ } else {
+ popupMgr.add(getCommandContributionItem(
+ HistoryViewCommands.CHECKOUT,
+ UIText.GitHistoryPage_CheckoutMenuLabel));
+ }
+
popupMgr.add(getCommandContributionItem(
HistoryViewCommands.PUSH_COMMIT,
UIText.GitHistoryPage_pushCommit));
@@ -863,6 +871,25 @@ class CommitGraphTable {
popupMgr.add(new Separator());
}
+ private boolean hasMultipleRefNodes() {
+ try {
+ Map<String, Ref> branches = input.getRepository()
+ .getRefDatabase().getRefs(Constants.R_HEADS);
+ int count = 0;
+ for (Ref branch : branches.values()) {
+ if (branch.getLeaf().getObjectId()
+ .equals(((RevCommit) ((IStructuredSelection) selectionProvider
+ .getSelection()).getFirstElement()).getId()))
+ count++;
+ }
+ return (count > 1);
+
+ } catch (IOException e) {
+ // ignore here
+ }
+ return false;
+ }
+
private CommandContributionItem getCommandContributionItem(
String commandId, String menuLabel) {
CommandContributionItemParameter parameter = new CommandContributionItemParameter(
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index e61c9a2..f13ab69 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -153,6 +153,7 @@ GitHistoryPage_AllInRepoTooltip=Show all changes in repository containing the se
GitHistoryPage_AllOfResourceMenuLabel=All &Changes of Resource
GitHistoryPage_AllOfResourceTooltip=Show all changes of selected resource and its children
GitHistoryPage_CheckoutMenuLabel=&Checkout
+GitHistoryPage_CheckoutMenuLabel2=&Checkout...
GitHistoryPage_CompareModeMenuLabel=Compare &Mode
GitHistoryPage_ReuseCompareEditorMenuLabel=Reuse Compare &Editor
GitHistoryPage_CompareWithCurrentHeadMenu=Compare with &HEAD