Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2008-09-03 14:54:48 -0400
committerrelves2008-09-03 14:54:48 -0400
commit757435e4799ca2d856f0e4a3e1b19ad70825bd72 (patch)
tree3ee676982ed66dfa73c89080f16708165fd8695c
parent2e288ec95ceff6101c9a33eb549f2d9fc643bbef (diff)
downloadorg.eclipse.mylyn.tasks-757435e4799ca2d856f0e4a3e1b19ad70825bd72.tar.gz
org.eclipse.mylyn.tasks-757435e4799ca2d856f0e4a3e1b19ad70825bd72.tar.xz
org.eclipse.mylyn.tasks-757435e4799ca2d856f0e4a3e1b19ad70825bd72.zip
NEW - bug 238329: task activity not migrated when submitting tasks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=238329
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java69
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java16
2 files changed, 85 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java
new file mode 100644
index 000000000..6366c4ea7
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ChangeActivityHandleOperation.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Mylyn project committers 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
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
+import org.eclipse.mylyn.internal.context.core.InteractionContext;
+import org.eclipse.mylyn.monitor.core.InteractionEvent;
+
+/**
+ * Changes handle from oldHandle to newHandle in Activity Meta Context
+ *
+ * @author Rob Elves
+ */
+public class ChangeActivityHandleOperation extends TaskListModifyOperation {
+
+ private final String oldHandle;
+
+ private final String newHandle;
+
+ public ChangeActivityHandleOperation(String oldHandle, String newHandle) {
+ this.oldHandle = oldHandle;
+ this.newHandle = newHandle;
+ }
+
+ @Override
+ protected void operations(IProgressMonitor monitor) throws CoreException, InvocationTargetException,
+ InterruptedException {
+ if (oldHandle == null || newHandle == null || oldHandle.equals(newHandle)) {
+ return;
+ }
+ try {
+ monitor.beginTask("Activity migration", IProgressMonitor.UNKNOWN);
+ refactorMetaContextHandles(oldHandle, newHandle);
+ TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
+ } finally {
+ monitor.done();
+ }
+ }
+
+ @SuppressWarnings("restriction")
+ private void refactorMetaContextHandles(String oldHandle, String newHandle) {
+ ContextCorePlugin.getContextManager().saveActivityMetaContext();
+ InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+ ContextCorePlugin.getContextManager().resetActivityMetaContext();
+ InteractionContext newMetaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
+ for (InteractionEvent event : metaContext.getInteractionHistory()) {
+ if (event.getStructureHandle() != null) {
+ if (event.getStructureHandle().equals(oldHandle)) {
+ event = new InteractionEvent(event.getKind(), event.getStructureKind(), newHandle,
+ event.getOriginId(), event.getNavigation(), event.getDelta(),
+ event.getInterestContribution(), event.getDate(), event.getEndDate());
+ }
+ }
+ newMetaContext.parseEvent(event);
+ }
+ ContextCorePlugin.getContextManager().saveActivityMetaContext();
+ }
+
+}
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 f0ae09507..58bb26703 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
@@ -8,6 +8,7 @@
package org.eclipse.mylyn.tasks.ui.editors;
+import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -52,6 +53,7 @@ import org.eclipse.mylyn.internal.tasks.core.DateRange;
import org.eclipse.mylyn.internal.tasks.core.ITaskListRunnable;
import org.eclipse.mylyn.internal.tasks.core.data.ITaskDataManagerListener;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManagerEvent;
+import org.eclipse.mylyn.internal.tasks.ui.ChangeActivityHandleOperation;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.ClearOutgoingAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.DeleteTaskEditorAction;
@@ -176,9 +178,23 @@ public abstract class AbstractTaskEditorPage extends FormPage implements ISelect
TasksUiPlugin.getTaskActivityManager().setDueDate(newTask, dueDate);
((AbstractTask) newTask).setEstimatedTimeHours(((AbstractTask) oldTask).getEstimatedTimeHours());
}
+
ContextCorePlugin.getContextStore().saveActiveContext();
ContextCore.getContextStore().cloneContext(oldTask.getHandleIdentifier(),
newTask.getHandleIdentifier());
+
+ ChangeActivityHandleOperation operation = new ChangeActivityHandleOperation(
+ oldTask.getHandleIdentifier(), newTask.getHandleIdentifier());
+
+ try {
+ operation.run(new NullProgressMonitor());
+ } catch (InvocationTargetException e) {
+ StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN,
+ "Failed to migrate activity to new task", e.getCause()));
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
close();
TasksUiInternal.getTaskList().deleteTask(oldTask);
ContextCore.getContextManager().deleteContext(oldTask.getHandleIdentifier());

Back to the top