git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [EGIT PATCH] Branch bar in resource history.
@ 2008-03-08  5:40 Roger C. Soares
  2008-03-10  0:00 ` Robin Rosenberg
  0 siblings, 1 reply; 4+ messages in thread
From: Roger C. Soares @ 2008-03-08  5:40 UTC (permalink / raw)
  To: git; +Cc: robin.rosenberg, Roger C. Soares

Adds a bar to show the current branch in resource history.
Because other programs can change the current branch, the branch bar
helps the user to remember what is being displayed in resource history.
The bar can be disabled through a local menu preference.
---
 org.spearce.egit.ui/icons/elcl16/branch.gif        |  Bin 0 -> 313 bytes
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |   58 +++++++++++++++++++-
 .../egit/ui/PluginPreferenceInitializer.java       |    1 +
 .../src/org/spearce/egit/ui/UIIcons.java           |    4 ++
 .../src/org/spearce/egit/ui/UIPreferences.java     |    2 +
 .../src/org/spearce/egit/ui/UIText.java            |    4 ++
 .../src/org/spearce/egit/ui/uitext.properties      |    2 +
 7 files changed, 70 insertions(+), 1 deletions(-)
 create mode 100644 org.spearce.egit.ui/icons/elcl16/branch.gif

diff --git a/org.spearce.egit.ui/icons/elcl16/branch.gif b/org.spearce.egit.ui/icons/elcl16/branch.gif
new file mode 100644
index 0000000000000000000000000000000000000000..50c33aa61169d83dc88e1e4d4f7aad90f0382bde
GIT binary patch
literal 313
zcmZ?wbhEHb6krfwSZc&z(h^g-t77Brs*QIlHr}b+c(-EHy|PXB$~WCF*>t~j^Znw@
zkMg%X%G>fdcgy3vEl;wxJjvPeBzMcx?5)o-x4lT-_9Aur%j9jZlD5A}+zupP$8Ud~
zu;Weqj<<0;-$(9zAGPyC_|6XzyFP~P`WU|JQ^>AQp}Rf@@A@3F=d1soZ@zoJ`R)Gh
zyXU+2p6@<;etPZw>9O~x=iZ-QYtHu(i4=dbFmf^2Gw3h?0mx4bY+(oH7kKDM^`BT$
zbW(+l;lc_N2bKjPD?_`Vb{&jscy(Nusn<pI(n%3HCM}WEs?9euEaq+#*pOf$B`6@o
hFDzVT&%ngO!pzFf#>v6e?jJNQ#CPVb+3t=E)&PoVqFDd{

literal 0
HcmV?d00001

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
index 268a6ba..7096f64 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
@@ -63,6 +63,7 @@ import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -70,6 +71,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Table;
@@ -115,8 +117,10 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 	/* private */static final SimpleDateFormat DATETIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm");
 	/* private */static final SimpleDateFormat DATETIMETZ_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
 	/* private */Font BANNER_FONT_BOLD;
+	Image BRANCH_ICON;
 
 	private Composite parentComposite;
+	private Composite branchBarComposite;
 	private SashForm localComposite;
 	private SashForm revisionInfoComposite;
 	/* private */FindToolbar findToolbar;
@@ -127,12 +131,15 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 	/* private */TextViewer revDetailTextViewer;
 	/* private */TextViewer revCommentTextViewer;
 	/* private */IAction toggleCommentWrapAction;
+	private IAction toggleBranchBarAction;
 	/* private */IAction toggleRevDetailAction;
 	/* private */IAction toggleRevCommentAction;
 	/* private */IAction toggleTooltipsAction;
 	/* private */IAction findAction;
 
 	/* private */Table table;
+	Label currentBranchLabel;
+
 	private MouseMoveListener tableMouseMoveListener;
 
 	/* private */List<IFileRevision> fileRevisions;
@@ -172,6 +179,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		Font bannerFont = JFaceResources.getBannerFont();
 		BANNER_FONT_BOLD = new Font(parent.getDisplay(),
 				new FontData(bannerFont.getFontData()[0].getName(), bannerFont.getFontData()[0].getHeight(), SWT.BOLD));
+		BRANCH_ICON = UIIcons.ELCL16_BRANCH.createImage();
 
 		parentComposite = new Composite(parent, SWT.NULL);
 		GridLayout parentLayout = new GridLayout();
@@ -182,6 +190,22 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		GridData parentData = new GridData(SWT.FILL, SWT.FILL, true, true);
 		parentComposite.setLayoutData(parentData);
 
+		branchBarComposite = new Composite(parentComposite, SWT.NULL);
+		GridLayout bbl = new GridLayout();
+		bbl.marginHeight = 0;
+		bbl.marginWidth = 1;
+		bbl.verticalSpacing = 0;
+		bbl.horizontalSpacing = 2;
+		bbl.numColumns = 2;
+		branchBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+		branchBarComposite.setLayout(bbl);
+
+		Label branchIcon = new Label(branchBarComposite, SWT.NULL);
+		branchIcon.setImage(BRANCH_ICON);
+		branchIcon.setToolTipText(UIText.ResourceHistory_currentBranchTooltip);
+		currentBranchLabel = new Label(branchBarComposite, SWT.NULL);
+		currentBranchLabel.setToolTipText(UIText.ResourceHistory_currentBranchTooltip);
+
 		localComposite = new SashForm(parentComposite, SWT.VERTICAL);
 		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
 		localComposite.setLayoutData(data);
@@ -376,6 +400,15 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		};
 		toggleCommentWrapAction.setChecked(prefs.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP));
 
