Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2011-09-01 12:55:55 +0000
committerCode Review2011-09-01 12:55:55 +0000
commit5e455e90257656803d1717b9b80b03d9f5ce3510 (patch)
tree9d586833edec4745c7dff427d70cb3d97faa939f
parent605b4e3d698cca795483ba9d9714f7a20a8a6959 (diff)
parent7aad71169277621e93ab34172f86b1f0a32413b9 (diff)
downloadegit-5e455e90257656803d1717b9b80b03d9f5ce3510.tar.gz
egit-5e455e90257656803d1717b9b80b03d9f5ce3510.tar.xz
egit-5e455e90257656803d1717b9b80b03d9f5ce3510.zip
Merge "Show messages in CommitDialog for errors that prevent committing."
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java42
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitMessageComponent.java24
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties3
4 files changed, 76 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index 5fee1e6a9e..fdaf1b6a36 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -1774,6 +1774,9 @@ public class UIText extends NLS {
public static String CommitDialog_Message;
/** */
+ public static String CommitDialog_MessageNoFilesSelected;
+
+ /** */
public static String CommitDialog_Path;
/** */
@@ -1885,6 +1888,12 @@ public class UIText extends NLS {
public static String SpellCheckingMessageArea_selectAll;
/** */
+ public static String CommitMessageComponent_MessageInvalidAuthor;
+
+ /** */
+ public static String CommitMessageComponent_MessageInvalidCommitter;
+
+ /** */
public static String CommitMessageViewer_author;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
index 7615dc5576..99d6239734 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
@@ -79,11 +79,14 @@ import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
@@ -297,6 +300,8 @@ public class CommitDialog extends TitleAreaDialog {
Section filesSection;
+ Button commitButton;
+
ArrayList<CommitItem> items = new ArrayList<CommitItem>();
private String commitMessage = null;
@@ -331,7 +336,6 @@ public class CommitDialog extends TitleAreaDialog {
*/
public CommitDialog(Shell parentShell) {
super(parentShell);
- setTitleImage(UIIcons.WIZBAN_CONNECT_REPO.createImage());
}
/**
@@ -481,9 +485,11 @@ public class CommitDialog extends TitleAreaDialog {
@Override
protected void createButtonsForButtonBar(Composite parent) {
toolkit.adapt(parent, false, false);
- createButton(parent, IDialogConstants.OK_ID, UIText.CommitDialog_Commit, true);
+ commitButton = createButton(parent, IDialogConstants.OK_ID,
+ UIText.CommitDialog_Commit, true);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
+ updateMessage();
}
@Override
@@ -803,6 +809,7 @@ public class CommitDialog extends TitleAreaDialog {
showUntracked = showUntrackedItem.getSelection();
filesViewer.refresh(true);
updateFileSectionText();
+ updateMessage();
}
});
@@ -817,6 +824,7 @@ public class CommitDialog extends TitleAreaDialog {
public void widgetSelected(SelectionEvent e) {
filesViewer.setAllChecked(true);
updateFileSectionText();
+ updateMessage();
}
});
@@ -831,6 +839,7 @@ public class CommitDialog extends TitleAreaDialog {
public void widgetSelected(SelectionEvent e) {
filesViewer.setAllChecked(false);
updateFileSectionText();
+ updateMessage();
}
});
@@ -867,12 +876,41 @@ public class CommitDialog extends TitleAreaDialog {
resourceCol.pack();
container.pack();
commitText.setFocus();
+ Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage();
+ UIUtils.hookDisposal(parent, titleImage);
+ setTitleImage(titleImage);
setTitle(UIText.CommitDialog_Title);
setMessage(UIText.CommitDialog_Message, IMessageProvider.INFORMATION);
+
+ ModifyListener validator = new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ updateMessage();
+ }
+ };
+ commitText.getTextWidget().addModifyListener(validator);
+ authorText.addModifyListener(validator);
+ committerText.addModifyListener(validator);
+ filesViewer.addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ updateMessage();
+ }
+ });
+
updateFileSectionText();
return container;
}
+ private void updateMessage() {
+ String message = commitMessageComponent.getMessage();
+ if (message == null && filesViewer.getCheckedElements().length == 0
+ && !amendingItem.getSelection())
+ message = UIText.CommitDialog_MessageNoFilesSelected;
+ setMessage(message, IMessageProvider.INFORMATION);
+ commitButton.setEnabled(message == null);
+ }
+
private Collection<String> getFileList() {
Collection<String> result = new ArrayList<String>();
for (CommitItem item : items) {
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 5094146661..7587bb07dd 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
@@ -325,6 +325,30 @@ public class CommitMessageComponent {
}
/**
+ * Get an informational message about the state of the commit message
+ * component input. This method checks the current state of the widgets and
+ * must always be called from the UI-thread.
+ *
+ * @return information message or null if none
+ */
+ public String getMessage() {
+ if (commitText.getText().trim().length() == 0)
+ return UIText.CommitDialog_Message;
+
+ String authorValue = authorText.getText();
+ if (authorValue.length() == 0
+ || RawParseUtils.parsePersonIdent(authorValue) == null)
+ return UIText.CommitMessageComponent_MessageInvalidAuthor;
+
+ String committerValue = committerText.getText();
+ if (committerValue.length() == 0
+ || RawParseUtils.parsePersonIdent(committerValue) == null)
+ return UIText.CommitMessageComponent_MessageInvalidCommitter;
+
+ return null;
+ }
+
+ /**
* @return true if commit info is ok
*/
public boolean checkCommitInfo() {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 2a16c028f3..4852b85254 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -612,6 +612,7 @@ CommitDialog_ConfigureLink=Preferences...
CommitDialog_ContentAssist=Content assist available for the files shown
CommitDialog_Files=Files ({0}/{1})
CommitDialog_Message=Enter commit message.
+CommitDialog_MessageNoFilesSelected=Select one or more files to commit
CommitDialog_Path=Path
CommitDialog_Title=Commit Changes to Git Repository
CommitDialog_WrongTypeOfCommitMessageProvider=The extension used as CommitMessageProvider has the wrong type (it must implement org.eclipse.egit.ui.ICommitMessageProvider)
@@ -620,6 +621,8 @@ SpellCheckingMessageArea_copy=&Copy
SpellCheckingMessageArea_cut=C&ut
SpellCheckingMessageArea_paste=&Paste
SpellCheckingMessageArea_selectAll=Select &All
+CommitMessageComponent_MessageInvalidAuthor=Invalid author specified. Example: A U Thor <author@example.com>
+CommitMessageComponent_MessageInvalidCommitter=Invalid committer specified. Example: C O Mitter <committer@example.com>
CommitMessageViewer_author=Author
CommitMessageViewer_child=Child
CommitMessageViewer_branches=Branches

Back to the top