diff options
author | Christian Georgi | 2015-08-29 09:10:02 +0000 |
---|---|---|
committer | Matthias Sohn | 2015-09-03 22:13:56 +0000 |
commit | 60765db5942dec2e2fb0853d8d1f98b124f1083b (patch) | |
tree | 563f99cdd17c06139aad576df4c1492a7fd9a412 | |
parent | dce67ceebeba336e13c8514dd132ee130640af20 (diff) | |
download | egit-60765db5942dec2e2fb0853d8d1f98b124f1083b.tar.gz egit-60765db5942dec2e2fb0853d8d1f98b124f1083b.tar.xz egit-60765db5942dec2e2fb0853d8d1f98b124f1083b.zip |
Make check for empty second line configurable
Bug: 475845
Change-Id: I94146efcd7e4fdfc59af91ec11659eeb17cc8211
Signed-off-by: Christian Georgi <christian.georgi@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 files changed, 53 insertions, 4 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java index feed3a008c..a79f48dd0b 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java @@ -5,6 +5,7 @@ * Copyright (C) 2012, Daniel Megert <daniel_megert@ch.ibm.com> * Copyright (C) 2013, Robin Stocker <robin@nibor.org> * Copyright (C) 2015, Jan-Ove Weichel <ovi.weichel@gmail.com> + * Copyright (C) 2015, SAP SE (Christian Georgi <christian.georgi@sap.com>) * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -75,6 +76,7 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer { store.setDefault(UIPreferences.FINDTOOLBAR_FIND_IN, FindToolbar.PREFS_FINDIN_ALL); store.setDefault(UIPreferences.COMMIT_DIALOG_HARD_WRAP_MESSAGE, true); + store.setDefault(UIPreferences.COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE, true); store.setDefault(UIPreferences.COMMIT_DIALOG_SIGNED_OFF_BY, false); store.setDefault(UIPreferences.REFESH_ON_INDEX_CHANGE, true); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java index c063d5055f..020a7c4e34 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java @@ -7,6 +7,7 @@ * Copyright (C) 2013, Tobias Pfeifer <to.pfeifer@sap.com> * Copyright (C) 2014, Marc Khouzam <marc.khouzam@ericsson.com> * Copyright (C) 2015, Jan-Ove Weichel <ovi.weichel@gmail.com> + * Copyright (C) 2015, SAP SE (Christian Georgi <christian.georgi@sap.com>) * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -66,6 +67,8 @@ public class UIPreferences { /** */ public final static String COMMIT_DIALOG_HARD_WRAP_MESSAGE = "commit_dialog_hard_wrap_message"; //$NON-NLS-1$ /** */ + public final static String COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE = "commit_dialog_warn_about_message_second_line"; //$NON-NLS-1$ + /** */ public final static String COMMIT_DIALOG_SIGNED_OFF_BY = "commit_dialog_signed_off_by"; //$NON-NLS-1$ /** */ public final static String COMMIT_DIALOG_HISTORY_SIZE = "commit_dialog_history_size"; //$NON-NLS-1$ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java index 42f9dfdb42..2c8e0d19e9 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java @@ -3172,6 +3172,12 @@ public class UIText extends NLS { public static String CommittingPreferencePage_hardWrapMessageTooltip; /** */ + public static String CommittingPreferencePage_warnAboutCommitMessageSecondLine; + + /** */ + public static String CommittingPreferencePage_secondLineCheckTooltip; + + /** */ public static String CommittingPreferencePage_footers; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageComponent.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageComponent.java index 010639486f..4b053ba112 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageComponent.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageComponent.java @@ -448,10 +448,13 @@ public class CommitMessageComponent { // Check format of commit message. The soft-wrapped text in the SWT // control must be converted to a hard-wrapped text, since this will be // the resulting commit message. - String message = commitText.getCommitMessage(); - String formatIssue = formatIssuesInCommitMessage(message); - if (formatIssue != null) { - return new CommitStatus(formatIssue, IMessageProvider.WARNING); + if (org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore() + .getBoolean(UIPreferences.COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE)) { + String message = commitText.getCommitMessage(); + String formatIssue = formatIssuesInCommitMessage(message); + if (formatIssue != null) { + return new CommitStatus(formatIssue, IMessageProvider.WARNING); + } } return CommitStatus.OK; 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 dd35f9dbe7..25d51b73df 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 @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (C) 2010, 2013 Robin Stocker <robin@nibor.org> and others. + * Copyright (C) 2015 SAP SE (Christian Georgi <christian.georgi@sap.com>) * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -58,6 +59,13 @@ public class CommittingPreferencePage extends FieldEditorPreferencePage 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); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java index 7c18160b07..bf3dc02cad 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (C) 2011, 2015 Bernard Leach <leachbj@bouncycastle.org> and others. + * Copyright (C) 2015 SAP SE (Christian Georgi <christian.georgi@sap.com>) * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -103,7 +104,9 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; +import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.LocalSelectionTransfer; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ContentViewer; import org.eclipse.jface.viewers.DecoratingLabelProvider; @@ -510,6 +513,23 @@ public class StagingView extends ViewPart implements IShowInSource { }; + private final IPropertyChangeListener uiPrefsListener = new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + if (UIPreferences.COMMIT_DIALOG_WARN_ABOUT_MESSAGE_SECOND_LINE + .equals(event.getProperty())) { + asyncExec(new Runnable() { + @Override + public void run() { + if (!commitMessageSection.isDisposed()) { + updateMessage(); + } + } + }); + } + } + }; + private Action signedOffByAction; private Action addChangeIdAction; @@ -957,6 +977,8 @@ public class StagingView extends ViewPart implements IShowInSource { else preferenceStore.setDefault(UIPreferences.STAGING_VIEW_SYNC_SELECTION, true); + preferenceStore.addPropertyChangeListener(uiPrefsListener); + InstanceScope.INSTANCE.getNode( org.eclipse.egit.core.Activator.getPluginId()) .addPreferenceChangeListener(prefListener); @@ -2936,6 +2958,9 @@ public class StagingView extends ViewPart implements IShowInSource { if (refsChangedListener != null) { refsChangedListener.remove(); } + + getPreferenceStore().removePropertyChangeListener(uiPrefsListener); + disposed = true; } 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 24eba92d04..f11b4fcd96 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 @@ -17,6 +17,7 @@ # Marc Khouzam <marc.khouzam@ericsson.com> - Add option not to checkout new branch from Gerrit # Mickael Istria (Red Hat Inc.) - 463339 Simple push wizard improvements # Axel Richard <axel.richard@obeo.fr> - handle symlink decorator in staging view +# Christian Georgi <christian.georgi@sap.com> - Check for empty second line is configurable ############################################################################### AbortRebaseCommand_CancelDialogMessage=The abort operation was canceled AbortRebaseCommand_JobName=Aborting Rebase @@ -1019,6 +1020,7 @@ CommittingPreferencePage_title=Committing CommittingPreferencePage_formatting=Formatting CommittingPreferencePage_hardWrapMessage=Hard-wrap commit message CommittingPreferencePage_hardWrapMessageTooltip=Wrap text in commit message editor while typing +CommittingPreferencePage_warnAboutCommitMessageSecondLine=Warn if second line of commit message is not empty CommittingPreferencePage_footers=Footers CommittingPreferencePage_includeUntrackedFiles=Include selected untracked files CommittingPreferencePage_includeUntrackedFilesTooltip=Check selected untracked files by default |