+		toggleBranchBarAction = new Action(UIText.ResourceHistory_toggleBranchBar) {
+			public void run() {
+				showHideBranchBar();
+				prefs.setValue(UIPreferences.RESOURCEHISTORY_SHOW_BRANCHBAR, toggleBranchBarAction.isChecked());
+				Activator.getDefault().savePluginPreferences();
+			}
+		};
+		toggleBranchBarAction.setChecked(prefs.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_BRANCHBAR));
+
 		toggleRevDetailAction = new Action(UIText.ResourceHistory_toggleRevDetail) {
 			public void run() {
 				updateResourceHistoryComposites();
@@ -408,12 +441,14 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		if (menuManager != null) {
 			menuManager.add(toggleCommentWrapAction);
 			menuManager.add(new Separator());
+			menuManager.add(toggleBranchBarAction);
 			menuManager.add(toggleRevDetailAction);
 			menuManager.add(toggleRevCommentAction);
 			menuManager.add(toggleTooltipsAction);
 			menuManager.add(new Separator());
 		}
 		actionBars.updateActionBars();
+		showHideBranchBar();
 		updateResourceHistoryComposites();
 		updateShowTooltips();
 		showHideFindToolbar();
@@ -422,6 +457,15 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		revisionInfoComposite.setWeights(new int[] {40, 60});
 	}
 
+	private void showHideBranchBar() {
+		if(toggleBranchBarAction.isChecked()) {
+			((GridData) branchBarComposite.getLayoutData()).heightHint = SWT.DEFAULT;
+		} else {
+			((GridData) branchBarComposite.getLayoutData()).heightHint = 0;
+		}
+		parentComposite.layout();
+	}
+
 	/* private */void updateResourceHistoryComposites() {
 		boolean commentWrap = toggleCommentWrapAction.isChecked();
 		boolean showRevDetail = toggleRevDetailAction.isChecked();
@@ -471,6 +515,11 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 		parentComposite.layout();
 	}
 
+	private void updateCurrentBranch(String currentBranchName) {
+		currentBranchLabel.setText(currentBranchName);
+		branchBarComposite.layout();
+	}
+
 	/* private */boolean isShowAllRepoVersions() {
 		return showAllRepoVersions;
 	}
@@ -975,6 +1024,12 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 				Map newappliedPatches = null;
 				try {
 					newappliedPatches = repositoryMapping.getRepository().getAppliedPatches();
+					final String currentBranchName = repositoryMapping.getRepository().getBranch();
+					table.getDisplay().asyncExec(new Runnable() {
+						public void run() {
+							updateCurrentBranch(currentBranchName);
+						}
+					});
 				} catch (IOException e) {
 					// TODO Auto-generated catch block
 					e.printStackTrace();
@@ -1063,7 +1118,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 				});
 				final Map fnewappliedPatches = newappliedPatches;
 				final Map<ObjectId,Tag[]> ftags = newtags;
