Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-02-28 22:22:42 -0500
committerspingel2010-02-28 22:22:42 -0500
commit864f1a68d01f919a723c80b840b420f4fc9374e8 (patch)
treef41218e1669707dcac4d5538d48b555060fd7739
parentf82c7826d750e25ee85532d4dcd86e2cb680e08d (diff)
downloadorg.eclipse.mylyn.tasks-864f1a68d01f919a723c80b840b420f4fc9374e8.tar.gz
org.eclipse.mylyn.tasks-864f1a68d01f919a723c80b840b420f4fc9374e8.tar.xz
org.eclipse.mylyn.tasks-864f1a68d01f919a723c80b840b420f4fc9374e8.zip
NEW - bug 296963: [patch][api] allow different URL's for opening task in browser and copying task details
https://bugs.eclipse.org/bugs/show_bug.cgi?id=296963
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java18
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenTaskAction.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenWithBrowserAction.java15
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java18
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java34
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java4
6 files changed, 74 insertions, 19 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
index 56a083b72..b330511c5 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.tasks.core;
+import java.net.URL;
import java.util.Collection;
import java.util.Date;
@@ -192,6 +193,23 @@ public abstract class AbstractRepositoryConnector {
public abstract String getTaskUrl(String repositoryUrl, String taskId);
/**
+ * Returns a URL for <code>element</code> that contains authentication information such as a session ID.
+ * <p>
+ * Returns <code>null</code> by default. Clients may override.
+ *
+ * @param repository
+ * the repository for <code>element</code>
+ * @param element
+ * the element to return the authenticated url for
+ * @return null, if no corresponding authenticated URL is available for <code>element</code>; the URL, otherwise
+ * @see IRepositoryElement#getUrl()
+ * @since 3.4
+ */
+ public URL getAuthenticatedUrl(TaskRepository repository, IRepositoryElement element) {
+ return null;
+ }
+
+ /**
* @since 3.0
*/
public abstract boolean hasTaskChanged(TaskRepository taskRepository, ITask task, TaskData taskData);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenTaskAction.java
index 386db130f..a463404e0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenTaskAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenTaskAction.java
@@ -47,9 +47,7 @@ public class OpenTaskAction extends ActionDelegate implements IWorkbenchWindowAc
if (result instanceof ITask) {
AbstractTask task = (AbstractTask) result;
if (dlg.getOpenInBrowser()) {
- if (TasksUiInternal.isValidUrl(task.getUrl())) {
- TasksUiUtil.openUrl(task.getUrl());
- }
+ TasksUiUtil.openWithBrowser(task);
} else {
TasksUiInternal.refreshAndOpenTaskListElement(task);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenWithBrowserAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenWithBrowserAction.java
index 1b60e5618..d06624deb 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenWithBrowserAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/OpenWithBrowserAction.java
@@ -14,7 +14,6 @@ package org.eclipse.mylyn.internal.tasks.ui.actions;
import java.util.Iterator;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.ITask;
@@ -46,18 +45,8 @@ public class OpenWithBrowserAction extends BaseSelectionListenerAction {
private void runWithSelection(Object selectedObject) {
String urlString = null;
- if (selectedObject instanceof ITask) {
- AbstractTask task = (AbstractTask) selectedObject;
- if (TasksUiInternal.isValidUrl(task.getUrl())) {
- urlString = task.getUrl();
- }
- } else if (selectedObject instanceof IRepositoryElement) {
- IRepositoryElement query = (IRepositoryElement) selectedObject;
- urlString = query.getUrl();
- }
-
- if (urlString != null) {
- TasksUiUtil.openUrl(urlString);
+ if (selectedObject instanceof IRepositoryElement) {
+ TasksUiUtil.openWithBrowser((IRepositoryElement) selectedObject);
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
index 81cddaf82..97afa9f29 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Tasktop Technologies - initial API and implementation
+ * Steve Elsemore - fix for bug 296963
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.util;
@@ -845,7 +846,7 @@ public class TasksUiInternal {
boolean openWithBrowser = !TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(
ITasksUiPreferenceConstants.EDITOR_TASKS_RICH);
if (openWithBrowser) {
- TasksUiUtil.openUrl(task.getUrl());
+ TasksUiUtil.openWithBrowser(taskRepository, task);
return new TaskOpenEvent(taskRepository, task, taskId, null, true);
} else {
IEditorInput editorInput = new TaskEditorInput(taskRepository, task);
@@ -1219,4 +1220,19 @@ public class TasksUiInternal {
throw exception;
}
+ public static String getAuthenticatedUrl(TaskRepository repository, IRepositoryElement element) {
+ IRepositoryManager repositoryManager = TasksUi.getRepositoryManager();
+ AbstractRepositoryConnector connector = repositoryManager.getRepositoryConnector(repository.getConnectorKind());
+ URL authenticatedUrl = connector.getAuthenticatedUrl(repository, element);
+ if (authenticatedUrl != null) {
+ return authenticatedUrl.toString();
+ } else {
+ String url = element.getUrl();
+ if (TasksUiInternal.isValidUrl(url)) {
+ return url;
+ }
+ }
+ return null;
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java
index 4f83b2c4d..e143fdb44 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java
@@ -35,6 +35,8 @@ import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
import org.eclipse.mylyn.internal.tasks.ui.wizards.MultiRepositoryAwareWizard;
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewLocalTaskWizard;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.IRepositoryElement;
+import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
@@ -364,6 +366,38 @@ public class TasksUiUtil {
}
/**
+ * Opens <code>element</code> in a browser using an authenticated URL if available.
+ *
+ * @since 3.4
+ */
+ public static boolean openWithBrowser(IRepositoryElement element) {
+ IRepositoryManager repositoryManager = TasksUi.getRepositoryManager();
+ TaskRepository repository = null;
+ if (element instanceof ITask) {
+ repository = repositoryManager.getRepository(((ITask) element).getConnectorKind(),
+ ((ITask) element).getRepositoryUrl());
+ } else if (element instanceof IRepositoryQuery) {
+ repository = repositoryManager.getRepository(((IRepositoryQuery) element).getConnectorKind(),
+ ((IRepositoryQuery) element).getRepositoryUrl());
+ }
+ return (repository != null) ? openWithBrowser(repository, element) : null;
+ }
+
+ /**
+ * Opens <code>element</code> in a browser using an authenticated URL if available.
+ *
+ * @since 3.4
+ */
+ public static boolean openWithBrowser(TaskRepository repository, IRepositoryElement element) {
+ String url = TasksUiInternal.getAuthenticatedUrl(repository, element);
+ if (url != null) {
+ openUrl(url);
+ return true;
+ }
+ return false;
+ }
+
+ /**
* @since 3.0
*/
public static IViewPart openTasksViewInActivePerspective() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java
index 262a8a5d9..37a1eb380 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java
@@ -920,12 +920,12 @@ public class TaskEditor extends SharedHeaderFormEditor {
toolBarManager.add(new GroupMarker("open")); //$NON-NLS-1$
toolBarManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- final String taskUrl = task.getUrl();
+ final String taskUrl = TasksUiInternal.getAuthenticatedUrl(taskRepository, task);
if (taskUrl != null && taskUrl.length() > 0) {
Action openWithBrowserAction = new Action() {
@Override
public void run() {
- TasksUiUtil.openUrl(taskUrl);
+ TasksUiUtil.openWithBrowser(taskRepository, task);
}
};
// ImageDescriptor overlay = TasksUiPlugin.getDefault().getOverlayIcon(taskRepository.getConnectorKind());

Back to the top