Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-06-27 21:12:48 +0000
committermkersten2005-06-27 21:12:48 +0000
commit9fa4576e36e0ed40d7b1e9e3379eb977186a3224 (patch)
tree6fa543d2c86e7a3d0b1f529c8602a020c44e6830
parentb72040c93d6ffcb1b53cd1dc9ee6f2e488819ef5 (diff)
downloadorg.eclipse.mylyn.tasks-9fa4576e36e0ed40d7b1e9e3379eb977186a3224.tar.gz
org.eclipse.mylyn.tasks-9fa4576e36e0ed40d7b1e9e3379eb977186a3224.tar.xz
org.eclipse.mylyn.tasks-9fa4576e36e0ed40d7b1e9e3379eb977186a3224.zip
Applied Ken's patch for Bugzilla Bug 101561
Categories and Tasks should be different
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java29
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java65
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java106
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java26
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java35
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java119
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java159
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java46
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java53
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java1006
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java430
12 files changed, 1231 insertions, 854 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
index ccb6e297b..01eac4a6a 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
@@ -24,9 +24,8 @@ import org.eclipse.mylar.core.search.IActiveSearchListener;
import org.eclipse.mylar.core.tests.support.WorkspaceSetupHelper;
import org.eclipse.mylar.core.tests.support.search.SearchPluginTestHelper;
import org.eclipse.mylar.tasks.BugzillaTask;
-import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
-import org.eclipse.mylar.tasks.Task;
import org.eclipse.mylar.tasks.TaskList;
import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState;
import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
@@ -215,26 +214,26 @@ public class BugzillaSearchPluginTest extends TestCase{
TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
MylarTasksPlugin.getTaskListManager().setTaskList(t);
- ITask cat = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Testing Category");
- t.addRootTask(cat);
+ Category cat = new Category("Testing Category");
+ t.addCategory(cat);
BugzillaTask bugTask1 = new BugzillaTask(bugPrefix +94185, "<bugzilla info>");
- cat.addSubtask(bugTask1);
+ cat.addTask(bugTask1);
while(bugTask1.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask2 = new BugzillaTask(bugPrefix + 3692, "<bugzilla info>");
- bugTask1.addSubtask(bugTask2);
+ cat.addTask(bugTask2);
while(bugTask2.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask3 = new BugzillaTask(bugPrefix + 3693, "<bugzilla info>");
- cat.addSubtask(bugTask3);
+ cat.addTask(bugTask3);
while(bugTask3.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask4 = new BugzillaTask(bugPrefix + 9583, "<bugzilla info>");
- bugTask3.addSubtask(bugTask4);
+ cat.addTask(bugTask4);
while(bugTask4.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
@@ -265,7 +264,7 @@ public class BugzillaSearchPluginTest extends TestCase{
assertEquals("Results not the right size", 3, c.size());
MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
- MylarTasksPlugin.getTaskListManager().deleteTask(cat);
+ MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat);
}
//TODO need to test a bug that wraps...should fail since we can only search on a single line
@@ -277,21 +276,21 @@ public class BugzillaSearchPluginTest extends TestCase{
TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
MylarTasksPlugin.getTaskListManager().setTaskList(t);
- ITask cat = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Testing Category");
- t.addRootTask(cat);
+ Category cat = new Category("Testing Category");
+ t.addCategory(cat);
BugzillaTask bugTask1 = new BugzillaTask(bugPrefix + 94185, "<bugzilla info>");
- cat.addSubtask(bugTask1);
+ cat.addTask(bugTask1);
while(bugTask1.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask2 = new BugzillaTask(bugPrefix + 9583, "<bugzilla info>");
- bugTask1.addSubtask(bugTask2);
+ cat.addTask(bugTask2);
while(bugTask2.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask3 = new BugzillaTask(bugPrefix + 3693, "<bugzilla info>");
- cat.addSubtask(bugTask3);
+ cat.addTask(bugTask3);
while(bugTask3.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
@@ -323,7 +322,7 @@ public class BugzillaSearchPluginTest extends TestCase{
assertEquals("Results not the right size", 1, c.size());
MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
- MylarTasksPlugin.getTaskListManager().deleteTask(cat);
+ MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat);
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
index c5ce152db..492df5ec5 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
@@ -13,12 +13,16 @@
*/
package org.eclipse.mylar.tasks.tests;
+import java.util.List;
import java.io.File;
import junit.framework.TestCase;
+import org.eclipse.mylar.tasks.Category;
+import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.TaskList;
import org.eclipse.mylar.tasks.TaskListManager;
/**
@@ -31,20 +35,59 @@ public class TaskListManagerTest extends TestCase {
file.deleteOnExit();
TaskListManager manager = new TaskListManager(file);
- manager.createNewTaskList();
-// Category category = taskList.createCategory("category");
+ TaskList tlist = manager.getTaskList();
Task task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
-// category.addTask(task1);
- task1.addSubtask(new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1"));
- assertEquals(task1.getChildren().size(), 1);
+ tlist.addRootTask(task1);
+ Task sub1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub 1");
+ task1.addSubTask(sub1);
+ sub1.setParent(task1);
+ Task task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 2");
+ tlist.addRootTask(task2);
+
+ Category cat1 = new Category("Category 1");
+ tlist.addCategory(cat1);
+ Task task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 3");
+ cat1.addTask(task3);
+ Task sub2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub 2");
+ task3.addSubTask(sub2);
+ sub2.setParent(task3);
+ Task task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 4");
+ cat1.addTask(task4);
+
+ Category cat2 = new Category("Category 2");
+ tlist.addCategory(cat2);
+ Task task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 5");
+ cat2.addTask(task5);
+ Task task6 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 6");
+ cat2.addTask(task6);
+
+ assertEquals(manager.getTaskList().getRoots().size(), 4);
manager.saveTaskList();
assertNotNull(manager.getTaskList());
- manager.setTaskList(null);
-// manager.readTaskList();
-// assertNotNull(manager.getTaskList());
-// assertEquals(manager.getTaskList().getCategories().size(), 1);
-// assertEquals(manager.getTaskList().findCategory("category").getTasks().size(), 1);
-// assertEquals(manager.getTaskList().findCategory("category").getTasks().get(0).getLabel(), "task 1");
+ TaskList list = new TaskList();
+ manager.setTaskList(list);
+ manager.readTaskList();
+ assertNotNull(manager.getTaskList());
+ assertEquals(manager.getTaskList().getRootTasks().size(), 2);
+ assertEquals(manager.getTaskList().getCategories().size(), 2);
+ check(manager);
+ }
+
+ public boolean check(TaskListManager manager) {
+ List<ITask> list = manager.getTaskList().getRootTasks();
+ assertTrue(list.get(0).getLabel().equals("task 1"));
+ assertTrue(list.get(0).getChildren().get(0).getLabel().equals("sub 1"));
+ assertTrue(list.get(1).getLabel().equals("task 2"));
+
+ List<Category> clist = manager.getTaskList().getCategories();
+ list = clist.get(0).getTasks();
+ assertTrue(list.get(0).getLabel().equals("task 3"));
+ assertTrue(list.get(0).getChildren().get(0).getLabel().equals("sub 2"));
+ assertTrue(list.get(1).getLabel().equals("task 4"));
+ list = clist.get(1).getTasks();
+ assertTrue(list.get(0).getLabel().equals("task 5"));
+ assertTrue(list.get(1).getLabel().equals("task 6"));
+ return true;
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
index 1bdcd3ed3..254914ffa 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
@@ -19,6 +19,7 @@ import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
@@ -36,19 +37,21 @@ import org.eclipse.ui.PartInitException;
*/
public class TaskListUiTest extends TestCase {
private TaskList tlist = null;
- private Task cat1 = null;
+ private Category cat1 = null;
private Task cat1task1 = null;
private Task cat1task2 = null;
private Task cat1task3 = null;
private Task cat1task4 = null;
private Task cat1task5 = null;
+ private Task cat1task1sub1 = null;
- private Task cat2 = null;
+ private Category cat2 = null;
private Task cat2task1 = null;
private Task cat2task2 = null;
private Task cat2task3 = null;
private Task cat2task4 = null;
private Task cat2task5 = null;
+ private Task cat2task1sub1 = null;
private final static int CHECK_COMPLETE_FILTER = 1;
@@ -60,61 +63,80 @@ public class TaskListUiTest extends TestCase {
File file = new File("foo" + MylarTasksPlugin.FILE_EXTENSION);
TaskListManager manager = new TaskListManager(file);
tlist = manager.createNewTaskList();
- cat1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "First Category");
- cat1.setIsCategory(true);
+ cat1 = new Category("First Category");
- cat1task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat1task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
cat1task1.setPriority("P1");
cat1task1.setCompleted(true);
- cat1.addSubtask(cat1task1);
+ cat1task1.setCategory(cat1);
+ cat1.addTask(cat1task1);
- cat1task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 2");
+ cat1task1sub1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat1task1sub1.setPriority("P1");
+ cat1task1sub1.setCompleted(true);
+ cat1task1sub1.setParent(cat1task1);
+ cat1task1.addSubTask(cat1task1sub1);
+
+ cat1task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 2");
cat1task2.setPriority("P2");
- cat1.addSubtask(cat1task2);
+ cat1task2.setCategory(cat1);
+ cat1.addTask(cat1task2);
- cat1task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 3");
+ cat1task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 3");
cat1task3.setPriority("P3");
cat1task3.setCompleted(true);
- cat1.addSubtask(cat1task3);
+ cat1task3.setCategory(cat1);
+ cat1.addTask(cat1task3);
- cat1task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 4");
+ cat1task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 4");
cat1task4.setPriority("P4");
- cat1.addSubtask(cat1task4);
+ cat1task4.setCategory(cat1);
+ cat1.addTask(cat1task4);
- cat1task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 5");
+ cat1task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 5");
cat1task5.setPriority("P5");
cat1task5.setCompleted(true);
- cat1.addSubtask(cat1task5);
+ cat1task5.setCategory(cat1);
+ cat1.addTask(cat1task5);
- tlist.addRootTask(cat1);
- assertEquals(cat1.getChildren().size(), 5);
+ tlist.addCategory(cat1);
+ assertEquals(cat1.getTasks().size(), 5);
- cat2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Second Category");
- cat2.setIsCategory(true);
+ cat2 = new Category("Second Category");
- cat2task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat2task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
cat2task1.setPriority("P1");
- cat2.addSubtask(cat2task1);
+ cat2task1.setCategory(cat2);
+ cat2.addTask(cat2task1);
+
+ cat2task1sub1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat2task1sub1.setPriority("P1");
+ cat2task1sub1.setParent(cat2task1);
+ cat2task1.addSubTask(cat2task1sub1);
- cat2task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 2");
+ cat2task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 2");
cat2task2.setPriority("P2");
cat2task2.setCompleted(true);
- cat2.addSubtask(cat2task2);
+ cat2task2.setCategory(cat2);
+ cat2.addTask(cat2task2);
- cat2task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 3");
+ cat2task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 3");
cat2task3.setPriority("P3");
- cat2.addSubtask(cat2task3);
+ cat2task3.setCategory(cat2);
+ cat2.addTask(cat2task3);
- cat2task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 4");
+ cat2task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 4");
cat2task4.setPriority("P4");
cat2task4.setCompleted(true);
- cat2.addSubtask(cat2task4);
+ cat2task4.setCategory(cat2);
+ cat2.addTask(cat2task4);
- cat2task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 5");
+ cat2task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 5");
cat2task5.setPriority("P5");
- cat2.addSubtask(cat2task5);
+ cat2task5.setCategory(cat2);
+ cat2.addTask(cat2task5);
- tlist.addRootTask(cat2);
+ tlist.addCategory(cat2);
manager.saveTaskList();
}
@@ -169,10 +191,7 @@ public class TaskListUiTest extends TestCase {
assertTrue(items.length == 2);
int count = 0;
for (int i = 0; i < items.length; i++) {
- assertTrue(items[i].getData() instanceof ITask);
- ITask cat = (ITask) items[i].getData();
- assertTrue(cat.isCategory());
-
+ assertTrue(items[i].getData() instanceof Category);
TreeItem[] sub = items[i].getItems();
for (int j = 0; j < sub.length; j++) {
assertTrue(sub[j].getData() instanceof ITask);
@@ -194,10 +213,7 @@ public class TaskListUiTest extends TestCase {
int p2Count = 0;
int p5Count = 0;
for (int i = 0; i < items.length; i++) {
- assertTrue(items[i].getData() instanceof ITask);
- ITask cat = (ITask) items[i].getData();
- assertTrue(cat.isCategory());
-
+ assertTrue(items[i].getData() instanceof Category);
TreeItem[] sub = items[i].getItems();
for (int j = 0; j < sub.length; j++) {
assertTrue(sub[j].getData() instanceof ITask);
@@ -222,24 +238,24 @@ public class TaskListUiTest extends TestCase {
// don't care if we are disposed
}
public Object[] getElements(Object parent) {
- return tlist.getRootTasks().toArray();
+ return tlist.getRoots().toArray();
}
public Object getParent(Object child) {
- if (child instanceof Task) {
- return ((Task)child).getParent();
+ if (child instanceof Category) {
+ return ((Task)child).getCategory();
}
return null;
}
public Object [] getChildren(Object parent) {
- if (parent instanceof ITask) {
- return ((ITask)parent).getChildren().toArray();
+ if (parent instanceof Category) {
+ return ((Category)parent).getTasks().toArray();
}
return new Object[0];
}
public boolean hasChildren(Object parent) {
- if (parent instanceof ITask) {
- ITask task = (ITask)parent;
- return task.getChildren() != null && task.getChildren().size() > 0;
+ if (parent instanceof Category) {
+ Category cat = (Category)parent;
+ return cat.getTasks() != null && cat.getTasks().size() > 0;
}
return false;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java
index 2d1db62f9..329b6f367 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java
@@ -14,6 +14,8 @@
package org.eclipse.mylar.tasks;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
/**
@@ -23,24 +25,24 @@ public class Category implements Serializable {
private static final long serialVersionUID = 3834024740813027380L;
-// private List<ITask> tasks = new ArrayList<ITask>();
+ private List<ITask> tasks = new ArrayList<ITask>();
private String name = "";
public Category(String name) {
this.name = name;
}
-// public void addTask(ITask task) {
-// tasks.add(task);
-// }
-//
-// public void removeTask(Task task) {
-// tasks.remove(task);
-// }
-//
-// public List<ITask> getTasks() {
-// return tasks;
-// }
+ public void addTask(ITask task) {
+ tasks.add(task);
+ }
+
+ public void removeTask(ITask task) {
+ tasks.remove(task);
+ }
+
+ public List<ITask> getTasks() {
+ return tasks;
+ }
@Override
public String toString() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
index d4dfc9034..cb8f5ed0e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
@@ -30,8 +30,6 @@ public interface ITask extends Serializable {
public abstract void setPath(String path);
- public abstract List<ITask> getChildren();
-
public abstract String getHandle();
public abstract void setHandle(String id);
@@ -39,14 +37,10 @@ public interface ITask extends Serializable {
public abstract String getLabel();
public abstract void setLabel(String label);
-
+
public abstract ITask getParent();
-
- public abstract void setParent(ITask parent);
-
- public abstract void removeSubtask(ITask task);
- public abstract void addSubtask(ITask task);
+ public abstract void setParent(ITask parent);
public abstract boolean isActive();
@@ -76,29 +70,28 @@ public interface ITask extends Serializable {
public abstract void setEstimatedTime(String estimated);
- public abstract List<ITask> getSubTasksInProgress();
-
- public abstract List<ITask> getCompletedSubTasks();
-
- public abstract boolean hasCompletedSubTasks(boolean completed);
-
- public abstract int findLargestTaskHandle();
-
- public abstract boolean hasSubTaskWithPriority(String priority);
+ public abstract List<ITask> getChildren();
+
+ public abstract void addSubTask(ITask t);
+
+ public abstract void removeSubTask(ITask t);
+
/**
* Opens this task in an editor
*/
public abstract void openTaskInEditor();
public abstract String getToolTipText();
-
- public abstract List<Category> getCategories();
public abstract String getPriority();
public abstract void setPriority(String priority);
-
+ @Deprecated
public abstract boolean isCategory();
-
+ @Deprecated
public abstract void setIsCategory(boolean b);
+
+ public abstract void setCategory(Category cat);
+
+ public abstract Category getCategory();
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
index ae5f8b771..74f8ab867 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
@@ -47,8 +47,8 @@ public class Task implements ITask {
private String estimatedTime = "";
private String elapsedTime = "";
private boolean completed;
- private transient List<Category> categories = new ArrayList<Category>();
private RelatedLinks links = new RelatedLinks();
+ private Category parentCategory = null;
/**
* null if root
@@ -67,16 +67,6 @@ public class Task implements ITask {
return path;
}
-// public String getRelativePath() {
-// //returns relative path from Mylar Directory
-//
-// if (path.startsWith("..")) {
-// return "../" + path;
-// } else {
-// return path.substring(path.indexOf('/')+1, path.length());
-// }
-// }
-
public void setPath(String path) {
if (path.startsWith(".mylar")) {
this.path = path.substring(path.lastIndexOf('/')+1, path.length());
@@ -90,10 +80,6 @@ public class Task implements ITask {
this.label = label;
this.path = handle;
}
-
- public List<ITask> getChildren() {
- return children;
- }
public String getHandle() {
return handle;
@@ -107,25 +93,17 @@ public class Task implements ITask {
public void setLabel(String label) {
this.label = label;
}
+
public ITask getParent() {
return parent;
}
+
public void setParent(ITask parent) {
this.parent = parent;
}
public Object getAdapter(Class adapter) {
return null;
- }
-
- public void removeSubtask(ITask task) {
- children.remove(task);
- task.setParent(null); // HACK
- }
-
- public void addSubtask(ITask task) {
- children.add(task);
- task.setParent(this);
- }
+ }
/**
* Package visible in order to prevent sets that don't update the index.
@@ -189,9 +167,6 @@ public class Task implements ITask {
// No tool-tip used for a general task as of yet.
return null;
}
- public List<Category> getCategories() {
- return categories;
- }
@Override
public boolean equals(Object obj) {
@@ -283,85 +258,25 @@ public class Task implements ITask {
public void setEstimatedTime(String estimated) {
this.estimatedTime = estimated;
- }
-
- public List<ITask> getSubTasksInProgress() {
- List<ITask> inprogress = new ArrayList<ITask>();
- for (ITask task : children) {
- if (!task.isCompleted()) {
- inprogress.add(task);
- }
- }
- return inprogress;
- }
-
- public List<ITask> getCompletedSubTasks() {
- List<ITask> complete = new ArrayList<ITask>();
- for (ITask task : children) {
- if (task.isCompleted()) {
- complete.add(task);
- }
- }
- return complete;
- }
+ }
- public boolean hasCompletedSubTasks(boolean completed) {
- return findCompletedSubtask(getChildren(), completed);
- }
-
- private boolean findCompletedSubtask(List<ITask> subtasks, boolean completed) {
- for(ITask t : subtasks) {
- if (t.isCompleted() == completed) {
- return true;
- }
- findCompletedSubtask(t.getChildren(), completed);
- }
- return false;
+ public List<ITask> getChildren() {
+ return children;
}
- public int findLargestTaskHandle() {
- int ihandle = 0;
- if (this instanceof BugzillaTask) {
- ihandle = 0;
- } else {
- ihandle = Integer.parseInt(this.handle.substring(handle.indexOf('-')+1, handle.length()));
- }
- int maxSub = findLargestSubTaskHandle(getChildren());
- return maxSub > ihandle ? maxSub : ihandle;
+ public void addSubTask(ITask t) {
+ children.add(t);
}
- private int findLargestSubTaskHandle(List<ITask> tasks) {
- int ihandle = 0;
- int maxHandle = 0;
- for (ITask t : tasks) {
- if (t instanceof BugzillaTask) {
- ihandle = 0;
- } else {
- ihandle = Integer.parseInt(t.getHandle().substring(t.getHandle().indexOf('-')+1, t.getHandle().length()));
- }
-
- if (ihandle > maxHandle) {
- maxHandle = ihandle;
- }
- int maxSub = findLargestSubTaskHandle(t.getChildren());
- if (maxSub > maxHandle) {
- maxHandle = maxSub;
- }
- }
- return maxHandle;
- }
-
- public boolean hasSubTaskWithPriority(String priority) {
- return findSubTaskWithPriority(getChildren(), priority);
+ public void removeSubTask(ITask t) {
+ children.remove(t);
}
- private boolean findSubTaskWithPriority(List<ITask> subtasks, String priority) {
- for(ITask t : subtasks) {
- if (t.getPriority().equals(priority)) {
- return true;
- }
- findSubTaskWithPriority(t.getChildren(), priority);
- }
- return false;
+ public void setCategory(Category cat) {
+ this.parentCategory = cat;
}
+
+ public Category getCategory() {
+ return parentCategory;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
index 55bd2fa2a..acaaa6708 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
@@ -15,11 +15,7 @@ package org.eclipse.mylar.tasks;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-
-import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState;
/**
@@ -30,12 +26,17 @@ public class TaskList implements Serializable {
private static final long serialVersionUID = 3618984485791021105L;
private List<ITask> rootTasks = new ArrayList<ITask>();
+ private List<Category> categories = new ArrayList<Category>();
private transient List<ITask> activeTasks = new ArrayList<ITask>();
public void addRootTask(ITask task) {
rootTasks.add(task);
}
+ public void addCategory(Category cat) {
+ categories.add(cat);
+ }
+
public void setActive(ITask task, boolean active) {
task.setActive(active);
if (active) {
@@ -45,20 +46,59 @@ public class TaskList implements Serializable {
}
}
+ public void deleteTask(ITask task) {
+ boolean deleted = deleteTaskHelper(rootTasks, task);
+ if (!deleted) {
+ for (Category cat : categories) {
+ deleted = deleteTaskHelper(cat.getTasks(), task);
+ if (deleted) {
+ return;
+ }
+ }
+ }
+
+ }
+
+ private boolean deleteTaskHelper(List<ITask> tasks, ITask t) {
+ for (ITask task : tasks) {
+ if (task.getHandle().equals(t.getHandle())) {
+ tasks.remove(task);
+ return true;
+ } else {
+ if (deleteTaskHelper(task.getChildren(), t))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void deleteCategory(Category category) {
+ if (category != null) {
+ category.getTasks().clear();
+ }
+ categories.remove(category);
+ }
/**
* TODO: make data structure handle this traversal
*/
public ITask getTaskForId(String id) {
- return setActiveHelper(rootTasks, id);
+ ITask t = null;
+ for (Category cat : categories) {
+ if ( (t = findTaskHelper(cat.getTasks(), id)) != null) {
+ return t;
+ }
+ }
+ return findTaskHelper(rootTasks, id);
}
- private ITask setActiveHelper(List<ITask> tasks, String id) {
+ private ITask findTaskHelper(List<ITask> tasks, String id) {
for (ITask task : tasks) {
if (task.getHandle() == id) {
return task;
- } else {
- ITask child = setActiveHelper(task.getChildren(), id);
- if (child != null) return child;
+ }
+ ITask t = findTaskHelper(task.getChildren(), id);
+ if (t != null) {
+ return t;
}
}
return null;
@@ -67,84 +107,53 @@ public class TaskList implements Serializable {
public List<ITask> getActiveTasks() {
return activeTasks;
}
-
- public List<ITask> getTaskFor(Category category) {
- List<ITask> categoryTasks = new ArrayList<ITask>();
- for (ITask task : rootTasks) {
- if (task.getCategories().contains(category)) categoryTasks.add(task);
- }
- return categoryTasks;
- }
public List<ITask> getRootTasks() {
return rootTasks;
}
- public Set<Category> getCategories() {
- Set<Category> categories = new HashSet<Category>();
- for (ITask task : rootTasks) {
- categories.addAll(task.getCategories());
- }
- return categories;
- }
-
- public void refreshRestoredTasks() {
- activeTasks = new ArrayList<ITask>();
- activateRestoredTasks(rootTasks);
- restoreParents(rootTasks, null);
- refreshBugReports(rootTasks);
- }
- private void activateRestoredTasks(List<ITask> tasks) {
- for (ITask task : tasks) {
- if (task.isActive()) {
- setActive(task, true);
- }
- activateRestoredTasks(task.getChildren());
- }
- }
- private void restoreParents(List<ITask> tasks, ITask parent) {
- for (ITask task : tasks) {
- task.setParent(parent);
- restoreParents(task.getChildren(), task);
- }
+ public List<Category> getCategories() {
+ return categories;
}
- private void refreshBugReports(List<ITask> tasks) {
- for (ITask task : tasks) {
- if (task instanceof BugzillaTask) {
- ((BugzillaTask)task).readBugReport();
- ((BugzillaTask)task).setState(BugTaskState.FREE);
- }
- refreshBugReports(task.getChildren());
+
+ public int findLargestTaskHandle() {
+ int max = 0;
+ max = Math.max(largestTaskHandleHelper(rootTasks), max);
+ for (Category cat : categories) {
+ max = Math.max(largestTaskHandleHelper(cat.getTasks()), max);
}
+ return max;
}
- public List<ITask> getTasksInProgress() {
- List<ITask> inprogress = new ArrayList<ITask>();
- for (ITask task : rootTasks) {
- if (!task.isCompleted()) {
- inprogress.add(task);
- }
- }
- return inprogress;
- }
- public List<ITask> getCompletedTasks() {
- List <ITask> complete = new ArrayList<ITask>();
- for (ITask task : rootTasks) {
- if (task.isCompleted()) {
- complete.add(task);
- } else if (task.hasCompletedSubTasks(false)) {
- complete.add(task);
+
+ private int largestTaskHandleHelper(List<ITask> tasks) {
+ int ihandle = 0;
+ int max = 0;
+ for (ITask t : tasks) {
+ if (t instanceof BugzillaTask) {
+ ihandle = 0;
+ } else {
+ ihandle = Integer.parseInt(t.getHandle().substring(t.getHandle().indexOf('-')+1, t.getHandle().length()));
}
+ max = Math.max(ihandle, max);
+ ihandle = largestTaskHandleHelper(t.getChildren());
+ max = Math.max(ihandle, max);
}
- return complete;
+ return max;
}
- public int findLargestTaskHandle() {
- int max = 0;
+
+ public List<Object> getRoots() {
+ List<Object> roots = new ArrayList<Object>();
for (ITask t : rootTasks) {
- int maxSub = t.findLargestTaskHandle();
- if (maxSub > max) {
- max = maxSub;
- }
+ roots.add(t);
}
- return max;
+ for (Category cat : categories) {
+ roots.add(cat);
+ }
+ return roots;
+ }
+
+ public void createCategory(String description) {
+ Category c = new Category(description);
+ categories.add(c);
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java
index 085be1a0e..02cb72bab 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java
@@ -85,12 +85,12 @@ public class TaskListManager {
}
public void deleteTask(ITask task) {
- taskList.setActive(task, false);
- if (taskList.getRootTasks().contains(task)) {
- taskList.getRootTasks().remove(task);
- } else {
- task.getParent().getChildren().remove(task);
- }
+ taskList.setActive(task, false);
+ taskList.deleteTask(task);
+ }
+
+ public void deleteCategory(Category cat) {
+ taskList.deleteCategory(cat);
}
public void addListener(ITaskActivityListener listener) {
@@ -102,28 +102,14 @@ public class TaskListManager {
}
public void activateTask(ITask task) {
- if (task.isCategory()) {
- for (ITask childTask : task.getChildren()) {
- taskList.setActive(childTask, true);
- for (ITaskActivityListener listener : listeners) listener.taskActivated(childTask);
- }
- } else {
- taskList.setActive(task, true);
- for (ITaskActivityListener listener : listeners) listener.taskActivated(task);
- }
- }
+ taskList.setActive(task, true);
+ for (ITaskActivityListener listener : listeners) listener.taskActivated(task);
+ }
- public void deactivateTask(ITask task) {
- if (task.isCategory()) {
- for (ITask childTask : task.getChildren()) {
- taskList.setActive(childTask, false);
- for (ITaskActivityListener listener : listeners) listener.taskDeactivated(childTask);
- }
- } else {
- taskList.setActive(task, false);
- for (ITaskActivityListener listener : listeners) listener.taskDeactivated(task);
- }
- }
+ public void deactivateTask(ITask task) {
+ taskList.setActive(task, false);
+ for (ITaskActivityListener listener : listeners) listener.taskDeactivated(task);
+ }
public void taskPropertyChanged(ITask task, String property) {
for (ITaskActivityListener listener : listeners) listener.taskPropertyChanged(task, property);
@@ -131,7 +117,11 @@ public class TaskListManager {
public void updateTaskscapeReference(String prevDir) {
List<ITask> rootTasks = this.getTaskList().getRootTasks();
+ for (Category cat : taskList.getCategories()) {
+ updateTaskscapeReferenceHelper(cat.getTasks(), prevDir);
+ }
updateTaskscapeReferenceHelper(rootTasks, prevDir);
+
}
public void updateTaskscapeReferenceHelper(List<ITask> list, String prevDir) {
for (ITask task : list) {
@@ -157,7 +147,7 @@ public class TaskListManager {
taskPropertyChanged(task, "Path");
}
}
- updateTaskscapeReferenceHelper(task.getChildren(), prevDir);
+// updateTaskscapeReferenceHelper(task.getChildren(), prevDir);
}
}
public void setFile(File f) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java
index 04f632e81..54afee971 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java
@@ -36,6 +36,7 @@ import org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.BugzillaTask;
import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
import org.eclipse.mylar.tasks.bugzilla.StackTrace;
@@ -181,7 +182,9 @@ public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation
// get all of the root tasks and start the search
List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
searchLocal(tasks, collector, elementName, monitor);
-
+ for (Category cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
+ searchLocal(cat.getTasks(), collector, elementName, monitor);
+ }
// return the collector
return collector;
}
@@ -222,12 +225,6 @@ public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation
}
}
}
-
- // get the children and perform the search on them as well
- List<ITask> children = task.getChildren();
- if(children != null){
- searchLocal(children, searchCollector, elementName, monitor);
- }
}
status = Status.OK_STATUS;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java
index 308c35755..1f990775b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java
@@ -18,6 +18,7 @@ import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.mylar.tasks.BugzillaTask;
+import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.ui.MylarImages;
import org.eclipse.mylar.ui.MylarUiPlugin;
@@ -38,33 +39,44 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
if (obj instanceof ITask) {
ITask task = (ITask) obj;
switch (columnIndex) {
- case 0: return " "; // padding for background
+ case 0: return ""; // padding for background
case 1: return "";
- case 2:
- if (task.isCategory()) {
- return "";
- } else {
- return task.getPriority();
- }
+ case 2: return task.getPriority();
case 3:
return task.getLabel();
case 4:
return task.getHandle();
}
+ } else if (obj instanceof Category) {
+ Category cat = (Category) obj;
+ switch (columnIndex) {
+ case 0: return ""; // padding for background
+ case 1: return "";
+ case 2: return "";
+ case 3:
+ return cat.getName();
+ case 4:
+ return "";
+ }
}
return null;
}
public Font getFont(Object element) {
if (element instanceof ITask) {
- ITask task = (ITask)element;
- if (task.isCategory()) {
- for (ITask child : task.getChildren()) {
- if (child.isActive()) return UiUtil.BOLD;
- }
- }
- if (task.isActive()) return UiUtil.BOLD;
+ ITask task = (ITask)element;
+ if (task.isActive()) return UiUtil.BOLD;
if (task.isCompleted()) return UiUtil.ITALIC;
+ for (ITask child : task.getChildren()) {
+ if (child.isActive())
+ return UiUtil.BOLD;
+ }
+ } else if (element instanceof Category) {
+ Category cat = (Category) element;
+ for (ITask child : cat.getTasks()) {
+ if (child.isActive())
+ return UiUtil.BOLD;
+ }
}
return null;
}
@@ -75,19 +87,13 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
return null;
}
if (columnIndex == 0) {
- if (((ITask) element).isCategory()) {
- return null;
- }
if (((ITask) element).isActive()) {
return MylarImages.getImage(MylarImages.TASK_ACTIVE);
} else {
return MylarImages.getImage(MylarImages.TASK_INACTIVE);
}
} else if (columnIndex == 1) {
- if (((ITask) element).isCategory()) {
- return null;
- // return MylarImages.getImage(MylarImages.CATEGORY);
- } else if (element instanceof BugzillaTask) {
+ if (element instanceof BugzillaTask) {
return MylarImages.getImage(MylarImages.TASK_BUGZILLA);
} else {
return MylarImages.getImage(MylarImages.TASK);
@@ -100,11 +106,10 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
public Color getBackground(Object element) {
if (element instanceof ITask) {
ITask task = (ITask)element;
- if (task.isCategory()) {
- return backgroundColor;
- }
Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle());
if (highlighter != null) return highlighter.getHighlightColor();
+ } else if (element instanceof Category) {
+ return backgroundColor;
}
return null;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
index 828329fbc..4d2ed08f9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
@@ -111,23 +111,24 @@ public class TaskListView extends ViewPart {
private TreeViewer viewer;
private DrillDownAdapter drillDownAdapter;
- private Action refresh;
- private Action createTask;
- private Action createCategory;
- private Action addBugzillaReport;
- private Action rename;
- private Action delete;
- private Action doubleClickAction;
- private Action clearSelectedTaskscapeAction;
+ private RefreshAction refresh;
+ private CreateTaskAction createTask;
+ private CreateCategoryAction createCategory;
+ private CreateBugzillaTaskAction createBugzillaTask;
+ private RenameAction rename;
+ private DeleteAction delete;
+ private OpenTaskEditorAction doubleClickAction;
+ private ClearTaskscapeAction clearSelectedTaskscapeAction;
//private Action toggleIntersectionModeAction = new ToggleIntersectionModeAction();
// private Action toggleFilteringAction = new ToggleGlobalInterestFilteringAction();
- private Action completeTask;
- private Action incompleteTask;
- private Action filterCompleteTask;
- private Action filterInCompleteTask;
+ private MarkTaskCompleteAction completeTask;
+ private MarkTaskIncompleteAction incompleteTask;
+ private FilterCompletedTasksAction filterCompleteTask;
+ private FilterIncompleteTasksAction filterInCompleteTask;
private PriorityDropDownAction filterOnPriority;
+ private Action moveTaskToRoot;
private PriorityFilter priorityFilter = new PriorityFilter();
protected String[] columnNames = new String[] { "", ".", "!", "Description", "handle" };
@@ -140,13 +141,322 @@ public class TaskListView extends ViewPart {
private String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" };
- private final class CreateTaskAction extends Action {
- private boolean isCategory = false;
-
- public CreateTaskAction(boolean isCategory) {
- this.isCategory = isCategory;
- }
-
+ private final class MoveTaskToRootAction extends Action {
+ public MoveTaskToRootAction() {
+ setText("Move Task to Root");
+ setToolTipText("Move Task to Root");
+ }
+ @Override
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (obj instanceof ITask) {
+ ITask t = (ITask) obj;
+ Category cat = t.getCategory();
+ if (cat != null) {
+ cat.removeTask(t);
+ t.setCategory(null);
+ t.setParent(null);
+ MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t);
+ viewer.refresh();
+ } else if (t.getParent() != null) {
+ t.getParent().removeSubTask(t);
+ t.setParent(null);
+ MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t);
+ viewer.refresh();
+ }
+ }
+ }
+ }
+
+ private final class FilterIncompleteTasksAction extends Action {
+ public FilterIncompleteTasksAction() {
+ setText("Filter Incomplete tasks");
+ setToolTipText("Filter Incomplete tasks");
+ setImageDescriptor(MylarImages.TASK_INACTIVE);
+ setChecked(MylarUiPlugin.getDefault().isFilterInCompleteMode());
+ }
+
+ @Override
+ public void run() {
+ MylarUiPlugin.getDefault().setFilterInCompleteMode(isChecked());
+ if (isChecked()) {
+ viewer.addFilter(inCompleteFilter);
+ filterCompleteTask.setChecked(false);
+ viewer.removeFilter(completeFilter);
+ } else {
+ viewer.removeFilter(inCompleteFilter);
+ }
+ viewer.refresh();
+ }
+ }
+
+ private final class FilterCompletedTasksAction extends Action {
+ public FilterCompletedTasksAction() {
+ setText("Filter Complete tasks");
+ setToolTipText("Filter Completed tasks");
+ setImageDescriptor(MylarImages.TASK_ACTIVE);
+ setChecked(MylarUiPlugin.getDefault().isFilterCompleteMode());
+ }
+ @Override
+ public void run() {
+ MylarUiPlugin.getDefault().setFilterCompleteMode(isChecked());
+ if (isChecked()) {
+ viewer.addFilter(completeFilter);
+ filterInCompleteTask.setChecked(false);
+ viewer.removeFilter(inCompleteFilter);
+ } else {
+ viewer.removeFilter(completeFilter);
+ }
+ viewer.refresh();
+ }
+ }
+
+ private final class OpenTaskEditorAction extends Action {
+ @Override
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (obj instanceof ITask) {
+ ((ITask)obj).openTaskInEditor();
+ }
+ viewer.refresh(obj);
+ }
+ }
+
+ private final class ClearTaskscapeAction extends Action {
+ public ClearTaskscapeAction() {
+ setText("Erase Taskscape");
+ setToolTipText("Erase Taskscape");
+ setImageDescriptor(MylarImages.ERASE_TASKSCAPE);
+ }
+ @Override
+ public void run() {
+ Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ if (selectedObject != null) {
+ MylarPlugin.getTaskscapeManager().taskDeleted(((Task)selectedObject).getHandle(), ((Task)selectedObject).getPath());
+ viewer.refresh();
+ }
+ }
+ }
+
+ private final class RenameAction extends Action {
+ public RenameAction() {
+ setText("Rename");
+ setToolTipText("Rename");
+ }
+ @Override
+ public void run() {
+ String label = "category";
+ Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ if (selectedObject instanceof Task) label = "task";
+
+ String newName = getLabelNameFromUser(label);
+ if (selectedObject instanceof Task) {
+ ((Task)selectedObject).setLabel(newName);
+ } else if (selectedObject instanceof Category) {
+ ((Category)selectedObject).setName(newName);
+ }
+ viewer.refresh(selectedObject);
+ }
+ }
+
+ private final class MarkTaskIncompleteAction extends Action {
+ public MarkTaskIncompleteAction() {
+ setText("Mark Incomplete");
+ setToolTipText("Mark Incomplete");
+ }
+ @Override
+ public void run() {
+ Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ if (selectedObject instanceof Task){
+ ((Task)selectedObject).setCompleted(false);
+ }
+ viewer.refresh();
+ }
+ }
+
+ private final class MarkTaskCompleteAction extends Action {
+ public MarkTaskCompleteAction() {
+ setText("Mark Complete");
+ setToolTipText("Mark Complete");
+ }
+ @Override
+ public void run() {
+ Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ if (selectedObject instanceof Task){
+ ((Task)selectedObject).setCompleted(true);
+ viewer.refresh(selectedObject);
+ }
+ }
+ }
+
+ private final class DeleteAction extends Action {
+ public DeleteAction() {
+ setText("Delete");
+ setToolTipText("Delete");
+ setImageDescriptor(MylarImages.REMOVE);
+ }
+ @Override
+ public void run() {
+ boolean deleteConfirmed = MessageDialog.openQuestion(
+ Workbench.getInstance().getActiveWorkbenchWindow().getShell(),
+ "Confirm delete",
+ "Delete selected item?");
+ if (!deleteConfirmed) {
+ return;
+ } else {
+ Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ if (selectedObject instanceof Task) {
+ MylarTasksPlugin.getTaskListManager().deleteTask((Task)selectedObject);
+ MylarPlugin.getTaskscapeManager().taskDeleted(((Task)selectedObject).getHandle(), ((Task)selectedObject).getPath());
+ IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ // if we couldn't get the page, get out of here
+ if (page == null)
+ return;
+ try{
+ closeTaskEditors((ITask)selectedObject, page);
+ }catch(Exception e){
+ MylarPlugin.log(e, " deletion failed");
+ }
+ } else if (selectedObject instanceof Category) {
+ Category cat = (Category) selectedObject;
+ for (ITask task : cat.getTasks()) {
+ MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath());
+ IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (page == null)
+ return;
+ try{
+ closeTaskEditors(task, page);
+ }catch(Exception e){
+ MylarPlugin.log(e, " deletion failed");
+ }
+ }
+ MylarTasksPlugin.getTaskListManager().deleteCategory((Category)selectedObject);
+ }
+ }
+ viewer.refresh();
+ }
+ }
+
+ private final class CreateBugzillaTaskAction extends Action {
+ public CreateBugzillaTaskAction() {
+ setText("Add bugzilla report");
+ setToolTipText("Add bugzilla report");
+ setImageDescriptor(MylarImages.TASK_BUGZILLA_NEW);
+ }
+ @Override
+ public void run() {
+ String bugIdString = getBugIdFromUser();
+ int bugId = -1;
+ try {
+ if (bugIdString != null) {
+ bugId = Integer.parseInt(bugIdString);
+ } else {
+ return;
+ }
+ } catch (NumberFormatException nfe) {
+ showMessage("Please enter a valid report number");
+ return;
+ }
+
+ // Check the existing tasks to see if the id is used already.
+ // This is to prevent the creation of mutliple Bugzilla tasks
+ // for the same Bugzilla report.
+ boolean doesIdExistAlready = false;
+ doesIdExistAlready = lookForId("Bugzilla-" + bugId);
+ if (doesIdExistAlready) {
+ showMessage("A Bugzilla task with ID Bugzilla-" + bugId + " already exists.");
+ return;
+ }
+
+ ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>");
+ Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ if (selectedObject instanceof Category){
+ ((Category)selectedObject).addTask(newTask);
+ } else {
+ MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask);
+ }
+ viewer.refresh();
+ }
+ }
+
+ private final class RefreshAction extends Action {
+ public RefreshAction() {
+ setText("Refresh all Bugzilla reports");
+ setToolTipText("Refresh all Bugzilla reports");
+ setImageDescriptor(MylarImages.REFRESH);
+ }
+
+ @Override
+ public void run() {
+ // TODO background?
+ // perform the update in an operation so that we get a progress monitor
+ // update the structure bridge cache with the reference provider cached bugs
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor) throws CoreException {
+
+ List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
+
+ for (ITask task : tasks) {
+ if (task instanceof BugzillaTask) {
+ ((BugzillaTask)task).refresh();
+ }
+ }
+ for (Category cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
+ for (ITask task : cat.getTasks()) {
+ if (task instanceof BugzillaTask) {
+ ((BugzillaTask)task).refresh();
+ }
+ }
+ refreshChildren(cat.getTasks());
+ }
+
+ // clear the caches
+ Set<String> cachedHandles = new HashSet<String>();
+ cachedHandles.addAll(MylarTasksPlugin.getDefault().getStructureBridge().getCachedHandles());
+ cachedHandles.addAll(MylarTasksPlugin.getReferenceProvider().getCachedHandles());
+ MylarTasksPlugin.getDefault().getStructureBridge().clearCache();
+ MylarTasksPlugin.getReferenceProvider().clearCachedReports();
+
+ BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge();
+ monitor.beginTask("Downloading Bugs" , cachedHandles.size());
+ for(String key: cachedHandles){
+ try {
+ String [] parts = key.split(";");
+ final int id = Integer.parseInt(parts[1]);
+ BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id);
+ if(bug != null)
+ bridge.cache(key, bug);
+ }catch(Exception e){}
+
+ monitor.worked(1);
+ }
+ monitor.done();
+ viewer.refresh();
+ }
+ };
+
+ // Use the progess service to execute the runnable
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ try {
+ service.run(true, false, op);
+ } catch (InvocationTargetException e) {
+ // Operation was canceled
+ } catch (InterruptedException e) {
+ // Handle the wrapped exception
+ }
+ }
+ }
+
+ private final class CreateTaskAction extends Action {
+ public CreateTaskAction() {
+ setText("Create task");
+ setToolTipText("Create task");
+ setImageDescriptor(MylarImages.TASK_NEW);
+ }
+
@Override
public void run() {
String label = getLabelNameFromUser("task");
@@ -154,13 +464,17 @@ public class TaskListView extends ViewPart {
Task newTask = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), label);
Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Task && !isCategory){
- ((Task)selectedObject).addSubtask(newTask);
- } else {
- if (isCategory) {
- newTask.setIsCategory(true);
- }
- MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask);
+ if (selectedObject instanceof Category){
+ newTask.setCategory((Category)selectedObject);
+ ((Category)selectedObject).addTask(newTask);
+ }
+// else if (selectedObject instanceof Task) {
+// ITask t = (ITask) selectedObject;
+// newTask.setParent(t);
+// t.addSubTask(newTask);
+// }
+ else {
+ MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask);
}
MylarUiPlugin.getDefault().setHighlighterMapping(
newTask.getHandle(),
@@ -169,6 +483,23 @@ public class TaskListView extends ViewPart {
}
}
+ private final class CreateCategoryAction extends Action {
+ public CreateCategoryAction() {
+ setText("Create category");
+ setToolTipText("Create category");
+ setImageDescriptor(MylarImages.CATEGORY_NEW);
+ }
+
+ @Override
+ public void run() {
+ String label = getLabelNameFromUser("Category");
+ if(label == null) return;
+ Category cat = new Category(label);
+ MylarTasksPlugin.getTaskListManager().getTaskList().addCategory(cat);
+ viewer.refresh();
+ }
+ }
+
private final class PriorityDropDownAction extends Action implements IMenuCreator {
private Menu dropDownMenu = null;
@@ -176,7 +507,7 @@ public class TaskListView extends ViewPart {
setText("Display Priorities");
setToolTipText("Show Tasks with Priority Levels");
setImageDescriptor(MylarImages.FILTER_DECLARATIONS);
- setMenuCreator(this);
+ setMenuCreator(this);
}
public void dispose() {
@@ -303,11 +634,9 @@ public class TaskListView extends ViewPart {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof ITask) {
- if (((ITask)element).hasCompletedSubTasks(false)) {
- return true;
- } else {
return !((ITask)element).isCompleted();
- }
+ } else if (element instanceof Category){
+ return true;
} else {
return false;
}
@@ -318,11 +647,9 @@ public class TaskListView extends ViewPart {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof ITask) {
- if (((ITask)element).hasCompletedSubTasks(true)) {
- return true;
- } else {
- return ((ITask)element).isCompleted();
- }
+ return ((ITask)element).isCompleted();
+ } else if (element instanceof Category){
+ return true;
} else {
return false;
}
@@ -367,19 +694,19 @@ public class TaskListView extends ViewPart {
ITask task = (ITask) element;
if (priorities.size() == PRIORITY_LEVELS.length) {
return true;
- } else if (task.isCategory()) {
- return true;
} else {
for (String filter : priorities) {
- if (task.getPriority().equals(filter) ||
- task.hasSubTaskWithPriority(filter)) {
+ if (task.getPriority().equals(filter)) {
return true;
}
}
return false;
}
- }
- return false;
+ } else if (element instanceof Category) {
+ return true;
+ } else {
+ return false;
+ }
}
};
@@ -393,27 +720,37 @@ public class TaskListView extends ViewPart {
}
public Object[] getElements(Object parent) {
if (parent.equals(getViewSite())) {
- return MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks().toArray();
+ return MylarTasksPlugin.getTaskListManager().getTaskList().getRoots().toArray();
}
return getChildren(parent);
}
public Object getParent(Object child) {
if (child instanceof Task) {
- return ((Task)child).getParent();
+ if (((Task)child).getParent() != null) {
+ return ((Task)child).getParent();
+ } else {
+ return ((Task)child).getCategory();
+ }
+
}
return null;
}
public Object [] getChildren(Object parent) {
- if (parent instanceof ITask) {
- return ((ITask)parent).getChildren().toArray();
+ if (parent instanceof Category) {
+ return ((Category)parent).getTasks().toArray();
+ } else if (parent instanceof Task) {
+ return ((Task)parent).getChildren().toArray();
}
return new Object[0];
}
public boolean hasChildren(Object parent) {
- if (parent instanceof ITask) {
- ITask task = (ITask)parent;
- return task.getChildren() != null && task.getChildren().size() > 0;
- }
+ if (parent instanceof Category) {
+ Category cat = (Category)parent;
+ return cat.getTasks() != null && cat.getTasks().size() > 0;
+ } else if (parent instanceof Task) {
+ Task t = (Task) parent;
+ return t.getChildren() != null && t.getChildren().size() > 0;
+ }
return false;
}
}
@@ -426,38 +763,60 @@ public class TaskListView extends ViewPart {
public boolean canModify(Object element, String property) {
int columnIndex = Arrays.asList(columnNames).indexOf(property);
- ITask task = (ITask) element;
- switch (columnIndex) {
- case 0:
- return true;
- case 1:
- return false;
- case 2:
- return !(task instanceof BugzillaTask);
- case 3:
- return !(task instanceof BugzillaTask);
- case 4:
- return false;
- }
+ if (element instanceof ITask) {
+ ITask task = (ITask) element;
+ switch (columnIndex) {
+ case 0: return true;
+ case 1: return false;
+ case 2: return !(task instanceof BugzillaTask);
+ case 3: return !(task instanceof BugzillaTask);
+ case 4: return false;
+ }
+ } else if (element instanceof Category) {
+ switch (columnIndex) {
+ case 0:
+ case 1:
+ case 2:
+ return false;
+ case 3: return true;
+ case 4: return false;
+ }
+ }
return false;
}
public Object getValue(Object element, String property) {
int columnIndex = Arrays.asList(columnNames).indexOf(property);
- ITask task = (ITask) element;
- switch (columnIndex) {
- case 0:
- return new Boolean(task.isCompleted());
- case 1:
- return "";
- case 2:
- String priorityString = task.getPriority().substring(1);
- return new Integer(priorityString);
- case 3:
- return task.getLabel();
- case 4:
- return task.getHandle();
- }
+ if (element instanceof ITask) {
+ ITask task = (ITask) element;
+ switch (columnIndex) {
+ case 0:
+ return new Boolean(task.isCompleted());
+ case 1:
+ return "";
+ case 2:
+ String priorityString = task.getPriority().substring(1);
+ return new Integer(priorityString);
+ case 3:
+ return task.getLabel();
+ case 4:
+ return task.getHandle();
+ }
+ } else if (element instanceof Category) {
+ Category cat = (Category) element;
+ switch (columnIndex) {
+ case 0:
+ return new Boolean(false);
+ case 1:
+ return "";
+ case 2:
+ return "";
+ case 3:
+ return cat.getName();
+ case 4:
+ return "";
+ }
+ }
return "";
}
@@ -465,36 +824,55 @@ public class TaskListView extends ViewPart {
int columnIndex = -1;
try {
columnIndex = Arrays.asList(columnNames).indexOf(property);
- ITask task = (ITask) ((TreeItem) element).getData();
- switch (columnIndex) {
- case 0:
- if (!task.isCategory()) {
+ if (((TreeItem) element).getData() instanceof ITask) {
+
+ ITask task = (ITask) ((TreeItem) element).getData();
+ switch (columnIndex) {
+ case 0:
if (task.isActive()) {
- MylarTasksPlugin.getTaskListManager().deactivateTask(
- task);
+ MylarTasksPlugin.getTaskListManager()
+ .deactivateTask(task);
} else {
MylarTasksPlugin.getTaskListManager().activateTask(
task);
}
+ viewer.setSelection(null);
+ break;
+ case 1:
+ break;
+ case 2:
+ Integer intVal = (Integer) value;
+ task.setPriority("P" + (intVal + 1));
+ viewer.setSelection(null);
+ break;
+ case 3:
+ task.setLabel(((String) value).trim());
+ MylarTasksPlugin.getTaskListManager()
+ .taskPropertyChanged(task, columnNames[3]);
+ viewer.setSelection(null);
+ break;
+ case 4:
+ break;
+ }
+ } else if (((TreeItem) element).getData() instanceof Category) {
+ Category cat = (Category)((TreeItem) element).getData();
+ switch (columnIndex) {
+ case 0:
+ viewer.setSelection(null);
+ break;
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ cat.setName(((String) value).trim());
+ viewer.setSelection(null);
+ break;
+ case 4:
+ break;
}
- viewer.setSelection(null);
- break;
- case 1:
- break;
- case 2:
- Integer intVal = (Integer) value;
- task.setPriority("P" + (intVal + 1));
- viewer.setSelection(null);
- break;
- case 3:
- task.setLabel(((String) value).trim());
- MylarTasksPlugin.getTaskListManager().taskPropertyChanged(task, columnNames[3]);
- viewer.setSelection(null);
- break;
- case 4:
- break;
}
- viewer.refresh(task);
+ viewer.refresh();
} catch (Exception e) {
MylarPlugin.log(e, e.getMessage());
}
@@ -516,26 +894,38 @@ public class TaskListView extends ViewPart {
*/
@Override
public int compare(Viewer compareViewer, Object o1, Object o2) {
- ITask task1 = (ITask) o1;
- ITask task2 = (ITask) o2;
-
- if (task1.isCompleted()) return 1;
- if (task2.isCompleted()) return -1;
- if (column == columnNames[1]) {
- if (task1 instanceof BugzillaTask && !(task2 instanceof BugzillaTask)) {
- return 1;
- } else {
- return -1;
- }
- } else if (column == columnNames[2]) {
- return task1.getPriority().compareTo(task2.getPriority());
- } else if (column == columnNames[3]) {
- return task1.getLabel().compareTo(task2.getLabel());
- } else if (column == columnNames[4]){
- return task1.getPath().compareTo(task2.getPath());
- } else {
- return 0;
- }
+ if (o1 instanceof Category) {
+ if (o2 instanceof Category) {
+ return 0;
+ } else {
+ return -1;
+ }
+ } else {
+ if (o2 instanceof Category) {
+ return -1;
+ } else {
+ ITask task1 = (ITask) o1;
+ ITask task2 = (ITask) o2;
+
+ if (task1.isCompleted()) return 1;
+ if (task2.isCompleted()) return -1;
+ if (column == columnNames[1]) {
+ if (task1 instanceof BugzillaTask && !(task2 instanceof BugzillaTask)) {
+ return 1;
+ } else {
+ return -1;
+ }
+ } else if (column == columnNames[2]) {
+ return task1.getPriority().compareTo(task2.getPriority());
+ } else if (column == columnNames[3]) {
+ return task1.getLabel().compareTo(task2.getLabel());
+ } else if (column == columnNames[4]){
+ return task1.getPath().compareTo(task2.getPath());
+ } else {
+ return 0;
+ }
+ }
+ }
}
}
@@ -586,6 +976,8 @@ public class TaskListView extends ViewPart {
}
viewer.setSorter(new TaskListTableSorter(columnNames[sortIndex]));
viewer.addFilter(priorityFilter);
+ if(MylarUiPlugin.getDefault().isFilterInCompleteMode()) viewer.addFilter(inCompleteFilter);
+ if(MylarUiPlugin.getDefault().isFilterCompleteMode()) viewer.addFilter(completeFilter);
viewer.refresh();
}
@@ -697,9 +1089,24 @@ public class TaskListView extends ViewPart {
.getSelection()).getFirstElement();
if (selectedObject instanceof ITask) {
ITask source = (ITask) selectedObject;
- ITask target = (ITask) getCurrentTarget();
- source.getParent().removeSubtask(source);
- target.addSubtask(source);
+ if (source.getCategory() != null) {
+ source.getCategory().removeTask(source);
+ } else if (source.getParent() != null) {
+ source.getParent().removeSubTask(source);
+ } else {
+ MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks().remove(source);
+ }
+
+ if (getCurrentTarget() instanceof Category) {
+ ((Category) getCurrentTarget()).addTask(source);
+ source.setCategory((Category)getCurrentTarget());
+ } else if (getCurrentTarget() instanceof ITask) {
+ ITask target = (ITask) getCurrentTarget();
+ source.setCategory(null);
+ target.addSubTask(source);
+ source.setParent(target);
+ }
+ viewer.setSelection(null);
viewer.refresh();
return true;
}
@@ -712,12 +1119,12 @@ public class TaskListView extends ViewPart {
Object selectedObject = ((IStructuredSelection) ((TreeViewer) getViewer())
.getSelection()).getFirstElement();
if (selectedObject instanceof ITask) {
- ITask source = (ITask) selectedObject;
- ITask target = (ITask) getCurrentTarget();
- if (target != null && !target.isCategory())
- return false;
- if (source.isCategory())
- return false;
+ if (getCurrentTarget() != null &&
+ (getCurrentTarget() instanceof ITask || getCurrentTarget() instanceof Category)) {
+ return true;
+ } else {
+ return false;
+ }
}
return TextTransfer.getInstance().isSupportedType(transferType);
}
@@ -763,10 +1170,11 @@ public class TaskListView extends ViewPart {
manager.add(incompleteTask);
// manager.add(new Separator());
manager.add(createTask);
- manager.add(addBugzillaReport);
+ manager.add(createBugzillaTask);
manager.add(rename);
manager.add(delete);
manager.add(clearSelectedTaskscapeAction);
+ manager.add(moveTaskToRoot);
manager.add(new Separator());
MenuManager subMenuManager = new MenuManager("choose highlighter");
for (Iterator<Highlighter> it = MylarUiPlugin.getDefault().getHighlighters().iterator(); it.hasNext();) {
@@ -803,7 +1211,7 @@ public class TaskListView extends ViewPart {
manager.add(createCategory);
manager.add(createTask);
// manager.add(new Separator());
- manager.add(addBugzillaReport);
+ manager.add(createBugzillaTask);
manager.add(refresh);
// manager.add(new Separator());
// manager.add(toggleFilteringAction);
@@ -820,289 +1228,20 @@ public class TaskListView extends ViewPart {
*
*/
private void makeActions() {
- refresh = new Action() {
-
- @Override
- public void run() {
- // TODO background?
- // perform the update in an operation so that we get a progress monitor
- // update the structure bridge cache with the reference provider cached bugs
- WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
- protected void execute(IProgressMonitor monitor) throws CoreException {
-
- List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
-
- for (ITask task : tasks) {
- if (task instanceof BugzillaTask) {
- ((BugzillaTask)task).refresh();
- }
- refreshChildren(task.getChildren());
- }
-
- // clear the caches
- Set<String> cachedHandles = new HashSet<String>();
- cachedHandles.addAll(MylarTasksPlugin.getDefault().getStructureBridge().getCachedHandles());
- cachedHandles.addAll(MylarTasksPlugin.getReferenceProvider().getCachedHandles());
- MylarTasksPlugin.getDefault().getStructureBridge().clearCache();
- MylarTasksPlugin.getReferenceProvider().clearCachedReports();
-
- BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge();
- monitor.beginTask("Downloading Bugs" , cachedHandles.size());
- for(String key: cachedHandles){
- try {
- String [] parts = key.split(";");
- final int id = Integer.parseInt(parts[1]);
- BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id);
- if(bug != null)
- bridge.cache(key, bug);
- }catch(Exception e){}
-
- monitor.worked(1);
- }
- monitor.done();
- viewer.refresh();
- }
- };
-
- // Use the progess service to execute the runnable
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.run(true, false, op);
- } catch (InvocationTargetException e) {
- // Operation was canceled
- } catch (InterruptedException e) {
- // Handle the wrapped exception
- }
- }
- };
- refresh.setText("Refresh all Bugzilla reports");
- refresh.setToolTipText("Refresh all Bugzilla reports");
- refresh.setImageDescriptor(MylarImages.REFRESH);
-
-// createCategory = new Action() {
-// public void run() {
-// try {
-// String label = getLabelNameFromUser("category");
-// MylarTasksPlugin.getTaskListManager().getTaskList().createCategory(label);
-// viewer.refresh();
-// } catch (Exception e) {
-// MylarPlugin.fail(e, "Couldn't create category", true);
-// }
-// }
-// };
-// createCategory.setText("Create category");
-// createCategory.setToolTipText("Create category");
-// createCategory.setImageDescriptor(MylarImages.TASK_CATEGORY_NEW);
-
- createTask = new CreateTaskAction(false);
- createTask.setText("Create task");
- createTask.setToolTipText("Create task");
- createTask.setImageDescriptor(MylarImages.TASK_NEW);
-
- createCategory = new CreateTaskAction(true);
- createCategory.setText("Create category");
- createCategory.setToolTipText("Create category");
- createCategory.setImageDescriptor(MylarImages.CATEGORY_NEW);
-
- addBugzillaReport = new Action() {
-
- @Override
- public void run() {
- String bugIdString = getBugIdFromUser();
- int bugId = -1;
- try {
- if (bugIdString != null) {
- bugId = Integer.parseInt(bugIdString);
- } else {
- return;
- }
- } catch (NumberFormatException nfe) {
- showMessage("Please enter a valid report number");
- return;
- }
-
- // Check the existing tasks to see if the id is used already.
- // This is to prevent the creation of mutliple Bugzilla tasks
- // for the same Bugzilla report.
- boolean doesIdExistAlready = false;
- List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
- for (Iterator<ITask> iter = tasks.iterator(); iter.hasNext() && !doesIdExistAlready;) {
- ITask task = iter.next();
- doesIdExistAlready = lookForId(task, "Bugzilla-" + bugId);
- }
- if (doesIdExistAlready) {
- showMessage("A Bugzilla task with ID Bugzilla-" + bugId + " already exists.");
- return;
- }
-
-
- //HACK need the server name and handle properly
- ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>");
-
- Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Task){
- ((Task)selectedObject).addSubtask(newTask);
- } else {
- MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask);
- }
- viewer.refresh();
- }
- };
- addBugzillaReport.setText("Add bugzilla report");
- addBugzillaReport.setToolTipText("Add bugzilla report");
- addBugzillaReport.setImageDescriptor(MylarImages.TASK_BUGZILLA_NEW);
-
- delete = new Action() {
-
- @Override
- public void run() {
- boolean deleteConfirmed = MessageDialog.openQuestion(
- Workbench.getInstance().getActiveWorkbenchWindow().getShell(),
- "Confirm delete",
- "Delete selected task and all subtasks?");
- if (!deleteConfirmed) {
- return;
- } else {
- Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Task) {
- MylarTasksPlugin.getTaskListManager().deleteTask((Task)selectedObject);
- MylarPlugin.getTaskscapeManager().taskDeleted(((Task)selectedObject).getHandle(), ((Task)selectedObject).getPath());
- IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
-
- // if we couldn't get the page, get out of here
- if (page == null)
- return;
- try{
- closeTaskEditors((ITask)selectedObject, page);
- }catch(Exception e){
- MylarPlugin.log(e, " deletion failed");
- }
- }
- }
- viewer.refresh();
- }
- };
- delete.setText("Delete");
- delete.setToolTipText("Delete");
- delete.setImageDescriptor(MylarImages.REMOVE);
-
- completeTask = new Action() {
-
- @Override
- public void run() {
- Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Task){
- ((Task)selectedObject).setCompleted(true);
- viewer.refresh(selectedObject);
- }
- }
- };
- completeTask.setText("Mark Complete");
- completeTask.setToolTipText("Mark Complete");
-// activateTask.setImageDescriptor(MylarImages.REMOVE);
-
- incompleteTask = new Action() {
-
- @Override
- public void run() {
- Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Task){
- ((Task)selectedObject).setCompleted(false);
- viewer.refresh(selectedObject);
- }
- }
- };
- incompleteTask.setText("Mark Incomplete");
- incompleteTask.setToolTipText("Mark Incomplete");
-// deactivateTask.setImageDescriptor(MylarImages.REMOVE);
-
- rename = new Action() {
-
- @Override
- public void run() {
- String label = "category";
- Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Task) label = "task";
-
- String newName = getLabelNameFromUser(label);
- if (selectedObject instanceof Task) {
- ((Task)selectedObject).setLabel(newName);
- } else if (selectedObject instanceof Category) {
- ((Category)selectedObject).setName(newName);
- }
- viewer.refresh(selectedObject);
- }
- };
- rename.setText("Rename");
- rename.setToolTipText("Rename");
-
- clearSelectedTaskscapeAction = new Action() {
-
- @Override
- public void run() {
- Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject != null) {
- MylarPlugin.getTaskscapeManager().taskDeleted(((Task)selectedObject).getHandle(), ((Task)selectedObject).getPath());
- viewer.refresh();
- }
- }
- };
- clearSelectedTaskscapeAction.setText("Erase Taskscape");
- clearSelectedTaskscapeAction.setToolTipText("Erase Taskscape");
- clearSelectedTaskscapeAction.setImageDescriptor(MylarImages.ERASE_TASKSCAPE);
-
- doubleClickAction = new Action() {
- @Override
- public void run() {
- ISelection selection = viewer.getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
- if (obj instanceof ITask) {
- ((ITask)obj).openTaskInEditor();
- }
- viewer.refresh(obj);
- }
- };
-
- filterCompleteTask = new Action() {
- @Override
- public void run() {
- MylarUiPlugin.getDefault().setFilterCompleteMode(isChecked());
- if (isChecked()) {
- viewer.addFilter(completeFilter);
- filterInCompleteTask.setChecked(false);
- viewer.removeFilter(inCompleteFilter);
- } else {
- viewer.removeFilter(completeFilter);
- }
- viewer.refresh();
- }
- };
- filterCompleteTask.setText("Filter Complete tasks");
- filterCompleteTask.setToolTipText("Filter Completed tasks");
- filterCompleteTask.setImageDescriptor(MylarImages.TASK_ACTIVE);
- filterCompleteTask.setChecked(MylarUiPlugin.getDefault().isFilterCompleteMode());
-
- filterInCompleteTask = new Action() {
- @Override
- public void run() {
- MylarUiPlugin.getDefault().setFilterInCompleteMode(isChecked());
- if (isChecked()) {
- viewer.addFilter(inCompleteFilter);
- filterCompleteTask.setChecked(false);
- viewer.removeFilter(completeFilter);
- } else {
- viewer.removeFilter(inCompleteFilter);
- }
- viewer.refresh();
- }
- };
- filterInCompleteTask.setText("Filter Incomplete tasks");
- filterInCompleteTask.setToolTipText("Filter Incomplete tasks");
- filterInCompleteTask.setImageDescriptor(MylarImages.TASK_INACTIVE);
- filterInCompleteTask.setChecked(MylarUiPlugin.getDefault().isFilterInCompleteMode());
-
-
- filterOnPriority = new PriorityDropDownAction();
+ refresh = new RefreshAction();
+ createTask = new CreateTaskAction();
+ createCategory = new CreateCategoryAction();
+ createBugzillaTask = new CreateBugzillaTaskAction();
+ delete = new DeleteAction();
+ completeTask = new MarkTaskCompleteAction();
+ incompleteTask = new MarkTaskIncompleteAction();
+ rename = new RenameAction();
+ clearSelectedTaskscapeAction = new ClearTaskscapeAction();
+ moveTaskToRoot = new MoveTaskToRootAction();
+ doubleClickAction = new OpenTaskEditorAction();
+ filterCompleteTask = new FilterCompletedTasksAction();
+ filterInCompleteTask = new FilterIncompleteTasksAction();
+ filterOnPriority = new PriorityDropDownAction();
}
/**
@@ -1116,22 +1255,19 @@ public class TaskListView extends ViewPart {
* @return <code>true</code> if the id was found in the node or any of its
* children
*/
- protected boolean lookForId(ITask task, String taskId) {
- if (task.getHandle().equals(taskId)) {
- return true;
- }
-
- List<ITask> children = task.getChildren();
- if (children == null) {
- return false;
- }
-
- for (ITask childTask : children) {
- if (lookForId(childTask, taskId)) {
- return true;
- }
- }
-
+ protected boolean lookForId(String taskId) {
+ for (ITask task : MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks()) {
+ if (task.getHandle().equals(taskId)) {
+ return true;
+ }
+ }
+ for (Category cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
+ for (ITask task : cat.getTasks()) {
+ if (task.getHandle().equals(taskId)) {
+ return true;
+ }
+ }
+ }
return false;
}
@@ -1146,14 +1282,7 @@ public class TaskListView extends ViewPart {
if (editor != null) {
page.closeEditor(editor, false);
- }
-
-
- List<ITask> children = task.getChildren();
- if (children == null)
- return;
- for (ITask child : children)
- closeTaskEditors(child, page);
+ }
}
protected void refreshChildren(List<ITask> children) {
@@ -1162,7 +1291,6 @@ public class TaskListView extends ViewPart {
if (child instanceof BugzillaTask) {
((BugzillaTask)child).refresh();
}
- refreshChildren(child.getChildren());
}
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
index f0aa3ff82..a4dc6b2ef 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
@@ -35,6 +35,7 @@ import javax.xml.transform.stream.StreamResult;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.BugzillaTask;
+import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.Task;
import org.eclipse.mylar.tasks.TaskList;
@@ -71,12 +72,15 @@ public class XmlUtil {
}
Element root = doc.createElement("TaskList");
- root.setAttribute("Version", "1.0.0");
+ root.setAttribute("Version", "1.0.1");
// iterate through each subtask and externalize those
//
- for (int i = 0; i < tlist.getRootTasks().size(); i++) {
- writeTask(tlist.getRootTasks().get(i), doc, root);
+ for (Category cat : tlist.getCategories()) {
+ writeCategory(cat, doc, root);
+ }
+ for (ITask task : tlist.getRootTasks()) {
+ writeTask(task, doc, root);
}
doc.appendChild(root);
writeDOMtoFile(doc, outFile);
@@ -89,7 +93,7 @@ public class XmlUtil {
* doc - the document to write
* file - the file to be written to
*/
- public static void writeDOMtoFile(Document doc, File file) {
+ private static void writeDOMtoFile(Document doc, File file) {
try {
// A file output stream is an output stream for writing data to a File
//
@@ -108,7 +112,7 @@ public class XmlUtil {
* doc - the document to be written
* outputStream - the stream to which the document is to be written
*/
- public static void writeDOMtoStream(Document doc, OutputStream outputStream) {
+ private static void writeDOMtoStream(Document doc, OutputStream outputStream) {
// Prepare the DOM document for writing
// DOMSource - Acts as a holder for a transformation Source tree in the
// form of a Document Object Model (DOM) tree
@@ -141,39 +145,103 @@ public class XmlUtil {
}
}
- /**
- *
- * @param t
- * @param doc
- * @param root
- */
- public static void writeTask(ITask t, Document doc, Element root) {
+// /**
+// * Method deprecated until subtasks are introduced again.
+// * @param t
+// * @param doc
+// * @param root
+// */
+// private static void writeTaskAndSubTasks(ITask t, Document doc, Element root) {
+//
+// // create node and set attributes
+// //
+// Element node = doc.createElement("Task");
+// node.setAttribute("Path", t.getPath());
+// node.setAttribute("Label", t.getLabel());
+// node.setAttribute("Handle", t.getHandle());
+// node.setAttribute("Priority", t.getPriority());
+//
+// if (t.isCategory()) {
+// node.setAttribute("IsCategory", "true");
+// } else {
+// node.setAttribute("IsCategory", "false");
+// }
+// if (t.isCompleted()) {
+// node.setAttribute("Complete", "true");
+// } else {
+// node.setAttribute("Complete", "false");
+// }
+// if (t.isActive()) {
+// node.setAttribute("Active", "true");
+// } else {
+// node.setAttribute("Active", "false");
+// }
+// if (t instanceof BugzillaTask) {
+// BugzillaTask bt = (BugzillaTask) t;
+// node.setAttribute("Bugzilla", "true");
+// node.setAttribute("LastDate", new Long(bt.getLastRefreshTime()
+// .getTime()).toString());
+// if (bt.isDirty()) {
+// node.setAttribute("Dirty", "true");
+// } else {
+// node.setAttribute("Dirty", "false");
+// }
+// bt.saveBugReport(false);
+// } else {
+// node.setAttribute("Bugzilla", "false");
+// }
+// node.setAttribute("Notes", t.getNotes());
+// node.setAttribute("Elapsed", t.getElapsedTime());
+// node.setAttribute("Estimated", t.getEstimatedTime());
+// List<String> rl = t.getRelatedLinks().getLinks();
+// int i = 0;
+// for (String link : rl) {
+// node.setAttribute("link"+i, link);
+// i++;
+// }
+//
+// List<ITask> children = t.getChildren();
+//
+// i = 0;
+// for (i = 0; i < children.size(); i++) {
+// writeTaskAndSubTasks(children.get(i), doc, node);
+// }
+//
+// // append new node to root node
+// //
+// root.appendChild(node);
+// return;
+// }
- // create node and set attributes
- //
- Element node = doc.createElement("Task");
- node.setAttribute("Path", t.getPath());
- node.setAttribute("Label", t.getLabel());
- node.setAttribute("Handle", t.getHandle());
- node.setAttribute("Priority", t.getPriority());
-
- if (t.isCategory()) {
- node.setAttribute("IsCategory", "true");
- } else {
- node.setAttribute("IsCategory", "false");
+ private static void writeCategory(Category cat, Document doc, Element parent) {
+ Element node = doc.createElement("Category");
+ node.setAttribute("Name", cat.getName());
+
+ for (ITask t : cat.getTasks()) {
+ writeTask(t, doc, node);
}
- if (t.isCompleted()) {
+ parent.appendChild(node);
+ }
+
+ private static void writeTask(ITask task, Document doc, Element parent) {
+ Element node = doc.createElement("Task");
+ node.setAttribute("Path", task.getPath());
+ node.setAttribute("Label", task.getLabel());
+ node.setAttribute("Handle", task.getHandle());
+ node.setAttribute("Priority", task.getPriority());
+
+ if (task.isCompleted()) {
node.setAttribute("Complete", "true");
} else {
node.setAttribute("Complete", "false");
}
- if (t.isActive()) {
+ if (task.isActive()) {
node.setAttribute("Active", "true");
} else {
node.setAttribute("Active", "false");
}
- if (t instanceof BugzillaTask) {
- BugzillaTask bt = (BugzillaTask) t;
+ if (task instanceof BugzillaTask) {
+ BugzillaTask bt = (BugzillaTask) task;
node.setAttribute("Bugzilla", "true");
node.setAttribute("LastDate", new Long(bt.getLastRefreshTime()
.getTime()).toString());
@@ -186,29 +254,23 @@ public class XmlUtil {
} else {
node.setAttribute("Bugzilla", "false");
}
- node.setAttribute("Notes", t.getNotes());
- node.setAttribute("Elapsed", t.getElapsedTime());
- node.setAttribute("Estimated", t.getEstimatedTime());
- List<String> rl = t.getRelatedLinks().getLinks();
+ node.setAttribute("Notes", task.getNotes());
+ node.setAttribute("Elapsed", task.getElapsedTime());
+ node.setAttribute("Estimated", task.getEstimatedTime());
+ List<String> rl = task.getRelatedLinks().getLinks();
int i = 0;
for (String link : rl) {
node.setAttribute("link"+i, link);
i++;
}
- List<ITask> children = t.getChildren();
-
- i = 0;
- for (i = 0; i < children.size(); i++) {
- writeTask(children.get(i), doc, node);
+ for (ITask t : task.getChildren()) {
+ writeTask(t, doc, node);
}
-
- // append new node to root node
- //
- root.appendChild(node);
+ parent.appendChild(node);
return;
}
-
+
public static void readTaskList(TaskList tlist, File inFile) {
try {
// parse file
@@ -220,10 +282,23 @@ public class XmlUtil {
Element root = doc.getDocumentElement();
readVersion = root.getAttribute("Version");
- NodeList list = root.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- tlist.addRootTask(readTask(child, null, tlist));
+ if (readVersion.equals("1.0.0")) {
+ NodeList list = root.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ readTasksToNewFormat(child, tlist);
+ //tlist.addRootTask(readTaskAndSubTasks(child, null, tlist));
+ }
+ } else {
+ NodeList list = root.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ if (child.getNodeName().equals("Category")) {
+ readCategory(child, tlist);
+ } else {
+ tlist.addRootTask(readTask(child, tlist, null, null));
+ }
+ }
}
} catch (Exception e) {
String name = inFile.getAbsolutePath();
@@ -241,7 +316,7 @@ public class XmlUtil {
* Throws - XMLException if the file cannot be parsed as XML
* - IOException if the file cannot be opened
*/
- public static Document openAsDOM(File inputFile) throws IOException {
+ private static Document openAsDOM(File inputFile) throws IOException {
// A factory API that enables applications to obtain a parser
// that produces DOM object trees from XML documents
@@ -270,19 +345,113 @@ public class XmlUtil {
}
return document;
}
+
+// private static ITask readTaskAndSubTasks(Node node, ITask root, TaskList tlist) {
+// //extract node and create new sub task
+// //
+// Element e = (Element) node;
+// ITask t;
+// String handle = "";
+// if (e.hasAttribute("ID")) {
+// handle = e.getAttribute("ID");
+// } else {
+// handle = e.getAttribute("Handle");
+// }
+//
+// String label = e.getAttribute("Label");
+// String priority = e.getAttribute("Priority");
+//
+// if (e.getAttribute("Bugzilla").compareTo("true") == 0) {
+// t = new BugzillaTask(handle, label, true);
+// BugzillaTask bt = (BugzillaTask) t;
+// bt.setState(BugTaskState.FREE);
+// bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate"))
+// .longValue()));
+// if (e.getAttribute("Dirty").compareTo("true") == 0) {
+// bt.setDirty(true);
+// } else {
+// bt.setDirty(false);
+// }
+// if (bt.readBugReport() == false) {
+// MylarPlugin.log("Failed to read bug report", null);
+// }
+// } else {
+// t = new Task(handle, label);
+// }
+// t.setPriority(priority);
+// t.setPath(e.getAttribute("Path"));
+//
+// if (e.getAttribute("Active").compareTo("true") == 0) {
+// t.setActive(true);
+// tlist.setActive(t, true);
+// } else {
+// t.setActive(false);
+// }
+//
+// if (e.getAttribute("Complete").compareTo("true") == 0) {
+// t.setCompleted(true);
+// } else {
+// t.setCompleted(false);
+// }
+// if (e.getAttribute("IsCategory").compareTo("true") == 0) {
+// t.setIsCategory(true);
+// } else {
+// t.setIsCategory(false);
+// }
+//
+// if (e.hasAttribute("Notes")) {
+// t.setNotes(e.getAttribute("Notes"));
+// } else {
+// t.setNotes("");
+// }
+// if (e.hasAttribute("Elapsed")) {
+// t.setElapsedTime(e.getAttribute("Elapsed"));
+// } else {
+// t.setElapsedTime("");
+// }
+// if (e.hasAttribute("Estimated")) {
+// t.setEstimatedTime(e.getAttribute("Estimated"));
+// } else {
+// t.setEstimatedTime("");
+// }
+//
+// int i = 0;
+// while (e.hasAttribute("link"+i)) {
+// t.getRelatedLinks().add(e.getAttribute("link"+i));
+// i++;
+// }
+//
+// if (!readVersion.equals("1.0.0")) {
+// // for newer revisions
+// }
+//
+// i = 0;
+// NodeList list = e.getChildNodes();
+// for (i = 0; i < list.getLength(); i++) {
+// Node child = list.item(i);
+// t.addSubTask(readTaskAndSubTasks(child, t, tlist));
+// }
+// if (root != null) {
+// t.setParent(root);
+// }
+// return t;
+// }
- public static ITask readTask(Node node, ITask root, TaskList tlist) {
- //extract node and create new sub task
- //
+ private static void readCategory(Node node, TaskList tlist) {
Element e = (Element) node;
- ITask t;
- String handle = "";
- if (e.hasAttribute("ID")) {
- handle = e.getAttribute("ID");
- } else {
- handle = e.getAttribute("Handle");
+ Category cat = new Category(e.getAttribute("Name"));
+ tlist.addCategory(cat);
+ NodeList list = node.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ cat.addTask(readTask(child, tlist, cat, null));
}
-
+ }
+
+ private static ITask readTask(Node node, TaskList tlist, Category cat, ITask parent) {
+ Element e = (Element) node;
+ ITask t;
+ String handle = e.getAttribute("Handle");
String label = e.getAttribute("Label");
String priority = e.getAttribute("Priority");
@@ -312,18 +481,11 @@ public class XmlUtil {
} else {
t.setActive(false);
}
-
if (e.getAttribute("Complete").compareTo("true") == 0) {
t.setCompleted(true);
} else {
t.setCompleted(false);
- }
- if (e.getAttribute("IsCategory").compareTo("true") == 0) {
- t.setIsCategory(true);
- } else {
- t.setIsCategory(false);
- }
-
+ }
if (e.hasAttribute("Notes")) {
t.setNotes(e.getAttribute("Notes"));
} else {
@@ -345,22 +507,140 @@ public class XmlUtil {
t.getRelatedLinks().add(e.getAttribute("link"+i));
i++;
}
-
- if (!readVersion.equals("1.0.0")) {
- // for newer revisions
- // XXX: readVersion had to be read once to remove warning..
+ t.setCategory(cat);
+ t.setParent(parent);
+ NodeList list = e.getChildNodes();
+ for (i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ t.addSubTask(readTask(child, tlist, null, t));
}
+ return t;
+ }
+
+ private static void readTasksToNewFormat(Node node, TaskList tlist) {
+ Element e = (Element) node;
+ ITask t;
+ String handle = e.getAttribute("Handle");
+ String label = e.getAttribute("Label");
+
+ if (e.getAttribute("IsCategory").compareTo("true") == 0) {
+ Category c = new Category(label);
+ NodeList list = e.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ readSubTasksToNewFormat(child, tlist, c);
+ }
+ tlist.addCategory(c);
+ } else {
+ String priority = e.getAttribute("Priority");
+ if (e.getAttribute("Bugzilla").compareTo("true") == 0) {
+ t = new BugzillaTask(handle, label, true);
+ BugzillaTask bt = (BugzillaTask) t;
+ bt.setState(BugTaskState.FREE);
+ bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate"))
+ .longValue()));
+ if (e.getAttribute("Dirty").compareTo("true") == 0) {
+ bt.setDirty(true);
+ } else {
+ bt.setDirty(false);
+ }
+ if (bt.readBugReport() == false) {
+ MylarPlugin.log("Failed to read bug report", null);
+ }
+ } else {
+ t = new Task(handle, label);
+ }
+ t.setPriority(priority);
+ t.setPath(e.getAttribute("Path"));
+ t.setNotes(e.getAttribute("Notes"));
+ t.setElapsedTime(e.getAttribute("Elapsed"));
+ t.setEstimatedTime(e.getAttribute("Estimated"));
+ if (e.getAttribute("Active").compareTo("true") == 0) {
+ t.setActive(true);
+ tlist.setActive(t, true);
+ } else {
+ t.setActive(false);
+ }
+ if (e.getAttribute("Complete").compareTo("true") == 0) {
+ t.setCompleted(true);
+ } else {
+ t.setCompleted(false);
+ }
+
+ int i = 0;
+ while (e.hasAttribute("link" + i)) {
+ t.getRelatedLinks().add(e.getAttribute("link" + i));
+ i++;
+ }
+ tlist.addRootTask(t);
+ i = 0;
+ NodeList list = e.getChildNodes();
+ for (i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ readSubTasksToNewFormat(child, tlist, null);
+ }
+ }
+ }
+ private static void readSubTasksToNewFormat(Node node, TaskList tlist, Category cat) {
+ Element e = (Element) node;
+ ITask t;
+ String handle = e.getAttribute("Handle");
+ String label = e.getAttribute("Label");
+ String priority = e.getAttribute("Priority");
+ if (e.getAttribute("Bugzilla").compareTo("true") == 0) {
+ t = new BugzillaTask(handle, label, true);
+ BugzillaTask bt = (BugzillaTask) t;
+ bt.setState(BugTaskState.FREE);
+ bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate"))
+ .longValue()));
+ if (e.getAttribute("Dirty").compareTo("true") == 0) {
+ bt.setDirty(true);
+ } else {
+ bt.setDirty(false);
+ }
+ if (bt.readBugReport() == false) {
+ MylarPlugin.log("Failed to read bug report", null);
+ }
+ } else {
+ t = new Task(handle, label);
+ }
+ t.setPriority(priority);
+ t.setPath(e.getAttribute("Path"));
+ t.setNotes(e.getAttribute("Notes"));
+ t.setElapsedTime(e.getAttribute("Elapsed"));
+ t.setEstimatedTime(e.getAttribute("Estimated"));
+
+ if (e.getAttribute("Active").compareTo("true") == 0) {
+ t.setActive(true);
+ tlist.setActive(t, true);
+ } else {
+ t.setActive(false);
+ }
+ if (e.getAttribute("Complete").compareTo("true") == 0) {
+ t.setCompleted(true);
+ } else {
+ t.setCompleted(false);
+ }
+
+ int i = 0;
+ while (e.hasAttribute("link" + i)) {
+ t.getRelatedLinks().add(e.getAttribute("link" + i));
+ i++;
+ }
+ if (cat == null) {
+ tlist.addRootTask(t);
+ } else {
+ cat.addTask(t);
+ t.setCategory(cat);
+ }
+
i = 0;
NodeList list = e.getChildNodes();
for (i = 0; i < list.getLength(); i++) {
Node child = list.item(i);
- t.addSubtask(readTask(child, t, tlist));
+ readSubTasksToNewFormat(child, tlist, cat);
}
- if (root != null) {
- t.setParent(root);
- }
- return t;
- }
+ }
}

Back to the top