-	
+
 				table.getDisplay().asyncExec(new Runnable() {
 				
 					public void run() {
@@ -1293,6 +1348,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 	@Override
 	public void dispose() {
 		BANNER_FONT_BOLD.dispose();
+		BRANCH_ICON.dispose();
 		super.dispose();
 	}
 
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/PluginPreferenceInitializer.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/PluginPreferenceInitializer.java
index ecb79b8..e480a9e 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/PluginPreferenceInitializer.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/PluginPreferenceInitializer.java
@@ -41,6 +41,7 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer {
 		prefs.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_REV_DETAIL, true);
 		prefs.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_REV_COMMENT, true);
 		prefs.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_TOOLTIPS, false);
+		prefs.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_BRANCHBAR, true);
 
 		prefs.setDefault(UIPreferences.FINDTOOLBAR_IGNORE_CASE, true);
 		prefs.setDefault(UIPreferences.FINDTOOLBAR_COMMIT_ID, true);
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 881265d..7172aec 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
@@ -47,6 +47,9 @@ public class UIIcons {
 	/** Previous arrow icon */
 	public static final ImageDescriptor ELCL16_PREVIOUS;
 
+	/** Branch icon */
+	public static final ImageDescriptor ELCL16_BRANCH;
+
 	private static final URL base;
 
 	static {
@@ -59,6 +62,7 @@ public class UIIcons {
 		ELCL16_FIND = map("elcl16/find.gif");
 		ELCL16_NEXT = map("elcl16/next.gif");
 		ELCL16_PREVIOUS = map("elcl16/previous.gif");
+		ELCL16_BRANCH = map("elcl16/branch.gif");
 	}
 
 	private static ImageDescriptor map(final String icon) {
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIPreferences.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIPreferences.java
index cb9443b..de1dc10 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIPreferences.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIPreferences.java
@@ -32,6 +32,8 @@ public class UIPreferences {
 	/** */
 	public final static String RESOURCEHISTORY_SHOW_FINDTOOLBAR = "resourcehistory_show_findtoolbar";
 	/** */
+	public final static String RESOURCEHISTORY_SHOW_BRANCHBAR = "resourcehistory_show_branchbar";
+	/** */
 	public final static String FINDTOOLBAR_IGNORE_CASE = "findtoolbar_ignore_case";
 	/** */
 	public final static String FINDTOOLBAR_COMMIT_ID = "findtoolbar_commit_id";
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 1454124..4f0aeb8 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
@@ -56,11 +56,15 @@ public class UIText extends NLS {
 	/** */
 	public static String ResourceHistory_toggleCommentWrap;
 	/** */
+	public static String ResourceHistory_toggleBranchBar;
+	/** */
 	public static String ResourceHistory_toggleRevDetail;
 	/** */
 	public static String ResourceHistory_toggleRevComment;
 	/** */
 	public static String ResourceHistory_toggleTooltips;
+	/** */
+	public static String ResourceHistory_currentBranchTooltip;
 
 	static {
 		initializeMessages(UIText.class.getPackage().getName() + ".uitext",
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 be02978..c4eb779 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
@@ -30,6 +30,8 @@ Decorator_failedLazyLoading=Resource decorator failed to load tree contents on d
 QuickDiff_failedLoading=Quick diff failed to obtain file data.
 
 ResourceHistory_toggleCommentWrap=Wrap Comments
+ResourceHistory_toggleBranchBar=Show Branch Bar
 ResourceHistory_toggleRevDetail=Show Revision Details
 ResourceHistory_toggleRevComment=Show Revision Comment
 ResourceHistory_toggleTooltips=Show Revision Tooltip
+ResourceHistory_currentBranchTooltip=Current Branch
-- 
1.5.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [EGIT PATCH] Branch bar in resource history.
  2008-03-08  5:40 [EGIT PATCH] Branch bar in resource history Roger C. Soares
@ 2008-03-10  0:00 ` Robin Rosenberg
  2008-03-10  5:13   ` Roger Carneiro Soares
  0 siblings, 1 reply; 4+ messages in thread
From: Robin Rosenberg @ 2008-03-10  0:00 UTC (permalink / raw)
  To: Roger C. Soares, Shawn O. Pearce, Dave Watson; +Cc: git

Den Saturday 08 March 2008 06.40.28 skrev Roger C. Soares:
> Adds a bar to show the current branch in resource history.
> Because other programs can change the current branch, the branch bar
> helps the user to remember what is being displayed in resource history.
> The bar can be disabled through a local menu preference.

Good idea, but I wonder if we wouldn't be better off trying too keep compact
and do this decoration in the first bar instead, either as an icon or just 
text. I only have 15 inches of preciousss screen space. Compare to what you 
did with the compare view in removing those unnecessary directory levels that
really only wasted space. That was very good.

Another idea would be to allow the user to filter which branches and I think
one could combine this indicator with that functionality through e.g. a poup 
menu. 

The green color on the indicator sugests something is "ok"?

-- robin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [EGIT PATCH] Branch bar in resource history.
  2008-03-10  0:00 ` Robin Rosenberg
@ 2008-03-10  5:13   ` Roger Carneiro Soares
  2008-03-10 23:14     ` Shawn O. Pearce
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Carneiro Soares @ 2008-03-10  5:13 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Shawn O. Pearce, Dave Watson, git

Hi Robin,

> Good idea, but I wonder if we wouldn't be better off trying too keep compact
> and do this decoration in the first bar instead, either as an icon or just 
> text. I only have 15 inches of preciousss screen space. Compare to what you 
> did with the compare view in removing those unnecessary directory levels that
> really only wasted space. That was very good.
>   
My first attempt was to put the current branch name in the first bar, 
before the path, like:
[mybranch]/myproject

But from what I noticed after a little debuging, the history page API 
doesn't allow us to change this value, probably because of the "Show 
Previous Histories" where this value is also stored. We would need to 
change parent classes to make it possible.

I also tried to add the branch name as an icon, but I didn't really like 
it there. In the end I accepted to lose some space, especially because 
when I'm searching for something I end up maximizing the history page. 
And I also started thinking about other uses for it, to convince me that 
another bar there could have some use :)
. maybe put the SHA1 there, like in gitk.
. show the bar in a different color when some filter is applied to help 
avoid confusion when you don't see a commit there.
. put a trail for some common operation.

but, unless someone really sees the need for something, I'm not 
seriously considering any of it right now...

Another attempt I made was to put a vertical bar on the left, but it 
would require the installation of some extra eclipse package to write 
the text in the vertical. I saw that eclipse can also use the java 
graphics api to render things, so if people think it would be the best 
option, I can give it a try.


> Another idea would be to allow the user to filter which branches and I think
> one could combine this indicator with that functionality through e.g. a poup 
> menu. 
>   
This would be really nice :)

Some time ago I wrote a quick hack to show only the commits in the 
current branch and it's been very useful for us. It isn't implemented 
the proper way but I consider it simple and safe and others may find it 
useful too... I'll review it later and post a patch for you to decide.

> The green color on the indicator sugests something is "ok"?
>   
It was my attempt to make a branch icon following eclipse guidelines :) 
It will be more obvious when we have the "list references" icon (get a 
look on gitk: file->list references). It was intended as an icon to 
designate branch.

[]s,
Roger.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [EGIT PATCH] Branch bar in resource history.
  2008-03-10  5:13   ` Roger Carneiro Soares
@ 2008-03-10 23:14     ` Shawn O. Pearce
  0 siblings, 0 replies; 4+ messages in thread
From: Shawn O. Pearce @ 2008-03-10 23:14 UTC (permalink / raw)
  To: Roger Carneiro Soares; +Cc: Robin Rosenberg, Dave Watson, git

Roger Carneiro Soares <rogersoares@intelinet.com.br> wrote:
> >Another idea would be to allow the user to filter which branches and I 
> >think
> >one could combine this indicator with that functionality through e.g. a 
> >poup menu. 
>   
> This would be really nice :)
> 
> Some time ago I wrote a quick hack to show only the commits in the 
> current branch and it's been very useful for us. It isn't implemented 
> the proper way but I consider it simple and safe and others may find it 
> useful too... I'll review it later and post a patch for you to decide.

Now that we have index v2 support implemented my current project
has been "proper" revision machinary for jgit.  Mostly because I
found the History pane too damn slow to be useful, but also as I
need it for the packer for a push implementation.

I have most of the machinary implemented and am right now working on
the path limiter / history simplification.  I already have features
like "--author" and "--grep" working to filter commits, as well
as the commit set difference like "^A ^C B D".  Its wicked fast;
about the exact same speed as C Git, from the time my test "main"
gets invoked to the time I have the full results.

Not unsurprisingly jgit bottlenecks in about the exact same major
areas that C Git bottlenecks, and in about the exact same ratio.
If I remember what JProbe was telling me correctly its about 30%
in zlib's inflate(), 30% in commit parsing, and 30% in the rest of
the lookup-packed-object code.

Pack v4 was being created to reduce the 60% inflate()+parse costs,
as that is the major impact to C Git.

In short, I'm not sure I can squeeze too much more out of jgit.
Given that I'm really close to C Git I think we're nearing the
point where it just can't get faster.

The above mentioned revision machinary is a completely new set of
code in jgit.  I'm basically abandoning the work Robin has done on
this previously.  I also am moving away from the Commit and Tree
classes in favor of smaller, lighter abstractions that perform
better when faced with 17,000 commits.

Most of this code is in my spearce fork of egit in my sp/revwalk
branch, but a good chunk isn't pushed up there yet.  Its not ready
to be merged, but maybe in another week.

-- 
Shawn.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-10 23:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-08  5:40 [EGIT PATCH] Branch bar in resource history Roger C. Soares
2008-03-10  0:00 ` Robin Rosenberg
2008-03-10  5:13   ` Roger Carneiro Soares
2008-03-10 23:14     ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).