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 49347 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]
Reworked patch (now with dynamic extensions and content assist)
CommitTemplatesForMylar.patch (text/plain), 62.38 KB, created by
Eike Stepper
on 2006-09-04 10:38:05 EDT
(
hide
)
Description:
Reworked patch (now with dynamic extensions and content assist)
Filename:
MIME Type:
Creator:
Eike Stepper
Created:
2006-09-04 10:38:05 EDT
Size:
62.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.team >Index: src/org/eclipse/mylar/team/MylarTeamPlugin.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.team/src/org/eclipse/mylar/team/MylarTeamPlugin.java,v >retrieving revision 1.4 >diff -u -r1.4 MylarTeamPlugin.java >--- src/org/eclipse/mylar/team/MylarTeamPlugin.java 24 Jul 2006 23:44:26 -0000 1.4 >+++ src/org/eclipse/mylar/team/MylarTeamPlugin.java 4 Sep 2006 14:38:31 -0000 >@@ -1,3 +1,14 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia 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: >+ * University Of British Columbia - initial API and implementation >+ * Eike Stepper - template based commit templates >+ *******************************************************************************/ > package org.eclipse.mylar.team; > > import org.eclipse.mylar.context.core.MylarStatusHandler; >@@ -20,13 +31,13 @@ > > public static final String CHANGE_SET_MANAGE = "org.eclipse.mylar.team.changesets.manage"; > >- public static final String COMMIT_PREFIX_COMPLETED = "org.eclipse.mylar.team.commit.template.completed"; >+ public static final String COMMIT_TEMPLATE_COMPLETED = "org.eclipse.mylar.team.commit.template.completed"; > >- public static final String COMMIT_PREFIX_PROGRESS = "org.eclipse.mylar.team.commit.template.progress"; >+ public static final String COMMIT_TEMPLATE_PROGRESS = "org.eclipse.mylar.team.commit.template.progress"; > >- public static final String DEFAULT_PREFIX_PROGRESS = "Progress on:"; >+ public static final String DEFAULT_TEMPLATE_PROGRESS = "[${task.id}] ${task.summary}"; > >- public static final String DEFAULT_PREFIX_COMPLETED = "Completed:"; >+ public static final String DEFAULT_TEMPLATE_COMPLETED = "[${task.id}] ${task.summary} (COMPLETED)"; > > public MylarTeamPlugin() { > INSTANCE = this; >@@ -63,10 +74,10 @@ > > private void initPreferenceDefaults() { > getPreferenceStore().setDefault(CHANGE_SET_MANAGE, true); >- getPreferenceStore().setDefault(COMMIT_PREFIX_COMPLETED, >- DEFAULT_PREFIX_COMPLETED); >- getPreferenceStore().setDefault(COMMIT_PREFIX_PROGRESS, >- DEFAULT_PREFIX_PROGRESS); >+ getPreferenceStore().setDefault(COMMIT_TEMPLATE_COMPLETED, >+ DEFAULT_TEMPLATE_COMPLETED); >+ getPreferenceStore().setDefault(COMMIT_TEMPLATE_PROGRESS, >+ DEFAULT_TEMPLATE_PROGRESS); > } > > public static MylarTeamPlugin getDefault() { >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 4 Sep 2006 14:38:31 -0000 >@@ -7,15 +7,10 @@ > * > * Contributors: > * University Of British Columbia - initial API and implementation >+ * Eike Stepper - template based commit templates > *******************************************************************************/ >- > 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; >@@ -25,6 +20,7 @@ > import org.eclipse.mylar.context.core.InteractionEvent; > import org.eclipse.mylar.resources.MylarResourcesPlugin; > import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.team.ITemplateHandlersManager; > import org.eclipse.mylar.team.MylarTeamPlugin; > import org.eclipse.team.core.TeamException; > import org.eclipse.team.core.diff.IDiff; >@@ -35,245 +31,321 @@ > 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 > */ >-public class ContextChangeSet extends CVSActiveChangeSet implements IAdaptable { >+public class ContextChangeSet extends CVSActiveChangeSet implements IAdaptable >+{ > >- private static final String PREFIX_HTTP = "http://"; >+ private static final String PREFIX_HTTP = "http://"; > >- private static final String PREFIX_HTTPS = "https://"; >+ private static final String PREFIX_HTTPS = "https://"; > >- private static final String PREFIX_DELIM = ": "; >+ private static final String PREFIX_DELIM = ": "; > >- // HACK: copied from super >- private static final String CTX_TITLE = "title"; >- >- public static final String SOURCE_ID = "org.eclipse.mylar.java.context.changeset.add"; >- >- private boolean suppressInterestContribution = false; >- >- private ITask task; >- >- public ContextChangeSet(ITask task, ActiveChangeSetManager manager) { >- super(manager, task.getDescription()); >- this.task = task; >- initTitle(); >- } >- >- @Override >- public boolean isUserCreated() { >- return true; >- } >- >- public void initTitle() { >- super.setName(task.getDescription()); >- super.setTitle(task.getDescription()); >- } >- >- /** >- * Encodes the handle in the title, since init won't get called on this >- * class. >- */ >- @Override >- public void save(Preferences prefs) { >- super.save(prefs); >- prefs.put(CTX_TITLE, getTitleForPersistance()); >- } >- >- private String getTitleForPersistance() { >- return getTitle() + " (" + task.getHandleIdentifier() + ")"; >- } >- >- public static String getHandleFromPersistedTitle(String title) { >- int delimStart = title.lastIndexOf('('); >- int delimEnd = title.lastIndexOf(')'); >- if (delimStart != -1 && delimEnd != -1) { >- return title.substring(delimStart + 1, delimEnd); >- } else { >- return null; >- } >- } >- >- @Override >- public String getComment() { >- String completedPrefix = MylarTeamPlugin.getDefault().getPreferenceStore().getString( >- MylarTeamPlugin.COMMIT_PREFIX_COMPLETED); >- String progressPrefix = MylarTeamPlugin.getDefault().getPreferenceStore().getString( >- MylarTeamPlugin.COMMIT_PREFIX_PROGRESS); >- String comment = ""; >- comment = generateComment(task, completedPrefix, progressPrefix); >- return comment; >- } >- >- @Override >- public void remove(IResource resource) { >- super.remove(resource); >- } >- >- @Override >- public void remove(IResource[] newResources) { >- super.remove(newResources); >- } >- >- @Override >- public void add(IDiff diff) { >- super.add(diff); >- IResource resource = getResourceFromDiff(diff); >- if (!suppressInterestContribution && resource != null) { >- Set<IResource> resources = new HashSet<IResource>(); >- resources.add(resource); >- if (MylarResourcesPlugin.getDefault() != null) { >- MylarResourcesPlugin.getDefault().getInterestUpdater().addResourceToContext(resources, InteractionEvent.Kind.SELECTION); >- } >- } >- } >- >- private IResource getResourceFromDiff(IDiff diff) { >- if (diff instanceof ResourceDiff) { >- return ((ResourceDiff)diff).getResource(); >- } else if (diff instanceof ThreeWayDiff) { >- ThreeWayDiff threeWayDiff = (ThreeWayDiff)diff; >- return ResourcesPlugin.getWorkspace().getRoot().findMember(threeWayDiff.getPath()); >- } else { >- return null; >- } >- } >- >- @Override >- public void add(IDiff[] diffs) { >- super.add(diffs); >- } >- >- @Override >- public void add(IResource[] newResources) throws CoreException { >- super.add(newResources); >- } >- >- public void restoreResources(IResource[] newResources) throws CoreException { >- suppressInterestContribution = true; >- try { >- super.add(newResources); >- setComment(getComment()); >- } catch (TeamException e) { >- throw e; >- } finally { >- suppressInterestContribution = false; >- } >- } >- >- @Override >- public IResource[] getResources() { >- List<IResource> allResources = getAllResourcesInChangeContext(); >- return allResources.toArray(new IResource[allResources.size()]); >- } >- >- public List<IResource> getAllResourcesInChangeContext() { >- Set<IResource> allResources = new HashSet<IResource>(); >- allResources.addAll(Arrays.asList(super.getResources())); >- if (MylarResourcesPlugin.getDefault() != null && task.isActive()) { >- // TODO: if super is always managed correctly should remove following line >- allResources.addAll(MylarResourcesPlugin.getDefault().getInterestingResources()); >- } >- return new ArrayList<IResource>(allResources); >- } >- >- /** >- * TODO: unnessary check context? >- */ >- public boolean contains(IResource local) { >- return getAllResourcesInChangeContext().contains(local); >- } >- >- public static String generateComment(ITask task, String completedPrefix, String progressPrefix) { >- String comment; >- completedPrefix = fixUpDelimIfPresent(completedPrefix); >- progressPrefix = fixUpDelimIfPresent(progressPrefix); >- if (task.isCompleted()) { >- comment = completedPrefix + PREFIX_DELIM; >- } else { >- comment = progressPrefix + PREFIX_DELIM; >- } >- comment += task.getDescription(); >- String url = task.getUrl(); >- if (url != null && !url.equals("") && !url.endsWith("//")) { >- comment += " \n" + url; >- } >- return comment; >- } >- >- private static String fixUpDelimIfPresent(String prefix) { >- if (prefix.endsWith(":") || prefix.endsWith(PREFIX_DELIM)) { >- prefix = prefix.substring(0, prefix.lastIndexOf(':')); >- } >- return prefix; >- } >- >- public static String getTaskIdFromCommentOrLabel(String comment) { >- int firstDelimIndex = comment.indexOf(PREFIX_DELIM); >- if (firstDelimIndex != -1) { >- int idStart = firstDelimIndex + PREFIX_DELIM.length(); >- int idEnd = comment.indexOf(PREFIX_DELIM, firstDelimIndex + PREFIX_DELIM.length());// comment.indexOf(PREFIX_DELIM); >- if (idEnd != -1 && idStart < idEnd) { >- String id = comment.substring(idStart, idEnd); >- if (id != null) >- return id.trim(); >- } else { >- // change set label >- return comment.substring(0, firstDelimIndex); >- } >- } >- return null; >- } >- >- public static String getUrlFromComment(String comment) { >- int httpIndex = comment.indexOf(PREFIX_HTTP); >- int httpsIndex = comment.indexOf(PREFIX_HTTPS); >- int idStart = -1; >- if (httpIndex != -1) { >- idStart = httpIndex; >- } else if (httpsIndex != -1) { >- idStart = httpsIndex; >- } >- if (idStart != -1) { >- int idEnd = comment.indexOf(' ', idStart); >- if (idEnd == -1) { >- return comment.substring(idStart); >- } else if (idEnd != -1 && idStart < idEnd) { >- return comment.substring(idStart, idEnd); >- } >- } >- return null; >- } >- >- @Override >- public boolean equals(Object object) { >- if (object instanceof ContextChangeSet && task != null) { >- ContextChangeSet changeSet = (ContextChangeSet) object; >- return task.equals(changeSet.getTask()); >- } else { >- return super.equals(object); >- } >- } >- >- @Override >- public int hashCode() { >- if (task != null) { >- return task.hashCode(); >- } else { >- return super.hashCode(); >- } >- } >- >- public ITask getTask() { >- return task; >- } >- >- public Object getAdapter(Class adapter) { >- if (adapter == ResourceMapping.class) { >- return new ChangeSetResourceMapping(this); >- } else { >- return null; >- } >- } >+ // HACK: copied from super >+ private static final String CTX_TITLE = "title"; >+ >+ public static final String SOURCE_ID = "org.eclipse.mylar.java.context.changeset.add"; >+ >+ private boolean suppressInterestContribution = false; >+ >+ private ITask task; >+ >+ public ContextChangeSet(ITask task, ActiveChangeSetManager manager) >+ { >+ super(manager, task.getDescription()); >+ this.task = task; >+ initTitle(); >+ } >+ >+ @Override >+ public boolean isUserCreated() >+ { >+ return true; >+ } >+ >+ public void initTitle() >+ { >+ super.setName(task.getDescription()); >+ super.setTitle(task.getDescription()); >+ } >+ >+ /** >+ * Encodes the handle in the title, since init won't get called on this >+ * class. >+ */ >+ @Override >+ public void save(Preferences prefs) >+ { >+ super.save(prefs); >+ prefs.put(CTX_TITLE, getTitleForPersistance()); >+ } >+ >+ private String getTitleForPersistance() >+ { >+ return getTitle() + " (" + task.getHandleIdentifier() + ")"; >+ } >+ >+ public static String getHandleFromPersistedTitle(String title) >+ { >+ int delimStart = title.lastIndexOf('('); >+ int delimEnd = title.lastIndexOf(')'); >+ if (delimStart != -1 && delimEnd != -1) >+ { >+ return title.substring(delimStart + 1, delimEnd); >+ } >+ else >+ { >+ return null; >+ } >+ } >+ >+ @Override >+ public String getComment() >+ { >+ String completedTemplate = MylarTeamPlugin.getDefault().getPreferenceStore().getString( >+ MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED); >+ String progressTemplate = MylarTeamPlugin.getDefault().getPreferenceStore().getString( >+ MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS); >+ return ITemplateHandlersManager.INSTANCE.generateComment(task, completedTemplate, >+ progressTemplate); >+ } >+ >+ @Override >+ public void remove(IResource resource) >+ { >+ super.remove(resource); >+ } >+ >+ @Override >+ public void remove(IResource[] newResources) >+ { >+ super.remove(newResources); >+ } >+ >+ @Override >+ public void add(IDiff diff) >+ { >+ super.add(diff); >+ IResource resource = getResourceFromDiff(diff); >+ if (!suppressInterestContribution && resource != null) >+ { >+ Set<IResource> resources = new HashSet<IResource>(); >+ resources.add(resource); >+ if (MylarResourcesPlugin.getDefault() != null) >+ { >+ MylarResourcesPlugin.getDefault().getInterestUpdater().addResourceToContext(resources, >+ InteractionEvent.Kind.SELECTION); >+ } >+ } >+ } >+ >+ private IResource getResourceFromDiff(IDiff diff) >+ { >+ if (diff instanceof ResourceDiff) >+ { >+ return ((ResourceDiff)diff).getResource(); >+ } >+ else if (diff instanceof ThreeWayDiff) >+ { >+ ThreeWayDiff threeWayDiff = (ThreeWayDiff)diff; >+ return ResourcesPlugin.getWorkspace().getRoot().findMember(threeWayDiff.getPath()); >+ } >+ else >+ { >+ return null; >+ } >+ } >+ >+ @Override >+ public void add(IDiff[] diffs) >+ { >+ super.add(diffs); >+ } >+ >+ @Override >+ public void add(IResource[] newResources) throws CoreException >+ { >+ super.add(newResources); >+ } >+ >+ public void restoreResources(IResource[] newResources) throws CoreException >+ { >+ suppressInterestContribution = true; >+ try >+ { >+ super.add(newResources); >+ setComment(getComment()); >+ } >+ catch (TeamException e) >+ { >+ throw e; >+ } >+ finally >+ { >+ suppressInterestContribution = false; >+ } >+ } >+ >+ @Override >+ public IResource[] getResources() >+ { >+ List<IResource> allResources = getAllResourcesInChangeContext(); >+ return allResources.toArray(new IResource[allResources.size()]); >+ } >+ >+ public List<IResource> getAllResourcesInChangeContext() >+ { >+ Set<IResource> allResources = new HashSet<IResource>(); >+ allResources.addAll(Arrays.asList(super.getResources())); >+ if (MylarResourcesPlugin.getDefault() != null && task.isActive()) >+ { >+ // TODO: if super is always managed correctly should remove following line >+ allResources.addAll(MylarResourcesPlugin.getDefault().getInterestingResources()); >+ } >+ return new ArrayList<IResource>(allResources); >+ } >+ >+ /** >+ * TODO: unnessary check context? >+ */ >+ public boolean contains(IResource local) >+ { >+ return getAllResourcesInChangeContext().contains(local); >+ } >+ >+ /** >+ * @deprecated Use {@link ITemplateHandlersManager#generateComment(ITask, String, String)} instead. >+ */ >+ public static String generateComment(ITask task, String completedPrefix, String progressPrefix) >+ { >+ String comment; >+ completedPrefix = fixUpDelimIfPresent(completedPrefix); >+ progressPrefix = fixUpDelimIfPresent(progressPrefix); >+ if (task.isCompleted()) >+ { >+ comment = completedPrefix + PREFIX_DELIM; >+ } >+ else >+ { >+ comment = progressPrefix + PREFIX_DELIM; >+ } >+ comment += task.getDescription(); >+ String url = task.getUrl(); >+ if (url != null && !url.equals("") && !url.endsWith("//")) >+ { >+ comment += " \n" + url; >+ } >+ return comment; >+ } >+ >+ private static String fixUpDelimIfPresent(String prefix) >+ { >+ if (prefix.endsWith(":") || prefix.endsWith(PREFIX_DELIM)) >+ { >+ prefix = prefix.substring(0, prefix.lastIndexOf(':')); >+ } >+ return prefix; >+ } >+ >+ public static String getTaskIdFromCommentOrLabel(String comment) >+ { >+ int firstDelimIndex = comment.indexOf(PREFIX_DELIM); >+ if (firstDelimIndex != -1) >+ { >+ int idStart = firstDelimIndex + PREFIX_DELIM.length(); >+ int idEnd = comment.indexOf(PREFIX_DELIM, firstDelimIndex + PREFIX_DELIM.length());// comment.indexOf(PREFIX_DELIM); >+ if (idEnd != -1 && idStart < idEnd) >+ { >+ String id = comment.substring(idStart, idEnd); >+ if (id != null) return id.trim(); >+ } >+ else >+ { >+ // change set label >+ return comment.substring(0, firstDelimIndex); >+ } >+ } >+ return null; >+ } >+ >+ public static String getUrlFromComment(String comment) >+ { >+ int httpIndex = comment.indexOf(PREFIX_HTTP); >+ int httpsIndex = comment.indexOf(PREFIX_HTTPS); >+ int idStart = -1; >+ if (httpIndex != -1) >+ { >+ idStart = httpIndex; >+ } >+ else if (httpsIndex != -1) >+ { >+ idStart = httpsIndex; >+ } >+ if (idStart != -1) >+ { >+ int idEnd = comment.indexOf(' ', idStart); >+ if (idEnd == -1) >+ { >+ return comment.substring(idStart); >+ } >+ else if (idEnd != -1 && idStart < idEnd) >+ { >+ return comment.substring(idStart, idEnd); >+ } >+ } >+ return null; >+ } >+ >+ @Override >+ public boolean equals(Object object) >+ { >+ if (object instanceof ContextChangeSet && task != null) >+ { >+ ContextChangeSet changeSet = (ContextChangeSet)object; >+ return task.equals(changeSet.getTask()); >+ } >+ else >+ { >+ return super.equals(object); >+ } >+ } >+ >+ @Override >+ public int hashCode() >+ { >+ if (task != null) >+ { >+ return task.hashCode(); >+ } >+ else >+ { >+ return super.hashCode(); >+ } >+ } >+ >+ public ITask getTask() >+ { >+ return task; >+ } >+ >+ public Object getAdapter(Class adapter) >+ { >+ if (adapter == ResourceMapping.class) >+ { >+ return new ChangeSetResourceMapping(this); >+ } >+ else >+ { >+ return null; >+ } >+ } > } >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 4 Sep 2006 14:38:31 -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,92 @@ > </viewerActionBinding> > </extension> > >+ <extension >+ point="org.eclipse.mylar.team.templateHandlers"> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$RepositoryKind" >+ description="Provides the repository kind of a Mylar task." >+ recognizedKeyword="repository.kind"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$RepositoryURL" >+ description="Provides the repository URL of a Mylar task." >+ recognizedKeyword="repository.url"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskAssignee" >+ description="Provides the user a Mylar task is assigned to, if available." >+ recognizedKeyword="task.assignee"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskCC" >+ description="Provides the comma separated CC list of a Mylar task, if available." >+ recognizedKeyword="task.cc"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskDescription" >+ description="Provides the description of a Mylar task." >+ recognizedKeyword="task.description"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskHandle" >+ description="Provides the handle of a Mylar task." >+ recognizedKeyword="task.handle"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskID" >+ description="Provides the ID of a Mylar task." >+ recognizedKeyword="task.id"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskKeywords" >+ description="Provides the comma separated keyword list of a Mylar task, if available." >+ recognizedKeyword="task.keywords"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskLastModified" >+ description="Provides the date of last modification of a Mylar task, if available." >+ recognizedKeyword="task.lastmodified"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskNotes" >+ description="Provides the notes of a Mylar task." >+ recognizedKeyword="task.notes"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskPriority" >+ description="Provides the priority of a Mylar task." >+ recognizedKeyword="task.priority"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskProduct" >+ description="Provides the prroduct a Mylar task belongs to, if available." >+ recognizedKeyword="task.product"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskReporter" >+ description="Provides the user who reported a Mylar task, if available." >+ recognizedKeyword="task.reporter"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskResolution" >+ description="Provides the resolution of a Mylar task, if available." >+ recognizedKeyword="task.resolution"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskStatus" >+ description="Provides the status of a Mylar task, if available." >+ recognizedKeyword="task.status"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskSummary" >+ description="Provides the summary or description of a Mylar task, whichever is available." >+ recognizedKeyword="task.summary"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskType" >+ description="Provides the type of a Mylar task." >+ recognizedKeyword="task.type"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskURL" >+ description="Provides the URL of a Mylar task." >+ recognizedKeyword="task.url"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$Date$TaskCompletion" >+ description="Provides the completion date of a Mylar task." >+ recognizedKeyword="task.completiondate"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$Date$TaskCreation" >+ description="Provides the creation date of a Mylar task." >+ recognizedKeyword="task.creationdate"/> >+ <templateHandler >+ class="org.eclipse.mylar.internal.team.template.TemplateHandler$Date$TaskReminder" >+ description="Provides the reminder date of a Mylar task." >+ recognizedKeyword="task.reminderdate"/> >+ </extension> >+ > </plugin> >Index: src/org/eclipse/mylar/internal/team/ui/preferences/MylarTeamPreferencePage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.team/src/org/eclipse/mylar/internal/team/ui/preferences/MylarTeamPreferencePage.java,v >retrieving revision 1.3 >diff -u -r1.3 MylarTeamPreferencePage.java >--- src/org/eclipse/mylar/internal/team/ui/preferences/MylarTeamPreferencePage.java 2 Aug 2006 07:50:06 -0000 1.3 >+++ src/org/eclipse/mylar/internal/team/ui/preferences/MylarTeamPreferencePage.java 4 Sep 2006 14:38:31 -0000 >@@ -7,11 +7,18 @@ > * > * Contributors: > * University Of British Columbia - initial API and implementation >+ * Eike tepper - commit comment template preferences > *******************************************************************************/ > > package org.eclipse.mylar.internal.team.ui.preferences; > >+ >+import org.eclipse.jface.fieldassist.IContentProposalProvider; >+import org.eclipse.jface.fieldassist.IControlContentAdapter; >+import org.eclipse.jface.fieldassist.IControlCreator; >+import org.eclipse.jface.fieldassist.TextContentAdapter; > import org.eclipse.jface.preference.PreferencePage; >+import org.eclipse.mylar.internal.team.template.TemplateHandlerContentProposalProvider; > import org.eclipse.mylar.team.MylarTeamPlugin; > import org.eclipse.swt.SWT; > import org.eclipse.swt.layout.GridData; >@@ -24,105 +31,143 @@ > import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchPreferencePage; >+import org.eclipse.ui.fieldassist.ContentAssistField; >+ > > /** > * @author Mik Kersten > */ >-public class MylarTeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { >- >- private Button changeSetsManage; >- >- private Text commitPrefixCompleted = null; >- >- private Text commitPrefixProgress = null; >- >- public MylarTeamPreferencePage() { >- super(); >- setPreferenceStore(MylarTeamPlugin.getDefault().getPreferenceStore()); >- } >- >- @Override >- protected Control createContents(Composite parent) { >- Composite container = new Composite(parent, SWT.NULL); >- GridLayout layout = new GridLayout(1, false); >- container.setLayout(layout); >- >- createChangeSetGroup(container); >- createCommitGroup(container); >- return container; >- } >- >- public void init(IWorkbench workbench) { >- // TODO Auto-generated method stub >- } >- >- @Override >- public boolean performOk() { >- getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_PREFIX_COMPLETED, commitPrefixCompleted.getText()); >- getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_PREFIX_PROGRESS, commitPrefixProgress.getText()); >- getPreferenceStore().setValue(MylarTeamPlugin.CHANGE_SET_MANAGE, changeSetsManage.getSelection()); >- >- if (changeSetsManage.getSelection()) { >- MylarTeamPlugin.getDefault().getChangeSetManager().enable(); >- } else { >- MylarTeamPlugin.getDefault().getChangeSetManager().disable(); >- } >- return true; >- } >- >- @Override >- public boolean performCancel() { >- return true; >- } >- >- public void performDefaults() { >- super.performDefaults(); >- commitPrefixCompleted.setText(getPreferenceStore().getDefaultString(MylarTeamPlugin.COMMIT_PREFIX_COMPLETED)); >- commitPrefixProgress.setText(getPreferenceStore().getDefaultString(MylarTeamPlugin.COMMIT_PREFIX_PROGRESS)); >- changeSetsManage.setSelection(getPreferenceStore().getDefaultBoolean(MylarTeamPlugin.CHANGE_SET_MANAGE)); >- } >- >- private Label createLabel(Composite parent, String text) { >- Label label = new Label(parent, SWT.LEFT); >- label.setText(text); >- GridData data = new GridData(); >- data.horizontalSpan = 2; >- data.horizontalAlignment = GridData.BEGINNING; >- label.setLayoutData(data); >- return label; >- } >- >- private void createChangeSetGroup(Composite parent) { >- Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); >- group.setText("Change Sets"); >- group.setLayout(new GridLayout(1, false)); >- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- >- changeSetsManage = new Button(group, SWT.CHECK); >- changeSetsManage.setText("Automatically create and manage with task context"); >- changeSetsManage.setSelection(getPreferenceStore().getBoolean(MylarTeamPlugin.CHANGE_SET_MANAGE)); >- } >- >- private void createCommitGroup(Composite parent) { >- Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); >- group.setText("Automatic Commit Messages"); >- group.setLayout(new GridLayout(2, false)); >- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- >- Label completedLabel = createLabel(group, "Completed task prefix: "); >- completedLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); >- >- String completedPrefix = getPreferenceStore().getString(MylarTeamPlugin.COMMIT_PREFIX_COMPLETED); >- commitPrefixCompleted = new Text(group, SWT.BORDER); >- commitPrefixCompleted.setText(completedPrefix); >- commitPrefixCompleted.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- >- Label progressLabel = createLabel(group, "In progress task prefix: "); >- progressLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); >- >- String progressPrefix = getPreferenceStore().getString(MylarTeamPlugin.COMMIT_PREFIX_PROGRESS); >- commitPrefixProgress = new Text(group, SWT.BORDER); >- commitPrefixProgress.setText(progressPrefix); >- commitPrefixProgress.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- } >+public class MylarTeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage >+{ >+ private Button changeSetsManage; >+ >+ private Text commitTemplateCompleted = null; >+ >+ private Text commitTemplateProgress = null; >+ >+ public MylarTeamPreferencePage() >+ { >+ super(); >+ setPreferenceStore(MylarTeamPlugin.getDefault().getPreferenceStore()); >+ } >+ >+ @Override >+ protected Control createContents(Composite parent) >+ { >+ Composite container = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(1, false); >+ container.setLayout(layout); >+ >+ createChangeSetGroup(container); >+ createCommitGroup(container); >+ return container; >+ } >+ >+ public void init(IWorkbench workbench) >+ { >+ // TODO Auto-generated method stub >+ } >+ >+ @Override >+ public boolean performOk() >+ { >+ getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED, >+ commitTemplateCompleted.getText()); >+ getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS, >+ commitTemplateProgress.getText()); >+ getPreferenceStore().setValue(MylarTeamPlugin.CHANGE_SET_MANAGE, >+ changeSetsManage.getSelection()); >+ >+ if (changeSetsManage.getSelection()) >+ { >+ MylarTeamPlugin.getDefault().getChangeSetManager().enable(); >+ } >+ else >+ { >+ MylarTeamPlugin.getDefault().getChangeSetManager().disable(); >+ } >+ return true; >+ } >+ >+ @Override >+ public boolean performCancel() >+ { >+ return true; >+ } >+ >+ public void performDefaults() >+ { >+ super.performDefaults(); >+ commitTemplateCompleted.setText(getPreferenceStore().getDefaultString( >+ MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED)); >+ commitTemplateProgress.setText(getPreferenceStore().getDefaultString( >+ MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS)); >+ changeSetsManage.setSelection(getPreferenceStore().getDefaultBoolean( >+ MylarTeamPlugin.CHANGE_SET_MANAGE)); >+ } >+ >+ private Label createLabel(Composite parent, String text) >+ { >+ Label label = new Label(parent, SWT.LEFT); >+ label.setText(text); >+ GridData data = new GridData(); >+ data.horizontalSpan = 2; >+ data.horizontalAlignment = GridData.BEGINNING; >+ label.setLayoutData(data); >+ return label; >+ } >+ >+ private void createChangeSetGroup(Composite parent) >+ { >+ Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); >+ group.setText("Change Sets"); >+ group.setLayout(new GridLayout(1, false)); >+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ changeSetsManage = new Button(group, SWT.CHECK); >+ changeSetsManage.setText("Automatically create and manage with task context"); >+ changeSetsManage.setSelection(getPreferenceStore() >+ .getBoolean(MylarTeamPlugin.CHANGE_SET_MANAGE)); >+ } >+ >+ private void createCommitGroup(Composite parent) >+ { >+ Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); >+ group.setText("Automatic Commit Messages"); >+ group.setLayout(new GridLayout(2, false)); >+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ Label completedLabel = createLabel(group, "Completed task template: "); >+ completedLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); >+ >+ String completedTemplate = getPreferenceStore().getString( >+ MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED); >+ addTemplateField(group, completedTemplate); >+ >+ Label progressLabel = createLabel(group, "In progress task template: "); >+ progressLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); >+ >+ String progressTemplate = getPreferenceStore().getString( >+ MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS); >+ addTemplateField(group, progressTemplate); >+ } >+ >+ private ContentAssistField addTemplateField(final Composite parent, final String text) >+ { >+ IControlContentAdapter adapter = new TextContentAdapter(); >+ IContentProposalProvider provider = new TemplateHandlerContentProposalProvider(); >+ IControlCreator controlCreator = new IControlCreator() >+ { >+ public Control createControl(Composite parent, int style) >+ { >+ Text control = new Text(parent, style); >+ control.setText(text); >+ control.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ return control; >+ } >+ }; >+ >+ return new ContentAssistField(parent, SWT.BORDER, controlCreator, adapter, provider, null, >+ new char[] {'$'}); >+ } > } >Index: src/org/eclipse/mylar/internal/team/template/TemplateHandlersManager.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TemplateHandlersManager.java >diff -N src/org/eclipse/mylar/internal/team/template/TemplateHandlersManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TemplateHandlersManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,212 @@ >+/*************************************************************************** >+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. >+ * 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: >+ * Eike Stepper - initial API and implementation >+ **************************************************************************/ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+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.ITemplateHandlersManager; >+import org.eclipse.mylar.team.MylarTeamPlugin; >+ >+import java.text.MessageFormat; >+import java.util.ArrayList; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public class TemplateHandlersManager implements ITemplateHandlersManager >+{ >+ 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"; >+ >+ public TemplateHandlersManager() >+ { >+ } >+ >+ public String[] getRecognizedKeywords() >+ { >+ final ArrayList<String> result = new ArrayList<String>(); >+ new ExtensionProcessor() >+ { >+ @Override >+ protected Object processContribution(IConfigurationElement element, String keyword, >+ String description, String className) throws Exception >+ { >+ result.add(keyword); >+ return null; >+ } >+ }.run(); >+ >+ return result.toArray(new String[result.size()]); >+ } >+ >+ public String getHandlerDescription(final String keyword) >+ { >+ return (String)new ExtensionProcessor() >+ { >+ @Override >+ protected Object processContribution(IConfigurationElement element, String foundKeyword, >+ String description, String className) throws Exception >+ { >+ return keyword.equals(foundKeyword) ? description : null; >+ } >+ }.run(); >+ } >+ >+ public ITemplateHandler createHandler(final String keyword) >+ { >+ return (ITemplateHandler)new ExtensionProcessor() >+ { >+ @Override >+ protected Object processContribution(IConfigurationElement element, String foundKeyword, >+ String description, String className) throws Exception >+ { >+ if (keyword.equals(foundKeyword)) >+ { >+ ITemplateHandler handler = (ITemplateHandler)element >+ .createExecutableExtension(ATTR_CLASS); >+ if (handler instanceof TemplateHandler) >+ { >+ ((TemplateHandler)handler).setDescription(description); >+ ((TemplateHandler)handler).setRecognizedKeyword(foundKeyword); >+ } >+ else >+ { >+ String recognizedKeyword = handler.getRecognizedKeyword(); >+ if (recognizedKeyword == null || !recognizedKeyword.equals(foundKeyword)) >+ { >+ throw new IllegalArgumentException( >+ "Keyword markup does not match handler implementation"); >+ } >+ } >+ >+ return handler; >+ } >+ >+ return null; >+ } >+ }.run(); >+ } >+ >+ public String generateComment(ITask task, String completedTemplate, String progressTemplate) >+ { >+ String template = task.isCompleted() ? completedTemplate : progressTemplate; >+ return processKeywords(task, template); >+ } >+ >+ private 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 = processKeyword(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 processKeyword(ITask task, String keyword) >+ { >+ ITemplateHandler handler = createHandler(keyword); >+ if (handler != null) >+ { >+ return handler.getValue(task); >+ } >+ >+ return null; >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ private static class ExtensionProcessor >+ { >+ public Object run() >+ { >+ 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 >+ { >+ Object result = processContribution(element); >+ if (result != null) return result; >+ } >+ catch (Exception ex) >+ { >+ final String msg = MessageFormat.format( >+ "Error while processing template handler contribution {0} from plugin {1}.", >+ element.getAttribute(ATTR_CLASS), element.getContributor().getName()); >+ MylarStatusHandler.log(ex, msg); >+ } >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ protected Object processContribution(IConfigurationElement element) throws Exception >+ { >+ String keyword = element.getAttribute(ATTR_RECOGNIZED_KEYWORD); >+ String description = element.getAttribute(ATTR_DESCRIPTION); >+ String className = element.getAttribute(ATTR_CLASS); >+ return processContribution(element, keyword, description, className); >+ } >+ >+ protected Object processContribution(IConfigurationElement element, String keyword, >+ String description, String className) throws Exception >+ { >+ return null; >+ } >+ } >+} >Index: src/org/eclipse/mylar/team/ITemplateHandlersManager.java >=================================================================== >RCS file: src/org/eclipse/mylar/team/ITemplateHandlersManager.java >diff -N src/org/eclipse/mylar/team/ITemplateHandlersManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/team/ITemplateHandlersManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/*************************************************************************** >+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. >+ * 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: >+ * Eike Stepper - initial API and implementation >+ **************************************************************************/ >+package org.eclipse.mylar.team; >+ >+ >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public interface ITemplateHandlersManager >+{ >+ public static final ITemplateHandlersManager INSTANCE = new org.eclipse.mylar.internal.team.template.TemplateHandlersManager(); >+ >+ public String[] getRecognizedKeywords(); >+ >+ public String getHandlerDescription(String keyword); >+ >+ public ITemplateHandler createHandler(String keyword); >+ >+ public String generateComment(ITask task, String completedTemplate, String progressTemplate); >+} >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/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,27 @@ >+/*************************************************************************** >+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. >+ * 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: >+ * Eike Stepper - initial API and implementation >+ **************************************************************************/ >+package org.eclipse.mylar.team; >+ >+ >+import org.eclipse.mylar.tasks.core.ITask; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public interface ITemplateHandler >+{ >+ public String getDescription(); >+ >+ public String getRecognizedKeyword(); >+ >+ public String getValue(ITask task); >+} >Index: src/org/eclipse/mylar/internal/team/template/TemplateHandler.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TemplateHandler.java >diff -N src/org/eclipse/mylar/internal/team/template/TemplateHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TemplateHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,384 @@ >+/*************************************************************************** >+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. >+ * 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: >+ * Eike Stepper - initial API and implementation >+ **************************************************************************/ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.mylar.tasks.core.AbstractRepositoryTask; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.team.ITemplateHandler; >+ >+import java.util.List; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public abstract class TemplateHandler implements ITemplateHandler >+{ >+ protected String description; >+ >+ protected String recognizedKeyword; >+ >+ protected TemplateHandler() >+ { >+ } >+ >+ 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"); //$NON-NLS-1$ >+ } >+ >+ this.recognizedKeyword = recognizedKeyword; >+ } >+ >+ public static String implode(List<String> list, String separator) >+ { >+ StringBuilder builder = new StringBuilder(); >+ for (String cc : list) >+ { >+ if (builder.length() != 0) >+ { >+ builder.append(separator); >+ } >+ >+ builder.append(cc); >+ } >+ >+ return builder.toString(); >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class RepositoryKind extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getRepositoryKind(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class RepositoryURL extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getRepositoryUrl(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskProduct extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getTaskData().getProduct(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskAssignee extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getTaskData().getAssignedTo(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskReporter extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getTaskData().getReporter(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskResolution extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getTaskData().getResolution(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskStatus extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getTaskData().getStatus(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskCC extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ List<String> list = ((AbstractRepositoryTask)task).getTaskData().getCC(); >+ return implode(list, ", "); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskKeywords extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ List<String> list = ((AbstractRepositoryTask)task).getTaskData().getKeywords(); >+ return implode(list, ", "); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskLastModified extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getTaskData().getLastModified(); >+ } >+ >+ return null; >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskSummary extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ if (task instanceof AbstractRepositoryTask) >+ { >+ return ((AbstractRepositoryTask)task).getTaskData().getSummary(); >+ } >+ >+ return task.getDescription(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskDescription extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ return task.getDescription(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskHandle extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ return task.getHandleIdentifier(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskID extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ return AbstractRepositoryTask.getTaskId(task.getHandleIdentifier()); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskNotes extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ return task.getNotes(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskPriority extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ return task.getPriority(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskType extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ return task.getTaskType(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskURL extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ return task.getUrl(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ protected static abstract class Date extends TemplateHandler >+ { >+ public String getValue(ITask task) >+ { >+ java.util.Date date = getDate(task); >+ return formatDate(date); >+ } >+ >+ protected String formatDate(java.util.Date date) >+ { >+ return date.toString(); >+ } >+ >+ protected abstract java.util.Date getDate(ITask task); >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskCompletion extends Date >+ { >+ @Override >+ protected java.util.Date getDate(ITask task) >+ { >+ return task.getCompletionDate(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskCreation extends Date >+ { >+ @Override >+ protected java.util.Date getDate(ITask task) >+ { >+ return task.getCreationDate(); >+ } >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ public static class TaskReminder extends Date >+ { >+ @Override >+ protected java.util.Date getDate(ITask task) >+ { >+ return task.getReminderDate(); >+ } >+ } >+ } >+} >Index: src/org/eclipse/mylar/internal/team/template/TemplateHandlerContentProposalProvider.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/template/TemplateHandlerContentProposalProvider.java >diff -N src/org/eclipse/mylar/internal/team/template/TemplateHandlerContentProposalProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/template/TemplateHandlerContentProposalProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,158 @@ >+/*************************************************************************** >+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. >+ * 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: >+ * Eike Stepper - initial API and implementation >+ **************************************************************************/ >+package org.eclipse.mylar.internal.team.template; >+ >+ >+import org.eclipse.jface.fieldassist.IContentProposal; >+import org.eclipse.jface.fieldassist.IContentProposalProvider; >+import org.eclipse.mylar.team.ITemplateHandlersManager; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public class TemplateHandlerContentProposalProvider implements IContentProposalProvider >+{ >+ public IContentProposal[] getProposals(String contents, int position) >+ { >+ ProposalComputer proposalComputer = new ProposalComputer(contents, position); >+ return proposalComputer.computeProposals(); >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ protected static class ProposalComputer >+ { >+ private String contents; >+ >+ private int position; >+ >+ private List<IContentProposal> result = new ArrayList<IContentProposal>(); >+ >+ private String[] keywords; >+ >+ private String prefix; >+ >+ public ProposalComputer(String contents, int position) >+ { >+ this.contents = contents; >+ this.position = position; >+ initKeywords(); >+ initPrefix(); >+ } >+ >+ public IContentProposal[] computeProposals() >+ { >+ for (String keyword : keywords) >+ { >+ String proposal = getMatch(keyword); >+ if (proposal != null) >+ { >+ addProposal(proposal, keyword); >+ } >+ } >+ >+ return result.toArray(new IContentProposal[result.size()]); >+ } >+ >+ protected ITemplateHandlersManager getTemplateHandlersManager() >+ { >+ return ITemplateHandlersManager.INSTANCE; >+ } >+ >+ private void initKeywords() >+ { >+ keywords = getTemplateHandlersManager().getRecognizedKeywords(); >+ } >+ >+ private void initPrefix() >+ { >+ prefix = ""; >+ String beforePosition = contents.substring(0, position); >+ if (beforePosition.endsWith("$")) >+ { >+ prefix = "$"; >+ } >+ else >+ { >+ int start = beforePosition.lastIndexOf("${"); >+ if (start >= 0) >+ { >+ int end = contents.indexOf('}', start); >+ if (end >= position) >+ { >+ prefix = contents.substring(start, position); >+ } >+ } >+ } >+ } >+ >+ private String getMatch(String keyword) >+ { >+ String wholeProposal = "${" + keyword + "}"; >+ if (wholeProposal.startsWith(prefix)) >+ { >+ return wholeProposal.substring(prefix.length()); >+ } >+ >+ return null; >+ } >+ >+ private void addProposal(String proposal, String keyword) >+ { >+ String description = getTemplateHandlersManager().getHandlerDescription(keyword); >+ result.add(new Proposal(proposal, keyword, description)); >+ } >+ >+ /** >+ * @author Eike Stepper >+ */ >+ private static final class Proposal implements IContentProposal >+ { >+ private final String proposal; >+ >+ private final String keyword; >+ >+ private final String description; >+ >+ private Proposal(String proposal, String keyword, String description) >+ { >+ this.proposal = proposal; >+ this.keyword = keyword; >+ this.description = description; >+ } >+ >+ public String getContent() >+ { >+ return proposal; >+ } >+ >+ public int getCursorPosition() >+ { >+ return proposal.length(); >+ } >+ >+ public String getDescription() >+ { >+ return description; >+ } >+ >+ public String getLabel() >+ { >+ return "${" + keyword + "}"; >+ } >+ } >+ } >+}
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