Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Nowak2015-08-27 10:51:59 +0000
committerMatthias Sohn2015-09-11 23:35:17 +0000
commitc575f5b76fe2937ecaed8dbe45da62eee3a737e1 (patch)
treee7aa2b9dded821f61bea08b344aa5a8b6eba6b12 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences
parent189356ba819ea2be0e4e4a40d5b54ba541b1e05a (diff)
downloadegit-c575f5b76fe2937ecaed8dbe45da62eee3a737e1.tar.gz
egit-c575f5b76fe2937ecaed8dbe45da62eee3a737e1.tar.xz
egit-c575f5b76fe2937ecaed8dbe45da62eee3a737e1.zip
Add check for warnings and errors before commit
- Add optional check for warnings and errors before commit which can be configured in preferences - Allow to configure if and when a warning should be displayed and if warnings/errors should block the commit - Add a flag to the staging view which allows to override blocking ad-hoc for the next commit Bug: 475559 Change-Id: I352c33d0fed1b610babda2992c6b1b211952dfb2 Signed-off-by: Pawel Nowak <siersciotluk@gmail.com> Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java121
1 files changed, 117 insertions, 4 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
index 25d51b73df..f86601bccd 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/CommittingPreferencePage.java
@@ -10,15 +10,21 @@
package org.eclipse.egit.ui.internal.preferences;
import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.PluginPreferenceInitializer;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
@@ -28,6 +34,16 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
public class CommittingPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
+ private Button warnCheckbox;
+
+ private Group buildProblemsGroup;
+
+ private ComboFieldEditor warnCombo;
+
+ private Button blockCheckbox;
+
+ private ComboFieldEditor blockCombo;
+
/** */
public CommittingPreferencePage() {
super(GRID);
@@ -84,10 +100,59 @@ public class CommittingPreferencePage extends FieldEditorPreferencePage
addField(signedOffBy);
updateMargins(footersGroup);
- IntegerFieldEditor historySize = new IntegerFieldEditor(
- UIPreferences.COMMIT_DIALOG_HISTORY_SIZE,
- UIText.CommittingPreferencePage_commitMessageHistory, main);
- addField(historySize);
+ 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);
BooleanFieldEditor includeUntracked = new BooleanFieldEditor(
UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED,
@@ -95,6 +160,11 @@ public class CommittingPreferencePage extends FieldEditorPreferencePage
includeUntracked.getDescriptionControl(main).setToolTipText(
UIText.CommittingPreferencePage_includeUntrackedFilesTooltip);
addField(includeUntracked);
+
+ IntegerFieldEditor historySize = new IntegerFieldEditor(
+ UIPreferences.COMMIT_DIALOG_HISTORY_SIZE,
+ UIText.CommittingPreferencePage_commitMessageHistory, main);
+ addField(historySize);
}
private void updateMargins(Group group) {
@@ -104,4 +174,47 @@ public class CommittingPreferencePage extends FieldEditorPreferencePage
layout.marginWidth = 5;
layout.marginHeight = 5;
}
+
+ private Button createCheckBox(Composite group, String label) {
+ Button button = new Button(group, SWT.CHECK | SWT.LEFT);
+ button.setText(label);
+ GridData data = new GridData(GridData.FILL);
+ data.verticalAlignment = GridData.CENTER;
+ data.horizontalAlignment = GridData.FILL;
+ button.setLayoutData(data);
+ return button;
+ }
+
+ private void handleBlockCheckboxSelection(boolean selection) {
+ blockCombo.setEnabled(selection, buildProblemsGroup);
+ }
+
+ private void handleWarnCheckboxSelection(boolean selection) {
+ warnCombo.setEnabled(selection, buildProblemsGroup);
+ blockCheckbox.setEnabled(selection);
+ blockCombo.setEnabled(selection, buildProblemsGroup);
+ }
+
+ @Override
+ public boolean performOk() {
+ doGetPreferenceStore().setValue(UIPreferences.WARN_BEFORE_COMMITTING,
+ warnCheckbox.getSelection());
+ doGetPreferenceStore().setValue(UIPreferences.BLOCK_COMMIT,
+ blockCheckbox.getSelection());
+ return super.performOk();
+ }
+
+ private Group createGroup(Composite parent, int numColumns) {
+ Group group = new Group(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ group.setLayout(layout);
+ GridData data = new GridData(SWT.FILL);
+ data.horizontalIndent = 0;
+ data.verticalAlignment = SWT.FILL;
+ data.horizontalAlignment = SWT.END;
+ data.grabExcessHorizontalSpace = true;
+ group.setLayoutData(data);
+ return group;
+ }
}

Back to the top