From 4b5392f48ea79268f56f89d7f08b0bff513cb927 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Wed, 27 Jun 2018 19:17:16 +0200 Subject: [PATCH] Fix history preference page field editor layout BooleanFieldEditors manipulate the GridLayout of their composite parent to have only one column. Therefore avoid BooleanFieldEditors as last field editor, if some of the other field editors need more than one column. Also improve the option label for shortening long branch and tag names. See screenshots in bugzilla. Change-Id: I1cc6656da65467081ea33327fdb8d683cb37b3a6 Signed-off-by: Michael Keppler Bug:536357 --- .../ui/internal/preferences/HistoryPreferencePage.java | 18 ++++++++++++------ .../src/org/eclipse/egit/ui/internal/uitext.properties | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryPreferencePage.java index 730d0a201..8c0399645 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryPreferencePage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/HistoryPreferencePage.java @@ -16,6 +16,7 @@ import org.eclipse.egit.ui.internal.UIText; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IntegerFieldEditor; @@ -84,6 +85,8 @@ public class HistoryPreferencePage extends FieldEditorPreferencePage implements UIPreferences.RESOURCEHISTORY_SHOW_EMAIL_ADDRESSES, UIText.HistoryPreferencePage_toggleEmailAddresses, showGroup)); + addField(new BooleanFieldEditor(UIPreferences.HISTORY_CUT_AT_START, + UIText.HistoryPreferencePage_toggleShortenAtStart, showGroup)); addField(new IntegerFieldEditor(UIPreferences.HISTORY_MAX_NUM_COMMITS, UIText.ResourceHistory_MaxNumCommitsInList, showGroup)); @@ -96,10 +99,8 @@ public class HistoryPreferencePage extends FieldEditorPreferencePage implements showGroup)); addField(new IntegerFieldEditor(UIPreferences.HISTORY_MAX_DIFF_LINES, UIText.HistoryPreferencePage_MaxDiffLines, showGroup)); - - addField(new BooleanFieldEditor(UIPreferences.HISTORY_CUT_AT_START, - UIText.HistoryPreferencePage_toggleShortenAtStart, showGroup)); updateMargins(showGroup); + Group commentGroup = new Group(main, SWT.SHADOW_ETCHED_IN); // we need a span of 2 to accommodate the field editors GridDataFactory.fillDefaults().grab(true, false).span(2, 1) @@ -120,12 +121,17 @@ public class HistoryPreferencePage extends FieldEditorPreferencePage implements UIText.ResourceHistory_toggleCommentFill, commentGroup)); updateMargins(commentGroup); - adjustGridLayout(); } + /** + * {@link FieldEditor} sets the margin of its parent to zero in its + * createControl(Composite) method. Therefore fix the group + * margin only after adding the field editors. + * + * @param group + * group control + */ private void updateMargins(Group group) { - // make sure there is some room between the group border - // and the controls in the group GridLayout layout = (GridLayout) group.getLayout(); layout.marginWidth = 5; layout.marginHeight = 5; 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 d51eb3da6..a562e84fe 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 @@ -722,7 +722,7 @@ HistoryPage_findbar_reference=Branch/Tag HistoryPreferencePage_toggleAllBranches=All &Branches and Tags HistoryPreferencePage_toggleAdditionalRefs=&Additional Refs HistoryPreferencePage_toggleEmailAddresses=&E-mail addresses in Author/Committer columns -HistoryPreferencePage_toggleShortenAtStart=&Shorten long tag and branch names at start +HistoryPreferencePage_toggleShortenAtStart=&Shorten long tag and branch names at the front HistoryPreferencePage_MaxBranchLength=Maximum characters to show for a &branch: HistoryPreferencePage_MaxDiffLines=Maximum lines to show for a &diff: HistoryPreferencePage_MaxTagLength=&Maximum characters to show for a tag: -- 2.11.4.GIT