Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Folk2014-10-29 12:45:05 -0400
committerSam Davis2014-10-30 18:13:31 -0400
commitc1f5d8e09359c93afe76143e9f10352753692aa4 (patch)
tree6e9d89fc0ab2a18ce765880d7224bd7aab3ecf41
parentdcdbb2290e00179f91eb07c941631fd8a3bf9d0a (diff)
downloadorg.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>
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SubmitTaskAttachmentJob.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/AttachmentUtil.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java7
4 files changed, 27 insertions, 7 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SubmitTaskAttachmentJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SubmitTaskAttachmentJob.java
index 04e84064f..1b91c1eb2 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SubmitTaskAttachmentJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SubmitTaskAttachmentJob.java
@@ -95,8 +95,9 @@ public class SubmitTaskAttachmentJob extends SubmitJob {
subMonitorFor(monitor, 100));
fireTaskSubmitted(monitor);
monitor.subTask(Messages.SubmitTaskAttachmentJob_Updating_task);
- TaskData taskData = connector.getTaskData(taskRepository, task.getTaskId(), subMonitorFor(monitor, 100));
- taskDataManager.putUpdatedTaskData(task, taskData, true);
+ TaskData updatedTaskData = connector.getTaskData(taskRepository, task.getTaskId(),
+ subMonitorFor(monitor, 100));
+ taskDataManager.putUpdatedTaskData(task, updatedTaskData, true);
fireTaskSynchronized(monitor);
} catch (CoreException e) {
errorStatus = e.getStatus();
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$
}
}

Back to the top