Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Dong2016-07-07 23:12:49 +0000
committerMatthias Sohn2016-09-13 21:45:06 +0000
commit219458f33d8a4d97cfdc4e7f635cbc08eaa83c71 (patch)
treeda7ff2c4cee43381ef9f649b2fc94a2c52ff1309
parent435f10cb1e2679c1d47764f294fd2fc07f8a9fac (diff)
downloadegit-219458f33d8a4d97cfdc4e7f635cbc08eaa83c71.tar.gz
egit-219458f33d8a4d97cfdc4e7f635cbc08eaa83c71.tar.xz
egit-219458f33d8a4d97cfdc4e7f635cbc08eaa83c71.zip
Reset commit message in staging view when new task is activated
Bug: 472716 Change-Id: I8c82e078f81078cae5ab14424f4d86e55847dec9 Signed-off-by: Brandon Dong <brandon.dong@tasktop.com>
-rw-r--r--org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.egit.mylyn.ui/plugin.xml7
-rw-r--r--org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/CommitTextTaskActivationListener.java30
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java16
4 files changed, 54 insertions, 2 deletions
diff --git a/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF
index e80412032..7a156cc9b 100644
--- a/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF
@@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.team.core,
org.eclipse.mylyn.context.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.ui.workbench.texteditor,
org.eclipse.jface.text,
- org.eclipse.ui.forms
+ org.eclipse.ui.forms,
+ org.eclipse.egit.ui;bundle-version="[4.5.0,4.6.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/org.eclipse.egit.mylyn.ui/plugin.xml b/org.eclipse.egit.mylyn.ui/plugin.xml
index 59036f9e6..0e9ce6141 100644
--- a/org.eclipse.egit.mylyn.ui/plugin.xml
+++ b/org.eclipse.egit.mylyn.ui/plugin.xml
@@ -34,4 +34,11 @@
class="org.eclipse.egit.internal.mylyn.ui.commit.ActiveTaskBranchNameProvider">
</branchNameProvider>
</extension>
+ <extension
+ point="org.eclipse.mylyn.tasks.core.taskActivationListeners">
+ <listener
+ id="org.eclipse.egit.mylyn.ui.commit.CommitTextTaskActivationListener"
+ class="org.eclipse.egit.internal.mylyn.ui.commit.CommitTextTaskActivationListener">
+ </listener>
+ </extension>
</plugin>
diff --git a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/CommitTextTaskActivationListener.java b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/CommitTextTaskActivationListener.java
new file mode 100644
index 000000000..acaee890a
--- /dev/null
+++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/CommitTextTaskActivationListener.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Brandon Dong <brandon.dong@tasktop.com>
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.internal.mylyn.ui.commit;
+
+import org.eclipse.egit.ui.internal.staging.StagingView;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * A listener that updates commit text in staging view when a task is activated
+ */
+public class CommitTextTaskActivationListener extends TaskActivationAdapter {
+
+ @Override
+ public void taskActivated(ITask task) {
+ StagingView view = (StagingView) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .findView(StagingView.VIEW_ID);
+ if (view != null) {
+ view.resetCommitMessageComponent();
+ }
+ }
+
+}
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 6b85a623d..db867786e 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
@@ -3638,6 +3638,20 @@ public class StagingView extends ViewPart implements IShowInSource {
updateMessage();
}
+ /**
+ * Resets the commit message component state and saves the overwritten
+ * commit message into message history
+ */
+ public void resetCommitMessageComponent() {
+ if (currentRepository != null) {
+ String commitMessage = commitMessageComponent.getCommitMessage();
+ if (commitMessage.trim().length() > 0) {
+ CommitMessageHistory.saveCommitHistory(commitMessage);
+ }
+ loadInitialState(new CommitHelper(currentRepository));
+ }
+ }
+
private void loadExistingState(CommitHelper helper,
CommitMessageComponentState oldState) {
boolean headCommitChanged = !oldState.getHeadCommit().equals(
@@ -3708,7 +3722,7 @@ public class StagingView extends ViewPart implements IShowInSource {
if (message.trim().equals(chIdLine))
return false;
- // change id was added automatically, but ther is more in the
+ // change id was added automatically, but there is more in the
// message; strip the id, and check for the signed-off-by tag
message = message.replace(chIdLine, ""); //$NON-NLS-1$
}

Back to the top