1 /*******************************************************************************
2 * Copyright (C) 2011, Mathias Kinzler <mathias.kinzler@sap.com>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
10 *******************************************************************************/
11 package org
.eclipse
.egit
.ui
.internal
.preferences
;
13 import org
.eclipse
.egit
.ui
.Activator
;
14 import org
.eclipse
.egit
.ui
.UIPreferences
;
15 import org
.eclipse
.egit
.ui
.internal
.UIText
;
16 import org
.eclipse
.jface
.layout
.GridDataFactory
;
17 import org
.eclipse
.jface
.layout
.GridLayoutFactory
;
18 import org
.eclipse
.jface
.preference
.BooleanFieldEditor
;
19 import org
.eclipse
.jface
.preference
.FieldEditor
;
20 import org
.eclipse
.jface
.preference
.FieldEditorPreferencePage
;
21 import org
.eclipse
.jface
.preference
.IPreferenceStore
;
22 import org
.eclipse
.jface
.preference
.IntegerFieldEditor
;
23 import org
.eclipse
.swt
.SWT
;
24 import org
.eclipse
.swt
.layout
.GridLayout
;
25 import org
.eclipse
.swt
.widgets
.Composite
;
26 import org
.eclipse
.swt
.widgets
.Group
;
27 import org
.eclipse
.ui
.IWorkbench
;
28 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
31 * Preference page for the History view
33 public class HistoryPreferencePage
extends FieldEditorPreferencePage
implements
34 IWorkbenchPreferencePage
{
37 * The default constructor
39 public HistoryPreferencePage() {
44 protected IPreferenceStore
doGetPreferenceStore() {
45 return Activator
.getDefault().getPreferenceStore();
49 public void init(final IWorkbench workbench
) {
54 protected void createFieldEditors() {
55 Composite main
= getFieldEditorParent();
56 GridLayoutFactory
.swtDefaults().margins(0, 0).applyTo(main
);
57 Group showGroup
= new Group(main
, SWT
.SHADOW_ETCHED_IN
);
58 showGroup
.setText(UIText
.HistoryPreferencePage_ShowGroupLabel
);
59 // we need a span of 2 to accommodate the field editors
60 GridDataFactory
.fillDefaults().grab(true, false).span(2, 1)
62 addField(new BooleanFieldEditor(
63 UIPreferences
.RESOURCEHISTORY_SHOW_ALL_BRANCHES
,
64 UIText
.HistoryPreferencePage_toggleAllBranches
, showGroup
));
65 addField(new BooleanFieldEditor(
66 UIPreferences
.RESOURCEHISTORY_SHOW_FIRST_PARENT_ONLY_DEFAULT
,
67 UIText
.HistoryPreferencePage_showFirstParentOnlyDefault
,
69 addField(new BooleanFieldEditor(
70 UIPreferences
.RESOURCEHISTORY_SHOW_ADDITIONAL_REFS
,
71 UIText
.HistoryPreferencePage_toggleAdditionalRefs
, showGroup
));
72 addField(new BooleanFieldEditor(
73 UIPreferences
.RESOURCEHISTORY_SHOW_NOTES
,
74 UIText
.ResourceHistory_toggleShowNotes
, showGroup
));
75 addField(new BooleanFieldEditor(
76 UIPreferences
.RESOURCEHISTORY_FOLLOW_RENAMES
,
77 UIText
.GitHistoryPage_FollowRenames
, showGroup
));
78 addField(new BooleanFieldEditor(
79 UIPreferences
.RESOURCEHISTORY_SHOW_REV_COMMENT
,
80 UIText
.ResourceHistory_toggleRevComment
, showGroup
));
81 addField(new BooleanFieldEditor(
82 UIPreferences
.RESOURCEHISTORY_SHOW_REV_DETAIL
,
83 UIText
.ResourceHistory_toggleRevDetail
, showGroup
));
84 addField(new BooleanFieldEditor(
85 UIPreferences
.RESOURCEHISTORY_SHOW_RELATIVE_DATE
,
86 UIText
.ResourceHistory_toggleRelativeDate
,
88 addField(new BooleanFieldEditor(
89 UIPreferences
.RESOURCEHISTORY_SHOW_EMAIL_ADDRESSES
,
90 UIText
.HistoryPreferencePage_toggleEmailAddresses
,
92 addField(new BooleanFieldEditor(UIPreferences
.HISTORY_CUT_AT_START
,
93 UIText
.HistoryPreferencePage_toggleShortenAtStart
, showGroup
));
94 addField(new IntegerFieldEditor(UIPreferences
.HISTORY_MAX_NUM_COMMITS
,
95 UIText
.ResourceHistory_MaxNumCommitsInList
,
97 addField(new IntegerFieldEditor(UIPreferences
.HISTORY_MAX_TAG_LENGTH
,
98 UIText
.HistoryPreferencePage_MaxTagLength
,
100 addField(new IntegerFieldEditor(
101 UIPreferences
.HISTORY_MAX_BRANCH_LENGTH
,
102 UIText
.HistoryPreferencePage_MaxBranchLength
,
104 addField(new IntegerFieldEditor(UIPreferences
.HISTORY_MAX_DIFF_LINES
,
105 UIText
.HistoryPreferencePage_MaxDiffLines
, showGroup
));
106 updateMargins(showGroup
);
108 Group commentGroup
= new Group(main
, SWT
.SHADOW_ETCHED_IN
);
109 // we need a span of 2 to accommodate the field editors
110 GridDataFactory
.fillDefaults().grab(true, false).span(2, 1)
111 .applyTo(commentGroup
);
112 commentGroup
.setText(UIText
.HistoryPreferencePage_ShowInRevCommentGroupLabel
);
113 addField(new BooleanFieldEditor(
114 UIPreferences
.HISTORY_SHOW_BRANCH_SEQUENCE
,
115 UIText
.ResourceHistory_ShowBranchSequence
, commentGroup
));
116 addField(new BooleanFieldEditor(
117 UIPreferences
.HISTORY_SHOW_TAG_SEQUENCE
,
118 UIText
.ResourceHistory_ShowTagSequence
, commentGroup
));
119 addField(new BooleanFieldEditor(
120 UIPreferences
.HISTORY_VERIFY_SIGNATURES
,
121 UIText
.ResourceHistory_verifySignatures
, commentGroup
));
122 addField(new BooleanFieldEditor(
123 UIPreferences
.RESOURCEHISTORY_SHOW_COMMENT_WRAP
,
124 UIText
.ResourceHistory_toggleCommentWrap
,
126 addField(new BooleanFieldEditor(
127 UIPreferences
.RESOURCEHISTORY_SHOW_COMMENT_FILL
,
128 UIText
.ResourceHistory_toggleCommentFill
,
130 updateMargins(commentGroup
);
134 * {@link FieldEditor} sets the margin of its parent to zero in its
135 * <code>createControl(Composite)</code> method. Therefore fix the group
136 * margin only after adding the field editors.
141 private void updateMargins(Group group
) {
142 GridLayout layout
= (GridLayout
) group
.getLayout();
143 layout
.marginWidth
= 5;
144 layout
.marginHeight
= 5;