diff options
author | Nicholas Folk | 2014-10-29 16:45:05 +0000 |
---|---|---|
committer | Sam Davis | 2014-10-30 22:13:31 +0000 |
commit | c1f5d8e09359c93afe76143e9f10352753692aa4 (patch) | |
tree | 6e9d89fc0ab2a18ce765880d7224bd7aab3ecf41 /org.eclipse.mylyn.tasks.ui | |
parent | dcdbb2290e00179f91eb07c941631fd8a3bf9d0a (diff) | |
download | org.eclipse.mylyn.tasks-c1f5d8e09359c93afe76143e9f10352753692aa4.tar.gz org.eclipse.mylyn.tasks-c1f5d8e09359c93afe76143e9f10352753692aa4.tar.xz org.eclipse.mylyn.tasks-c1f5d8e09359c93afe76143e9f10352753692aa4.zip |
provide attachment attribute when attaching context
Change-Id: I21644f2c77c51385e4e282e3a16eed0aea139b27
Signed-off-by: Nicholas Folk <Nicholas.folk@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
3 files changed, 24 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java index e90fb4fbd..2fb95dd2e 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java @@ -195,8 +195,18 @@ public class AttachmentUtil { source.setContentType(CONTEXT_CONTENT_TYPE); AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector( repository.getConnectorKind()); + TaskAttribute taskAttribute = null; + try { + TaskData taskData = TasksUi.getTaskDataManager().getTaskData(task); + if (taskData != null) { + taskAttribute = taskData.getRoot().createMappedAttribute(TaskAttribute.NEW_ATTACHMENT); + } + } catch (CoreException e) { + StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, + "Unexpected error while attaching context. Continuing with task submission.", e)); //$NON-NLS-1$ + } final SubmitJob submitJob = TasksUiInternal.getJobFactory().createSubmitTaskAttachmentJob(connector, - repository, task, source, comment, null); + repository, task, source, comment, taskAttribute); try { context.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java index 40da56950..2495ac4a8 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java @@ -46,6 +46,7 @@ import org.eclipse.mylyn.tasks.core.TaskRepository; import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource; import org.eclipse.mylyn.tasks.core.data.TaskAttachmentModel; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.core.data.TaskData; import org.eclipse.mylyn.tasks.core.sync.SubmitJob; import org.eclipse.mylyn.tasks.core.sync.SubmitJobEvent; import org.eclipse.mylyn.tasks.core.sync.SubmitJobListener; @@ -364,14 +365,17 @@ public class TaskAttachmentWizard extends Wizard { public void taskSubmitted(SubmitJobEvent event, IProgressMonitor monitor) throws CoreException { if (attachContext) { monitor.subTask(Messages.TaskAttachmentWizard_Attaching_context); - AttachmentUtil.postContext(connector, model.getTaskRepository(), model.getTask(), null, null, - monitor); + TaskData taskData = model.getAttribute().getTaskData(); + TaskAttribute taskAttribute = taskData.getRoot() + .createMappedAttribute(TaskAttribute.NEW_ATTACHMENT); + AttachmentUtil.postContext(connector, model.getTaskRepository(), model.getTask(), null, + taskAttribute, monitor); } } @Override public void taskSynchronized(SubmitJobEvent event, IProgressMonitor monitor) throws CoreException { - // ignore + // ignore } }); if (previewPage.runInBackground()) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java index 70a8895ec..5adee388a 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java @@ -244,7 +244,12 @@ public abstract class AbstractTaskEditorPage extends TaskFormPage implements ISe @Override public void taskSubmitted(SubmitJobEvent event, IProgressMonitor monitor) throws CoreException { if (!getModel().getTaskData().isNew() && attachContext) { - AttachmentUtil.postContext(connector, getModel().getTaskRepository(), task, "", null, monitor); //$NON-NLS-1$ + TaskData taskData = getModel().getTaskData(); + TaskAttribute taskAttribute = null; + if (taskData != null) { + taskAttribute = taskData.getRoot().createMappedAttribute(TaskAttribute.NEW_ATTACHMENT); + } + AttachmentUtil.postContext(connector, getModel().getTaskRepository(), task, "", taskAttribute, monitor); //$NON-NLS-1$ } } |