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 54525 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]
Reworked Open Correspond Task action
aaa.patch (text/plain), 62.23 KB, created by
Eugene Kuleshov
on 2006-11-26 01:31:26 EST
(
hide
)
Description:
Reworked Open Correspond Task action
Filename:
MIME Type:
Creator:
Eugene Kuleshov
Created:
2006-11-26 01:31:26 EST
Size:
62.23 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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 26 Nov 2006 06:28:05 -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.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 26 Nov 2006 06:28:05 -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.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 26 Nov 2006 06:28:05 -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.context.core >Index: .classpath >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.context.core/.classpath,v >retrieving revision 1.10 >diff -u -r1.10 .classpath >--- .classpath 21 Nov 2006 21:19:02 -0000 1.10 >+++ .classpath 26 Nov 2006 06:28:06 -0000 >@@ -2,7 +2,7 @@ > <classpath> > <classpathentry exported="true" kind="lib" path="lib/ws-commons-util-1.0.1.jar" sourcepath="lib/ws-commons-util-1.0.1-sources.jar"/> > <classpathentry exported="true" kind="lib" path="lib/commons-codec-1.3.jar"/> >- <classpathentry exported="true" kind="lib" path="lib/commons-httpclient-3.0.jar"/> >+ <classpathentry exported="true" kind="lib" path="lib/commons-httpclient-3.0.jar" sourcepath="lib/commons-httpclient-3.0-src.zip"/> > <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> > <classpathentry kind="src" path="src"/> > <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> >#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 26 Nov 2006 06:28:06 -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.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.8 >diff -u -r1.8 WebRepositoryConnector.java >--- src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java 25 Nov 2006 00:46:10 -0000 1.8 >+++ src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java 26 Nov 2006 06:28:07 -0000 >@@ -149,14 +149,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(); > } > } > >@@ -173,7 +175,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; > } > >#P org.eclipse.mylar.tasks.ui >Index: src/org/eclipse/mylar/internal/tasks/ui/TaskUiUtil.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/internal/tasks/ui/TaskUiUtil.java,v >retrieving revision 1.24 >diff -u -r1.24 TaskUiUtil.java >--- src/org/eclipse/mylar/internal/tasks/ui/TaskUiUtil.java 25 Nov 2006 00:45:41 -0000 1.24 >+++ src/org/eclipse/mylar/internal/tasks/ui/TaskUiUtil.java 26 Nov 2006 06:28:07 -0000 >@@ -39,6 +39,7 @@ > import org.eclipse.mylar.tasks.core.Task; > import org.eclipse.mylar.tasks.core.TaskCategory; > import org.eclipse.mylar.tasks.core.TaskRepository; >+import org.eclipse.mylar.tasks.core.TaskRepositoryManager; > import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi; > import org.eclipse.mylar.tasks.ui.TasksUiPlugin; > import org.eclipse.swt.graphics.Image; >@@ -110,29 +111,36 @@ > } else { > AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getRepositoryUi(repository.getKind()); > if (connectorUi != null) { >- connectorUi.openRemoteTask(repository.getUrl(), taskId); >- opened = true; >+ opened = connectorUi.openRemoteTask(repository.getUrl(), taskId); > } > } > return opened; > } > > /** >- * Either pass in a repository and id, or fullUrl, or all of them >+ * Either pass in a repositoryUrl and taskId, or fullUrl, or all of them > */ > public static boolean openRepositoryTask(String repositoryUrl, String taskId, String fullUrl) { >- boolean opened = false; >+ TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager(); >+ AbstractRepositoryConnector connector = repositoryManager.getConnectorForRepositoryTaskUrl(fullUrl); >+ if (taskId == null && connector != null) { >+ taskId = connector.getTaskIdFromTaskUrl(fullUrl); >+ } >+ if (repositoryUrl == null && connector != null) { >+ repositoryUrl = connector.getRepositoryUrlFromTaskUrl(fullUrl); >+ } >+ > ITask task = null; > if (taskId != null) { > String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId); > task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(handle); > } >- if (task == null) { >- // search for it >+ if (task == null && fullUrl != null) { >+ // search by fullUrl > for (ITask currTask : TasksUiPlugin.getTaskListManager().getTaskList().getAllTasks()) { > if (currTask instanceof AbstractRepositoryTask) { > String currUrl = ((AbstractRepositoryTask) currTask).getUrl(); >- if (currUrl != null && !currUrl.equals("") && currUrl.equals(fullUrl)) { >+ if (fullUrl.equals(currUrl)) { > task = currTask; > break; > } >@@ -140,19 +148,17 @@ > } > } > >+ boolean opened = false; > if (task != null) { > TaskUiUtil.refreshAndOpenTaskListElement(task); > opened = true; >- } else { >- AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() >- .getConnectorForRepositoryTaskUrl(fullUrl); >+ } else if (connector != null) { > AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getRepositoryUi(connector.getRepositoryType()); >- >- if (connector != null) { >+ if (connectorUi != null) { > opened = connectorUi.openRemoteTask(repositoryUrl, taskId); > } > } >- if (!opened) { >+ if (!opened && fullUrl != null) { > TaskUiUtil.openUrl(fullUrl); > opened = true; > } >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 26 Nov 2006 06:28:07 -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.TaskUiUtil; > 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()); >+ TaskUiUtil.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.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.5 >diff -u -r1.5 JiraRepositoryConnector.java >--- src/org/eclipse/mylar/internal/jira/core/JiraRepositoryConnector.java 25 Nov 2006 00:45:09 -0000 1.5 >+++ src/org/eclipse/mylar/internal/jira/core/JiraRepositoryConnector.java 26 Nov 2006 06:28:07 -0000 >@@ -198,10 +198,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) { >Index: src/org/eclipse/mylar/internal/jira/core/JiraServerFacade.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.jira.ui/src/org/eclipse/mylar/internal/jira/core/JiraServerFacade.java,v >retrieving revision 1.1 >diff -u -r1.1 JiraServerFacade.java >--- src/org/eclipse/mylar/internal/jira/core/JiraServerFacade.java 22 Nov 2006 17:01:12 -0000 1.1 >+++ src/org/eclipse/mylar/internal/jira/core/JiraServerFacade.java 26 Nov 2006 06:28:07 -0000 >@@ -53,8 +53,11 @@ > String serverHostname = getServerHost(repository); > JiraServer server = serverManager.getServer(serverHostname); > if (server == null) { >- server = serverManager.createServer(serverHostname, repository.getUrl(), false, >- repository.getUserName(), repository.getPassword()); >+ String userName = repository.getUserName(); >+ String password = repository.getPassword(); >+ server = serverManager.createServer(serverHostname, repository.getUrl(), false, // >+ userName == null ? "" : userName, // >+ password == null ? "" : password); > serverManager.addServer(server); > } > return server; >#P org.eclipse.mylar.team >Index: src/org/eclipse/mylar/internal/team/ui/actions/OpenCorrespondingTaskAction.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.team/src/org/eclipse/mylar/internal/team/ui/actions/OpenCorrespondingTaskAction.java,v >retrieving revision 1.11 >diff -u -r1.11 OpenCorrespondingTaskAction.java >--- src/org/eclipse/mylar/internal/team/ui/actions/OpenCorrespondingTaskAction.java 25 Nov 2006 00:45:16 -0000 1.11 >+++ src/org/eclipse/mylar/internal/team/ui/actions/OpenCorrespondingTaskAction.java 26 Nov 2006 06:28:08 -0000 >@@ -11,243 +11,310 @@ > > package org.eclipse.mylar.internal.team.ui.actions; > >-import org.eclipse.compare.structuremergeviewer.IDiffElement; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.mylar.internal.tasks.ui.TaskListImages; > import org.eclipse.mylar.internal.tasks.ui.TaskUiUtil; >-import org.eclipse.mylar.internal.team.ContextChangeSet; >-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.internal.team.ILinkedTaskInfo; > import org.eclipse.mylar.tasks.core.TaskRepository; >-import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi; > import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >-import org.eclipse.mylar.team.MylarTeamPlugin; >-import org.eclipse.team.core.history.IFileRevision; >-import org.eclipse.team.core.variants.IResourceVariant; >-import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry; >-import org.eclipse.team.internal.ccvs.core.mapping.CVSCheckedInChangeSet; >-import org.eclipse.team.internal.ccvs.core.resources.RemoteResource; >-import org.eclipse.team.internal.core.subscribers.DiffChangeSet; >-import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode; >-import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement; > import org.eclipse.ui.IViewActionDelegate; > import org.eclipse.ui.IViewPart; > import org.eclipse.ui.internal.ObjectPluginAction; > > /** > * @author Mik Kersten >+ * @author Eugene Kuleshov > */ > public class OpenCorrespondingTaskAction extends Action implements IViewActionDelegate { > >- private static final String LABEL = "Open Corresponding Task"; >+ private static final String LABEL = "Open Corresponding Task"; > >- private ISelection selection; >+ private ISelection selection; > >- 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://"; > >- public OpenCorrespondingTaskAction() { >- setText(LABEL); >- setToolTipText(LABEL); >- setImageDescriptor(TaskListImages.TASK_REPOSITORY); >- } >- >- public void init(IViewPart view) { >- // ignore >- } >- >- @Override >- public void run() { >- if (selection instanceof StructuredSelection) { >- run((StructuredSelection) selection); >+ public OpenCorrespondingTaskAction() { >+ setText(LABEL); >+ setToolTipText(LABEL); >+ setImageDescriptor(TaskListImages.TASK_REPOSITORY); >+ } >+ >+ public void init(IViewPart view) { >+ // ignore >+ } >+ >+ @Override >+ public void run() { >+ if (selection instanceof StructuredSelection) { >+ run((StructuredSelection) selection); >+ } >+ } >+ >+ public void run(IAction action) { >+ if (action instanceof ObjectPluginAction) { >+ ObjectPluginAction objectAction = (ObjectPluginAction) action; >+ if (objectAction.getSelection() instanceof StructuredSelection) { >+ StructuredSelection selection = (StructuredSelection) objectAction.getSelection(); >+ run(selection); >+ } >+ } >+ } >+ >+ private void run(StructuredSelection selection) { >+ Object element = selection.getFirstElement(); >+ >+ ILinkedTaskInfo info = null; >+ if (element instanceof IAdaptable) { >+ info = (ILinkedTaskInfo) ((IAdaptable) element).getAdapter(ILinkedTaskInfo.class); > } >- } >- >- public void run(IAction action) { >- if (action instanceof ObjectPluginAction) { >- ObjectPluginAction objectAction = (ObjectPluginAction) action; >- if (objectAction.getSelection() instanceof StructuredSelection) { >- StructuredSelection selection = (StructuredSelection) objectAction.getSelection(); >- run(selection); >- } >+ if (info == null) { >+ info = (ILinkedTaskInfo) Platform.getAdapterManager().getAdapter(element, ILinkedTaskInfo.class); > } >- } >- >- private void run(StructuredSelection selection) { >- Object element = selection.getFirstElement(); >- boolean opened = false; >- >- if (element instanceof ChangeSetDiffNode) { >- ChangeSetDiffNode diffNode = (ChangeSetDiffNode) element; >- if (diffNode.getSet() instanceof ContextChangeSet) { >- ITask task = ((ContextChangeSet) diffNode.getSet()).getTask(); >- TaskUiUtil.openEditor(task, false); >- opened = true; >- } >- } else if (element instanceof ContextChangeSet) { >- ITask task = ((ContextChangeSet) element).getTask(); >- if (task != null) { >- TaskUiUtil.openEditor(task, false); >- opened = true; >+ >+ if (info != null) { >+ if(info.getTask()!=null) { >+ // TODO Which one to use? >+ // TaskUiUtil.openEditor(info.getTask(), false); >+ TaskUiUtil.refreshAndOpenTaskListElement(info.getTask()); >+ return; > } >- } >- >- if (!opened) { >- IProject project = findCorrespondingProject(element); >- String comment = getCommentFromSelection(element); >- >- if (comment != null) { >- String id = MylarTeamPlugin.getDefault().getCommitTemplateManager() >- .getTaskIdFromCommentOrLabel(comment); >- if (id == null) { >- id = getTaskIdFromLegacy07Label(comment); >+ if(info.getRepositoryUrl()!=null && info.getTaskId()!=null) { >+ TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(info.getRepositoryUrl()); >+ if(repository!=null) { >+ if(TaskUiUtil.openRepositoryTask(repository, info.getTaskId())) { >+ return; >+ } > } >- >+ } >+ if(info.getTaskFullUrl()!=null) { >+ TaskUiUtil.openUrl(info.getTaskFullUrl()); >+ return; >+ } >+ } >+ >+ // XXX show open remote task dialog >+ >+ return; >+/* >+ if (element instanceof ChangeSetDiffNode) { >+ ChangeSetDiffNode diffNode = (ChangeSetDiffNode) element; >+ ChangeSet set = diffNode.getSet(); >+ if (set instanceof ContextChangeSet) { >+ ITask task = ((ContextChangeSet) set).getTask(); >+ TaskUiUtil.openEditor(task, false); >+ return; >+ } else { >+ if(set.getClass().getName().startsWith("org.tigris")) { >+ if(openIssueFromSubclipseChangeset(diffNode, set)) { >+ return; >+ } >+ } >+ } >+ } else if (element instanceof ContextChangeSet) { >+ ITask task = ((ContextChangeSet) element).getTask(); >+ if (task != null) { >+ TaskUiUtil.openEditor(task, false); >+ return; >+ } >+ } >+ >+ String comment = getCommentFromSelection(element); >+ if (comment != null) { >+ String id = MylarTeamPlugin.getDefault().getCommitTemplateManager() >+ .getTaskIdFromCommentOrLabel(comment); >+ if (id == null) { >+ id = getTaskIdFromLegacy07Label(comment); >+ } >+ >+ boolean opened = false; >+ if (id != null) { >+ IProject project = findCorrespondingProject(element); > if (project != null) { > TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, false); > if (repository != null) { >- AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getRepositoryUi(repository.getKind()); >- if (connectorUi != null && id != null) { >- opened = TaskUiUtil.openRepositoryTask(repository, id); >- } >+ opened = TaskUiUtil.openRepositoryTask(repository, id); > } > } >+ } > >- // try opening via URL if present >- if (!opened) { >- String fullUrl = getUrlFromComment(comment); >- >- String repositoryUrl = null; >- if (fullUrl != null) { >- AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() >- .getConnectorForRepositoryTaskUrl(fullUrl); >- if (connector != null) { >- repositoryUrl = connector.getRepositoryUrlFromTaskUrl(fullUrl); >- } >- } else { >- ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask(); >- if (task instanceof AbstractRepositoryTask) { >- repositoryUrl = ((AbstractRepositoryTask) task).getRepositoryUrl(); >- } else if (TasksUiPlugin.getRepositoryManager().getAllRepositories().size() == 1) { >- repositoryUrl = TasksUiPlugin.getRepositoryManager().getAllRepositories().get(0).getUrl(); >- } >- } >+ // try opening via URL if present >+ if (!opened) { >+ String fullUrl = getUrlFromComment(comment); >+ >+ String repositoryUrl = null; >+ if (fullUrl != null) { >+ AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() >+ .getConnectorForRepositoryTaskUrl(fullUrl); >+ if (connector != null) { >+ repositoryUrl = connector.getRepositoryUrlFromTaskUrl(fullUrl); >+ } >+ } else { >+ // WTF?! opening a random task? >+ ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask(); >+ if (task instanceof AbstractRepositoryTask) { >+ repositoryUrl = ((AbstractRepositoryTask) task).getRepositoryUrl(); >+ } else if (TasksUiPlugin.getRepositoryManager().getAllRepositories().size() == 1) { >+ repositoryUrl = TasksUiPlugin.getRepositoryManager().getAllRepositories().get(0).getUrl(); >+ } >+ } > >+ if ((repositoryUrl != null && id != null) || fullUrl != null) { > opened = TaskUiUtil.openRepositoryTask(repositoryUrl, id, fullUrl); >- if (!opened) { >+ if (!opened && fullUrl != null) { > TaskUiUtil.openUrl(fullUrl); > } > } >- } >- } >- } >+ } >+ } >+*/ >+ } > >- private String getCommentFromSelection(Object element) { >- if (element instanceof DiffChangeSet) { >- return ((CVSCheckedInChangeSet) element).getComment(); >- } else if (element instanceof ChangeSetDiffNode) { >- return ((ChangeSetDiffNode) element).getName(); >- } else if (element instanceof LogEntry) { >- return ((LogEntry) element).getComment(); >- } else if (element instanceof IFileRevision) { >- return ((IFileRevision) element).getComment(); >- } >- return null; >- } >- >- private 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) { >- // TODO: there must be a better way to get at the local resource >- IResourceVariant resourceVariant = (IResourceVariant) ((IAdaptable) element) >- .getAdapter(IResourceVariant.class); >- if (resourceVariant != null && resourceVariant instanceof RemoteResource) { >- RemoteResource remoteResource = (RemoteResource) resourceVariant; >- String path = remoteResource.getRepositoryRelativePath(); >- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >- return root.getProject(new Path(path).removeFirstSegments(1).uptoSegment(1).toString()); >- } >- } else { >- >- } >- return null; >- } >+/* >+ private boolean openIssueFromSubclipseChangeset(ChangeSetDiffNode diff, ChangeSet set) { > >- 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; >- } >+ SynchronizeModelElement diffContainer = (SynchronizeModelElement) diff.getChildren()[0]; > >- 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); >- } >+ 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(); >+ } >+ >+ ProjectProperties props = null; >+ try { >+ props = ProjectProperties.getProjectProperties(res); >+ } catch (TeamException ex) { >+ // ignore? >+ } >+ String[] urls = null; >+ if(props!=null) { >+ urls = props.getLinkList(comment).getUrls(); > } >- return null; >- } >- >+ if (urls == null || urls.length == 0) { >+ urls = ProjectProperties.getUrls(comment).getUrls(); >+ } >+ if (urls != null && urls.length > 0) { >+ String taskUrl = urls[0]; >+ TaskUiUtil.openRepositoryTask(null, null, taskUrl); >+ return true; >+ } >+ return false; >+ } >+ >+ private String getCommentFromSelection(Object element) { >+ if (element instanceof DiffChangeSet) { >+ return ((CVSCheckedInChangeSet) element).getComment(); >+ } else if (element instanceof ChangeSetDiffNode) { >+ return ((ChangeSetDiffNode) element).getName(); >+ } else if (element instanceof LogEntry) { >+ return ((LogEntry) element).getComment(); >+ } else if (element instanceof IFileRevision) { >+ return ((IFileRevision) element).getComment(); >+ } >+ return null; >+ } >+ >+ private 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) { >+ // TODO: there must be a better way to get at the local resource >+ IResourceVariant resourceVariant = (IResourceVariant) ((IAdaptable) element) >+ .getAdapter(IResourceVariant.class); >+ if (resourceVariant != null && resourceVariant instanceof RemoteResource) { >+ RemoteResource remoteResource = (RemoteResource) resourceVariant; >+ String path = remoteResource.getRepositoryRelativePath(); >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ return root.getProject(new Path(path).removeFirstSegments(1).uptoSegment(1).toString()); >+ } >+ } else { >+ >+ } >+ 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 Object findParent(ISynchronizeModelElement element) { > // if (element instanceof ChangeSetDiffNode) { >@@ -257,10 +324,10 @@ > // } > // return null; > // } >- > >- public void selectionChanged(IAction action, ISelection selection) { >- this.selection = selection; >- } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ this.selection = selection; >+ } > > } >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 26 Nov 2006 06:28:08 -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; >@@ -60,6 +61,8 @@ > } > } > }); >+ >+ LinkedTaskInfoAdapterFactory.registerAdapters(); > } > > public void earlyStartup() { >@@ -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 26 Nov 2006 06:28:08 -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,333 @@ >+/******************************************************************************* >+ * 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://"; >+ >+ >+ 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. need to do something when Subclibse is not installed >+ adapterManager.registerAdapters(FACTORY, org.tigris.subversion.subclipse.core.history.LogEntry.class); >+ } >+ >+ 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(object instanceof org.tigris.subversion.subclipse.core.history.LogEntry) { >+ return adaptSubclipseLogEntry(object); >+ } >+ >+ // TODO add other adapted types >+ >+/* >+ if (object instanceof DiffChangeSet) { >+ return ((CVSCheckedInChangeSet) object).getComment(); >+ } else if (object instanceof ChangeSetDiffNode) { >+ return ((ChangeSetDiffNode) object).getName(); >+ } else if (object instanceof LogEntry) { >+ return ((LogEntry) object).getComment(); >+ } else if (object instanceof IFileRevision) { >+ return ((IFileRevision) object).getComment(); >+ } >+*/ >+ >+ 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(set.getClass().getName().startsWith("org.tigris")) { >+ return adaptSubclipseChangeset(diffNode, set); >+ } >+ >+ return adaptFromComment(object); >+ } >+ >+ private 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 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 ILinkedTaskInfo adaptFromComment(Object object, IResource res, String comment) { >+ ProjectProperties props = null; >+ try { >+ props = ProjectProperties.getProjectProperties(res); >+ } catch (TeamException ex) { >+ // ignore? >+ } >+ String[] urls = null; >+ if(props!=null) { >+ urls = props.getLinkList(comment).getUrls(); >+ } >+ if (urls == null || urls.length == 0) { >+ urls = ProjectProperties.getUrls(comment).getUrls(); >+ } >+ if (urls != null && urls.length > 0) { >+ return new LinkedTaskInfo(urls[0]); >+ } >+ 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; >+ } >+ >+} >#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 26 Nov 2006 06:28:09 -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) {
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