diff options
author | Mathias Kinzler | 2010-09-06 09:08:13 +0000 |
---|---|---|
committer | Mathias Kinzler | 2010-09-06 09:08:13 +0000 |
commit | 81f5c32b35653940da7adbcaab2b2b70db84b81e (patch) | |
tree | 5437878f2306cffb14814daf820cd66e6906d650 /org.eclipse.egit.ui | |
parent | aa7b1ea7ddab6f32d2d6ca0c5d7f5b487ebd4306 (diff) | |
download | egit-81f5c32b35653940da7adbcaab2b2b70db84b81e.tar.gz egit-81f5c32b35653940da7adbcaab2b2b70db84b81e.tar.xz egit-81f5c32b35653940da7adbcaab2b2b70db84b81e.zip |
History View: always show selected resource
The behavior of the history view is quite confusing for most users:
instead of showing the current input, a combination of input and
the currently checked button is displayed above the list. Not only
do the users have a hard time to understand what they are seeing
and why they have certain context menus available at a given time,
but also when the "Repository" button is selected, the repository name
is always shown as input, no matter where you click. Subsequently,
the navigation history will contain the same String several times, and
you don't see what you have in fact visited.
This change does replace the current String with something
like "File: MyProject/folder/File.txt [myRepository]", or
"Project: MyProject [myRepository]" etc.
The getDescription() method was also changed to return something
like the above appended with a description of the current "filter" setting,
for example "All changes in Repository of this Resource" or "All changes
of this Resource", but unfortunately, this information is never rendered
(the javadoc says it might be rendered as tooltip or such)... I opened
bug 324386 for this one.
Bug: 320998
Change-Id: I9409728d133a70875f9ee16ff93cce33a94361fb
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui')
3 files changed, 94 insertions, 16 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 358da7008c..c2a0dfc8b4 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 @@ -229,6 +229,18 @@ public class UIText extends NLS { public static String GitDocument_errorRefreshQuickdiff; /** */ + public static String GitHistoryPage_AllChangesInFolderHint; + + /** */ + public static String GitHistoryPage_AllChangesInProjectHint; + + /** */ + public static String GitHistoryPage_AllChangesInRepoHint; + + /** */ + public static String GitHistoryPage_AllChangesOfResourceHint; + + /** */ public static String GitDocument_errorResolveQuickdiff; /** */ @@ -271,6 +283,12 @@ public class UIText extends NLS { public static String GitHistoryPage_FileNotInCommit; /** */ + public static String GitHistoryPage_FileType; + + /** */ + public static String GitHistoryPage_FolderType; + + /** */ public static String GitHistoryPage_fileNotFound; /** */ @@ -286,9 +304,15 @@ public class UIText extends NLS { public static String GitHistoryPage_From; /** */ + public static String GitHistoryPage_MultiResourcesType; + + /** */ public static String GitHistoryPage_OpenMenuLabel; /** */ + public static String GitHistoryPage_ProjectType; + + /** */ public static String GitHistoryPage_QuickdiffMenuLabel; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java index 32bf454861..a26413e607 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java @@ -70,7 +70,6 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevFlag; import org.eclipse.jgit.revwalk.RevSort; import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.revwalk.filter.RevFilter; import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; @@ -110,6 +109,10 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { private static final String POPUP_ID = "org.eclipse.egit.ui.historyPageContributions"; //$NON-NLS-1$ + private static final String DESCRIPTION_PATTERN = "{0} - {1}"; //$NON-NLS-1$ + + private static final String NAME_PATTERN = "{0}: {1} [{2}]"; //$NON-NLS-1$ + /** Standard action: select all */ private IAction selectAllAction; @@ -266,6 +269,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { @Override public void run() { String oldName = getName(); + String oldDescription = getDescription(); if (!isChecked()) { if (showAllFilter == filter) { showAllFilter = ShowFilter.SHOWALLRESOURCE; @@ -287,6 +291,11 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { } GitHistoryPage.this.firePropertyChange(GitHistoryPage.this, P_NAME, oldName, getName()); + // even though this is currently ending nowhere (see bug 324386), we + // still create the event + GitHistoryPage.this.firePropertyChange(GitHistoryPage.this, + P_DESCRIPTION, oldDescription, GitHistoryPage.this + .getDescription()); Activator.getDefault().getPreferenceStore().setValue( PREF_SHOWALLFILTER, showAllFilter.toString()); } @@ -1206,31 +1215,68 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { } public String getName() { + // we always visualize the current input in the form + // <type>: <path> [<respository name>] + // in order to give the user an understanding which context + // menus they can expect with the current input + // we show the filter hint only upon getDescription() + // as it wrongly pollutes the navigation history + final String repositoryName = Activator.getDefault() + .getRepositoryUtil().getRepositoryName(db); final ResourceList in = (ResourceList) super.getInput(); - if (currentWalk == null || in == null) - return ""; //$NON-NLS-1$ - final IResource[] items = in.getItems(); - if (items.length == 0) + if (currentWalk == null || in == null || in.getItems().length == 0) return ""; //$NON-NLS-1$ - final StringBuilder b = new StringBuilder(); - b.append(db.getDirectory().getParentFile().getName()); - if (currentWalk.getRevFilter() != RevFilter.ALL) { - b.append(": "); //$NON-NLS-1$ - b.append(currentWalk.getRevFilter()); - } - if (currentWalk.getTreeFilter() != TreeFilter.ALL) { - b.append(":"); //$NON-NLS-1$ + if (in.getItems().length == 1) { + IResource resource = in.getItems()[0]; + final String type; + switch (resource.getType()) { + case IResource.FILE: + type = UIText.GitHistoryPage_FileType; + break; + case IResource.PROJECT: + type = UIText.GitHistoryPage_ProjectType; + break; + default: + type = UIText.GitHistoryPage_FolderType; + break; + } + String path = resource.getFullPath().makeRelative().toString(); + if (resource.getType() == IResource.FOLDER) + path = path + '/'; + return NLS.bind(NAME_PATTERN, new Object[] { type, path, + repositoryName }); + } else { + // can this happen at all? the generic history view can't + // handle multiple selection + StringBuilder b = new StringBuilder(); for (final String p : pathFilters) { - b.append(' '); b.append(p); + b.append(' '); } + return NLS.bind(NAME_PATTERN, new Object[] { + UIText.GitHistoryPage_MultiResourcesType, b.toString(), repositoryName }); } - return b.toString(); } public String getDescription() { - return getName(); + // this doesn't seem to be rendered anywhere, but still... + String filterHint = null; + switch (showAllFilter) { + case SHOWALLREPO: + filterHint = UIText.GitHistoryPage_AllChangesInRepoHint; + break; + case SHOWALLPROJECT: + filterHint = UIText.GitHistoryPage_AllChangesInProjectHint; + break; + case SHOWALLFOLDER: + filterHint = UIText.GitHistoryPage_AllChangesInFolderHint; + break; + case SHOWALLRESOURCE: + filterHint = UIText.GitHistoryPage_AllChangesOfResourceHint; + break; + } + return NLS.bind(DESCRIPTION_PATTERN, getName(), filterHint); } private abstract class BooleanPrefAction extends Action implements 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 520842ef2f..29ab00e6eb 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 @@ -82,6 +82,10 @@ GitDocument_errorLoadCommit=Could not load commit {0} for {1} corresponding to { GitDocument_errorLoadTree=Could not load tree {0} for {1} corresponding to {2} in {3} GitDocument_errorRefreshQuickdiff=Failed to refresh quickdiff GitDocument_errorResolveQuickdiff=Could not resolve quickdiff baseline {0} corresponding to {1} in {2} +GitHistoryPage_AllChangesInFolderHint=All changes of this resource's parent folder and its children +GitHistoryPage_AllChangesInProjectHint=All changes of this resource's project and its children +GitHistoryPage_AllChangesInRepoHint=All changes in the Repository containing this resource +GitHistoryPage_AllChangesOfResourceHint=Changes of this resource and its children only GitHistoryPage_CheckoutMenuLabel=&Checkout GitHistoryPage_CompareWithEachOtherMenuLabel=Compare with &each other GitHistoryPage_CompareWithWorkingTreeMenuMenuLabel=Compare with &working tree @@ -99,8 +103,12 @@ GitHistoryPage_notContainedInCommits=File {0} is not contained in the commits: { GitHistoryPage_openFailed=Opening Editor failed GitHistoryPage_Date=Date GitHistoryPage_FileNotInCommit={0} not in {1} +GitHistoryPage_FileType=File +GitHistoryPage_FolderType=Folder GitHistoryPage_From=From +GitHistoryPage_MultiResourcesType=Multiple Resources GitHistoryPage_OpenMenuLabel=&Open +GitHistoryPage_ProjectType=Project GitHistoryPage_QuickdiffMenuLabel=&Quick Diff GitHistoryPage_ResetBaselineToHeadMenuLabel=Reset Baseline to &HEAD GitHistoryPage_ResetBaselineToParentOfHeadMenuLabel=Reset Baseline to first &Parent of HEAD |