in org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java [103:309]
protected void createFieldEditors() {
Composite main = getFieldEditorParent();
generalGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
generalGroup.setText(UIText.CommittingPreferencePage_general);
GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
.applyTo(generalGroup);
useStagingView = new BooleanFieldEditor(
UIPreferences.ALWAYS_USE_STAGING_VIEW,
UIText.CommittingPreferencePage_AlwaysUseStagingView,
generalGroup);
addField(useStagingView);
autoStage = new BooleanFieldEditor(UIPreferences.AUTO_STAGE_ON_COMMIT,
UIText.CommittingPreferencePage_AutoStageOnCommit,
generalGroup);
GridDataFactory.fillDefaults().indent(UIUtils.getControlIndent(), 0)
.applyTo(autoStage.getDescriptionControl(generalGroup));
addField(autoStage);
autoStage.setEnabled(getPreferenceStore()
.getBoolean(UIPreferences.ALWAYS_USE_STAGING_VIEW),
generalGroup);
BooleanFieldEditor includeUntracked = new BooleanFieldEditor(
UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED,
UIText.CommittingPreferencePage_includeUntrackedFiles,
generalGroup);
includeUntracked.getDescriptionControl(generalGroup).setToolTipText(
UIText.CommittingPreferencePage_includeUntrackedFilesTooltip);
addField(includeUntracked);
BooleanFieldEditor autoStageDeletion = new BooleanFieldEditor(
GitCorePreferences.core_autoStageDeletion,
UIText.CommittingPreferencePage_autoStageDeletion,
generalGroup) {
@Override
public void setPreferenceStore(IPreferenceStore store) {
super.setPreferenceStore(
store == null ? null : getSecondaryPreferenceStore());
}
};
addField(autoStageDeletion);
BooleanFieldEditor autoStageMoves = new BooleanFieldEditor(
GitCorePreferences.core_autoStageMoves,
UIText.CommittingPreferencePage_autoStageMoves, generalGroup) {
@Override
public void setPreferenceStore(IPreferenceStore store) {
super.setPreferenceStore(
store == null ? null : getSecondaryPreferenceStore());
}
};
addField(autoStageMoves);
IntegerFieldEditor historySize = new IntegerFieldEditor(
UIPreferences.COMMIT_DIALOG_HISTORY_SIZE,
UIText.CommittingPreferencePage_commitMessageHistory,
generalGroup);
addField(historySize);
gpgSigner = new ComboFieldEditor(GitCorePreferences.core_gpgSigner,
UIText.CommittingPreferencePage_gpgSignerLabel,
GPG_SIGNER_NAMES_AND_VALUES, generalGroup) {
@Override
public void setPreferenceStore(IPreferenceStore store) {
super.setPreferenceStore(
store == null ? null : getSecondaryPreferenceStore());
}
};
addField(gpgSigner);
gpgExecutable = new FullWidthFileFieldEditor(
GitCorePreferences.core_gpgExecutable,
UIText.CommittingPreferencePage_gpgExecutableLabel, true,
generalGroup) {
@Override
public void setPreferenceStore(IPreferenceStore store) {
super.setPreferenceStore(
store == null ? null : getSecondaryPreferenceStore());
}
@Override
protected boolean doCheckState() {
Text text = getTextControl();
if (text != null) {
String value = text.getText().trim();
if (!value.isEmpty()) {
try {
// Super class resolves symlinks.
if (!Files.isExecutable(Paths.get(value))) {
setErrorMessage(
UIText.CommittingPreferencePage_gpgExecutableNotExecutable);
return false;
}
} catch (InvalidPathException e) {
setErrorMessage(
UIText.CommittingPreferencePage_gpgExecutableInvalid);
return false;
}
}
}
return super.doCheckState();
}
};
gpgExecutable.indent(UIUtils.getControlIndent(), 0);
addField(gpgExecutable);
gpgExecutable.getLabelControl(generalGroup).setToolTipText(
UIText.CommittingPreferencePage_gpgExecutableTooltip);
updateMargins(generalGroup);
Group formattingGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
formattingGroup.setText(UIText.CommittingPreferencePage_formatting);
GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
.applyTo(formattingGroup);
BooleanFieldEditor hardWrap = new BooleanFieldEditor(
UIPreferences.COMMIT_DIALOG_HARD_WRAP_MESSAGE,
UIText.CommittingPreferencePage_hardWrapMessage, formattingGroup);
hardWrap.getDescriptionControl(formattingGroup).setToolTipText(
UIText.CommittingPreferencePage_hardWrapMessageTooltip);
addField(hardWrap);
BooleanFieldEditor secondLineCheck = new BooleanFieldEditor(
UIPreferences.COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE,
UIText.CommittingPreferencePage_warnAboutCommitMessageSecondLine,
formattingGroup);
addField(secondLineCheck);
updateMargins(formattingGroup);
Group footersGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
footersGroup.setText(UIText.CommittingPreferencePage_footers);
GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
.applyTo(footersGroup);
BooleanFieldEditor signedOffBy = new BooleanFieldEditor(
UIPreferences.COMMIT_DIALOG_SIGNED_OFF_BY,
UIText.CommittingPreferencePage_signedOffBy,
footersGroup);
signedOffBy
.getDescriptionControl(footersGroup)
.setToolTipText(
UIText.CommittingPreferencePage_signedOffByTooltip);
addField(signedOffBy);
updateMargins(footersGroup);
buildProblemsGroup = createGroup(main, 1);
buildProblemsGroup.setText(
UIText.CommittingPreferencePage_WarnBeforeCommittingTitle);
GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
.applyTo(buildProblemsGroup);
warnCheckbox = createCheckBox(buildProblemsGroup,
UIText.CommittingPreferencePage_CheckBeforeCommitting);
((GridData) warnCheckbox.getLayoutData()).horizontalSpan = 3;
warnCheckbox.setSelection(doGetPreferenceStore()
.getBoolean(UIPreferences.WARN_BEFORE_COMMITTING));
warnCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleWarnCheckboxSelection(warnCheckbox.getSelection());
}
});
warnCombo = new ComboFieldEditor(UIPreferences.WARN_BEFORE_COMMITTING_LEVEL,
UIText.CommittingPreferencePage_WarnBeforeCommitting,
new String[][] {
{ UIText.CommittingPreferencePage_WarnBlock_Errors,
PluginPreferenceInitializer.COMMITTING_PREFERENCE_PAGE_WARN_BLOCK_ERRORS },
{ UIText.CommittingPreferencePage_WarnBlock_WarningsAndErrors,
PluginPreferenceInitializer.COMMITTING_PREFERENCE_PAGE_WARN_BLOCK_WARNINGS_AND_ERRORS } },
buildProblemsGroup);
addField(warnCombo);
blockCheckbox = createCheckBox(buildProblemsGroup,
UIText.CommittingPreferencePage_BlockCommit);
((GridData) blockCheckbox.getLayoutData()).horizontalSpan = 3;
blockCheckbox.setSelection(
doGetPreferenceStore().getBoolean(UIPreferences.BLOCK_COMMIT));
blockCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleBlockCheckboxSelection(blockCheckbox.getSelection());
}
});
blockCombo = new ComboFieldEditor(UIPreferences.BLOCK_COMMIT_LEVEL,
UIText.CommittingPreferencePage_BlockCommitCombo,
new String[][] {
{ UIText.CommittingPreferencePage_WarnBlock_Errors,
PluginPreferenceInitializer.COMMITTING_PREFERENCE_PAGE_WARN_BLOCK_ERRORS },
{ UIText.CommittingPreferencePage_WarnBlock_WarningsAndErrors,
PluginPreferenceInitializer.COMMITTING_PREFERENCE_PAGE_WARN_BLOCK_WARNINGS_AND_ERRORS } },
buildProblemsGroup);
addField(blockCombo);
handleWarnCheckboxSelection(warnCheckbox.getSelection());
handleBlockCheckboxSelection(blockCheckbox.getSelection());
updateMargins(buildProblemsGroup);
gpgExecutable.setEnabled("gpg".equals(getSecondaryPreferenceStore() //$NON-NLS-1$
.getString(GitCorePreferences.core_gpgSigner)), generalGroup);
}