Have icon for "reset" entry in reflog
[egit/eclipse.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / preferences / HistoryPreferencePage.java
blob8c0399645206c1db6ca5b496b16819b4bb9e3567
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;
30 /**
31 * Preference page for the History view
33 public class HistoryPreferencePage extends FieldEditorPreferencePage implements
34 IWorkbenchPreferencePage {
36 /**
37 * The default constructor
39 public HistoryPreferencePage() {
40 super(GRID);
43 @Override
44 protected IPreferenceStore doGetPreferenceStore() {
45 return Activator.getDefault().getPreferenceStore();
48 @Override
49 public void init(final IWorkbench workbench) {
50 // Do nothing.
53 @Override
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)
61 .applyTo(showGroup);
62 addField(new BooleanFieldEditor(
63 UIPreferences.RESOURCEHISTORY_SHOW_ALL_BRANCHES,
64 UIText.HistoryPreferencePage_toggleAllBranches, showGroup));
65 addField(new BooleanFieldEditor(
66 UIPreferences.RESOURCEHISTORY_SHOW_ADDITIONAL_REFS,
67 UIText.HistoryPreferencePage_toggleAdditionalRefs, showGroup));
68 addField(new BooleanFieldEditor(
69 UIPreferences.RESOURCEHISTORY_SHOW_NOTES,
70 UIText.ResourceHistory_toggleShowNotes, showGroup));
71 addField(new BooleanFieldEditor(
72 UIPreferences.RESOURCEHISTORY_FOLLOW_RENAMES,
73 UIText.GitHistoryPage_FollowRenames, showGroup));
74 addField(new BooleanFieldEditor(
75 UIPreferences.RESOURCEHISTORY_SHOW_REV_COMMENT,
76 UIText.ResourceHistory_toggleRevComment, showGroup));
77 addField(new BooleanFieldEditor(
78 UIPreferences.RESOURCEHISTORY_SHOW_REV_DETAIL,
79 UIText.ResourceHistory_toggleRevDetail, showGroup));
80 addField(new BooleanFieldEditor(
81 UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE,
82 UIText.ResourceHistory_toggleRelativeDate,
83 showGroup));
84 addField(new BooleanFieldEditor(
85 UIPreferences.RESOURCEHISTORY_SHOW_EMAIL_ADDRESSES,
86 UIText.HistoryPreferencePage_toggleEmailAddresses,
87 showGroup));
88 addField(new BooleanFieldEditor(UIPreferences.HISTORY_CUT_AT_START,
89 UIText.HistoryPreferencePage_toggleShortenAtStart, showGroup));
90 addField(new IntegerFieldEditor(UIPreferences.HISTORY_MAX_NUM_COMMITS,
91 UIText.ResourceHistory_MaxNumCommitsInList,
92 showGroup));
93 addField(new IntegerFieldEditor(UIPreferences.HISTORY_MAX_TAG_LENGTH,
94 UIText.HistoryPreferencePage_MaxTagLength,
95 showGroup));
96 addField(new IntegerFieldEditor(
97 UIPreferences.HISTORY_MAX_BRANCH_LENGTH,
98 UIText.HistoryPreferencePage_MaxBranchLength,
99 showGroup));
100 addField(new IntegerFieldEditor(UIPreferences.HISTORY_MAX_DIFF_LINES,
101 UIText.HistoryPreferencePage_MaxDiffLines, showGroup));
102 updateMargins(showGroup);
104 Group commentGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
105 // we need a span of 2 to accommodate the field editors
106 GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
107 .applyTo(commentGroup);
108 commentGroup.setText(UIText.HistoryPreferencePage_ShowInRevCommentGroupLabel);
109 addField(new BooleanFieldEditor(
110 UIPreferences.HISTORY_SHOW_BRANCH_SEQUENCE,
111 UIText.ResourceHistory_ShowBranchSequence, commentGroup));
112 addField(new BooleanFieldEditor(
113 UIPreferences.HISTORY_SHOW_TAG_SEQUENCE,
114 UIText.ResourceHistory_ShowTagSequence, commentGroup));
115 addField(new BooleanFieldEditor(
116 UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP,
117 UIText.ResourceHistory_toggleCommentWrap,
118 commentGroup));
119 addField(new BooleanFieldEditor(
120 UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL,
121 UIText.ResourceHistory_toggleCommentFill,
122 commentGroup));
123 updateMargins(commentGroup);
127 * {@link FieldEditor} sets the margin of its parent to zero in its
128 * <code>createControl(Composite)</code> method. Therefore fix the group
129 * margin only after adding the field editors.
131 * @param group
132 * group control
134 private void updateMargins(Group group) {
135 GridLayout layout = (GridLayout) group.getLayout();
136 layout.marginWidth = 5;
137 layout.marginHeight = 5;