From 9859d128313b86d3aad8aa13cdcea96153150e06 Mon Sep 17 00:00:00 2001 From: Manuel Doninger Date: Fri, 21 Jan 2011 16:17:26 +0100 Subject: Fetch commit message template from project specific settings Resources of the commit are registered and the commit template of the project, that contains a resource to commit is used for the commit message. If resources of multiple projects with their own template are committed, then the template of the first project in the workspace is taken. Bug: 334879 Change-Id: I0ba46429790630787497f00ffdfb26bd6b9b5157 Signed-off-by: Manuel Doninger Signed-off-by: Matthias Sohn --- .../ui/commit/MylynCommitMessageProvider.java | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java index b505aa0b42..f191c0693e 100644 --- a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java +++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java @@ -15,9 +15,10 @@ package org.eclipse.egit.internal.mylyn.ui.commit; import org.eclipse.core.resources.IResource; import org.eclipse.egit.ui.ICommitMessageProvider; -import org.eclipse.mylyn.internal.team.ui.FocusedTeamUiPlugin; +import org.eclipse.mylyn.context.core.ContextCore; +import org.eclipse.mylyn.context.core.IInteractionContext; +import org.eclipse.mylyn.internal.team.ui.ContextChangeSet; import org.eclipse.mylyn.tasks.core.ITask; -import org.eclipse.mylyn.tasks.core.ITaskActivityManager; import org.eclipse.mylyn.tasks.ui.TasksUi; @@ -32,16 +33,31 @@ public class MylynCommitMessageProvider implements ICommitMessageProvider { * @return the mylyn commit message template defined in the preferences */ public String getMessage(IResource[] resources) { - String message = ""; - ITaskActivityManager tam = TasksUi.getTaskActivityManager(); - ITask task = tam.getActiveTask(); - if(task == null) + String message = ""; //$NON-NLS-1$ + if (resources == null) return message; - // generate the comment based on the active mylyn task - String template = FocusedTeamUiPlugin.getDefault().getPreferenceStore().getString(FocusedTeamUiPlugin.COMMIT_TEMPLATE); - FocusedTeamUiPlugin.getDefault().getCommitTemplateManager().generateComment(task, template); - message = FocusedTeamUiPlugin.getDefault().getCommitTemplateManager().generateComment(task, template); + ITask task = getCurrentTask(); + if (task == null) + return message; + boolean checkTaskRepository = true; + message = ContextChangeSet.getComment(checkTaskRepository, task, + resources); + return message; } + /** + * @return the currently activated task or null if no task is + * activated + */ + protected ITask getCurrentTask() { + return TasksUi.getTaskActivityManager().getActiveTask(); + } + + /** + * @return the activecontext or null if no activecontext exists + */ + protected IInteractionContext getActiveContext() { + return ContextCore.getContextManager().getActiveContext(); + } } -- cgit v1.2.3