From 8322857a739a69759ee8e7841a8487d0a1661792 Mon Sep 17 00:00:00 2001 From: Chris Aniszczyk Date: Mon, 17 Jan 2011 17:56:39 +0100 Subject: Add initial EGit Mylyn integration Generates the commit dialog message by getting the active mylyn task. The commit message is generated by combinging the title with description and commit message template defined in the mylyn preferences. Bug: 306001 Change-Id: I344546626c8cb089c019db08afa400e4847e6fc4 Signed-off-by: Chris Aniszczyk Signed-off-by: Benjamin Muskalla --- .../egit/internal/mylyn/ui/EGitMylynUI.java | 52 ++++++++++++++++++++++ .../ui/commit/MylynCommitMessageProvider.java | 47 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/EGitMylynUI.java create mode 100644 org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java (limited to 'org.eclipse.egit.mylyn.ui/src/org') diff --git a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/EGitMylynUI.java b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/EGitMylynUI.java new file mode 100644 index 0000000000..15b411f80a --- /dev/null +++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/EGitMylynUI.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2011 Chris Aniszczyk and others. + * 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 + * + * Contributors: + * Chris Aniszczyk - initial API and implementation + *******************************************************************************/ +package org.eclipse.egit.internal.mylyn.ui; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class EGitMylynUI extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.egit.mylyn.ui"; //$NON-NLS-1$ + + // The shared instance + private static EGitMylynUI plugin; + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * @return the shared instance + */ + public static EGitMylynUI getDefault() { + return plugin; + } + +} 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 new file mode 100644 index 0000000000..b505aa0b42 --- /dev/null +++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/MylynCommitMessageProvider.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2011 Chris Aniszczyk and others. + * 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 + * + * Contributors: + * Chris Aniszczyk - initial API and implementation + * Manuel Doninger + * Benjamin Muskalla + * Thorsten Kamann + *******************************************************************************/ +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.tasks.core.ITask; +import org.eclipse.mylyn.tasks.core.ITaskActivityManager; +import org.eclipse.mylyn.tasks.ui.TasksUi; + + +/** + * Gets the active task and combines the description and title with + * the commit message template defined in the preferences + */ +@SuppressWarnings("restriction") +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) + 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); + return message; + } + +} -- cgit v1.2.3