Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Hohenegger2016-07-20 21:16:03 +0000
committerMatthias Sohn2016-08-29 20:55:29 +0000
commitb6a287ada0201ab00b19924eeac11d3682677389 (patch)
tree32d09b6228cca4e5a503ba45b9bb3155437a8094
parent4dc4487dd18070a971deb013882c57d3641bcd82 (diff)
downloadegit-b6a287ada0201ab00b19924eeac11d3682677389.tar.gz
egit-b6a287ada0201ab00b19924eeac11d3682677389.tar.xz
egit-b6a287ada0201ab00b19924eeac11d3682677389.zip
Added date time column to feature checkout dialog
The new column displays the time and date when the latest commit on a feature branch was last updated. Additionally, the table is now sorted after the new column, resulting in the last active branches being listed at the top. Change-Id: Id0fc08bcbf02323385b94f37e2a2fb356eda5cb0 Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/UIText.java3
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java36
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/uitext.properties1
3 files changed, 36 insertions, 4 deletions
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/UIText.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/UIText.java
index 61473ab1c..7c09984ca 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/UIText.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/UIText.java
@@ -34,6 +34,9 @@ public class UIText extends NLS {
public static String FeatureFinishHandler_Conflicts;
/** */
+ public static String FilteredBranchesWidget_lastModified;
+
+ /** */
public static String FinishHandler_conflictsWhileMergingFromTo;
/** */
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java
index a72cfd71e..fd4d67cdf 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/dialogs/FilteredBranchesWidget.java
@@ -12,6 +12,7 @@ import java.util.List;
import org.eclipse.egit.gitflow.GitFlowRepository;
import org.eclipse.egit.gitflow.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.PreferenceBasedDateFormatter;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.TreeColumnLayout;
import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -25,6 +26,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.util.GitDateFormatter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -49,6 +51,8 @@ public class FilteredBranchesWidget {
private BranchComparator comparator;
+ private GitDateFormatter dateFormatter;
+
FilteredBranchesWidget(List<Ref> refs, String prefix, GitFlowRepository gfRepo) {
this.refs = refs;
this.prefix = prefix;
@@ -89,10 +93,7 @@ public class FilteredBranchesWidget {
branchesViewer.setComparator(comparator);
DecoratedBranchLabelProvider nameLabelProvider = new DecoratedBranchLabelProvider(gfRepo.getRepository(), prefix);
- TreeColumn nameColumn = createColumn(
- UIText.BranchSelectionTree_NameColumn, branchesViewer,
- nameLabelProvider);
- setSortedColumn(nameColumn, nameLabelProvider);
+ TreeColumn nameColumn = createColumn(UIText.BranchSelectionTree_NameColumn, branchesViewer, nameLabelProvider);
TreeColumn idColumn = createColumn(UIText.BranchSelectionTree_IdColumn, branchesViewer, new ColumnLabelProvider() {
@@ -107,6 +108,23 @@ public class FilteredBranchesWidget {
}
return super.getText(element);
}});
+ ColumnLabelProvider dateLabelProvider = new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof Ref) {
+ String name = ((Ref) element).getName().substring(Constants.R_HEADS.length());
+ RevCommit revCommit = gfRepo.findHead(name);
+ if (revCommit == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getDateFormatter().formatDate(revCommit.getCommitterIdent());
+ }
+ return super.getText(element);
+ }};
+ TreeColumn dateColumn = createColumn(UIText.FilteredBranchesWidget_lastModified, branchesViewer, dateLabelProvider);
+ setSortedColumn(dateColumn, dateLabelProvider);
+
TreeColumn msgColumn = createColumn(UIText.BranchSelectionTree_MessageColumn, branchesViewer, new ColumnLabelProvider() {
@Override
@@ -122,6 +140,7 @@ public class FilteredBranchesWidget {
return super.getText(element);
}});
+
GridDataFactory.fillDefaults().grab(true, true).applyTo(branchesViewer.getControl());
branchesViewer.setContentProvider(new BranchListContentProvider());
@@ -133,6 +152,8 @@ public class FilteredBranchesWidget {
layout.setColumnData(nameColumn, new ColumnWeightData(0, nameColumn.getWidth()));
idColumn.pack();
layout.setColumnData(idColumn, new ColumnWeightData(0, idColumn.getWidth()));
+ dateColumn.pack();
+ layout.setColumnData(dateColumn, new ColumnWeightData(0, dateColumn.getWidth()));
layout.setColumnData(msgColumn, new ColumnWeightData(100));
branchesViewer.getTree().getParent().setLayout(layout);
@@ -140,6 +161,13 @@ public class FilteredBranchesWidget {
return area;
}
+ private GitDateFormatter getDateFormatter() {
+ if (dateFormatter == null) {
+ dateFormatter = PreferenceBasedDateFormatter.create();
+ }
+ return dateFormatter;
+ }
+
private TreeColumn createColumn(final String name, TreeViewer treeViewer, final ColumnLabelProvider labelProvider) {
final TreeColumn column = new TreeColumn(treeViewer.getTree(), SWT.LEFT);
column.setAlignment(SWT.LEFT);
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/uitext.properties b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/uitext.properties
index 98e69b769..80ded82e1 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/uitext.properties
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/uitext.properties
@@ -8,6 +8,7 @@
###############################################################################
DynamicHistoryMenu_startGitflowReleaseFrom=Start release from commit {0}...
FeatureFinishHandler_Conflicts=Conflicts
+FilteredBranchesWidget_lastModified=Last modified
FinishHandler_conflictsWhileMergingFromTo=Conflicts while merging from {0} to {1}
AbstractGitFlowHandler_finishConflicts=Finishing resulted in conflicts.
AbstractGitFlowHandler_rebaseConflicts=Rebasing resulted in conflicts.

Back to the top