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 54587 Details for
Bug 165581
Improve Open Correspond Task action
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]
Updating stale patch
aaa.patch (text/plain), 41.87 KB, created by
Eugene Kuleshov
on 2006-11-27 16:38:30 EST
(
hide
)
Description:
Updating stale patch
Filename:
MIME Type:
Creator:
Eugene Kuleshov
Created:
2006-11-27 16:38:30 EST
Size:
41.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.jira.ui >Index: src/org/eclipse/mylar/internal/jira/core/JiraRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.jira.ui/src/org/eclipse/mylar/internal/jira/core/JiraRepositoryConnector.java,v >retrieving revision 1.6 >diff -u -r1.6 JiraRepositoryConnector.java >--- src/org/eclipse/mylar/internal/jira/core/JiraRepositoryConnector.java 27 Nov 2006 18:29:03 -0000 1.6 >+++ src/org/eclipse/mylar/internal/jira/core/JiraRepositoryConnector.java 27 Nov 2006 21:34:16 -0000 >@@ -197,10 +197,21 @@ > return null; > } > int index = url.indexOf(DELIM_URL); >- if (index != -1) { >- return url.substring(0, index); >+ return index == -1 ? null : url.substring(0, index); >+ } >+ >+ @Override >+ public String getTaskIdFromTaskUrl(String url) { >+ if (url == null) { >+ return null; > } >- return null; >+ int index = url.indexOf(DELIM_URL); >+ return index == -1 ? null : url.substring(index + DELIM_URL.length()); >+ } >+ >+ @Override >+ public String getTaskWebUrl(String repositoryUrl, String taskId) { >+ return repositoryUrl + DELIM_URL + taskId; > } > > public static void updateTaskDetails(String repositoryUrl, JiraTask task, Issue issue, boolean notifyOfChange) { >@@ -226,7 +237,7 @@ > PriorityLevel priorityLevel = JiraTask.PriorityLevel.fromPriority(issue.getPriority()); > if (priorityLevel != null) { > task.setPriority(priorityLevel.toString()); >- } >+ } > // else { > // MylarStatusHandler.log("unrecognized priority: " + issue.getPriority().getDescription(), null); > // } >#P org.eclipse.mylar.tasks.core >Index: src/org/eclipse/mylar/tasks/core/AbstractRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.core/src/org/eclipse/mylar/tasks/core/AbstractRepositoryConnector.java,v >retrieving revision 1.15 >diff -u -r1.15 AbstractRepositoryConnector.java >--- src/org/eclipse/mylar/tasks/core/AbstractRepositoryConnector.java 20 Nov 2006 18:39:47 -0000 1.15 >+++ src/org/eclipse/mylar/tasks/core/AbstractRepositoryConnector.java 27 Nov 2006 21:34:17 -0000 >@@ -26,7 +26,7 @@ > > /** > * Operations on a task repository >- * >+ * > * @author Mik Kersten > * @author Rob Elves > */ >@@ -45,7 +45,7 @@ > protected TaskList taskList; > > public void init(TaskList taskList) { >- this.taskList = taskList; >+ this.taskList = taskList; > } > > /** >@@ -58,8 +58,12 @@ > */ > public abstract IOfflineTaskHandler getOfflineTaskHandler(); > >- public abstract String getRepositoryUrlFromTaskUrl(String url); >+ public abstract String getRepositoryUrlFromTaskUrl(String taskFullUrl); > >+ public abstract String getTaskIdFromTaskUrl(String taskFullUrl); >+ >+ public abstract String getTaskWebUrl(String repositoryUrl, String taskId); >+ > public abstract boolean canCreateTaskFromKey(TaskRepository repository); > > public abstract boolean canCreateNewTask(TaskRepository repository); >@@ -78,7 +82,7 @@ > > /** > * Implementors must execute query synchronously. >- * >+ * > * @param query > * @param repository > * TODO >@@ -128,7 +132,7 @@ > * Implementors of this repositoryOperations must perform it locally without > * going to the server since it is used for frequent repositoryOperations > * such as decoration. >- * >+ * > * @return an empty set if no contexts > */ > public final Set<RepositoryAttachment> getContextAttachments(TaskRepository repository, AbstractRepositoryTask task) { >@@ -155,7 +159,7 @@ > > /** > * Attaches the associated context to <code>task</code>. >- * >+ * > * @return false, if operation is not supported by repository > */ > public final boolean attachContext(TaskRepository repository, AbstractRepositoryTask task, String longComment) throws CoreException { >@@ -185,7 +189,7 @@ > /** > * Retrieves a context stored in <code>attachment</code> from > * <code>task</code>. >- * >+ * > * @return false, if operation is not supported by repository > */ > public final boolean retrieveContext(TaskRepository repository, AbstractRepositoryTask task, >@@ -216,6 +220,10 @@ > return templates; > } > >+ public void removeTemplate(RepositoryTemplate template) { >+ this.templates.remove(template); >+ } >+ > /** returns null if template not found */ > public RepositoryTemplate getTemplate(String label) { > for (RepositoryTemplate template : getTemplates()) { >@@ -233,7 +241,7 @@ > /** > * Reset and update the repository attributes from the server (e.g. > * products, components) >- * >+ * > * TODO: remove? > */ > public abstract void updateAttributes(TaskRepository repository, IProgressMonitor monitor) throws CoreException; >#P org.eclipse.mylar.bugzilla.core >Index: src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.bugzilla.core/src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryConnector.java,v >retrieving revision 1.24 >diff -u -r1.24 BugzillaRepositoryConnector.java >--- src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryConnector.java 25 Nov 2006 00:45:34 -0000 1.24 >+++ src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryConnector.java 27 Nov 2006 21:34:19 -0000 >@@ -193,14 +193,23 @@ > public String getRepositoryUrlFromTaskUrl(String url) { > if (url == null) { > return null; >- } else { >- int index = url.indexOf(IBugzillaConstants.URL_GET_SHOW_BUG); >- if (index != -1) { >- return url.substring(0, index); >- } else { >- return null; >- } > } >+ int index = url.indexOf(IBugzillaConstants.URL_GET_SHOW_BUG); >+ return index == -1 ? null : url.substring(0, index); >+ } >+ >+ @Override >+ public String getTaskIdFromTaskUrl(String url) { >+ if (url == null) { >+ return null; >+ } >+ int index = url.indexOf(IBugzillaConstants.URL_GET_SHOW_BUG); >+ return index == -1 ? null : url.substring(index + IBugzillaConstants.URL_GET_SHOW_BUG.length()); >+ } >+ >+ @Override >+ public String getTaskWebUrl(String repositoryUrl, String taskId) { >+ return repositoryUrl + IBugzillaConstants.URL_GET_SHOW_BUG + taskId; > } > > // @Override >#P org.eclipse.mylar.tasks.tests >Index: src/org/eclipse/mylar/tasks/tests/connector/MockRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.tests/src/org/eclipse/mylar/tasks/tests/connector/MockRepositoryConnector.java,v >retrieving revision 1.17 >diff -u -r1.17 MockRepositoryConnector.java >--- src/org/eclipse/mylar/tasks/tests/connector/MockRepositoryConnector.java 23 Nov 2006 18:00:34 -0000 1.17 >+++ src/org/eclipse/mylar/tasks/tests/connector/MockRepositoryConnector.java 27 Nov 2006 21:34:20 -0000 >@@ -81,8 +81,19 @@ > // ignore > return null; > } >+ >+ @Override >+ public String getTaskIdFromTaskUrl(String url) { >+ // ignore >+ return null; >+ } > > @Override >+ public String getTaskWebUrl(String repositoryUrl, String taskId) { >+ return null; >+ } >+ >+ @Override > public List<String> getSupportedVersions() { > // ignore > return null; >#P org.eclipse.mylar.tasks.web >Index: src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.web/src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java,v >retrieving revision 1.9 >diff -u -r1.9 WebRepositoryConnector.java >--- src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java 27 Nov 2006 19:12:21 -0000 1.9 >+++ src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java 27 Nov 2006 21:34:23 -0000 >@@ -52,7 +52,7 @@ > > /** > * Generic connector for web based issue tracking systems >- * >+ * > * @author Eugene Kuleshov > */ > public class WebRepositoryConnector extends AbstractRepositoryConnector { >@@ -89,6 +89,8 @@ > > public static final String REQUEST_GET = "GET"; > >+ >+ > @Override > public String getRepositoryType() { > return WebTask.REPOSITORY_TYPE; >@@ -146,14 +148,16 @@ > > @Override > public String getRepositoryUrlFromTaskUrl(String url) { >+ if (url == null) { >+ return null; >+ } >+ > // lookup repository using task prefix url > TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager(); >- for (TaskRepository repository : repositoryManager.getAllRepositories()) { >- if (getRepositoryType().equals(repository.getKind())) { >- String start = evaluateParams(repository.getProperty(PROPERTY_TASK_URL), repository); >- if (start != null && url.startsWith(start)) { >- return repository.getUrl(); >- } >+ for (TaskRepository repository : repositoryManager.getRepositories(getRepositoryType())) { >+ String start = evaluateParams(repository.getProperty(PROPERTY_TASK_URL), repository); >+ if (start != null && url.startsWith(start)) { >+ return repository.getUrl(); > } > } > >@@ -170,7 +174,33 @@ > } > } > } >+ return null; >+ } >+ >+ @Override >+ public String getTaskIdFromTaskUrl(String url) { >+ if (url == null) { >+ return null; >+ } > >+ TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager(); >+ for (TaskRepository repository : repositoryManager.getRepositories(getRepositoryType())) { >+ String start = evaluateParams(repository.getProperty(PROPERTY_TASK_URL), repository); >+ if (start != null && url.startsWith(start)) { >+ return url.substring(start.length()); >+ } >+ } >+ return null; >+ } >+ >+ @Override >+ public String getTaskWebUrl(String repositoryUrl, String taskId) { >+ TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager(); >+ TaskRepository repository = repositoryManager.getRepository(getRepositoryType(), repositoryUrl); >+ if (repository != null) { >+ String prefix = evaluateParams(repository.getProperty(PROPERTY_TASK_URL), repository); >+ return prefix + taskId; >+ } > return null; > } > >@@ -229,6 +259,7 @@ > public void updateTask(TaskRepository repository, AbstractRepositoryTask repositoryTask) throws CoreException { > } > >+ > // utility methods > > public static IStatus performQuery(String resource, String regexp, String taskPrefix, IProgressMonitor monitor, >@@ -279,52 +310,48 @@ > return text.trim(); > } > >- // public static IStatus performRssQuery(String queryUrl, String taskPrefix, >- // String repositoryUrl, >- // String repositoryUser, String repositoryPassword, IProgressMonitor >- // monitor, QueryHitCollector collector) { >- // SyndFeedInput input = new SyndFeedInput(); >- // try { >- // SyndFeed feed = input.build(new XmlReader(new URL(queryUrl))); >- // >- // SimpleDateFormat df = new SimpleDateFormat("MMM dd, HH:mm"); >- // >- // for (Iterator it = feed.getEntries().iterator(); it.hasNext();) { >- // SyndEntry entry = (SyndEntry) it.next(); >- // >- // Date date = entry.getUpdatedDate(); >- // if (date == null) { >- // date = entry.getPublishedDate(); >- // } >- // if (date == null) { >- // DCModule module = (DCModule) >- // entry.getModule("http://purl.org/dc/elements/1.1/"); >- // date = module.getDate(); >- // } >- // if (date == null) { >- // // TODO >- // } >- // >- // String entryUri = entry.getUri(); >- // if (entryUri.startsWith(taskPrefix)) { >- // String id = df.format(date); // entryUri.substring(taskPrefix.length()); >- // >- // try { >- // collector.accept(new WebQueryHit(id, id + ": " + entry.getTitle(), >- // taskPrefix, repositoryUrl)); >- // } catch (CoreException e) { >- // return new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, >- // "Unable collect results.", e); >- // } >- // } >- // } >- // return Status.OK_STATUS; >- // } catch (Exception ex) { >- // return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.OK, "Could >- // not fetch resource: " + queryUrl, >- // ex); >- // } >- // } >+ >+// public static IStatus performRssQuery(String queryUrl, String taskPrefix, String repositoryUrl, >+// String repositoryUser, String repositoryPassword, IProgressMonitor monitor, QueryHitCollector collector) { >+// SyndFeedInput input = new SyndFeedInput(); >+// try { >+// SyndFeed feed = input.build(new XmlReader(new URL(queryUrl))); >+// >+// SimpleDateFormat df = new SimpleDateFormat("MMM dd, HH:mm"); >+// >+// for (Iterator it = feed.getEntries().iterator(); it.hasNext();) { >+// SyndEntry entry = (SyndEntry) it.next(); >+// >+// Date date = entry.getUpdatedDate(); >+// if (date == null) { >+// date = entry.getPublishedDate(); >+// } >+// if (date == null) { >+// DCModule module = (DCModule) entry.getModule("http://purl.org/dc/elements/1.1/"); >+// date = module.getDate(); >+// } >+// if (date == null) { >+// // TODO >+// } >+// >+// String entryUri = entry.getUri(); >+// if (entryUri.startsWith(taskPrefix)) { >+// String id = df.format(date); // entryUri.substring(taskPrefix.length()); >+// >+// try { >+// collector.accept(new WebQueryHit(id, id + ": " + entry.getTitle(), taskPrefix, repositoryUrl)); >+// } catch (CoreException e) { >+// return new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, >+// "Unable collect results.", e); >+// } >+// } >+// } >+// return Status.OK_STATUS; >+// } catch (Exception ex) { >+// return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.OK, "Could not fetch resource: " + queryUrl, >+// ex); >+// } >+// } > > public static String fetchResource(String url, Map<String, String> params, TaskRepository repository) > throws IOException { >@@ -394,14 +421,14 @@ > int statusCode = client.executeMethod(method); > if (statusCode == 300 || statusCode == 301 || statusCode == 302 || statusCode == 303 || statusCode == 307) { > Header location = method.getResponseHeader("Location"); >- if (location != null) { >+ if (location!=null) { > refreshUrl = location.getValue(); > if (!refreshUrl.startsWith("/")) { > refreshUrl = "/" + refreshUrl; > } > } > } >- if (refreshUrl == null) { >+ if(refreshUrl == null) { > refreshUrl = getRefreshUrl(url, method); > } > if (refreshUrl == null) { >#P org.eclipse.mylar.trac.core >Index: src/org/eclipse/mylar/internal/trac/core/TracRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.trac.core/src/org/eclipse/mylar/internal/trac/core/TracRepositoryConnector.java,v >retrieving revision 1.15 >diff -u -r1.15 TracRepositoryConnector.java >--- src/org/eclipse/mylar/internal/trac/core/TracRepositoryConnector.java 20 Nov 2006 18:39:26 -0000 1.15 >+++ src/org/eclipse/mylar/internal/trac/core/TracRepositoryConnector.java 27 Nov 2006 21:34:24 -0000 >@@ -81,10 +81,24 @@ > if (url == null) { > return null; > } >- int i = url.lastIndexOf(ITracClient.TICKET_URL); >- return (i != -1) ? url.substring(0, i) : null; >+ int index = url.lastIndexOf(ITracClient.TICKET_URL); >+ return index == -1 ? null : url.substring(0, index); > } > >+ public String getTaskIdFromTaskUrl(String url) { >+ if (url == null) { >+ return null; >+ } >+ int index = url.lastIndexOf(ITracClient.TICKET_URL); >+ return index == -1 ? null : url.substring(index + ITracClient.TICKET_URL.length()); >+ } >+ >+ @Override >+ public String getTaskWebUrl(String repositoryUrl, String taskId) { >+ return repositoryUrl + ITracClient.TICKET_URL + taskId; >+ } >+ >+ > @Override > public List<String> getSupportedVersions() { > if (supportedVersions == null) { >#P org.eclipse.mylar.ide.tests >Index: src/org/eclipse/mylar/ide/tests/OpenCorrespondingTaskActionTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.ide.tests/src/org/eclipse/mylar/ide/tests/OpenCorrespondingTaskActionTest.java,v >retrieving revision 1.2 >diff -u -r1.2 OpenCorrespondingTaskActionTest.java >--- src/org/eclipse/mylar/ide/tests/OpenCorrespondingTaskActionTest.java 20 Oct 2006 20:19:29 -0000 1.2 >+++ src/org/eclipse/mylar/ide/tests/OpenCorrespondingTaskActionTest.java 27 Nov 2006 21:34:25 -0000 >@@ -13,7 +13,7 @@ > > import junit.framework.TestCase; > >-import org.eclipse.mylar.internal.team.ui.actions.OpenCorrespondingTaskAction; >+import org.eclipse.mylar.internal.team.LinkedTaskInfoAdapterFactory; > > /** > * @author Mik Kersten >@@ -34,13 +34,13 @@ > > public void test07LegacyMatching() { > String label = "Progress on: 123: foo \nhttps://bugs.eclipse.org"; >- String id = OpenCorrespondingTaskAction.getTaskIdFromLegacy07Label(label); >+ String id = LinkedTaskInfoAdapterFactory.getTaskIdFromLegacy07Label(label); > assertEquals("123", id); > } > > public void testUrlMatching() { > String label = "bla bla\nhttp://foo.bar-123 bla bla"; >- String id = OpenCorrespondingTaskAction.getUrlFromComment(label); >+ String id = LinkedTaskInfoAdapterFactory.getUrlFromComment(label); > assertEquals("http://foo.bar-123", id); > } > >#P org.eclipse.mylar.tasks.ui >Index: src/org/eclipse/mylar/tasks/ui/AbstractRepositoryConnectorUi.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/tasks/ui/AbstractRepositoryConnectorUi.java,v >retrieving revision 1.6 >diff -u -r1.6 AbstractRepositoryConnectorUi.java >--- src/org/eclipse/mylar/tasks/ui/AbstractRepositoryConnectorUi.java 2 Nov 2006 17:42:32 -0000 1.6 >+++ src/org/eclipse/mylar/tasks/ui/AbstractRepositoryConnectorUi.java 27 Nov 2006 21:34:26 -0000 >@@ -14,10 +14,13 @@ > import org.eclipse.jface.wizard.WizardDialog; > import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.mylar.context.core.MylarStatusHandler; >+import org.eclipse.mylar.internal.tasks.ui.TasksUiUtil; > import org.eclipse.mylar.internal.tasks.ui.wizards.AbstractRepositorySettingsPage; > import org.eclipse.mylar.internal.tasks.ui.wizards.CommonAddExistingTaskWizard; >+import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; > import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery; > import org.eclipse.mylar.tasks.core.TaskRepository; >+import org.eclipse.mylar.tasks.core.TaskRepositoryManager; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.PlatformUI; > >@@ -82,13 +85,18 @@ > > /** > * Only override if task should be opened by a custom editor, default >- * beahvior is to open with browser. >+ * behavior is to open with browser. > * >- * @return true if the task was successfully opened >+ * @return true if the task was successfully opened > */ > public boolean openRemoteTask(String repositoryUrl, String idString) { >- return false; >-// MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), >-// TasksUiPlugin.TITLE_DIALOG, "Not supported by connector: " + this.getClass().getSimpleName()); >+ TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager(); >+ AbstractRepositoryConnector connector = repositoryManager.getRepositoryConnector(getRepositoryType()); >+ TasksUiUtil.openUrl(connector.getTaskWebUrl(repositoryUrl, idString)); >+ >+ return true; >+ // MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), >+ // TasksUiPlugin.TITLE_DIALOG, "Not supported by connector: " + >+ // this.getClass().getSimpleName()); > } > } >#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.11 >diff -u -r1.11 MylarTeamPlugin.java >--- src/org/eclipse/mylar/team/MylarTeamPlugin.java 25 Nov 2006 00:45:16 -0000 1.11 >+++ src/org/eclipse/mylar/team/MylarTeamPlugin.java 27 Nov 2006 21:34:28 -0000 >@@ -13,6 +13,7 @@ > > import org.eclipse.mylar.context.core.MylarStatusHandler; > import org.eclipse.mylar.internal.team.ContextChangeSetManager; >+import org.eclipse.mylar.internal.team.LinkedTaskInfoAdapterFactory; > import org.eclipse.mylar.internal.team.template.CommitTemplateManager; > import org.eclipse.ui.IStartup; > import org.eclipse.ui.PlatformUI; >@@ -48,6 +49,8 @@ > initPreferenceDefaults(); > commitTemplateManager = new CommitTemplateManager(); > >+ LinkedTaskInfoAdapterFactory.registerAdapters(); >+ > PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { > public void run() { > try { >@@ -71,6 +74,8 @@ > INSTANCE = null; > super.stop(context); > changeSetManager.disable(); >+ >+ LinkedTaskInfoAdapterFactory.unregisterAdapters(); > } > > private void initPreferenceDefaults() { >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.team/plugin.xml,v >retrieving revision 1.12 >diff -u -r1.12 plugin.xml >--- plugin.xml 20 Nov 2006 22:21:28 -0000 1.12 >+++ plugin.xml 27 Nov 2006 21:34:28 -0000 >@@ -68,6 +68,22 @@ > tooltip="Open Corresponding Task"> > </action> > </objectContribution> >+ >+ <!-- Subclipse History view --> >+ <objectContribution >+ objectClass="org.tigris.subversion.subclipse.core.history.LogEntry" >+ id="org.eclipse.mylar.ui.team.synchronize.open.report"> >+ <action >+ class="org.eclipse.mylar.internal.team.ui.actions.OpenCorrespondingTaskAction" >+ enablesFor="1" >+ icon="icons/elcl16/task-repository.gif" >+ id="org.eclipse.mylar.ui.team.synchronize.contribution.open.report" >+ label="Open Corresponding Task" >+ menubarPath="mylar" >+ tooltip="Open Corresponding Task"> >+ </action> >+ </objectContribution> >+ > <!-- > <objectContribution > objectClass="org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode" >Index: src/org/eclipse/mylar/internal/team/ILinkedTaskInfo.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/ILinkedTaskInfo.java >diff -N src/org/eclipse/mylar/internal/team/ILinkedTaskInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/ILinkedTaskInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * 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: >+ * Eugene Kuleshov - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.team; >+ >+import org.eclipse.mylar.tasks.core.ITask; >+ >+/** >+ * Task information linked to artifacts from version control integration >+ * >+ * TODO move to mylar core? >+ * >+ * @author Eugene Kuleshov >+ */ >+public interface ILinkedTaskInfo { >+ >+ String getTaskId(); >+ >+ String getTaskFullUrl(); >+ >+ String getRepositoryUrl(); >+ >+ ITask getTask(); >+ >+} >Index: src/org/eclipse/mylar/internal/team/LinkedTaskInfo.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/LinkedTaskInfo.java >diff -N src/org/eclipse/mylar/internal/team/LinkedTaskInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/LinkedTaskInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,120 @@ >+/******************************************************************************* >+ * 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: >+ * Eugene Kuleshov - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.team; >+ >+import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; >+import org.eclipse.mylar.tasks.core.AbstractRepositoryTask; >+import org.eclipse.mylar.tasks.core.ITask; >+import org.eclipse.mylar.tasks.core.TaskRepository; >+import org.eclipse.mylar.tasks.core.TaskRepositoryManager; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+ >+/** >+ * Default implementation of {@link ILinkedTaskInfo} >+ * >+ * @author Eugene Kuleshov >+ */ >+public class LinkedTaskInfo implements ILinkedTaskInfo { >+ >+ private String taskId; >+ >+ private String taskFullUrl; >+ >+ private String repositoryUrl; >+ >+ private ITask task; >+ >+ public LinkedTaskInfo(ITask task) { >+ init(task, // >+ AbstractRepositoryTask.getRepositoryUrl(task.getHandleIdentifier()), // >+ AbstractRepositoryTask.getTaskId(task.getHandleIdentifier()), // >+ task.getUrl()); >+ } >+ >+ public LinkedTaskInfo(String taskFullUrl) { >+ init(null, null, null, taskFullUrl); >+ } >+ >+ public LinkedTaskInfo(String repositoryUrl, String taskId, String taskFullUrl) { >+ init(null, repositoryUrl, taskId, taskFullUrl); >+ } >+ >+ private void init(ITask task, String repositoryUrl, String taskId, String taskFullUrl) { >+ // TODO should this even be here? >+ >+ TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager(); >+ AbstractRepositoryConnector connector = repositoryManager.getConnectorForRepositoryTaskUrl(taskFullUrl); >+ if (connector == null && repositoryUrl != null) { >+ TaskRepository repository = repositoryManager.getRepository(repositoryUrl); >+ if (repository != null) { >+ connector = repositoryManager.getRepositoryConnector(repository.getKind()); >+ } >+ } >+ >+ if (repositoryUrl == null && connector != null) { >+ repositoryUrl = connector.getRepositoryUrlFromTaskUrl(taskFullUrl); >+ } >+ >+ if (taskId == null && connector != null) { >+ taskId = connector.getTaskIdFromTaskUrl(taskFullUrl); >+ } >+ >+ if (taskFullUrl == null && repositoryUrl != null && taskId != null && connector != null) { >+ taskFullUrl = connector.getTaskWebUrl(repositoryUrl, taskId); >+ } >+ >+ if (task == null) { >+ if (taskId != null && repositoryUrl != null) { >+ String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId); >+ task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(handle); >+ } >+ if (task == null && taskFullUrl != null) { >+ // search by fullUrl >+ for (ITask currTask : TasksUiPlugin.getTaskListManager().getTaskList().getAllTasks()) { >+ if (currTask instanceof AbstractRepositoryTask) { >+ String currUrl = ((AbstractRepositoryTask) currTask).getUrl(); >+ if (taskFullUrl.equals(currUrl)) { >+ task = currTask; >+ break; >+ } >+ } >+ } >+ } >+ } >+ >+ if (taskFullUrl == null && task != null) { >+ taskFullUrl = task.getUrl(); >+ } >+ >+ this.task = task; >+ this.repositoryUrl = repositoryUrl; >+ this.taskId = taskId; >+ this.taskFullUrl = taskFullUrl; >+ } >+ >+ public String getRepositoryUrl() { >+ return repositoryUrl; >+ } >+ >+ public ITask getTask() { >+ return task; >+ } >+ >+ public String getTaskFullUrl() { >+ return taskFullUrl; >+ } >+ >+ public String getTaskId() { >+ return taskId; >+ } >+ >+} >Index: src/org/eclipse/mylar/internal/team/LinkedTaskInfoAdapterFactory.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/team/LinkedTaskInfoAdapterFactory.java >diff -N src/org/eclipse/mylar/internal/team/LinkedTaskInfoAdapterFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/team/LinkedTaskInfoAdapterFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,363 @@ >+/******************************************************************************* >+ * 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: >+ * Eugene Kuleshov - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.team; >+ >+import org.eclipse.compare.structuremergeviewer.DiffNode; >+import org.eclipse.compare.structuremergeviewer.IDiffElement; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IAdapterFactory; >+import org.eclipse.core.runtime.IAdapterManager; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.mylar.internal.team.template.CommitTemplateManager; >+import org.eclipse.mylar.tasks.core.TaskRepository; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylar.team.MylarTeamPlugin; >+import org.eclipse.team.core.TeamException; >+import org.eclipse.team.core.history.IFileRevision; >+import org.eclipse.team.core.variants.IResourceVariant; >+import org.eclipse.team.internal.ccvs.core.CVSException; >+import org.eclipse.team.internal.ccvs.core.ICVSResource; >+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; >+import org.eclipse.team.internal.ccvs.core.resources.RemoteResource; >+import org.eclipse.team.internal.core.subscribers.ChangeSet; >+import org.eclipse.team.internal.core.subscribers.DiffChangeSet; >+import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode; >+import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; >+import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement; >+ >+import org.tigris.subversion.subclipse.core.ISVNRemoteResource; >+import org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo; >+import org.tigris.subversion.subclipse.ui.settings.ProjectProperties; >+import org.tigris.subversion.svnclientadapter.ISVNLogMessage; >+import org.tigris.subversion.svnclientadapter.SVNRevision; >+ >+ >+/** >+ * Adapter factory used to create adapters for <code>LinkedTaskInfo</code> >+ * >+ * @author Eugene Kuleshov >+ */ >+public class LinkedTaskInfoAdapterFactory implements IAdapterFactory { >+ >+ private static final Class[] ADAPTER_TYPES = new Class[] { ILinkedTaskInfo.class }; >+ >+ private static IAdapterFactory FACTORY = new LinkedTaskInfoAdapterFactory(); >+ >+ private static final String PREFIX_HTTP = "http://"; >+ >+ private static final String PREFIX_HTTPS = "https://"; >+ >+ private static boolean haveSubclipse; >+ >+ >+ public static void registerAdapters() { >+ IAdapterManager adapterManager = Platform.getAdapterManager(); >+ >+ // Mylar >+ adapterManager.registerAdapters(FACTORY, ContextChangeSet.class); >+ >+ // Team public >+ adapterManager.registerAdapters(FACTORY, IFileRevision.class); >+ adapterManager.registerAdapters(FACTORY, DiffNode.class); >+ >+ // Team internal >+ adapterManager.registerAdapters(FACTORY, DiffChangeSet.class); // CVSCheckedInChangeSet ??? >+ adapterManager.registerAdapters(FACTORY, ChangeSetDiffNode.class); >+ adapterManager.registerAdapters(FACTORY, SynchronizeModelElement.class); >+ >+ // Team CVS internal; is it used? Maybe CVS History view in Eclipse 3.1? >+ adapterManager.registerAdapters(FACTORY, org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry.class); >+ >+ // Subclipse >+ try { >+ SubclipseWrapper.init(adapterManager, FACTORY); >+ haveSubclipse = true; >+ } catch (Throwable ex) { >+ // ignore >+ } >+ } >+ >+ public static void unregisterAdapters() { >+ Platform.getAdapterManager().unregisterAdapters(FACTORY); >+ } >+ >+ >+ private LinkedTaskInfoAdapterFactory() { >+ } >+ >+ public Object getAdapter(Object object, Class adapterType) { >+ if(!ILinkedTaskInfo.class.equals(adapterType)) { >+ return null; >+ } >+ >+ if(object instanceof ChangeSetDiffNode) { >+ return adaptChangeSetDiffNode(object); >+ } >+ >+ if(object instanceof DiffNode) { >+ return getAdapter(((DiffNode) object).getParent(), adapterType); >+ } >+ >+ if(haveSubclipse && >+ "org.tigris.subversion.subclipse.core.history.LogEntry".equals(object.getClass().getName())) { >+ ILinkedTaskInfo info = SubclipseWrapper.adaptSubclipseLogEntry(object); >+ if(info!=null) { >+ return info; >+ } >+ } >+ >+ // TODO add other adapted types >+ >+ return adaptFromComment(object); >+ } >+ >+ public Class[] getAdapterList() { >+ return ADAPTER_TYPES; >+ } >+ >+ private ILinkedTaskInfo adaptChangeSetDiffNode(Object object) { >+ ChangeSetDiffNode diffNode = (ChangeSetDiffNode) object; >+ ChangeSet set = diffNode.getSet(); >+ if (set instanceof ContextChangeSet) { >+ return new LinkedTaskInfo(((ContextChangeSet) set).getTask()); >+ } else if(haveSubclipse && set.getClass().getName().startsWith("org.tigris")) { >+ ILinkedTaskInfo info = SubclipseWrapper.adaptSubclipseChangeset(diffNode, set); >+ if(info!=null) { >+ return info; >+ } >+ } >+ >+ return adaptFromComment(object); >+ } >+ >+ private ILinkedTaskInfo adaptFromComment(Object object) { >+ String comment = getCommentFromElement(object); >+ >+ CommitTemplateManager commitTemplateManager = MylarTeamPlugin.getDefault().getCommitTemplateManager(); >+ String taskId = commitTemplateManager.getTaskIdFromCommentOrLabel(comment); >+ if (taskId == null) { >+ taskId = getTaskIdFromLegacy07Label(comment); >+ } >+ >+ IProject project = findCorrespondingProject(object); >+ if (project != null) { >+ TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, false); >+ if (repository != null && taskId!=null) { >+ return new LinkedTaskInfo(repository.getUrl(), taskId, null); >+ } >+ } >+ >+ String fullTaskUrl = getUrlFromComment(comment); >+ if(fullTaskUrl!=null) { >+ return new LinkedTaskInfo(fullTaskUrl); >+ } >+ >+ return null; >+ } >+ >+ private String getCommentFromElement(Object element) { >+ if (element instanceof DiffChangeSet) { >+ return ((DiffChangeSet) element).getComment(); >+ } else if (element instanceof ChangeSetDiffNode) { >+ return ((ChangeSetDiffNode) element).getName(); >+ } else if (element instanceof IFileRevision) { >+ return ((IFileRevision) element).getComment(); >+ } else if (element instanceof org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry) { >+ return ((org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry) element).getComment(); >+ } else if (element instanceof org.tigris.subversion.subclipse.core.history.LogEntry) { >+ return ((org.tigris.subversion.subclipse.core.history.LogEntry) element).getComment(); >+ } >+ 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; >+ } >+ >+ public static String getTaskIdFromLegacy07Label(String comment) { >+ String PREFIX_DELIM = ":"; >+ String PREFIX_START_1 = "Progress on:"; >+ String PREFIX_START_2 = "Completed:"; >+ String usedPrefix = PREFIX_START_1; >+ int firstDelimIndex = comment.indexOf(PREFIX_START_1); >+ if (firstDelimIndex == -1) { >+ firstDelimIndex = comment.indexOf(PREFIX_START_2); >+ usedPrefix = PREFIX_START_2; >+ } >+ if (firstDelimIndex != -1) { >+ int idStart = firstDelimIndex + usedPrefix.length(); >+ int idEnd = comment.indexOf(PREFIX_DELIM, firstDelimIndex + usedPrefix.length());// comment.indexOf(PREFIX_DELIM); >+ if (idEnd != -1 && idStart < idEnd) { >+ String id = comment.substring(idStart, idEnd); >+ if (id != null) { >+ return id.trim(); >+ } >+ } else { >+ return comment.substring(0, firstDelimIndex); >+ } >+ } >+ return null; >+ } >+ >+ private static IProject findCorrespondingProject(Object element) { >+ if (element instanceof DiffChangeSet) { >+ IResource[] resources = ((DiffChangeSet) element).getResources(); >+ if (resources.length > 0) { >+ // TODO: only checks first resource >+ return resources[0].getProject(); >+ } >+ } else if (element instanceof SynchronizeModelElement) { >+ SynchronizeModelElement modelElement = (SynchronizeModelElement)element; >+ IResource resource = modelElement.getResource(); >+ if (resource != null) { >+ return resource.getProject(); >+ } else { >+ IDiffElement[] elements = modelElement.getChildren(); >+ if (elements.length > 0) { >+ // TODO: only checks first diff >+ if (elements[0] instanceof SynchronizeModelElement) { >+ return ((SynchronizeModelElement)elements[0]).getResource().getProject(); >+ } >+ } >+ } >+ } else if (element instanceof IAdaptable) { >+ IAdaptable adaptable = (IAdaptable) element; >+ IResourceVariant resourceVariant = (IResourceVariant) adaptable.getAdapter(IResourceVariant.class); >+ if (resourceVariant != null && resourceVariant instanceof RemoteResource) { >+ RemoteResource remoteResource = (RemoteResource) resourceVariant; >+ // TODO is there a better way then iterating trough all projects? >+ String path = remoteResource.getRepositoryRelativePath(); >+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { >+ if(project.isAccessible()) { >+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSFolderFor(project); >+ try { >+ if(cvsResource!=null && path.startsWith(cvsResource.getRepositoryRelativePath())) { >+ return project; >+ } >+ } catch (CVSException ex) { >+ // ignore >+ } >+ } >+ } >+ >+ return null; >+ } >+ } else { >+ // TODO >+ >+ } >+ return null; >+ } >+ >+ >+ /** >+ * Wrapper class used to isolate Subclibse dependencies >+ */ >+ private static class SubclipseWrapper { >+ >+ public static void init(IAdapterManager adapterManager, IAdapterFactory factory) { >+ Class logEntryClass = org.tigris.subversion.subclipse.core.history.LogEntry.class; >+ adapterManager.registerAdapters(FACTORY, logEntryClass); >+ } >+ >+ private static ILinkedTaskInfo adaptSubclipseChangeset(ChangeSetDiffNode diff, ChangeSet set) { >+ SynchronizeModelElement diffContainer = (SynchronizeModelElement) diff.getChildren()[0]; >+ >+ IResource res = diffContainer.getResource(); >+ >+ SyncInfoModelElement melement = (SyncInfoModelElement) diffContainer.getChildren()[0]; >+ >+ // Specific to Subclipse >+ SVNStatusSyncInfo info = (SVNStatusSyncInfo) melement.getSyncInfo(); >+ >+ ISVNRemoteResource remoteResource = (ISVNRemoteResource) info.getRemote(); >+ SVNRevision rev = remoteResource.getLastChangedRevision(); >+ >+ String comment; >+ try { >+ ISVNLogMessage[] messages = remoteResource.getLogMessages(rev, rev, SVNRevision.START, false, false, 1); >+ comment = messages[0].getMessage(); >+ } catch (TeamException ex) { >+ comment = diff.getSet().getComment(); >+ } >+ return adaptFromComment(diff, res, comment); >+ } >+ >+ private static ILinkedTaskInfo adaptSubclipseLogEntry(Object object) { >+ org.tigris.subversion.subclipse.core.history.LogEntry logEntry = >+ (org.tigris.subversion.subclipse.core.history.LogEntry) object; >+ >+ String comment = logEntry.getComment(); >+ IResource res = logEntry.getResource().getResource(); >+ >+ return adaptFromComment(object, res, comment); >+ } >+ >+ private static ILinkedTaskInfo adaptFromComment(Object object, IResource res, String comment) { >+ ProjectProperties props = null; >+ try { >+ props = ProjectProperties.getProjectProperties(res); >+ } catch (TeamException ex) { >+ // ignore? >+ } >+ >+ String[] urls = null; >+ String repositoryUrl = null; >+ if(props!=null) { >+ repositoryUrl = getRepositoryUrl(props.getUrl()); >+ urls = props.getLinkList(comment).getUrls(); >+ } >+ if (urls == null || urls.length == 0) { >+ // we can do better job then this method >+ urls = ProjectProperties.getUrls(comment).getUrls(); >+ } >+ if (urls != null && urls.length > 0) { >+ return new LinkedTaskInfo(repositoryUrl, null, urls[0]); >+ } >+ return null; >+ } >+ >+ private static String getRepositoryUrl(String url) { >+ for (TaskRepository repository : TasksUiPlugin.getRepositoryManager().getAllRepositories()) { >+ if(url.startsWith(repository.getUrl())) { >+ return repository.getUrl(); >+ } >+ } >+ return null; >+ } >+ >+ } >+ >+} >+
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 165581
:
54525
|
54527
|
54587
|
54696
|
54697
|
54698
|
54925
|
55032
|
55033