Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 49080 Details for
Bug 117517
add support for commit comment templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
CommitTemplatesForMylar Patch
CommitTemplatesForMylar.patch (text/plain), 25.96 KB, created by
Eike Stepper
on 2006-08-30 13:32:17 EDT
(
hide
)
Description:
CommitTemplatesForMylar Patch
Filename:
MIME Type:
Creator:
Eike Stepper
Created:
2006-08-30 13:32:17 EDT
Size:
25.96 KB
patch
obsolete
>Index: src/org/eclipse/mylar/internal/team/ContextChangeSet.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.team/src/org/eclipse/mylar/internal/team/ContextChangeSet.java,v >retrieving revision 1.1 >diff -u -r1.1 ContextChangeSet.java >--- src/org/eclipse/mylar/internal/team/ContextChangeSet.java 17 Jul 2006 03:34:59 -0000 1.1 >+++ src/org/eclipse/mylar/internal/team/ContextChangeSet.java 30 Aug 2006 17:22:13 -0000 >@@ -11,12 +11,6 @@ > > package org.eclipse.mylar.internal.team; > >-import java.util.ArrayList; >-import java.util.Arrays; >-import java.util.HashSet; >-import java.util.List; >-import java.util.Set; >- > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.resources.mapping.ResourceMapping; >@@ -35,6 +29,12 @@ > import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager; > import org.osgi.service.prefs.Preferences; > >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.HashSet; >+import java.util.List; >+import java.util.Set; >+ > /** > * @author Mik Kersten > */ >@@ -101,9 +101,10 @@ > MylarTeamPlugin.COMMIT_PREFIX_COMPLETED); > String progressPrefix = MylarTeamPlugin.getDefault().getPreferenceStore().getString( > MylarTeamPlugin.COMMIT_PREFIX_PROGRESS); >- String comment = ""; >- comment = generateComment(task, completedPrefix, progressPrefix); >- return comment; >+// String comment = ""; >+// comment = generateComment(task, completedPrefix, progressPrefix); >+// return comment; >+ return TemplateHandlersManager.INSTANCE.generateComment(task, completedPrefix,progressPrefix); > } > > @Override >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.team/plugin.xml,v >retrieving revision 1.5 >diff -u -r1.5 plugin.xml >--- plugin.xml 24 Aug 2006 17:51:15 -0000 1.5 >+++ plugin.xml 30 Aug 2006 17:22:13 -0000 >@@ -3,6 +3,7 @@ > <?eclipse version="3.0"?> > <plugin> > <extension-point id="providers" name="Mylar Team Providers" schema="schema/providers.exsd"/> >+ <extension-point id="templateHandlers" name="Mylar Template Handlers" schema="schema/templateHandlers.exsd"/> > > <extension > point="org.eclipse.mylar.team.providers"> >@@ -152,4 +153,44 @@ > </viewerActionBinding> > </extension> > >+ <extension >+ point="org.eclipse.mylar.team.templateHandlers"> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskCompletionDateTemplateHandler" >+ description="Provides the completion date of a Mylar task." >+ recognizedKeyword="task.completion.date"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskCreationDateTemplateHandler" >+ description="Provides the creation date of a Mylar task." >+ recognizedKeyword="task.creation.date"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskDescriptionTemplateHandler" >+ description="Provides the description of a Mylar task." >+ recognizedKeyword="task.description"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskHandleIdentifierTemplateHandler" >+ description="Provides the handle or identifier of a Mylar task." >+ recognizedKeyword="task.id"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskNotesTemplateHandler" >+ description="Provides the notes of a Mylar task." >+ recognizedKeyword="task.notes"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskPriorityTemplateHandler" >+ description="Provides the priority of a Mylar task." >+ recognizedKeyword="task.priority"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskReminderDateTemplateHandler" >+ description="Provides the reminder date of a Mylar task." >+ recognizedKeyword="task.reminder.date"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskTypeTemplateHandler" >+ description="Provides the type of a Mylar task." >+ recognizedKeyword="task.type"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TaskURLTemplateHandler" >+ description="Provides the URL of a Mylar task." >+ recognizedKeyword="task.url"/> >+ </extension> >+ > </plugin> >Index: src/org/eclipse/mylar/internal/team/template/AbstractDateTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/AbstractDateTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/AbstractDateTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/AbstractDateTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.internal.team.AbstractTemplateHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+ >+import java.util.Date; >+ >+ >+public abstract class AbstractDateTemplateHandler extends AbstractTemplateHandler >+{ >+ public AbstractDateTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.team.ITemplateHandler#getValue(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ public String getValue(ITask task) >+ { >+ Date date = getDate(task); >+ return date.toString(); >+ } >+ >+ protected abstract Date getDate(ITask task); >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskCreationDateTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskCreationDateTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskCreationDateTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskCreationDateTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+import org.eclipse.mylar.tasks.core.ITask; >+ >+import java.util.Date; >+ >+public class TaskCreationDateTemplateHandler extends AbstractDateTemplateHandler >+{ >+ public TaskCreationDateTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.internal.team.template.AbstractDateTemplateHandler#getDate(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ @Override >+ protected Date getDate(ITask task) >+ { >+ return task.getCreationDate(); >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskNotesTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskNotesTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskNotesTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskNotesTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.internal.team.AbstractTemplateHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+public class TaskNotesTemplateHandler extends AbstractTemplateHandler >+{ >+ public TaskNotesTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.team.ITemplateHandler#getValue(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ public String getValue(ITask task) >+ { >+ return task.getNotes(); >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskHandleIdentifierTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskHandleIdentifierTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskHandleIdentifierTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskHandleIdentifierTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.internal.team.AbstractTemplateHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+public class TaskHandleIdentifierTemplateHandler extends AbstractTemplateHandler >+{ >+ public TaskHandleIdentifierTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.team.ITemplateHandler#getValue(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ public String getValue(ITask task) >+ { >+ return task.getHandleIdentifier(); >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskReminderDateTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskReminderDateTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskReminderDateTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskReminderDateTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+import org.eclipse.mylar.tasks.core.ITask; >+ >+import java.util.Date; >+ >+public class TaskReminderDateTemplateHandler extends AbstractDateTemplateHandler >+{ >+ public TaskReminderDateTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.internal.team.template.AbstractDateTemplateHandler#getDate(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ @Override >+ protected Date getDate(ITask task) >+ { >+ return task.getReminderDate(); >+ } >+} >Index: src/org/eclipse/mylar/internal/team/AbstractTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/AbstractTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/AbstractTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/AbstractTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+package org.eclipse.mylar.internal.team; >+ >+ >+import org.eclipse.mylar.team.ITemplateHandler; >+ >+ >+public abstract class AbstractTemplateHandler implements ITemplateHandler >+{ >+ protected String description; >+ >+ protected String recognizedKeyword; >+ >+ public AbstractTemplateHandler() >+ { >+ } >+ >+ public String getDescription() >+ { >+ return description != null ? description : "Handler for '" + recognizedKeyword + "'"; >+ } >+ >+ public void setDescription(String description) >+ { >+ this.description = description; >+ } >+ >+ public String getRecognizedKeyword() >+ { >+ return recognizedKeyword; >+ } >+ >+ public void setRecognizedKeyword(String recognizedKeyword) >+ { >+ if (recognizedKeyword == null) >+ { >+ throw new IllegalArgumentException("Keyword to recognize must not be null"); >+ } >+ >+ this.recognizedKeyword = recognizedKeyword; >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskPriorityTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskPriorityTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskPriorityTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskPriorityTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.internal.team.AbstractTemplateHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+public class TaskPriorityTemplateHandler extends AbstractTemplateHandler >+{ >+ public TaskPriorityTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.team.ITemplateHandler#getValue(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ public String getValue(ITask task) >+ { >+ return task.getPriority(); >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskCompletionDateTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskCompletionDateTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskCompletionDateTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskCompletionDateTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+import org.eclipse.mylar.tasks.core.ITask; >+ >+import java.util.Date; >+ >+public class TaskCompletionDateTemplateHandler extends AbstractDateTemplateHandler >+{ >+ public TaskCompletionDateTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.internal.team.template.AbstractDateTemplateHandler#getDate(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ @Override >+ protected Date getDate(ITask task) >+ { >+ return task.getCompletionDate(); >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskURLTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskURLTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskURLTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskURLTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.internal.team.AbstractTemplateHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+public class TaskURLTemplateHandler extends AbstractTemplateHandler >+{ >+ public TaskURLTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.team.ITemplateHandler#getValue(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ public String getValue(ITask task) >+ { >+ return task.getUrl(); >+ } >+} >Index: schema/templateHandlers.exsd >=================================================================== >RCS file: schema/templateHandlers.exsd >diff -N schema/templateHandlers.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/templateHandlers.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,122 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.mylar.team"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.mylar.team" id="templateHandlers" name="Mylar Template Handlers"/> >+ </appInfo> >+ <documentation> >+ [Enter description of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence> >+ <element ref="templateHandler" minOccurs="1" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="templateHandler"> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.mylar.team.ITemplateHandler"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="description" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="recognizedKeyword" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ [Enter the first release in which this extension point appears.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ [Enter extension point usage example here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/mylar/internal/team/TemplateHandlersManager.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/TemplateHandlersManager.java >diff -N src/org/eclipse/mylar/internal/team/TemplateHandlersManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/TemplateHandlersManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,155 @@ >+package org.eclipse.mylar.internal.team; >+ >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.mylar.context.core.MylarStatusHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.team.ITemplateHandler; >+import org.eclipse.mylar.team.MylarTeamPlugin; >+ >+import java.text.MessageFormat; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public class TemplateHandlersManager >+{ >+ public static final TemplateHandlersManager INSTANCE = new TemplateHandlersManager(); >+ >+ private static final String ATTR_CLASS = "class"; >+ >+ private static final String ATTR_DESCRIPTION = "description"; >+ >+ private static final String ATTR_RECOGNIZED_KEYWORD = "recognizedKeyword"; >+ >+ private static final String ELEM_TEMPLATE_HANDLER = "templateHandler"; >+ >+ private static final String EXT_POINT_TEMPLATE_HANDLERS = "templateHandlers"; >+ >+ private List<ITemplateHandler> handlers; >+ >+ private TemplateHandlersManager() >+ { >+ readExtensions(); >+ } >+ >+ private void readExtensions() >+ { >+ ArrayList<ITemplateHandler> handlerList = new ArrayList<ITemplateHandler>(); >+ IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint( >+ MylarTeamPlugin.PLUGIN_ID, EXT_POINT_TEMPLATE_HANDLERS); >+ IExtension[] extensions = extPoint.getExtensions(); >+ for (int i = 0; i < extensions.length; i++) >+ { >+ IExtension extension = extensions[i]; >+ IConfigurationElement[] elements = extension.getConfigurationElements(); >+ for (int j = 0; j < elements.length; j++) >+ { >+ IConfigurationElement element = elements[j]; >+ if (ELEM_TEMPLATE_HANDLER.equals(element.getName())) >+ { >+ try >+ { >+ String description = element.getAttribute(ATTR_DESCRIPTION); >+ String keyword = element.getAttribute(ATTR_RECOGNIZED_KEYWORD); >+ ITemplateHandler handler = (ITemplateHandler)element >+ .createExecutableExtension(ATTR_CLASS); >+ if (handler instanceof AbstractTemplateHandler) >+ { >+ ((AbstractTemplateHandler)handler).setDescription(description); >+ ((AbstractTemplateHandler)handler).setRecognizedKeyword(keyword); >+ } >+ else >+ { >+ String recognizedKeyword = handler.getRecognizedKeyword(); >+ if (recognizedKeyword == null || !recognizedKeyword.equals(keyword)) >+ { >+ throw new IllegalArgumentException( >+ "Keyword markup does not match handler implementation"); >+ } >+ } >+ >+ handlerList.add(handler); >+ } >+ catch (Exception e) >+ { >+ MylarStatusHandler.log(e, MessageFormat.format( >+ "Error while initializing template handler contribution {0} from plugin {1}.", >+ element.getAttribute(ATTR_CLASS), element.getContributor().getName())); >+ } >+ } >+ } >+ } >+ >+ handlerList.trimToSize(); >+ this.handlers = Collections.unmodifiableList(handlerList); >+ } >+ >+ /** >+ * Returns the list of contributed {@link ITemplateHandler}. >+ * >+ * @return a list of {@link ITemplateHandler} >+ */ >+ public List<ITemplateHandler> getHandlers() >+ { >+ return handlers; >+ } >+ >+ public String generateComment(ITask task, String completedTemplate, >+ String progressTemplate) >+ { >+ String template = task.isCompleted() ? completedTemplate : progressTemplate; >+ return processKeywords(task, template); >+ } >+ >+ public String processKeywords(ITask task, String template) >+ { >+ String[] segments = template.split("\\$\\{"); >+ StringBuffer buffer = new StringBuffer(segments[0]); >+ >+ for (int i = 1; i < segments.length; i++) >+ { >+ String segment = segments[i]; >+ String value = null; >+ int brace = segment.indexOf('}'); >+ if (brace > 0) >+ { >+ String keyword = segment.substring(0, brace); >+ value = handleKeyword(task, keyword); >+ } >+ >+ if (value != null) >+ { >+ buffer.append(value); >+ buffer.append(segment.substring(brace + 1)); >+ } >+ else >+ { >+ buffer.append("${"); >+ buffer.append(segment); >+ } >+ } >+ >+ return buffer.toString(); >+ } >+ >+ private String handleKeyword(ITask task, String keyword) >+ { >+ for (ITemplateHandler handler : getHandlers()) >+ { >+ if (handler.getRecognizedKeyword().equals(keyword)) >+ { >+ return handler.getValue(task); >+ } >+ } >+ >+ return null; >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskTypeTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskTypeTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskTypeTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskTypeTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.internal.team.AbstractTemplateHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+public class TaskTypeTemplateHandler extends AbstractTemplateHandler >+{ >+ public TaskTypeTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.team.ITemplateHandler#getValue(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ public String getValue(ITask task) >+ { >+ return task.getTaskType(); >+ } >+} >Index: src/org/eclipse/mylar/team/ITemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/team/ITemplateHandler.java >diff -N src/org/eclipse/mylar/team/ITemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/team/ITemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,14 @@ >+package org.eclipse.mylar.team; >+ >+ >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+public interface ITemplateHandler >+{ >+ public String getDescription(); >+ >+ public String getRecognizedKeyword(); >+ >+ public String getValue(ITask task); >+} >Index: src/org/eclipse/mylar/internal/team/template/TaskDescriptionTemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TaskDescriptionTemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TaskDescriptionTemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TaskDescriptionTemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.internal.team.AbstractTemplateHandler; >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+public class TaskDescriptionTemplateHandler extends AbstractTemplateHandler >+{ >+ public TaskDescriptionTemplateHandler() >+ { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.mylar.team.ITemplateHandler#getValue(org.eclipse.mylar.tasks.core.ITask) >+ */ >+ public String getValue(ITask task) >+ { >+ return task.getDescription(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 117517
:
49080
|
49343
|
49344
|
49347
|
49369
|
49380
|
50234
|
52014
|
52413