diff options
author | Thomas Wolf | 2018-08-25 21:45:59 +0000 |
---|---|---|
committer | Thomas Wolf | 2018-08-25 21:57:19 +0000 |
commit | 00f6df65446c87fdb87f916053705f1d6575fbe5 (patch) | |
tree | 40b3207e67c51771e4dfc519076aa8ca7eae7e82 | |
parent | 2f9b90656fc1f8db08b1d3c6306fcf60c8ffc304 (diff) | |
download | egit-00f6df65446c87fdb87f916053705f1d6575fbe5.tar.gz egit-00f6df65446c87fdb87f916053705f1d6575fbe5.tar.xz egit-00f6df65446c87fdb87f916053705f1d6575fbe5.zip |
Fix layout and title in CommitSelectionDialog
Since commit 7011de7 the Table of a CommitGraphTable is wrapped
in an intermediate Composite for its TableColumnLayout so that
column widths can be adapted in response to resizes.
However, CommitGraphTable.getControl() still returned the table.
As a result, the GridLayoutData used in the CommitSelectionDialog
got attached to the wrong widget.
Fix this by returning the intermediate Composite from getControl().
Add a new getTable() method that indeed returns the Table; it's
needed for focus tracking. (The getControl().setFocus() calls are
fine; the Composite forwards the focus to its first focusable child,
which is the Table.)
Also use the short repository name in the dialog title instead of
the git directory path.
Bug: 537959
Change-Id: I636982330ca53888d1a23e3ba1ff1f8698829de8
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 files changed, 15 insertions, 8 deletions
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 32736814ad..c58e3aaea2 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 @@ -125,6 +125,8 @@ class CommitGraphTable { private static final String LINESEP = System.getProperty("line.separator"); //$NON-NLS-1$ + private final Composite tableContainer; + private final TableViewer table; private final CommitGraphTableLayout tableLayout; @@ -176,7 +178,7 @@ class CommitGraphTable { hFont = highlightFont(); tableLoader = loader; - Composite tableContainer = new Composite(parent, SWT.NONE); + 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); @@ -317,7 +319,7 @@ class CommitGraphTable { final IAction selectAll = ActionUtils.createGlobalAction( ActionFactory.SELECT_ALL, () -> getTableView().getTable().selectAll()); - ActionUtils.setGlobalActions(getControl(), copy, selectAll); + ActionUtils.setGlobalActions(getTable(), copy, selectAll); getTableView().addOpenListener(new IOpenListener() { @Override @@ -357,13 +359,17 @@ class CommitGraphTable { menuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); menuMgr.add(new Separator()); menuMgr.add(copy); - Control c = getControl(); + Control c = getTable(); menuMgr.addMenuListener(manager -> c.setFocus()); c.setMenu(menuMgr.createContextMenu(c)); } Control getControl() { - return table.getControl(); + return tableContainer; + } + + Table getTable() { + return table.getTable(); } void selectCommitStored(final RevCommit c) { diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitSelectionDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitSelectionDialog.java index b8edd72dcf..13cd1101a0 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitSelectionDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitSelectionDialog.java @@ -21,6 +21,7 @@ import org.eclipse.egit.core.project.RepositoryMapping; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.egit.ui.UIUtils; +import org.eclipse.egit.ui.internal.GitLabels; import org.eclipse.egit.ui.internal.UIText; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.dialogs.TitleAreaDialog; @@ -234,9 +235,9 @@ public class CommitSelectionDialog extends TitleAreaDialog { } private void updateUi() { - setTitle(NLS.bind(UIText.CommitSelectionDialog_DialogTitle, Integer - .valueOf(allCommits.size()), repository.getDirectory() - .toString())); + setTitle(NLS.bind(UIText.CommitSelectionDialog_DialogTitle, + Integer.valueOf(allCommits.size()), + GitLabels.getPlainShortLabel(repository))); setMessage(UIText.CommitSelectionDialog_DialogMessage); table.setInput(highlightFlag, allCommits, allCommits .toArray(new SWTCommit[0]), null, true); 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 0494aa7775..f1bb9e6c03 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 @@ -1331,7 +1331,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener, // Track which of our controls has the focus, so that we can focus the // last focused one in setFocus(). focusTracker = new FocusTracker(); - trackFocus(graph.getControl()); + trackFocus(graph.getTable()); trackFocus(diffViewer.getControl()); trackFocus(commentViewer.getControl()); trackFocus(fileViewer.getControl()); |