Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-03-10 16:24:03 -0400
committerspingel2008-03-10 16:24:03 -0400
commitcc9a56dcb4c60658d8be1092f3bfea4ccda1c969 (patch)
tree35d431b86b075cceffac45c19047efe2d067cbe4
parentf5db7e10605d2b41a165da20bd38c619909cc6ec (diff)
downloadorg.eclipse.mylyn.tasks-cc9a56dcb4c60658d8be1092f3bfea4ccda1c969.tar.gz
org.eclipse.mylyn.tasks-cc9a56dcb4c60658d8be1092f3bfea4ccda1c969.tar.xz
org.eclipse.mylyn.tasks-cc9a56dcb4c60658d8be1092f3bfea4ccda1c969.zip
NEW - bug 204279: support subtask nesting of local tasks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=204279
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java58
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java85
2 files changed, 110 insertions, 33 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
index 9e2597ddf..422f659c7 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
@@ -256,7 +256,47 @@ public class TaskList {
}
}
+ if(parentContainer != null){
+ // ensure that we don't have loops
+ if(task.contains(parentContainer.getHandleIdentifier())){
+ parentContainer = null;
+ }
+ }
+
+
if (parentContainer != null) {
+ // ensure local tasks aren't duplicated in the uncategorized category when subtasks are enabled
+ if(task instanceof LocalTask && parentContainer instanceof LocalTask){
+ if (!tasks.containsKey(task.getHandleIdentifier())) {
+ tasks.put(task.getHandleIdentifier(), task);
+ }
+
+ Set<TaskContainerDelta> delta = new HashSet<TaskContainerDelta>();
+ delta.add(new TaskContainerDelta(parentContainer, TaskContainerDelta.Kind.CHANGED));
+
+ AbstractTaskCategory category = TaskCategory.getParentTaskCategory(task);
+ if(category != null) {
+ task.removeParentContainer(category);
+ category.internalRemoveChild(task);
+ delta.add(new TaskContainerDelta(category, TaskContainerDelta.Kind.CHANGED));
+ } else if(!task.getParentContainers().isEmpty()){
+
+ // local tasks should only have 1 parent
+ for(AbstractTaskContainer parent: task.getParentContainers()){
+ if(parent != null){
+ task.removeParentContainer(parent);
+ parent.internalRemoveChild(task);
+ delta.add(new TaskContainerDelta(parent, TaskContainerDelta.Kind.CHANGED));
+ }
+ }
+ }
+ if(!delta.isEmpty()){
+ for (ITaskListChangeListener listener : changeListeners) {
+ listener.containersChanged(delta);
+ }
+ }
+ }
+
if (parentContainer instanceof AbstractTask) {
// Ensure the parent task exists in the task list
tasks.put(parentContainer.getHandleIdentifier(), (AbstractTask) parentContainer);
@@ -265,7 +305,7 @@ public class TaskList {
if(parentContainer instanceof AbstractTaskCategory) {
removeFromCategory(TaskCategory.getParentTaskCategory(newTask), newTask);
- }
+ }
removeOrphan(newTask, null);
newTask.addParentContainer(parentContainer);
parentContainer.internalAddChild(newTask);
@@ -287,6 +327,12 @@ public class TaskList {
if (!tasks.containsKey(task.getHandleIdentifier())) {
tasks.put(task.getHandleIdentifier(), task);
}
+
+ // ensure that we don't have loops
+ if(task.contains(container.getHandleIdentifier())){
+ return;
+ }
+
Set<TaskContainerDelta> delta = new HashSet<TaskContainerDelta>();
delta.add(new TaskContainerDelta(container, TaskContainerDelta.Kind.CHANGED));
@@ -295,6 +341,16 @@ public class TaskList {
task.removeParentContainer(category);
category.internalRemoveChild(task);
delta.add(new TaskContainerDelta(category, TaskContainerDelta.Kind.CHANGED));
+ } else if(task instanceof LocalTask && !task.getParentContainers().isEmpty()){
+
+ // local tasks should only have 1 parent
+ for(AbstractTaskContainer parent: task.getParentContainers()){
+ if(parent != null){
+ task.removeParentContainer(parent);
+ parent.internalRemoveChild(task);
+ delta.add(new TaskContainerDelta(parent, TaskContainerDelta.Kind.CHANGED));
+ }
+ }
}
if (container != null) {
addTask(task, container);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
index 019af5ab2..55e838aee 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
@@ -28,6 +28,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerDropAdapter;
import org.eclipse.mylyn.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContext;
+import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
@@ -36,6 +37,7 @@ import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer;
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants;
import org.eclipse.mylyn.internal.tasks.ui.RetrieveTitleFromUrlJob;
import org.eclipse.mylyn.internal.tasks.ui.TaskTransfer;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPreferenceConstants;
import org.eclipse.mylyn.internal.tasks.ui.actions.QueryImportAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskActivateAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskImportAction;
@@ -168,41 +170,49 @@ public class TaskListDropAdapter extends ViewerDropAdapter {
}
}
- for (AbstractTask task : tasksToMove) {
- if (currentTarget instanceof UncategorizedTaskContainer) {
- TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task, (UncategorizedTaskContainer) currentTarget);
- } else if (currentTarget instanceof TaskCategory) {
- TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task, (TaskCategory) currentTarget);
- } else if (currentTarget instanceof UnmatchedTaskContainer) {
- if (((UnmatchedTaskContainer) currentTarget).getRepositoryUrl().equals(task.getRepositoryUrl())) {
- TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task,
- (AbstractTaskCategory) currentTarget);
+ if(currentTarget instanceof LocalTask && areAllLocalTasks(tasksToMove) && getCurrentLocation() == LOCATION_ON && TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(TasksUiPreferenceConstants.LOCAL_SUB_TASKS_ENABLED)){
+ for (AbstractTask task : tasksToMove) {
+ if(!task.contains(((LocalTask)currentTarget).getHandleIdentifier())){
+ TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task, (LocalTask) currentTarget);
}
- } else if (currentTarget instanceof AbstractTask) {
- AbstractTask targetTask = (AbstractTask) currentTarget;
- AbstractTaskCategory targetCategory = null;
- // TODO: TaskCategory only used what about AbstractTaskCategory descendants?
- AbstractTaskContainer container = TaskCategory.getParentTaskCategory(targetTask);
- if (container instanceof TaskCategory || container instanceof UncategorizedTaskContainer) {
- targetCategory = (AbstractTaskCategory) container;
- } else if (container instanceof UnmatchedTaskContainer) {
- if (((UnmatchedTaskContainer) container).getRepositoryUrl().equals(task.getRepositoryUrl())) {
+ }
+ } else {
+ for (AbstractTask task : tasksToMove) {
+ if (currentTarget instanceof UncategorizedTaskContainer) {
+ TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task, (UncategorizedTaskContainer) currentTarget);
+ } else if (currentTarget instanceof TaskCategory) {
+ TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task, (TaskCategory) currentTarget);
+ } else if (currentTarget instanceof UnmatchedTaskContainer) {
+ if (((UnmatchedTaskContainer) currentTarget).getRepositoryUrl().equals(task.getRepositoryUrl())) {
+ TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task,
+ (AbstractTaskCategory) currentTarget);
+ }
+ } else if (currentTarget instanceof AbstractTask) {
+ AbstractTask targetTask = (AbstractTask) currentTarget;
+ AbstractTaskCategory targetCategory = null;
+ // TODO: TaskCategory only used what about AbstractTaskCategory descendants?
+ AbstractTaskContainer container = TaskCategory.getParentTaskCategory(targetTask);
+ if (container instanceof TaskCategory || container instanceof UncategorizedTaskContainer) {
targetCategory = (AbstractTaskCategory) container;
+ } else if (container instanceof UnmatchedTaskContainer) {
+ if (((UnmatchedTaskContainer) container).getRepositoryUrl().equals(task.getRepositoryUrl())) {
+ targetCategory = (AbstractTaskCategory) container;
+ }
}
+ if (targetCategory != null) {
+ TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task, targetCategory);
+ }
+ } else if (currentTarget instanceof ScheduledTaskContainer) {
+ ScheduledTaskContainer container = (ScheduledTaskContainer) currentTarget;
+ Calendar newSchedule = TaskActivityUtil.getCalendar();
+ newSchedule.setTimeInMillis(container.getStart().getTimeInMillis());
+ TaskActivityUtil.snapEndOfWorkDay(newSchedule);
+ TasksUiPlugin.getTaskActivityManager().setScheduledFor(task, newSchedule.getTime(), container.isCaptureFloating());
+ } else if (currentTarget == null) {
+ TasksUiPlugin.getTaskListManager().getTaskList().moveTask(
+ newTask,
+ TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
}
- if (targetCategory != null) {
- TasksUiPlugin.getTaskListManager().getTaskList().moveTask(task, targetCategory);
- }
- } else if (currentTarget instanceof ScheduledTaskContainer) {
- ScheduledTaskContainer container = (ScheduledTaskContainer) currentTarget;
- Calendar newSchedule = TaskActivityUtil.getCalendar();
- newSchedule.setTimeInMillis(container.getStart().getTimeInMillis());
- TaskActivityUtil.snapEndOfWorkDay(newSchedule);
- TasksUiPlugin.getTaskActivityManager().setScheduledFor(task, newSchedule.getTime(), container.isCaptureFloating());
- } else if (currentTarget == null) {
- TasksUiPlugin.getTaskListManager().getTaskList().moveTask(
- newTask,
- TasksUiPlugin.getTaskListManager().getTaskList().getDefaultCategory());
}
}
@@ -217,6 +227,15 @@ public class TaskListDropAdapter extends ViewerDropAdapter {
}
+ private boolean areAllLocalTasks(List<AbstractTask> tasksToMove) {
+ for(AbstractTask task: tasksToMove){
+ if(!(task instanceof LocalTask)){
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* @return true if string is a http(s) url
*/
@@ -330,7 +349,9 @@ public class TaskListDropAdapter extends ViewerDropAdapter {
} else if (getCurrentTarget() instanceof AbstractTaskContainer
&& (getCurrentLocation() == ViewerDropAdapter.LOCATION_AFTER || getCurrentLocation() == ViewerDropAdapter.LOCATION_BEFORE)) {
return true;
- } else {
+ } else if(getCurrentTarget() instanceof LocalTask && getCurrentLocation() == ViewerDropAdapter.LOCATION_ON && TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(TasksUiPreferenceConstants.LOCAL_SUB_TASKS_ENABLED)){
+ return true;
+ }else {
return false;
}
}

Back to the top