Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-07-20 17:08:38 +0000
committermkersten2005-07-20 17:08:38 +0000
commitecf292179e351767b769b55486300acee935084c (patch)
treef67b5c7311997030e1bf68a90071502a7c1f3620
parent1051f15709456250ebba01bb32c8fa2aaa0b9de0 (diff)
downloadorg.eclipse.mylyn.tasks-ecf292179e351767b769b55486300acee935084c.tar.gz
org.eclipse.mylyn.tasks-ecf292179e351767b769b55486300acee935084c.tar.xz
org.eclipse.mylyn.tasks-ecf292179e351767b769b55486300acee935084c.zip
Patch for Bugzilla Bug 103092
improve category filtering and sorting
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java35
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskFilter.java18
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCategory.java3
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCompleteFilter.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskList.java62
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskPriorityFilter.java47
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java249
12 files changed, 324 insertions, 147 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java
index dfb5c10ef..628a0ee53 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java
@@ -150,4 +150,11 @@ public class BugzillaHit implements ITaskListElement {
}
return null;
}
+
+ public boolean isCompleted() {
+ if (status.startsWith("RESO") || status.startsWith("CLO") || status.startsWith("VERI")) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java
index 9792b447e..746de4a03 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java
@@ -206,4 +206,8 @@ public class BugzillaQueryCategory extends AbstractCategory {
}
return null;
}
+
+ public boolean isCompleted() {
+ return false;
+ }
}
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 8b4fbb0a2..3f9d70a05 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
@@ -25,8 +25,8 @@ import org.eclipse.mylar.tasks.Task;
import org.eclipse.mylar.tasks.TaskListManager;
import org.eclipse.mylar.tasks.internal.TaskCategory;
import org.eclipse.mylar.tasks.internal.TaskList;
+import org.eclipse.mylar.tasks.internal.TaskPriorityFilter;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
-import org.eclipse.mylar.tasks.ui.views.TaskListView.PriorityFilter;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.PartInitException;
@@ -149,25 +149,26 @@ public class TaskListUiTest extends TestCase {
TreeViewer viewer = TaskListView.getDefault().getViewer();
viewer.setContentProvider(new ContentProvider());
viewer.refresh();
- viewer.addFilter(TaskListView.getDefault().getCompleteFilter());
+ MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(TaskListView.getDefault().getCompleteFilter());
viewer.refresh();
viewer.expandAll();
TreeItem[] items = viewer.getTree().getItems();
assertTrue(checkFilter(CHECK_COMPLETE_FILTER, items));
- // check complete tasks
+ MylarTasksPlugin.getTaskListManager().getTaskList().removeFilter(TaskListView.getDefault().getCompleteFilter());
- viewer.removeFilter(TaskListView.getDefault().getCompleteFilter());
- viewer.addFilter(TaskListView.getDefault().getInCompleteFilter());
- viewer.refresh();
- viewer.expandAll();
- items = viewer.getTree().getItems();
- assertTrue(checkFilter(CHECK_INCOMPLETE_FILTER, items));
+
+// MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(TaskListView.getDefault().getInCompleteFilter());
+// viewer.refresh();
+// viewer.expandAll();
+// items = viewer.getTree().getItems();
+// assertTrue(checkFilter(CHECK_INCOMPLETE_FILTER, items));
+// MylarTasksPlugin.getTaskListManager().getTaskList().removeFilter(TaskListView.getDefault().getInCompleteFilter());
// check incomplte tasks
- viewer.removeFilter(TaskListView.getDefault().getInCompleteFilter());
- PriorityFilter filter = TaskListView.getDefault().getPriorityFilter();
+
+ TaskPriorityFilter filter = (TaskPriorityFilter)TaskListView.getDefault().getPriorityFilter();
filter.displayPrioritiesAbove("P2");
- viewer.addFilter(filter);
+ MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(filter);
viewer.refresh();
viewer.expandAll();
items = viewer.getTree().getItems();
@@ -223,8 +224,9 @@ public class TaskListUiTest extends TestCase {
p1Count++;
}
}
- }
- assertTrue(p2Count == 2 && p1Count == 2);
+ }
+ assertEquals(2, p1Count);
+ assertEquals(2, p2Count);
return true;
}
@@ -245,10 +247,7 @@ public class TaskListUiTest extends TestCase {
return null;
}
public Object [] getChildren(Object parent) {
- if (parent instanceof TaskCategory) {
- return ((TaskCategory)parent).getChildren().toArray();
- }
- return new Object[0];
+ return MylarTasksPlugin.getTaskListManager().getTaskList().getFilteredChildrenFor(parent).toArray();
}
public boolean hasChildren(Object parent) {
if (parent instanceof TaskCategory) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskFilter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskFilter.java
new file mode 100644
index 000000000..bc6f24373
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskFilter.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 University Of British Columbia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylar.tasks;
+
+/**
+* @author Ken Sueda
+*/
+public interface ITaskFilter {
+ public abstract boolean select(Object element);
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java
index 066dca76a..e7abd5a14 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java
@@ -52,4 +52,6 @@ public interface ITaskListElement {
public abstract Color getForeground();
public abstract Font getFont();
+
+ public abstract boolean isCompleted();
}
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 0e3280676..2f651b47b 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
@@ -31,7 +31,7 @@ public class TaskListManager {
private File taskListFile;
private TaskList taskList = new TaskList();
private List<ITaskActivityListener> listeners = new ArrayList<ITaskActivityListener>();
- private int nextTaskId;
+ private int nextTaskId;
public TaskListManager(File file) {
this.taskListFile = file;
@@ -40,7 +40,7 @@ public class TaskListManager {
} else {
nextTaskId = 1;
}
- }
+ }
public TaskList createNewTaskList() {
return taskList;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCategory.java
index d11b28360..7d57702e6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCategory.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCategory.java
@@ -109,4 +109,7 @@ public class TaskCategory extends AbstractCategory implements Serializable {
}
return null;
}
+ public boolean isCompleted(){
+ return false;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCompleteFilter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCompleteFilter.java
new file mode 100644
index 000000000..22caaa48d
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskCompleteFilter.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 University Of British Columbia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylar.tasks.internal;
+
+import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.ITaskFilter;
+import org.eclipse.mylar.tasks.ITaskListElement;
+
+/**
+ * @author Ken Sueda
+ */
+public class TaskCompleteFilter implements ITaskFilter {
+
+ public boolean select(Object element) {
+ if (element instanceof ITaskListElement) {
+// if(element instanceof ITask && ((ITaskListElement)element).hasCorrespondingActivatableTask()){
+ if(((ITaskListElement)element).hasCorrespondingActivatableTask()){
+ ITask task = ((ITaskListElement)element).getOrCreateCorrespondingTask();
+ if (task.isActive()) {
+ return true;
+ }
+ }
+ ITaskListElement t = (ITaskListElement)element;
+ return !t.isCompleted();
+ }
+ return false;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskList.java
index bbe8a06e6..b79495e83 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskList.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskList.java
@@ -19,7 +19,9 @@ import java.util.List;
import org.eclipse.mylar.tasks.AbstractCategory;
import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.ITaskFilter;
import org.eclipse.mylar.tasks.ITaskListElement;
+import org.eclipse.mylar.tasks.Task;
/**
@@ -32,6 +34,7 @@ public class TaskList implements Serializable {
private List<ITask> rootTasks = new ArrayList<ITask>();
private List<AbstractCategory> categories = new ArrayList<AbstractCategory>();
private transient List<ITask> activeTasks = new ArrayList<ITask>();
+ private List<ITaskFilter> filters = new ArrayList<ITaskFilter>();
public void addRootTask(ITask task) {
rootTasks.add(task);
@@ -148,14 +151,61 @@ public class TaskList implements Serializable {
public List<Object> getRoots() {
List<Object> roots = new ArrayList<Object>();
for (ITask t : rootTasks) {
- roots.add(t);
+ if (!filter(t)) {
+ roots.add(t);
+ }
}
for (AbstractCategory cat : categories) {
- roots.add(cat);
+ if (selectCategory(cat)) {
+ roots.add(cat);
+ }
}
return roots;
}
+ private boolean selectCategory(AbstractCategory cat) {
+ List<? extends ITaskListElement> list = cat.getChildren();
+ if (list.size() == 0) {
+ return true;
+ }
+ for (int i = 0; i < list.size(); i++) {
+ if (!filter(list.get(i))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List<Object> getFilteredChildrenFor(Object parent) {
+ List<Object> children = new ArrayList<Object>();
+ if (parent instanceof AbstractCategory) {
+ List<? extends ITaskListElement> list = ((AbstractCategory)parent).getChildren();
+ for (int i = 0; i < list.size(); i++) {
+ if (!filter(list.get(i))) {
+ children.add(list.get(i));
+ }
+ }
+ return children;
+ } else if (parent instanceof Task) {
+ List<ITask> subTasks = ((Task)parent).getChildren();
+ for (ITask t : subTasks) {
+ if (!filter(t)) {
+ children.add(t);
+ }
+ }
+ return children;
+ }
+ return new ArrayList<Object>();
+ }
+
+ private boolean filter(Object obj){
+ for (ITaskFilter filter : filters) {
+ if (!filter.select(obj)) {
+ return true;
+ }
+ }
+ return false;
+ }
public void createCategory(String description) {
TaskCategory c = new TaskCategory(description);
categories.add(c);
@@ -176,4 +226,12 @@ public class TaskList implements Serializable {
categories.clear();
rootTasks.clear();
}
+
+ public void addFilter(ITaskFilter filter) {
+ if (!filters.contains(filter)) filters.add(filter);
+ }
+
+ public void removeFilter(ITaskFilter filter) {
+ filters.remove(filter);
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskPriorityFilter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskPriorityFilter.java
new file mode 100644
index 000000000..ed0e86598
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskPriorityFilter.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 University Of British Columbia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylar.tasks.internal;
+
+import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.ITaskFilter;
+import org.eclipse.mylar.tasks.ITaskListElement;
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
+
+/**
+ * @author Ken Sueda
+ */
+public class TaskPriorityFilter implements ITaskFilter {
+
+ private String priorityLevel = "P5";
+
+ public TaskPriorityFilter() {
+ displayPrioritiesAbove(MylarTasksPlugin.getPriorityLevel());
+// System.out.println("Priority: " + priorityLevel);
+ }
+
+ public void displayPrioritiesAbove(String p) {
+ priorityLevel = p;
+ }
+ public boolean select(Object element) {
+// System.out.println("Priority: " + priorityLevel);
+ if (element instanceof ITaskListElement) {
+ if (element instanceof ITask && ((ITask)element).isActive()) {
+ return true;
+ }
+ if (priorityLevel.compareTo(((ITaskListElement)element).getPriority()) >= 0) {
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java
index a63c707c7..be8309caf 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java
@@ -38,11 +38,11 @@ public class FilterCompletedTasksAction extends Action {
// MylarPlugin.getDefault().actionObserved(this);
MylarTasksPlugin.getDefault().setFilterCompleteMode(isChecked());
if (isChecked()) {
- this.view.getViewer().addFilter(this.view.getCompleteFilter());
+ MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(this.view.getCompleteFilter());
// filterInCompleteTask.setChecked(false);
// viewer.removeFilter(inCompleteFilter);
} else {
- this.view.getViewer().removeFilter(this.view.getCompleteFilter());
+ MylarTasksPlugin.getTaskListManager().getTaskList().removeFilter(this.view.getCompleteFilter());
}
this.view.getViewer().refresh();
}
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 7dfe3c4d8..9cf9fa1e0 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
@@ -12,7 +12,6 @@
package org.eclipse.mylar.tasks.ui.views;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -44,7 +43,6 @@ import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.Window;
import org.eclipse.mylar.core.MylarPlugin;
@@ -57,6 +55,8 @@ import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
import org.eclipse.mylar.tasks.TaskListImages;
import org.eclipse.mylar.tasks.internal.TaskCategory;
+import org.eclipse.mylar.tasks.internal.TaskCompleteFilter;
+import org.eclipse.mylar.tasks.internal.TaskPriorityFilter;
import org.eclipse.mylar.tasks.ui.TaskEditorInput;
import org.eclipse.mylar.tasks.ui.actions.CreateCategoryAction;
import org.eclipse.mylar.tasks.ui.actions.CreateTaskAction;
@@ -127,7 +127,9 @@ public class TaskListView extends ViewPart {
// private FilterIncompleteTasksAction filterInCompleteTask;
private PriorityDropDownAction filterOnPriority;
// private Action moveTaskToRoot;
- private PriorityFilter priorityFilter = new PriorityFilter();
+// private PriorityFilter priorityFilter = new PriorityFilter();
+ private static TaskPriorityFilter PRIORITY_FILTER = new TaskPriorityFilter();
+ private static TaskCompleteFilter COMPLETE_FILTER = new TaskCompleteFilter();
protected String[] columnNames = new String[] { "", ".", "!", "Description" };
protected int[] columnWidths = new int[] { 70, 20, 20, 120 };
@@ -180,7 +182,7 @@ public class TaskListView extends ViewPart {
@Override
public void run() {
MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.PriorityLevel.P1);
- priorityFilter.displayPrioritiesAbove(PRIORITY_LEVELS[0]);
+ PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[0]);
viewer.refresh();
}
};
@@ -193,7 +195,7 @@ public class TaskListView extends ViewPart {
@Override
public void run() {
MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.PriorityLevel.P2);
- priorityFilter.displayPrioritiesAbove(PRIORITY_LEVELS[1]);
+ PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[1]);
viewer.refresh();
}
};
@@ -206,7 +208,7 @@ public class TaskListView extends ViewPart {
@Override
public void run() {
MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.PriorityLevel.P3);
- priorityFilter.displayPrioritiesAbove(PRIORITY_LEVELS[2]);
+ PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[2]);
viewer.refresh();
}
};
@@ -219,7 +221,7 @@ public class TaskListView extends ViewPart {
@Override
public void run() {
MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.PriorityLevel.P4);
- priorityFilter.displayPrioritiesAbove(PRIORITY_LEVELS[3]);
+ PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[3]);
viewer.refresh();
}
};
@@ -232,7 +234,7 @@ public class TaskListView extends ViewPart {
@Override
public void run() {
MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.PriorityLevel.P5);
- priorityFilter.displayPrioritiesAbove(PRIORITY_LEVELS[4]);
+ PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[4]);
viewer.refresh();
}
};
@@ -269,97 +271,97 @@ public class TaskListView extends ViewPart {
}
}
- private ViewerFilter completeFilter = new ViewerFilter(){
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof ITaskListElement) {
- if(element instanceof ITask && ((ITaskListElement)element).hasCorrespondingActivatableTask()){
- ITask task = ((ITaskListElement)element).getOrCreateCorrespondingTask();
- if (task.isActive()) {
- return true;
- }
- if(task != null){
- return !task.isCompleted();
- } else {
- return true;
- }
- } else {
- return true;
- }
- }
- return false;
- }
- };
-
- private ViewerFilter inCompleteFilter = new ViewerFilter(){
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof ITask) {
- return ((ITask)element).isCompleted();
- } else {
- return true;
- }
- }
- };
-
- public class PriorityFilter extends ViewerFilter {
- private List<String> priorities = new ArrayList<String>();
-
- public PriorityFilter() {
- displayPrioritiesAbove(MylarTasksPlugin.getPriorityLevel());
- }
-
- public void displayPrioritiesAbove(String p) {
- priorities.clear();
- if (p.equals(PRIORITY_LEVELS[0])) {
- priorities.add(PRIORITY_LEVELS[0]);
- }
- if (p.equals(PRIORITY_LEVELS[1])) {
- priorities.add(PRIORITY_LEVELS[0]);
- priorities.add(PRIORITY_LEVELS[1]);
- } else if (p.equals(PRIORITY_LEVELS[2])) {
- priorities.add(PRIORITY_LEVELS[0]);
- priorities.add(PRIORITY_LEVELS[1]);
- priorities.add(PRIORITY_LEVELS[2]);
- } else if (p.equals(PRIORITY_LEVELS[3])) {
- priorities.add(PRIORITY_LEVELS[0]);
- priorities.add(PRIORITY_LEVELS[1]);
- priorities.add(PRIORITY_LEVELS[2]);
- priorities.add(PRIORITY_LEVELS[3]);
- } else if (p.equals(PRIORITY_LEVELS[4])) {
- priorities.add(PRIORITY_LEVELS[0]);
- priorities.add(PRIORITY_LEVELS[1]);
- priorities.add(PRIORITY_LEVELS[2]);
- priorities.add(PRIORITY_LEVELS[3]);
- priorities.add(PRIORITY_LEVELS[4]);
- }
- }
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof ITaskListElement) {
- ITaskListElement task = (ITaskListElement) element;
- if (priorities.size() == PRIORITY_LEVELS.length) {
- return true;
- } else {
- return checkTask(task);
- }
- } else {
- return true;
- }
- }
- private boolean checkTask(ITaskListElement task) {
- if (task instanceof ITask && ((ITask)task).isActive()) {
- return true;
- }
- for (String filter : priorities) {
- if (task.getPriority().equals(filter)) {
- return true;
- }
- }
- return false;
- }
- };
+// private ViewerFilter completeFilter = new ViewerFilter(){
+// @Override
+// public boolean select(Viewer viewer, Object parentElement, Object element) {
+// if (element instanceof ITaskListElement) {
+// if(element instanceof ITask && ((ITaskListElement)element).hasCorrespondingActivatableTask()){
+// ITask task = ((ITaskListElement)element).getOrCreateCorrespondingTask();
+// if (task.isActive()) {
+// return true;
+// }
+// if(task != null){
+// return !task.isCompleted();
+// } else {
+// return true;
+// }
+// } else {
+// return true;
+// }
+// }
+// return false;
+// }
+// };
+//
+// private ViewerFilter inCompleteFilter = new ViewerFilter(){
+// @Override
+// public boolean select(Viewer viewer, Object parentElement, Object element) {
+// if (element instanceof ITask) {
+// return ((ITask)element).isCompleted();
+// } else {
+// return true;
+// }
+// }
+// };
+//
+// public class PriorityFilter extends ViewerFilter {
+// private List<String> priorities = new ArrayList<String>();
+//
+// public PriorityFilter() {
+// displayPrioritiesAbove(MylarTasksPlugin.getPriorityLevel());
+// }
+//
+// public void displayPrioritiesAbove(String p) {
+// priorities.clear();
+// if (p.equals(PRIORITY_LEVELS[0])) {
+// priorities.add(PRIORITY_LEVELS[0]);
+// }
+// if (p.equals(PRIORITY_LEVELS[1])) {
+// priorities.add(PRIORITY_LEVELS[0]);
+// priorities.add(PRIORITY_LEVELS[1]);
+// } else if (p.equals(PRIORITY_LEVELS[2])) {
+// priorities.add(PRIORITY_LEVELS[0]);
+// priorities.add(PRIORITY_LEVELS[1]);
+// priorities.add(PRIORITY_LEVELS[2]);
+// } else if (p.equals(PRIORITY_LEVELS[3])) {
+// priorities.add(PRIORITY_LEVELS[0]);
+// priorities.add(PRIORITY_LEVELS[1]);
+// priorities.add(PRIORITY_LEVELS[2]);
+// priorities.add(PRIORITY_LEVELS[3]);
+// } else if (p.equals(PRIORITY_LEVELS[4])) {
+// priorities.add(PRIORITY_LEVELS[0]);
+// priorities.add(PRIORITY_LEVELS[1]);
+// priorities.add(PRIORITY_LEVELS[2]);
+// priorities.add(PRIORITY_LEVELS[3]);
+// priorities.add(PRIORITY_LEVELS[4]);
+// }
+// }
+//
+// @Override
+// public boolean select(Viewer viewer, Object parentElement, Object element) {
+// if (element instanceof ITaskListElement) {
+// ITaskListElement task = (ITaskListElement) element;
+// if (priorities.size() == PRIORITY_LEVELS.length) {
+// return true;
+// } else {
+// return checkTask(task);
+// }
+// } else {
+// return true;
+// }
+// }
+// private boolean checkTask(ITaskListElement task) {
+// if (task instanceof ITask && ((ITask)task).isActive()) {
+// return true;
+// }
+// for (String filter : priorities) {
+// if (task.getPriority().equals(filter)) {
+// return true;
+// }
+// }
+// return false;
+// }
+// };
class TaskListContentProvider implements IStructuredContentProvider, ITreeContentProvider {
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
@@ -386,12 +388,7 @@ public class TaskListView extends ViewPart {
return null;
}
public Object [] getChildren(Object parent) {
- if (parent instanceof AbstractCategory) {
- return ((AbstractCategory)parent).getChildren().toArray();
- } else if (parent instanceof Task) {
- return ((Task)parent).getChildren().toArray();
- }
- return new Object[0];
+ return MylarTasksPlugin.getTaskListManager().getTaskList().getFilteredChildrenFor(parent).toArray();
}
public boolean hasChildren(Object parent) {
if (parent instanceof AbstractCategory) {
@@ -576,14 +573,18 @@ public class TaskListView extends ViewPart {
} else if(o2 instanceof ITaskListElement) {
ITaskListElement element1 = (ITaskListElement) o1;
ITaskListElement element2 = (ITaskListElement) o2;
-
- if (element1.hasCorrespondingActivatableTask() && element2.hasCorrespondingActivatableTask()) {
- ITask task1 = element1.getOrCreateCorrespondingTask();
- ITask task2 = element2.getOrCreateCorrespondingTask();
-
- if (task1.isCompleted()) return 1;
- if (task2.isCompleted()) return -1;
- }
+ if (element1.isCompleted() && element2.isCompleted()) {
+ return element1.getPriority().compareTo(element2.getPriority());
+ }
+ if (element1.isCompleted()) return 1;
+ if (element2.isCompleted()) return -1;
+// if (element1.hasCorrespondingActivatableTask() && element2.hasCorrespondingActivatableTask()) {
+// ITask task1 = element1.getOrCreateCorrespondingTask();
+// ITask task2 = element2.getOrCreateCorrespondingTask();
+//
+// if (task1.isCompleted()) return 1;
+// if (task2.isCompleted()) return -1;
+// }
if (column == columnNames[1]) {
return 0;
} else if (column == columnNames[2]) {
@@ -649,9 +650,11 @@ public class TaskListView extends ViewPart {
}
viewer.setSorter(new TaskListTableSorter(columnNames[sortIndex]));
}
- viewer.addFilter(priorityFilter);
- if (MylarTasksPlugin.getDefault().isFilterInCompleteMode()) viewer.addFilter(inCompleteFilter);
- if (MylarTasksPlugin.getDefault().isFilterCompleteMode()) viewer.addFilter(completeFilter);
+ MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(PRIORITY_FILTER);
+// if (MylarTasksPlugin.getDefault().isFilterInCompleteMode())
+// MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(inCompleteFilter);
+ if (MylarTasksPlugin.getDefault().isFilterCompleteMode())
+ MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(COMPLETE_FILTER);
viewer.refresh();
}
@@ -1066,16 +1069,16 @@ public class TaskListView extends ViewPart {
return viewer;
}
- public ViewerFilter getCompleteFilter() {
- return completeFilter;
+ public TaskCompleteFilter getCompleteFilter() {
+ return COMPLETE_FILTER;
}
- public ViewerFilter getInCompleteFilter() {
- return inCompleteFilter;
- }
+// public ViewerFilter getInCompleteFilter() {
+// return inCompleteFilter;
+// }
- public PriorityFilter getPriorityFilter() {
- return priorityFilter;
+ public TaskPriorityFilter getPriorityFilter() {
+ return PRIORITY_FILTER;
}
public class TaskInputDialog extends Dialog {
private String taskName = "";

Back to the top