From 245785859931c4ba9139766f7b9ec323439dee4e Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Thu, 5 Feb 2009 00:23:19 +0100 Subject: [PATCH] Resurrect group filtering options in history view This commit restores the ability to filter on not only the selected resource but instead all changes in the same folder, same project or same repository. The flag is persistent. Signed-off-by: Robin Rosenberg Signed-off-by: Shawn O. Pearce --- org.spearce.egit.ui/icons/elcl16/filterfolder.gif | Bin 0 -> 153 bytes org.spearce.egit.ui/icons/elcl16/filterproject.gif | Bin 0 -> 154 bytes org.spearce.egit.ui/icons/elcl16/filterrepo.gif | Bin 0 -> 322 bytes .../src/org/spearce/egit/ui/UIIcons.java | 12 +++ .../src/org/spearce/egit/ui/UIText.java | 9 ++ .../egit/ui/internal/history/GitHistoryPage.java | 113 ++++++++++++++++++++- .../src/org/spearce/egit/ui/uitext.properties | 4 + 7 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 org.spearce.egit.ui/icons/elcl16/filterfolder.gif create mode 100644 org.spearce.egit.ui/icons/elcl16/filterproject.gif create mode 100644 org.spearce.egit.ui/icons/elcl16/filterrepo.gif diff --git a/org.spearce.egit.ui/icons/elcl16/filterfolder.gif b/org.spearce.egit.ui/icons/elcl16/filterfolder.gif new file mode 100644 index 0000000000000000000000000000000000000000..55843e768f2d5509d2b48a1f881fe69ffbe9d59a GIT binary patch literal 153 zcwTe&bhEHb6krfw_{_lI8xA70<^9`?tD`8C{E-xErU-5LbO6*hE zJ^7$cvrWF+k# literal 0 HcwPel00001 diff --git a/org.spearce.egit.ui/icons/elcl16/filterrepo.gif b/org.spearce.egit.ui/icons/elcl16/filterrepo.gif new file mode 100644 index 0000000000000000000000000000000000000000..c1cfa7bedc95329943acc214bf92e072059ad54b GIT binary patch literal 322 zcwTe&bhEHb6krfw_^QU>8xd0UX E0D-q??*IS* literal 0 HcwPel00001 diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIIcons.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIIcons.java index 1697542a..ced186e6 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIIcons.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIIcons.java @@ -71,6 +71,15 @@ public class UIIcons { /** Connect Wizard banner */ public static final ImageDescriptor WIZBAN_CONNECT_REPO; + /** History filter, select all version in repo */ + public static ImageDescriptor FILTERREPO; + + /** History filter, select all version in same project */ + public static ImageDescriptor FILTERPROJECT; + + /** History filter, select all version in same folder */ + public static ImageDescriptor FILTERFOLDER; + private static final URL base; static { @@ -97,6 +106,9 @@ public class UIIcons { CHECKBOX_ENABLED_UNCHECKED = map("checkboxes/enabled_unchecked.gif"); CHECKBOX_DISABLED_CHECKED = map("checkboxes/disabled_checked.gif"); CHECKBOX_DISABLED_UNCHECKED = map("checkboxes/disabled_unchecked.gif"); + FILTERREPO = map("elcl16/filterrepo.gif"); + FILTERPROJECT = map("elcl16/filterproject.gif"); + FILTERFOLDER = map("elcl16/filterfolder.gif"); } private static ImageDescriptor map(final String icon) { diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java index 7a7d3efb..d74f53e6 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java @@ -913,6 +913,15 @@ public class UIText extends NLS { /** */ public static String BranchSelectionDialog_Refs; + /** */ + public static String HistoryPage_ShowAllVersionsForProject; + + /** */ + public static String HistoryPage_ShowAllVersionsForRepo; + + /** */ + public static String HistoryPage_ShowAllVersionsForFolder; + static { initializeMessages(UIText.class.getPackage().getName() + ".uitext", UIText.class); diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java index d718cd76..08887c86 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java @@ -1,5 +1,4 @@ /******************************************************************************* - * Copyright (C) 2008, Robin Rosenberg * Copyright (C) 2008, Roger C. Soares * Copyright (C) 2008, Shawn O. Pearce * @@ -27,6 +26,7 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -193,6 +193,98 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener { */ private RevObjectSelectionProvider revObjectSelectionProvider; + private static final String PREF_SHOWALLFILTER = "org.spearce.egit.ui.githistorypage.showallfilter"; //$NON-NLS-1$ + + enum ShowFilter { + SHOWALLRESOURCE, + SHOWALLFOLDER, + SHOWALLPROJECT, + SHOWALLREPO, + } + + class ShowFilterAction extends Action { + private final ShowFilter filter; + + ShowFilterAction(ShowFilter filter, ImageDescriptor icon, String toolTipText) { + super(null, IAction.AS_CHECK_BOX); + this.filter = filter; + setImageDescriptor(icon); + setToolTipText(toolTipText); + } + @Override + public void run() { + if (!isChecked()) { + if (showAllFilter == filter) { + showAllFilter = ShowFilter.SHOWALLRESOURCE; + refresh(); + } + } + if (isChecked() && showAllFilter != filter) { + showAllFilter = filter; + if (this != showAllRepoVersionsAction) + showAllRepoVersionsAction.setChecked(false); + if (this != showAllProjectVersionsAction) + showAllProjectVersionsAction.setChecked(false); + if (this != showAllFolderVersionsAction) + showAllFolderVersionsAction.setChecked(false); + refresh(); + } + Activator.getDefault().getPreferenceStore().setValue( + PREF_SHOWALLFILTER, showAllFilter.toString()); + } + @Override + public String toString() { + return "ShowFilter[" + filter.toString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + private ShowFilter showAllFilter = ShowFilter.SHOWALLRESOURCE; + + private ShowFilterAction showAllRepoVersionsAction; + + private ShowFilterAction showAllProjectVersionsAction; + + private ShowFilterAction showAllFolderVersionsAction; + + private void createResourceFilterActions() { + try { + showAllFilter = ShowFilter.valueOf(Activator.getDefault() + .getPreferenceStore().getString(PREF_SHOWALLFILTER)); + } catch (IllegalArgumentException e) { + showAllFilter = ShowFilter.SHOWALLRESOURCE; + } + + showAllRepoVersionsAction = new ShowFilterAction( + ShowFilter.SHOWALLREPO, UIIcons.FILTERREPO, + UIText.HistoryPage_ShowAllVersionsForRepo); + + showAllProjectVersionsAction = new ShowFilterAction( + ShowFilter.SHOWALLPROJECT, UIIcons.FILTERPROJECT, + UIText.HistoryPage_ShowAllVersionsForProject); + + showAllFolderVersionsAction = new ShowFilterAction( + ShowFilter.SHOWALLFOLDER, UIIcons.FILTERFOLDER, + UIText.HistoryPage_ShowAllVersionsForFolder); + + showAllRepoVersionsAction + .setChecked(showAllFilter == showAllRepoVersionsAction.filter); + showAllProjectVersionsAction + .setChecked(showAllFilter == showAllProjectVersionsAction.filter); + showAllFolderVersionsAction + .setChecked(showAllFilter == showAllFolderVersionsAction.filter); + + getSite().getActionBars().getToolBarManager().add(new Separator()); + + getSite().getActionBars().getToolBarManager().add( + showAllRepoVersionsAction); + + getSite().getActionBars().getToolBarManager().add( + showAllProjectVersionsAction); + + getSite().getActionBars().getToolBarManager().add( + showAllFolderVersionsAction); + } + @Override public void createControl(final Composite parent) { GridData gd; @@ -227,6 +319,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener { popupMgr = new MenuManager(null, POPUP_ID); attachCommitSelectionChanged(); createLocalToolbarActions(); + createResourceFilterActions(); createStandardActions(); createViewMenu(); @@ -566,9 +659,21 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener { else if (db != map.getRepository()) return false; - final String name = map.getRepoRelativePath(r); - if (name != null && name.length() > 0) - paths.add(name); + if (showAllFilter == ShowFilter.SHOWALLFOLDER) { + final String name = map.getRepoRelativePath(r.getParent()); + if (name != null && name.length() > 0) + paths.add(name); + } else if (showAllFilter == ShowFilter.SHOWALLPROJECT) { + final String name = map.getRepoRelativePath(r.getProject()); + if (name != null && name.length() > 0) + paths.add(name); + } else if (showAllFilter == ShowFilter.SHOWALLREPO) { + // nothing + } else /*if (showAllFilter == ShowFilter.SHOWALLRESOURCE)*/ { + final String name = map.getRepoRelativePath(r); + if (name != null && name.length() > 0) + paths.add(name); + } } if (db == null) diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties index a86e58b0..52fa4f8c 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties @@ -199,6 +199,10 @@ HistoryPage_findbar_changeto_committer=Change to Committer HistoryPage_findbar_exceeded=Results limit exceeded HistoryPage_findbar_notFound=String not found +HistoryPage_ShowAllVersionsForRepo=Show all versions for the repository containing the resource +HistoryPage_ShowAllVersionsForProject=Show all versions for the project containing the resource +HistoryPage_ShowAllVersionsForFolder=Show all versions for the folder containing the resource + HistoryPreferencePage_title=Git PushAction_wrongURIDescription=Remote repositories URIs configuration is corrupted. -- 2.11.4.GIT