Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-07-22 09:14:20 -0400
committerThomas Wolf2018-08-01 15:20:30 -0400
commit5b76c96c4b38c2e3a6286190c361dc8dcb3b4a71 (patch)
treefc5ac9df3a4160c7bf7e8c8d254771e30f2313b1
parent7011de74a8fd125677b6a9261d6fbddd51081c99 (diff)
downloadegit-5b76c96c4b38c2e3a6286190c361dc8dcb3b4a71.tar.gz
egit-5b76c96c4b38c2e3a6286190c361dc8dcb3b4a71.tar.xz
egit-5b76c96c4b38c2e3a6286190c361dc8dcb3b4a71.zip
History table: let the user define which columns are shown
Columns in tables cannot be shown/hidden individually. But we can set the width to zero to hide a column. Of course the user can hide and restore columns directly by dragging the column separators, too. Add a "Columns" sub-menu in the view menu where the user can check the columns to be shown/hidden. These modifications are transient; they are not saved or restored when the view is closed or opened, and they do not survive across and IDE restart. This is similar to the "pinned" state of a history view. To permanently change which columns are shown by default, there's a new preference page. Bug: 339796 Change-Id: Ib8daff29b6610eed1397969a203947e5e72b629a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/plugin.properties2
-rw-r--r--org.eclipse.egit.ui/plugin.xml68
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java160
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java37
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryColumnsPreferencePage.java63
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties5
9 files changed, 314 insertions, 54 deletions
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties
index 76e454f20..fdad269b8 100644
--- a/org.eclipse.egit.ui/plugin.properties
+++ b/org.eclipse.egit.ui/plugin.properties
@@ -71,6 +71,7 @@ CompareWithRevisionAction_label=Histor&y...
GitKeyword_label = git egit
GitKeyword_Refresh_label = refresh
GitKeyword_Date_label = date
+GitKeyword_History_label = history
GitActions_label=Git
GitActions_description = Git commands in workbench toolbar and menu
@@ -357,6 +358,7 @@ StashesMenu.label = &Stashes
DialogsPreferencePage.name = Confirmations and Warnings
SynchronizePreferencePage.name = Synchronize
HistoryPreferencePage.name = History
+HistoryColumnsPreferencePage.name = Columns
AdvancedMenu.label = Ad&vanced
RenameBranchMenu.label = &Rename Branch...
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index 7af12f8fe..b965a4e83 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -566,6 +566,18 @@
id="org.eclipse.egit.ui.keyword.git">
</keywordReference>
</page>
+ <page
+ category="org.eclipse.egit.ui.internal.preferences.HistoryPreferencePage"
+ class="org.eclipse.egit.ui.internal.preferences.HistoryColumnsPreferencePage"
+ id="org.eclipse.egit.ui.internal.preferences.HistoryColumnsPreferencePage"
+ name="%HistoryColumnsPreferencePage.name">
+ <keywordReference
+ id="org.eclipse.egit.ui.keyword.git">
+ </keywordReference>
+ <keywordReference
+ id="org.eclipse.egit.ui.keyword.history">
+ </keywordReference>
+ </page>
</extension>
<extension point="org.eclipse.ui.propertyPages">
@@ -573,46 +585,50 @@
name="%Git"
class="org.eclipse.egit.ui.internal.preferences.GitProjectPropertyPage"
id="org.eclipse.egit.ui.preferences.GitProjectPropertyPage">
- <enabledWhen>
- <adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.core.resources.projectPersistentProperty"
- args="org.eclipse.team.core.repository, org.eclipse.egit.core.GitProvider">
- </test>
- </adapt>
- </enabledWhen>
+ <enabledWhen>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.projectPersistentProperty"
+ args="org.eclipse.team.core.repository, org.eclipse.egit.core.GitProvider">
+ </test>
+ </adapt>
+ </enabledWhen>
</page>
<page
class="org.eclipse.egit.ui.internal.repository.RepositoryPropertyPage"
id="org.eclipse.egit.ui.property.RepositoryPropertyPage"
name="%RepositoryConfigPropertyPage">
- <enabledWhen>
- <instanceof value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode" />
- </enabledWhen>
+ <enabledWhen>
+ <instanceof value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode" />
+ </enabledWhen>
</page>
<page
class="org.eclipse.egit.ui.internal.repository.RepositoryStatisticsPage"
id="org.eclipse.egit.ui.property.RepositoryStatisticsPage"
name="%RepositoryStatisticsPage">
- <enabledWhen>
- <instanceof value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode" />
- </enabledWhen>
+ <enabledWhen>
+ <instanceof value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode" />
+ </enabledWhen>
</page>
</extension>
<extension point="org.eclipse.ui.keywords">
- <keyword
- id="org.eclipse.egit.ui.keyword.git"
- label="%GitKeyword_label">
- </keyword>
- <keyword
- id="org.eclipse.egit.ui.keyword.refresh"
- label="%GitKeyword_Refresh_label">
- </keyword>
- <keyword
- id="org.eclipse.egit.ui.keyword.date"
- label="%GitKeyword_Date_label">
- </keyword>
+ <keyword
+ id="org.eclipse.egit.ui.keyword.git"
+ label="%GitKeyword_label">
+ </keyword>
+ <keyword
+ id="org.eclipse.egit.ui.keyword.refresh"
+ label="%GitKeyword_Refresh_label">
+ </keyword>
+ <keyword
+ id="org.eclipse.egit.ui.keyword.date"
+ label="%GitKeyword_Date_label">
+ </keyword>
+ <keyword
+ id="org.eclipse.egit.ui.keyword.history"
+ label="%GitKeyword_History_label">
+ </keyword>
</extension>
<extension point="org.eclipse.ui.decorators">
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
index ce7478708..70010d32e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
@@ -149,6 +149,12 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(UIPreferences.USE_LOGICAL_MODEL, true);
store.setDefault(UIPreferences.REBASE_INTERACTIVE_SYNC_SELECTION, true);
+
+ store.setDefault(UIPreferences.HISTORY_COLUMN_ID, true);
+ store.setDefault(UIPreferences.HISTORY_COLUMN_AUTHOR, true);
+ store.setDefault(UIPreferences.HISTORY_COLUMN_AUTHOR_DATE, true);
+ store.setDefault(UIPreferences.HISTORY_COLUMN_COMMITTER, true);
+ store.setDefault(UIPreferences.HISTORY_COLUMN_COMMITTER_DATE, true);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
index b2bd9574a..4092a9cc7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
@@ -219,6 +219,22 @@ public class UIPreferences {
public static final String HISTORY_SHOW_TAG_SEQUENCE = "HistoryView_ShowTagSequence"; //$NON-NLS-1$
/** */
public static final String HISTORY_SHOW_BRANCH_SEQUENCE = "HistoryView_ShowBranchSequence"; //$NON-NLS-1$
+
+ /** */
+ public static final String HISTORY_COLUMN_ID = "HistoryView_ColumnIdShow"; //$NON-NLS-1$
+
+ /** */
+ public static final String HISTORY_COLUMN_AUTHOR = "HistoryView_ColumnAuthorShow"; //$NON-NLS-1$
+
+ /** */
+ public static final String HISTORY_COLUMN_AUTHOR_DATE = "HistoryView_ColumnAuthorDateShow"; //$NON-NLS-1$
+
+ /** */
+ public static final String HISTORY_COLUMN_COMMITTER = "HistoryView_ColumnCommitterShow"; //$NON-NLS-1$
+
+ /** */
+ public static final String HISTORY_COLUMN_COMMITTER_DATE = "HistoryView_ColumnCommitterDateShow"; //$NON-NLS-1$
+
/** */
public static final String STAGING_VIEW_SHOW_NEW_COMMITS = "StagingView_ShowNewCommits"; //$NON-NLS-1$
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index 2d7e4b9b1..396169b9d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -643,6 +643,9 @@ public class UIText extends NLS {
public static String GitHistoryPage_ShowSubMenuLabel;
/** */
+ public static String GitHistoryPage_ColumnsSubMenuLabel;
+
+ /** */
public static String GitHistoryPage_toggleEmailAddresses;
/** */
@@ -2107,6 +2110,12 @@ public class UIText extends NLS {
public static String HistoryPreferencePage_toggleEmailAddresses;
/** */
+ public static String HistoryColumnsPreferencePage_description;
+
+ /** */
+ public static String HistoryColumnsPreferencePage_title;
+
+ /** */
public static String PullWizardPage_PageName;
/** */
@@ -4556,7 +4565,7 @@ public class UIText extends NLS {
public static String CommitGraphTable_Committer;
/** */
- public static String CommitGraphTable_committerDataColumn;
+ public static String CommitGraphTable_committerDateColumn;
/** */
public static String CommitGraphTable_CompareWithEachOtherInTreeMenuLabel;
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 7339c39b4..32736814a 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
@@ -32,6 +32,7 @@ import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.egit.core.op.CreatePatchOperation;
import org.eclipse.egit.core.op.CreatePatchOperation.DiffHeaderFormat;
@@ -49,7 +50,10 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.viewers.ColumnLayoutData;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -90,6 +94,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Scrollable;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
@@ -122,6 +127,14 @@ class CommitGraphTable {
private final TableViewer table;
+ private final CommitGraphTableLayout tableLayout;
+
+ private final ColumnLayoutData[] columnLayouts = new ColumnLayoutData[6];
+
+ private final ColumnLayoutData[] baseLayouts = new ColumnLayoutData[6];
+
+ private final ColumnLayoutData[] defaultLayouts = new ColumnLayoutData[6];
+
private Clipboard clipboard;
private final SWTPlotRenderer renderer;
@@ -151,21 +164,22 @@ class CommitGraphTable {
private boolean enableAntialias = true;
- CommitGraphTable(Composite parent, final TableLoader loader,
- final ResourceManager resources) {
- this(parent, loader, resources, true);
+ CommitGraphTable(Composite parent, TableLoader loader,
+ ResourceManager resources, boolean canShowEmailAddresses) {
+ this(parent, loader, resources, canShowEmailAddresses, false);
}
CommitGraphTable(Composite parent, final TableLoader loader,
- final ResourceManager resources, boolean canShowEmailAddresses) {
+ final ResourceManager resources, boolean canShowEmailAddresses,
+ boolean useColumnPreferences) {
nFont = UIUtils.getFont(UIPreferences.THEME_CommitGraphNormalFont);
hFont = highlightFont();
tableLoader = loader;
Composite tableContainer = new Composite(parent, SWT.NONE);
final Table rawTable = new Table(tableContainer,
- SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
+ SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
+ | SWT.FULL_SELECTION | SWT.VIRTUAL);
rawTable.setHeaderVisible(true);
rawTable.setLinesVisible(false);
rawTable.setFont(nFont);
@@ -184,13 +198,43 @@ class CommitGraphTable {
}
});
- TableColumnLayout layout = new TableColumnLayout();
- tableContainer.setLayout(layout);
+ tableLayout = new CommitGraphTableLayout();
+ tableContainer.setLayout(tableLayout);
- createColumns(rawTable, layout);
+ createColumns(rawTable);
createPaintListener(rawTable);
- rawTable.addListener(SWT.Resize, event -> layout(rawTable, layout));
+ System.arraycopy(columnLayouts, 0, defaultLayouts, 0,
+ columnLayouts.length);
+ System.arraycopy(columnLayouts, 0, baseLayouts, 0,
+ columnLayouts.length);
+ if (useColumnPreferences) {
+ IPreferenceStore store = Activator.getDefault()
+ .getPreferenceStore();
+ applyColumnPreferences(store, rawTable);
+ IPropertyChangeListener prefsChanged = event -> {
+ String property = event.getProperty();
+ if (UIPreferences.HISTORY_COLUMN_ID.equals(property)
+ || UIPreferences.HISTORY_COLUMN_AUTHOR.equals(property)
+ || UIPreferences.HISTORY_COLUMN_AUTHOR_DATE
+ .equals(property)
+ || UIPreferences.HISTORY_COLUMN_COMMITTER
+ .equals(property)
+ || UIPreferences.HISTORY_COLUMN_COMMITTER_DATE
+ .equals(property)) {
+ rawTable.getDisplay().asyncExec(() -> {
+ if (!rawTable.isDisposed()) {
+ applyColumnPreferences(store, rawTable);
+ rawTable.getParent().layout();
+ }
+ });
+ }
+ };
+ store.addPropertyChangeListener(prefsChanged);
+ rawTable.addDisposeListener(
+ event -> store.removePropertyChangeListener(prefsChanged));
+ }
+ rawTable.addListener(SWT.Resize, event -> layout(rawTable));
table = new TableViewer(rawTable) {
@Override
@@ -268,7 +312,7 @@ class CommitGraphTable {
CommitGraphTable(final Composite parent, final IPageSite site,
final MenuManager menuMgr, final TableLoader loader,
final ResourceManager resources) {
- this(parent, loader, resources);
+ this(parent, loader, resources, true, true);
final IAction selectAll = ActionUtils.createGlobalAction(
ActionFactory.SELECT_ALL,
@@ -417,8 +461,7 @@ class CommitGraphTable {
}
}
- private void createColumns(Table rawTable,
- TableColumnLayout layout) {
+ private void createColumns(Table rawTable) {
final TableColumn commitId = new TableColumn(rawTable, SWT.NONE);
commitId.setResizable(true);
commitId.setText(UIText.CommitGraphTable_CommitId);
@@ -430,37 +473,43 @@ class CommitGraphTable {
} finally {
gc.dispose();
}
- layout.setColumnData(commitId, new ColumnPixelData(minWidth, false));
+ columnLayouts[0] = new ColumnPixelData(minWidth, false);
+ tableLayout.setColumnData(commitId, columnLayouts[0]);
final TableColumn graph = new TableColumn(rawTable, SWT.NONE);
graph.setResizable(true);
graph.setText(UIText.CommitGraphTable_messageColumn);
graph.setWidth(400);
- layout.setColumnData(graph, new ColumnWeightData(20, 200, true));
+ columnLayouts[1] = new ColumnWeightData(20, 200, true);
+ tableLayout.setColumnData(graph, columnLayouts[1]);
final TableColumn author = new TableColumn(rawTable, SWT.NONE);
author.setResizable(true);
author.setText(UIText.HistoryPage_authorColumn);
author.setWidth(100);
- layout.setColumnData(author, new ColumnWeightData(5, 80, true));
+ columnLayouts[2] = new ColumnWeightData(5, 80, true);
+ tableLayout.setColumnData(author, columnLayouts[2]);
final TableColumn date = new TableColumn(rawTable, SWT.NONE);
date.setResizable(true);
date.setText(UIText.HistoryPage_authorDateColumn);
date.setWidth(100);
- layout.setColumnData(date, new ColumnWeightData(5, 80, true));
+ columnLayouts[3] = new ColumnWeightData(5, 80, true);
+ tableLayout.setColumnData(date, columnLayouts[3]);
final TableColumn committer = new TableColumn(rawTable, SWT.NONE);
committer.setResizable(true);
committer.setText(UIText.CommitGraphTable_Committer);
committer.setWidth(100);
- layout.setColumnData(committer, new ColumnWeightData(5, 80, true));
+ columnLayouts[4] = new ColumnWeightData(5, 80, true);
+ tableLayout.setColumnData(committer, columnLayouts[4]);
final TableColumn committerDate = new TableColumn(rawTable, SWT.NONE);
committerDate.setResizable(true);
- committerDate.setText(UIText.CommitGraphTable_committerDataColumn);
+ committerDate.setText(UIText.CommitGraphTable_committerDateColumn);
committerDate.setWidth(100);
- layout.setColumnData(committerDate, new ColumnWeightData(5, 80, true));
+ columnLayouts[5] = new ColumnWeightData(5, 80, true);
+ tableLayout.setColumnData(committerDate, columnLayouts[5]);
}
private void createPaintListener(final Table rawTable) {
@@ -529,7 +578,7 @@ class CommitGraphTable {
return table;
}
- private void layout(Table rawTable, TableColumnLayout layout) {
+ private void layout(Table rawTable) {
rawTable.getParent().layout();
// Check that the table now fits
int tableWidth = rawTable.getSize().x;
@@ -540,11 +589,10 @@ class CommitGraphTable {
}
if (columnsWidth > tableWidth) {
// Re-distribute the space again
- layout.setColumnData(columns[1],
- new ColumnWeightData(20, 200, true));
- for (int i = 2; i < columns.length; i++) {
- layout.setColumnData(columns[i],
- new ColumnWeightData(5, 80, true));
+ for (int i = 1; i < columns.length; i++) {
+ if (columns[i].getWidth() != 0) {
+ tableLayout.setColumnData(columns[i], baseLayouts[i]);
+ }
}
rawTable.getParent().layout();
}
@@ -552,6 +600,66 @@ class CommitGraphTable {
rawTable.redraw();
}
+ void setVisible(int columnIndex, boolean visible) {
+ Assert.isLegal(columnIndex >= 0 && columnIndex < columnLayouts.length);
+ if (columnIndex == 1) {
+ return; // Commit message column is always visible
+ }
+ Table rawTable = table.getTable();
+ TableColumn col = rawTable.getColumn(columnIndex);
+ boolean isVisible = col.getWidth() > 0;
+ if (isVisible != visible) {
+ if (isVisible) {
+ columnLayouts[columnIndex] = tableLayout.getLayoutData(rawTable,
+ columnIndex);
+ if (columnLayouts[columnIndex] == null) {
+ columnLayouts[columnIndex] = defaultLayouts[columnIndex];
+ }
+ tableLayout.setColumnData(col, new ColumnPixelData(0));
+ } else {
+ tableLayout.setColumnData(col, columnLayouts[columnIndex]);
+ }
+ rawTable.getParent().layout();
+ }
+ }
+
+ private void setColumn(TableColumn column, int index, boolean visible) {
+ if (visible) {
+ baseLayouts[index] = defaultLayouts[index];
+ if (column.getWidth() > 0) {
+ return;
+ }
+ tableLayout.setColumnData(column, columnLayouts[index]);
+ } else {
+ baseLayouts[index] = new ColumnPixelData(0);
+ tableLayout.setColumnData(column, baseLayouts[index]);
+ }
+ }
+
+ private void applyColumnPreferences(IPreferenceStore store,
+ Table rawTable) {
+ setColumn(rawTable.getColumn(0), 0,
+ store.getBoolean(UIPreferences.HISTORY_COLUMN_ID));
+ setColumn(rawTable.getColumn(2), 2,
+ store.getBoolean(UIPreferences.HISTORY_COLUMN_AUTHOR));
+ setColumn(rawTable.getColumn(3), 3,
+ store.getBoolean(UIPreferences.HISTORY_COLUMN_AUTHOR_DATE));
+ setColumn(rawTable.getColumn(4), 4,
+ store.getBoolean(UIPreferences.HISTORY_COLUMN_COMMITTER));
+ setColumn(rawTable.getColumn(5), 5,
+ store.getBoolean(UIPreferences.HISTORY_COLUMN_COMMITTER_DATE));
+ }
+
+ private static class CommitGraphTableLayout extends TableColumnLayout {
+
+ @Override
+ protected ColumnLayoutData getLayoutData(Scrollable tableTree,
+ int columnIndex) {
+ // Make this method accessible here
+ return super.getLayoutData(tableTree, columnIndex);
+ }
+ }
+
private final class CommitDragSourceListener extends DragSourceAdapter {
@Override
public void dragStart(DragSourceEvent event) {
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 0b7a9e983..7265f7e0e 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
@@ -157,6 +157,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.team.ui.history.HistoryPage;
import org.eclipse.team.ui.history.IHistoryView;
import org.eclipse.ui.IActionBars;
@@ -173,6 +174,7 @@ import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.ui.progress.UIJob;
+import org.eclipse.ui.texteditor.IUpdate;
/** Graphical commit history viewer. */
public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
@@ -1518,11 +1520,46 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener,
mgr.add(actions.showAllBranchesAction);
}
+ private class ColumnAction extends Action implements IUpdate {
+
+ private final int columnIndex;
+
+ public ColumnAction(String text, int idx) {
+ super(text, IAction.AS_CHECK_BOX);
+ columnIndex = idx;
+ update();
+ }
+
+ @Override
+ public void run() {
+ graph.setVisible(columnIndex, isChecked());
+ }
+
+ @Override
+ public void update() {
+ setChecked(graph.getTableView().getTable().getColumn(columnIndex)
+ .getWidth() > 0);
+ }
+ }
+
private void setupViewMenu() {
IMenuManager viewMenuMgr = getSite().getActionBars().getMenuManager();
viewMenuMgr.add(actions.refreshAction);
viewMenuMgr.add(new Separator());
+ IMenuManager columnsMenuMgr = new MenuManager(
+ UIText.GitHistoryPage_ColumnsSubMenuLabel);
+ viewMenuMgr.add(columnsMenuMgr);
+ TableColumn[] columns = graph.getTableView().getTable().getColumns();
+ for (int i = 0; i < columns.length; i++) {
+ if (i != 1) {
+ ColumnAction action = new ColumnAction(columns[i].getText(), i);
+ columnsMenuMgr.add(action);
+ columns[i].addListener(SWT.Resize, event -> {
+ action.update();
+ });
+ }
+ }
IMenuManager showSubMenuMgr = new MenuManager(
UIText.GitHistoryPage_ShowSubMenuLabel);
viewMenuMgr.add(showSubMenuMgr);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryColumnsPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryColumnsPreferencePage.java
new file mode 100644
index 000000000..72cd1db86
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryColumnsPreferencePage.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (C) 2018 Thomas Wolf <thomas.wolf@paranor.ch>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.preferences;
+
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
+import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * Preferences defining which columns to show by default in the history view.
+ */
+public class HistoryColumnsPreferencePage extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ /** Creates a new instance. */
+ public HistoryColumnsPreferencePage() {
+ super(GRID);
+ setTitle(UIText.HistoryColumnsPreferencePage_title);
+ setDescription(UIText.HistoryColumnsPreferencePage_description);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ // Nothing to do
+ }
+
+ @Override
+ protected IPreferenceStore doGetPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ final Composite pane = getFieldEditorParent();
+ addField(new BooleanFieldEditor(UIPreferences.HISTORY_COLUMN_ID,
+ UIText.CommitGraphTable_CommitId, pane));
+ addField(new BooleanFieldEditor(UIPreferences.HISTORY_COLUMN_AUTHOR,
+ UIText.HistoryPage_authorColumn, pane));
+ addField(
+ new BooleanFieldEditor(UIPreferences.HISTORY_COLUMN_AUTHOR_DATE,
+ UIText.HistoryPage_authorDateColumn, pane));
+ addField(new BooleanFieldEditor(UIPreferences.HISTORY_COLUMN_COMMITTER,
+ UIText.CommitGraphTable_Committer, pane));
+ addField(new BooleanFieldEditor(
+ UIPreferences.HISTORY_COLUMN_COMMITTER_DATE,
+ UIText.CommitGraphTable_committerDateColumn, pane));
+ }
+
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index b0d3500a4..2c95fb4f9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -233,6 +233,7 @@ GitHistoryPage_InRevisionCommentSubMenuLabel=&In Revision Comment
GitHistoryPage_ListIncompleteWarningMessage=The list is incomplete
GitHistoryPage_pushCommit=&Push Commit...
GitHistoryPage_ShowSubMenuLabel=&Show
+GitHistoryPage_ColumnsSubMenuLabel=&Columns
GitHistoryPage_toggleEmailAddresses=&E-mail Addresses
GitPreferenceRoot_automaticallyEnableChangesetModel=Automatically enable commit &grouping in Git synchronizations
GitPreferenceRoot_BlameGroupHeader=Revision Information
@@ -728,6 +729,8 @@ HistoryPreferencePage_MaxDiffLines=Maximum lines to show for a &diff:
HistoryPreferencePage_MaxTagLength=&Maximum characters to show for a tag:
HistoryPreferencePage_ShowGroupLabel=Show
HistoryPreferencePage_ShowInRevCommentGroupLabel=Show in Revision Comment
+HistoryColumnsPreferencePage_description=Select which columns to show by default in the history view. You can change this temporarily via the view menu of the history view.
+HistoryColumnsPreferencePage_title=History Columns
PullWizardPage_PageName=PullWizardPage
PullWizardPage_PageTitle=Pull
@@ -1598,7 +1601,7 @@ DiffViewer_notContainedInCommit=File {0} is not contained in commit {1}
CommitGraphTable_CommitId=Id
CommitGraphTable_CopyCommitIdLabel=Cop&y Commit Id
CommitGraphTable_Committer=Committer
-CommitGraphTable_committerDataColumn=Committed Date
+CommitGraphTable_committerDateColumn=Committed Date
CommitGraphTable_CompareWithEachOtherInTreeMenuLabel=Compare with Each Other in &Tree
CommitGraphTable_DeleteBranchAction=&Delete Branch
CommitGraphTable_DeleteTagAction=De&lete Tag...

Back to the top