Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2010-05-12 01:22:43 +0000
committerrelves2010-05-12 01:22:43 +0000
commitef1329a85aa8998f9afa00278084973f7c5ae017 (patch)
treed3c356e57285f034013e6d423c12ec830eb00b24
parentde52c4bc394e75fc4eabe620a6871a9fd06c7dee (diff)
downloadorg.eclipse.mylyn.tasks-ef1329a85aa8998f9afa00278084973f7c5ae017.tar.gz
org.eclipse.mylyn.tasks-ef1329a85aa8998f9afa00278084973f7c5ae017.tar.xz
org.eclipse.mylyn.tasks-ef1329a85aa8998f9afa00278084973f7c5ae017.zip
NEW - bug 311634: [api] allow connectors to provide alternate IEditorInput
https://bugs.eclipse.org/bugs/show_bug.cgi?id=311634
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java47
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java18
2 files changed, 52 insertions, 13 deletions
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 c31adc012..a3056f69b 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
@@ -88,11 +88,11 @@ 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.ITask.PriorityLevel;
+import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
-import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
@@ -658,8 +658,10 @@ public class TasksUiInternal {
}
/**
- * @param connectorUi - repository connector ui
- * @param query - repository query
+ * @param connectorUi
+ * - repository connector ui
+ * @param query
+ * - repository query
* @return - true if dialog was opened successfully and not canceled, false otherwise
* @since 3.0
*/
@@ -861,13 +863,14 @@ public class TasksUiInternal {
if (window != null) {
TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(),
task.getRepositoryUrl());
- boolean openWithBrowser = !TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(
- ITasksUiPreferenceConstants.EDITOR_TASKS_RICH);
+ boolean openWithBrowser = !TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .getBoolean(ITasksUiPreferenceConstants.EDITOR_TASKS_RICH);
if (openWithBrowser) {
TasksUiUtil.openWithBrowser(taskRepository, task);
return new TaskOpenEvent(taskRepository, task, taskId, null, true);
} else {
- IEditorInput editorInput = new TaskEditorInput(taskRepository, task);
+ IEditorInput editorInput = getTaskEditorInput(taskRepository, task);
IEditorPart editor = refreshEditorContentsIfOpen(task, editorInput);
if (editor != null) {
synchronizeTask(taskRepository, task);
@@ -888,6 +891,18 @@ public class TasksUiInternal {
return null;
}
+ private static IEditorInput getTaskEditorInput(TaskRepository repository, ITask task) {
+ Assert.isNotNull(task);
+ Assert.isNotNull(repository);
+ AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(task.getConnectorKind());
+ IEditorInput editorInput = connectorUi.getTaskEditorInput(repository, task);
+ if (editorInput != null) {
+ return editorInput;
+ } else {
+ return new TaskEditorInput(repository, task);
+ }
+ }
+
private static String getTaskEditorId(final ITask task) {
String taskEditorId = TaskEditor.ID_EDITOR;
if (task != null) {
@@ -1169,15 +1184,21 @@ public class TasksUiInternal {
TasksUiInternal.displayStatus(title, new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
"Command execution failed", e)); //$NON-NLS-1$
} catch (NotDefinedException e) {
- TasksUiInternal.displayStatus(title, new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- NLS.bind("The command with the id ''{0}'' is not defined.", commandId), e)); //$NON-NLS-1$
+ TasksUiInternal.displayStatus(
+ title,
+ new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind(
+ "The command with the id ''{0}'' is not defined.", commandId), e)); //$NON-NLS-1$
} catch (NotHandledException e) {
- TasksUiInternal.displayStatus(title, new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- NLS.bind("The command with the id ''{0}'' is not bound.", commandId), e)); //$NON-NLS-1$
+ TasksUiInternal.displayStatus(
+ title,
+ new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind(
+ "The command with the id ''{0}'' is not bound.", commandId), e)); //$NON-NLS-1$
}
} else {
- TasksUiInternal.displayStatus(title, new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind(
- "The command with the id ''{0}'' does not exist.", commandId))); //$NON-NLS-1$
+ TasksUiInternal.displayStatus(
+ title,
+ new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind(
+ "The command with the id ''{0}'' does not exist.", commandId))); //$NON-NLS-1$
}
} else {
TasksUiInternal.displayStatus(
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
index b1b00b49c..ad45785f9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
@@ -32,9 +32,11 @@ import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentModel;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskSearchPage;
import org.eclipse.mylyn.tasks.ui.wizards.TaskAttachmentPage;
+import org.eclipse.ui.IEditorInput;
/**
* Extend to provide connector-specific UI extensions. TODO: consider refactoring into extension points
@@ -82,6 +84,22 @@ public abstract class AbstractRepositoryConnectorUi {
return TaskEditor.ID_EDITOR;
}
+ /**
+ * Default implementation returns the standard {@link org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput}. Override
+ * this method to return a custom task editor input. The connector author must ensure the corresponding editor is
+ * capable of opening this editor input and will likely need to override
+ * AbstractRepositoryConnectorUi.getTaskEditorId() as well.
+ *
+ * @param repository
+ * - task repository for which to construct an editor
+ * @param task
+ * - the task to edit
+ * @since 3.4
+ */
+ public IEditorInput getTaskEditorInput(TaskRepository repository, ITask task) {
+ return new TaskEditorInput(repository, task);
+ }
+
public abstract boolean hasSearchPage();
/**

Back to the top