Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-08-24 15:05:49 -0400
committersminto2005-08-24 15:05:49 -0400
commitcdda66c5587f330392bd2411189ca05797612b04 (patch)
treee076f628175c3ef327eb0c765c5ffa83118d2f20
parentdd191c8717d3b9f0cd6bfad86ea6d6c30879b86b (diff)
downloadorg.eclipse.mylyn.tasks-cdda66c5587f330392bd2411189ca05797612b04.tar.gz
org.eclipse.mylyn.tasks-cdda66c5587f330392bd2411189ca05797612b04.tar.xz
org.eclipse.mylyn.tasks-cdda66c5587f330392bd2411189ca05797612b04.zip
First crack at making generic queries
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java52
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java16
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java85
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java14
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java29
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java14
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java11
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/AbstractCategory.java64
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ICategory.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQuery.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java9
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java30
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListElement.java11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListExternalizer.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java28
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java65
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCompleteFilter.java21
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java66
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListExternalizer.java27
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/CompletedTaskCollector.java15
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ITasksCollector.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java13
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameSorter.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskEditorInput.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java8
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListLabelProvider.java11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java167
33 files changed, 566 insertions, 313 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java
index f6768645b..a065cf2ac 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java
@@ -54,7 +54,7 @@ public class CreateBugzillaQueryCategoryAction extends Action implements IViewAc
// TODO make this work properly
final BugzillaQueryCategory queryCategory = new BugzillaQueryCategory(sqd.getName(), sqd.getUrl(), sqd.getMaxHits());
- MylarTasklistPlugin.getTaskListManager().addCategory(queryCategory);
+ MylarTasklistPlugin.getTaskListManager().addQuery(queryCategory);
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws CoreException {
queryCategory.refreshBugs();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
index 886e6fdf4..e561758b3 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
@@ -26,6 +26,7 @@ import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaHit;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
import org.eclipse.mylar.core.MylarPlugin;
+import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
@@ -73,8 +74,8 @@ public class RefreshBugzillaAction extends Action implements IViewActionDelegate
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
cat.refreshBugs();
- for(BugzillaHit hit: cat.getChildren()){
- if(hit.hasCorrespondingActivatableTask()){
+ for(IQueryHit hit: cat.getChildren()){
+ if(hit.hasCorrespondingActivatableTask() && hit instanceof BugzillaHit){
BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)hit.getOrCreateCorrespondingTask());
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
index 76fb921ee..d9826bf0e 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
@@ -22,10 +22,11 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
-import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaHit;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
+import org.eclipse.mylar.tasklist.IQuery;
+import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
@@ -143,8 +144,11 @@ public class RefreshBugzillaReportsAction extends Action implements IViewActionD
BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)task);
}
}
- for (AbstractCategory cat : MylarTasklistPlugin
+ for (ICategory cat : MylarTasklistPlugin
.getTaskListManager().getTaskList().getCategories()) {
+ if(cat.isArchive())
+ continue;
+
if (cat instanceof TaskCategory) {
for (ITask task : ((TaskCategory) cat).getChildren()) {
if (task instanceof BugzillaTask && !task.isCompleted()) {
@@ -160,27 +164,33 @@ public class RefreshBugzillaReportsAction extends Action implements IViewActionD
}
}
}
- } else if (cat instanceof BugzillaQueryCategory) {
- final BugzillaQueryCategory bqc = (BugzillaQueryCategory) cat;
- PlatformUI.getWorkbench().getDisplay().syncExec(
- new Runnable() {
- public void run() {
- bqc.refreshBugs();
- for(BugzillaHit hit: bqc.getChildren()){
- if(hit.hasCorrespondingActivatableTask()){
- BugzillaTask task = ((BugzillaTask)hit.getOrCreateCorrespondingTask());
- if(!task.isCompleted()){
- BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed(task);
-// task.refresh();
- }
+ }
+ }
+ for(IQuery query: MylarTasklistPlugin
+ .getTaskListManager().getTaskList().getQueries()){
+ if(!(query instanceof BugzillaQueryCategory)){
+ continue;
+ }
+
+ final BugzillaQueryCategory bqc = (BugzillaQueryCategory) query;
+ PlatformUI.getWorkbench().getDisplay().syncExec(
+ new Runnable() {
+ public void run() {
+ bqc.refreshBugs();
+ for(IQueryHit hit: bqc.getChildren()){
+ if(hit.hasCorrespondingActivatableTask()){
+ BugzillaTask task = ((BugzillaTask)hit.getOrCreateCorrespondingTask());
+ if(!task.isCompleted()){
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed(task);
+// task.refresh();
}
}
- if(TaskListView.getDefault() != null)
- TaskListView.getDefault().getViewer().refresh();
}
- });
- }
- }
+ if(TaskListView.getDefault() != null)
+ TaskListView.getDefault().getViewer().refresh();
+ }
+ });
+ }
if(TaskListView.getDefault() != null)
TaskListView.getDefault().getViewer().refresh();
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java
index 834872ed7..45053cd83 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java
@@ -15,8 +15,8 @@ import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
+import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITask;
-import org.eclipse.mylar.tasklist.ITaskListElement;
import org.eclipse.mylar.tasklist.TaskListImages;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -25,7 +25,7 @@ import org.eclipse.swt.graphics.Image;
/**
* @author Ken Sueda
*/
-public class BugzillaHit implements ITaskListElement {
+public class BugzillaHit implements IQueryHit {
private String description;
private String priority;
@@ -165,4 +165,16 @@ public class BugzillaHit implements ITaskListElement {
return getDescription(true);
}
}
+
+ public void setDescription(String description) {
+ // can't set the description to anything
+ }
+
+ public String getStringForSortingDescription() {
+ return getID()+"";
+ }
+
+ public void setHandle(String id) {
+ // can't change the handle
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
index 2041bcf3e..9abd5cf32 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
@@ -30,8 +30,8 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.search.BugzillaResultCollector;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaCategorySearchOperation.ICategorySearchListener;
-import org.eclipse.mylar.tasklist.AbstractCategory;
-import org.eclipse.mylar.tasklist.ITask;
+import org.eclipse.mylar.tasklist.IQuery;
+import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITaskListElement;
import org.eclipse.mylar.tasklist.TaskListImages;
import org.eclipse.swt.graphics.Color;
@@ -42,16 +42,22 @@ import org.eclipse.ui.PlatformUI;
/**
* @author Shawn Minto
*/
-public class BugzillaQueryCategory extends AbstractCategory {
+public class BugzillaQueryCategory implements IQuery {
private static final long serialVersionUID = 5517146402031743253L;
- private String url;
+ private String queryString;
private int maxHits;
- private List<BugzillaHit> hits = new ArrayList<BugzillaHit>();
+ private List<IQueryHit> hits = new ArrayList<IQueryHit>();
private boolean hasBeenRefreshed = false;
protected Date lastRefresh;
+ protected String description = "";
+ private String handle = "";
+
+ private ICategorySearchListener listener = new BugzillaQueryCategorySearchListener();
+ private boolean isMaxReached = false;
+
public class BugzillaQueryCategorySearchListener implements ICategorySearchListener {
Map<Integer, BugzillaSearchHit> hits = new HashMap<Integer, BugzillaSearchHit>();
@@ -65,13 +71,10 @@ public class BugzillaQueryCategory extends AbstractCategory {
}
}
-
- private ICategorySearchListener listener = new BugzillaQueryCategorySearchListener();
- private boolean isMaxReached = false;
-
+
public BugzillaQueryCategory(String label, String url, String maxHits) {
- super(label);
- this.url = url;
+ this.description = label;
+ this.queryString = url;
try{
this.maxHits = Integer.parseInt(maxHits);
} catch (Exception e){
@@ -82,14 +85,14 @@ public class BugzillaQueryCategory extends AbstractCategory {
public String getDescription(boolean label) {
if (hits.size() > 0 || !label) {
if(isMaxReached && label){
- return super.getDescription(label) + " <first "+ maxHits +" hits>";
+ return description + " <first "+ maxHits +" hits>";
} else {
- return super.getDescription(label);
+ return description;
}
} else if (!hasBeenRefreshed) {
- return super.getDescription(label) + " <needs refresh>";
+ return description + " <needs refresh>";
} else {
- return super.getDescription(label) + " <no hits>";
+ return description + " <no hits>";
}
}
@@ -98,11 +101,13 @@ public class BugzillaQueryCategory extends AbstractCategory {
return TaskListImages.getImage(BugzillaImages.CATEGORY_QUERY);
}
- public String getUrl() {
- return url;
+ public String getQueryString() {
+ return queryString;
}
- public List<BugzillaHit> getChildren() {
+
+
+ public List<IQueryHit> getChildren() {
return hits;
}
@@ -119,7 +124,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
public void refreshBugs() {
hits.clear();
final BugzillaCategorySearchOperation catSearch = new BugzillaCategorySearchOperation(
- getUrl(), maxHits);
+ getQueryString(), maxHits);
catSearch.addResultsListener(listener);
final IStatus[] status = new IStatus[1];
@@ -169,8 +174,8 @@ public class BugzillaQueryCategory extends AbstractCategory {
return;
}
- public void setUrl(String url) {
- this.url = url;
+ public void setQueryString(String url) {
+ this.queryString = url;
}
public String getPriority() {
@@ -178,7 +183,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
if (hits.isEmpty()) {
return "P1";
}
- for (BugzillaHit hit : hits) {
+ for (IQueryHit hit : hits) {
if (highestPriority.compareTo(hit.getPriority()) > 0) {
highestPriority = hit.getPriority();
}
@@ -186,14 +191,6 @@ public class BugzillaQueryCategory extends AbstractCategory {
return highestPriority;
}
- public ITask getOrCreateCorrespondingTask() {
- return null;
- }
-
- public boolean hasCorrespondingActivatableTask() {
- return false;
- }
-
public boolean isDirectlyModifiable() {
return true;
}
@@ -242,11 +239,27 @@ public class BugzillaQueryCategory extends AbstractCategory {
return maxHits;
}
- public void setMaxHits(String maxHits) {
- try{
- this.maxHits = Integer.parseInt(maxHits);
- } catch (Exception e){
- this.maxHits = -1;
- }
+ public void setMaxHits(int maxHits) {
+ this.maxHits = maxHits;
+ }
+
+ public Image getStatusIcon() {
+ return null;
+ }
+
+ public String getHandle() {
+ return handle;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getStringForSortingDescription() {
+ return getDescription(true);
+ }
+
+ public void setHandle(String id) {
+ this.handle = id;
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
index 95084e425..55ba1bf63 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
@@ -131,10 +131,10 @@ public class BugzillaTask extends Task {
setPriority(hit.getPriority());
}
- @Override
- public String getLabel() {
- if (this.isBugDownloaded() || !super.getLabel().startsWith("<")) {
- return super.getLabel();
+ @Override
+ public String getDescription(boolean isLabel) {
+ if (this.isBugDownloaded() || !super.getDescription(isLabel).startsWith("<")) {
+ return super.getDescription(isLabel);
} else {
if (getState() == BugzillaTask.BugTaskState.FREE) {
return BugzillaTask.getBugId(getHandle()) + ": <Could not find bug>";
@@ -395,7 +395,7 @@ public class BugzillaTask extends Task {
if (status.equals("RESOLVED") || status.equals("CLOSED") || status.equals("VERIFIED")) {
setCompleted(true);
}
- this.setLabel(HtmlStreamTokenizer.unescape(BugzillaTask.getBugId(getHandle()) + ": " + bugReport.getSummary()));
+ this.setDescription(HtmlStreamTokenizer.unescape(BugzillaTask.getBugId(getHandle()) + ": " + bugReport.getSummary()));
} catch (NullPointerException npe) {
MylarPlugin.fail(npe, "Task details update failed", false);
}
@@ -573,4 +573,8 @@ public class BugzillaTask extends Task {
GetBugReportJob job = new GetBugReportJob("Refreshing with Bugzilla server...");
return job;
}
+
+ public String getStringForSortingDescription() {
+ return getBugId(getHandle())+"";
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
index c3263ab37..516b32249 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
@@ -16,12 +16,14 @@ import java.util.Date;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugTaskState;
import org.eclipse.mylar.core.MylarPlugin;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
+import org.eclipse.mylar.tasklist.IQuery;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskHandler;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
import org.eclipse.mylar.tasklist.internal.DefaultTaskListExternalizer;
import org.eclipse.mylar.tasklist.internal.MylarExternalizerException;
+import org.eclipse.mylar.tasklist.internal.TaskCategory;
import org.eclipse.mylar.tasklist.internal.TaskList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -74,13 +76,17 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
readRegistry(node, taskList);
} else {
BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute(DESCRIPTION), e.getAttribute(URL), e.getAttribute(MAX_HITS));
- taskList.internalAddCategory(cat);
+ taskList.internalAddQuery(cat);
}
}
public void readRegistry(Node node, TaskList taskList) throws MylarExternalizerException {
boolean hasCaughtException = false;
- NodeList list = node.getChildNodes();
+ NodeList list = node.getChildNodes();
+ TaskCategory cat = new TaskCategory("Bugzilla Archive");
+ cat.setIsArchive(true);
+ taskList.addCategory(cat);
+ BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().setTaskRegistyCategory(cat);
for (int i = 0; i < list.getLength(); i++) {
try {
Node child = list.item(i);
@@ -93,18 +99,23 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
hasCaughtException = true;
}
}
+
if (hasCaughtException) throw new MylarExternalizerException("Failed to restore all tasks");
}
- public boolean canCreateElementFor(AbstractCategory category) {
- return category instanceof BugzillaQueryCategory;
+ public boolean canCreateElementFor(IQuery query) {
+ return query instanceof BugzillaQueryCategory;
+ }
+
+ public boolean canCreateElementFor(ICategory cat) {
+ return false;
}
- public Element createCategoryElement(AbstractCategory category, Document doc, Element parent) {
- BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)category;
+ public Element createQueryElement(IQuery query, Document doc, Element parent) {
+ BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)query;
Element node = doc.createElement(getCategoryTagName());
node.setAttribute(DESCRIPTION, queryCategory.getDescription(false));
- node.setAttribute(URL, queryCategory.getUrl());
+ node.setAttribute(URL, queryCategory.getQueryString());
node.setAttribute(MAX_HITS, ""+queryCategory.getMaxHits());
parent.appendChild(node);
return node;
@@ -140,7 +151,7 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
}
@Override
- public ITask readTask(Node node, TaskList tlist, AbstractCategory category, ITask parent) throws MylarExternalizerException{
+ public ITask readTask(Node node, TaskList tlist, ICategory category, ITask parent) throws MylarExternalizerException{
Element element = (Element) node;
String handle;
String label;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
index 59aa9d77e..b5b820622 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
@@ -55,8 +55,8 @@ public class BugzillaTaskHandler implements ITaskHandler {
"Delete the selected query and all contained tasks?");
if (!deleteConfirmed)
return;
- BugzillaQueryCategory cat = (BugzillaQueryCategory) element;
- MylarTasklistPlugin.getTaskListManager().deleteCategory(cat);
+ BugzillaQueryCategory query = (BugzillaQueryCategory) element;
+ MylarTasklistPlugin.getTaskListManager().deleteQuery(query);
} else if (element instanceof BugzillaTask) {
BugzillaTask task = (BugzillaTask) element;
if (task.isActive()) {
@@ -109,11 +109,15 @@ public class BugzillaTaskHandler implements ITaskHandler {
}
else if (element instanceof BugzillaQueryCategory){
BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)element;
- BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell(), queryCategory.getUrl(), queryCategory.getDescription(false), queryCategory.getMaxHits()+"");
+ BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell(), queryCategory.getQueryString(), queryCategory.getDescription(false), queryCategory.getMaxHits()+"");
if(sqd.open() == Dialog.OK){
queryCategory.setDescription(sqd.getName());
- queryCategory.setUrl(sqd.getUrl());
- queryCategory.setMaxHits(sqd.getMaxHits());
+ queryCategory.setQueryString(sqd.getUrl());
+ int maxHits = -1;
+ try{
+ maxHits = Integer.parseInt(sqd.getMaxHits());
+ } catch(Exception e){}
+ queryCategory.setMaxHits(maxHits);
new RefreshBugzillaAction(queryCategory).run();
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
index 4fa99fe11..c5dbb45af 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
@@ -14,6 +14,8 @@ package org.eclipse.mylar.bugzilla.ui.tasklist;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.mylar.tasklist.internal.TaskCategory;
+
/**
* @author Mik Kersten and Ken Sueda
*/
@@ -21,11 +23,16 @@ public class BugzillaTaskListManager {
private Map<String, BugzillaTask> bugzillaTaskRegistry = new HashMap<String, BugzillaTask>();
+ private TaskCategory cat = null;
+
// XXX we never delete anything from this registry
public void addToBugzillaTaskRegistry(BugzillaTask task){
if(bugzillaTaskRegistry.get(task.getHandle()) == null){
bugzillaTaskRegistry.put(task.getHandle(), task);
+ if(cat != null){
+ cat.internalAddTask(task);
+ }
}
}
@@ -36,5 +43,9 @@ public class BugzillaTaskListManager {
public Map<String, BugzillaTask> getBugzillaTaskRegistry(){
return bugzillaTaskRegistry;
}
+
+ public void setTaskRegistyCategory(TaskCategory cat) {
+ this.cat = cat;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java
index cf60c5a38..ad2a627d5 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java
@@ -80,19 +80,19 @@ public class TaskListManagerTest extends TestCase {
assertEquals(2, manager.getTaskList().getCategories().size());
List<ITask> readList = manager.getTaskList().getRootTasks();
- assertTrue(readList.get(0).getLabel().equals("task 1"));
- assertTrue(readList.get(0).getChildren().get(0).getLabel().equals("sub 1"));
- assertTrue(readList.get(1).getLabel().equals("task 2"));
+ assertTrue(readList.get(0).getDescription(true).equals("task 1"));
+ assertTrue(readList.get(0).getChildren().get(0).getDescription(true).equals("sub 1"));
+ assertTrue(readList.get(1).getDescription(true).equals("task 2"));
assertTrue(readList.get(2) instanceof BugzillaTask);
List<TaskCategory> readCats = manager.getTaskList().getTaskCategories();
readList = readCats.get(0).getChildren();
- assertTrue(readList.get(0).getLabel().equals("task 3"));
- assertTrue(readList.get(0).getChildren().get(0).getLabel().equals("sub 2"));
- assertTrue(readList.get(1).getLabel().equals("task 4"));
+ assertTrue(readList.get(0).getDescription(true).equals("task 3"));
+ assertTrue(readList.get(0).getChildren().get(0).getDescription(true).equals("sub 2"));
+ assertTrue(readList.get(1).getDescription(true).equals("task 4"));
readList = readCats.get(1).getChildren();
- assertTrue(readList.get(0).getLabel().equals("task 5"));
- assertTrue(readList.get(1).getLabel().equals("task 6"));
+ assertTrue(readList.get(0).getDescription(true).equals("task 5"));
+ assertTrue(readList.get(1).getDescription(true).equals("task 6"));
assertTrue(readList.get(2) instanceof BugzillaTask);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/AbstractCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/AbstractCategory.java
deleted file mode 100644
index 3da6035dc..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/AbstractCategory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * 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.tasklist;
-
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author Ken Sueda
- */
-public abstract class AbstractCategory implements ITaskListElement {
-
- private String priority = "";
- protected String description = "";
- private String handle = "";
-
- public AbstractCategory(String description) {
- this.description = description;
- }
-
- public Image getIcon() {
- return null;
- }
-
- public String getPriority() {
- return priority;
- }
-
- public String getDescription(boolean label) {
- return description;
- }
-
- public String getHandle() {
- return handle;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public void setHandle(String handle) {
- this.handle = handle;
- }
-
- public void setPriority(String priority) {
- this.priority = priority;
- }
-
- public Image getStatusIcon() {
- return null;
- }
-
- public abstract List<? extends ITaskListElement> getChildren();
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ICategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ICategory.java
new file mode 100644
index 000000000..998ce1f99
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ICategory.java
@@ -0,0 +1,16 @@
+package org.eclipse.mylar.tasklist;
+
+import java.util.List;
+
+
+public interface ICategory extends ITaskListElement {
+
+ public List<ITask> getChildren();
+
+ public void removeTask(ITask task);
+
+ public boolean isArchive();
+
+ public void setIsArchive(boolean isArchive);
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQuery.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQuery.java
new file mode 100644
index 000000000..6614d07e1
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQuery.java
@@ -0,0 +1,16 @@
+package org.eclipse.mylar.tasklist;
+
+import java.util.List;
+
+public interface IQuery extends ITaskListElement{
+
+ public String getQueryString();
+
+ public void setQueryString(String query);
+
+ public List<IQueryHit> getChildren();
+
+ public int getMaxHits();
+
+ public void setMaxHits(int maxHits);
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java
new file mode 100644
index 000000000..f896939f8
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java
@@ -0,0 +1,9 @@
+package org.eclipse.mylar.tasklist;
+
+public interface IQueryHit extends ITaskListElement {
+
+ public ITask getOrCreateCorrespondingTask();
+
+ public abstract boolean hasCorrespondingActivatableTask();
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
index 699cffbfd..e1563ae7f 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
@@ -29,14 +29,6 @@ public interface ITask extends Serializable, ITaskListElement {
public abstract String getPath();
public abstract void setPath(String path);
-
- public abstract String getHandle();
-
- public abstract void setHandle(String id);
-
- public abstract String getLabel();
-
- public abstract void setLabel(String label);
public abstract ITask getParent();
@@ -45,9 +37,7 @@ public interface ITask extends Serializable, ITaskListElement {
public abstract boolean isActive();
public abstract void setActive(boolean active, boolean isStalled);
-
- public abstract boolean isCompleted();
-
+
public abstract void setCompleted(boolean completed);
public abstract RelatedLinks getRelatedLinks();
@@ -67,9 +57,7 @@ public interface ITask extends Serializable, ITaskListElement {
public abstract long getElapsedTimeLong();
public abstract void setElapsedTime(String elapsed);
-
-// public abstract String getEstimatedTimeForDisplay();
-
+
public abstract int getEstimateTime();
public abstract void setEstimatedTime(int estimated);
@@ -79,24 +67,16 @@ public interface ITask extends Serializable, ITaskListElement {
public abstract void addSubTask(ITask t);
public abstract void removeSubTask(ITask t);
-
- public abstract String getToolTipText();
-
- public abstract String getPriority();
-
- public abstract boolean canEditDescription();
public abstract String getDeleteConfirmationMessage();
public abstract void setPriority(String priority);
- public abstract void setCategory(TaskCategory cat);
+ public abstract void setCategory(ICategory cat);
- public abstract TaskCategory getCategory();
+ public abstract ICategory getCategory();
public abstract String getElapsedTimeForDisplay();
-
- public abstract boolean participatesInTaskHandles();
public abstract Date getEndDate();
@@ -125,4 +105,6 @@ public interface ITask extends Serializable, ITaskListElement {
public abstract void setReminded(boolean reminded);
abstract void internalSetCategory(TaskCategory category);
+
+ public abstract boolean participatesInTaskHandles();
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListElement.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListElement.java
index 80ebf5548..cd1799ab6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListElement.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListElement.java
@@ -34,14 +34,11 @@ public interface ITaskListElement {
public abstract String getDescription(boolean label);
+ public abstract void setDescription(String description);
+
public abstract String getHandle();
- /**
- * Used for wrapping bugzilla hits
- */
- public ITask getOrCreateCorrespondingTask();
-
- public abstract boolean hasCorrespondingActivatableTask();
+ public abstract void setHandle(String id);
public abstract boolean isDirectlyModifiable();
@@ -56,4 +53,6 @@ public interface ITaskListElement {
public abstract String getToolTipText();
public abstract boolean isCompleted();
+
+ public abstract String getStringForSortingDescription();
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListExternalizer.java
index 39c9b13db..254f7d4e9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListExternalizer.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListExternalizer.java
@@ -34,12 +34,16 @@ public interface ITaskListExternalizer {
public abstract String getTaskTagName();
- public abstract boolean canCreateElementFor(AbstractCategory category);
+ public abstract boolean canCreateElementFor(ICategory category);
+
+ public abstract boolean canCreateElementFor(IQuery category);
+
+ public abstract Element createQueryElement(IQuery query, Document doc, Element parent);
/**
* @return the element that was created, null if failed
*/
- public abstract Element createCategoryElement(AbstractCategory category, Document doc, Element parent);
+ public abstract Element createCategoryElement(ICategory category, Document doc, Element parent);
public abstract boolean canCreateElementFor(ITask task);
@@ -54,5 +58,5 @@ public interface ITaskListExternalizer {
public abstract boolean canReadTask(Node node);
- public abstract ITask readTask(Node node, TaskList tlist, AbstractCategory category, ITask parent) throws MylarExternalizerException;
+ public abstract ITask readTask(Node node, TaskList tlist, ICategory category, ITask parent) throws MylarExternalizerException;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java
index 0319ff3c6..b0498f990 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java
@@ -55,16 +55,16 @@ public class Task implements ITask {
private String priority = "P3";
private String notes = "";
private int estimatedTime = 0;
-// private String elapsedTime = "";
private boolean completed;
private RelatedLinks links = new RelatedLinks();
- private TaskCategory parentCategory = null;
+ private ICategory parentCategory = null;
private Date timeActivated = null;
private Date endDate = null;
private Date creationDate = null;
private Date reminderDate=null;
private long elapsed;
+
/**
* null if root
*/
@@ -105,13 +105,7 @@ public class Task implements ITask {
public void setHandle(String id) {
this.handle = id;
}
- public String getLabel() {
- return label;
- }
- public void setLabel(String label) {
- this.label = label;
- }
-
+
public ITask getParent() {
return parent;
}
@@ -335,7 +329,7 @@ public class Task implements ITask {
}
}
- public void setCategory(TaskCategory cat) {
+ public void setCategory(ICategory cat) {
this.parentCategory = cat;
if (MylarTasklistPlugin.getDefault() != null) {
MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
@@ -346,7 +340,7 @@ public class Task implements ITask {
this.parentCategory = cat;
}
- public TaskCategory getCategory() {
+ public ICategory getCategory() {
return parentCategory;
}
@@ -355,7 +349,7 @@ public class Task implements ITask {
}
public String getDescription(boolean label) {
- return getLabel();
+ return this.label;
}
public Image getStatusIcon() {
@@ -378,18 +372,10 @@ public class Task implements ITask {
public String getDeleteConfirmationMessage() {
return "Delete the selected task and discard task context?";
}
-
+
public boolean isDirectlyModifiable() {
return true;
}
-
- public ITask getOrCreateCorrespondingTask() {
- return this;
- }
-
- public boolean hasCorrespondingActivatableTask() {
- return true;
- }
public boolean isActivatable() {
return true;
@@ -538,4 +524,12 @@ public class Task implements ITask {
return "";
}
}
+
+ public void setDescription(String description) {
+ this.label = description;
+ }
+
+ public String getStringForSortingDescription() {
+ return getDescription(true);
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java
index 38583f9a5..431a231de 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java
@@ -98,10 +98,14 @@ public class TaskListManager {
taskList.addRootTask(task);
}
- public void addCategory(AbstractCategory cat) {
+ public void addCategory(ICategory cat) {
taskList.addCategory(cat);
}
+ public void addQuery(IQuery cat) {
+ taskList.addQuery(cat);
+ }
+
public void deleteTask(ITask task) {
TaskActiveTimerListener activeListener = listenerMap.remove(task);
if(activeListener != null)
@@ -110,10 +114,14 @@ public class TaskListManager {
taskList.deleteTask(task);
}
- public void deleteCategory(AbstractCategory cat) {
+ public void deleteCategory(ICategory cat) {
taskList.deleteCategory(cat);
}
+ public void deleteQuery(IQuery query) {
+ taskList.deleteQuery(query);
+ }
+
public void addListener(ITaskActivityListener listener) {
listeners.add(listener);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java
index 34aaeb35c..052e02ff4 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DefaultTaskListExternalizer.java
@@ -15,7 +15,8 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.mylar.core.MylarPlugin;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
+import org.eclipse.mylar.tasklist.IQuery;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskListExternalizer;
import org.eclipse.mylar.tasklist.Task;
@@ -59,14 +60,16 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer {
this.externalizers = externalizers;
}
- public boolean canCreateElementFor(AbstractCategory category) {
+ public boolean canCreateElementFor(ICategory category) {
return category instanceof TaskCategory;
}
- public Element createCategoryElement(AbstractCategory category, Document doc, Element parent) {
+ public Element createCategoryElement(ICategory category, Document doc, Element parent) {
+ if(category.isArchive())
+ return parent;
Element node = doc.createElement(getCategoryTagName());
node.setAttribute(NAME, category.getDescription(false));
-
+
for (ITask task : ((TaskCategory)category).getChildren()) {
try {
Element element = null;
@@ -90,7 +93,7 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer {
public Element createTaskElement(ITask task, Document doc, Element parent) {
Element node = doc.createElement(getTaskTagName());
node.setAttribute(PATH, task.getPath());
- node.setAttribute(LABEL, task.getLabel());
+ node.setAttribute(LABEL, task.getDescription(false));
node.setAttribute(HANDLE, task.getHandle());
node.setAttribute(PRIORITY, task.getPriority());
@@ -166,7 +169,7 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer {
return node.getNodeName().equals(getTaskTagName());
}
- public ITask readTask(Node node, TaskList tlist, AbstractCategory category, ITask parent) throws MylarExternalizerException {
+ public ITask readTask(Node node, TaskList tlist, ICategory category, ITask parent) throws MylarExternalizerException {
Element element = (Element) node;
String handle;
String label;
@@ -185,7 +188,7 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer {
return task;
}
- protected void readTaskInfo(ITask task, TaskList tlist, Element element, AbstractCategory category, ITask parent) throws MylarExternalizerException{
+ protected void readTaskInfo(ITask task, TaskList tlist, Element element, ICategory category, ITask parent) throws MylarExternalizerException{
if (element.hasAttribute(PRIORITY)) {
task.setPriority(element.getAttribute(PRIORITY));
} else {
@@ -280,4 +283,15 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer {
public void createRegistry(Document doc, Node parent) {
// nothing to do
}
+
+
+ public boolean canCreateElementFor(IQuery category) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Element createQueryElement(IQuery query, Document doc, Element parent) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java
index 3299b5ab3..c9ea3246a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java
@@ -17,7 +17,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
import org.eclipse.mylar.tasklist.TaskListImages;
@@ -29,16 +29,54 @@ import org.eclipse.swt.graphics.Image;
/**
* @author Mik Kersten
*/
-public class TaskCategory extends AbstractCategory implements Serializable {
+public class TaskCategory implements ICategory, Serializable {
private static final long serialVersionUID = 3834024740813027380L;
private List<ITask> tasks = new ArrayList<ITask>();
- public TaskCategory(String description) {
- super(description);
+ protected String description = "";
+ private String handle = "";
+ private boolean isArchive = false;
+ public TaskCategory(String description) {
+ this.description = description;
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.mylar.tasklist.ICategory#getDescription(boolean)
+ */
+ public String getDescription(boolean label) {
+ return description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.mylar.tasklist.ICategory#getHandle()
+ */
+ public String getHandle() {
+ return handle;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.mylar.tasklist.ICategory#setDescription(java.lang.String)
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.mylar.tasklist.ICategory#setHandle(java.lang.String)
+ */
+ public void setHandle(String handle) {
+ this.handle = handle;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.mylar.tasklist.ICategory#getStatusIcon()
+ */
+ public Image getStatusIcon() {
+ return null;
+ }
+
public Image getIcon() {
return TaskListImages.getImage(TaskListImages.CATEGORY);
}
@@ -64,7 +102,10 @@ public class TaskCategory extends AbstractCategory implements Serializable {
}
}
- void internalAddTask(ITask task) {
+ /**
+ * So it can be used by other externalizers
+ */
+ public void internalAddTask(ITask task) {
tasks.add(task);
}
@@ -131,4 +172,16 @@ public class TaskCategory extends AbstractCategory implements Serializable {
return tasks.size() + " tasks";
}
}
+
+ public boolean isArchive() {
+ return isArchive;
+ }
+
+ public void setIsArchive(boolean isArchive) {
+ this.isArchive = isArchive;;
+ }
+
+ public String getStringForSortingDescription() {
+ return getDescription(true);
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCompleteFilter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCompleteFilter.java
index bd53e2646..f9e09e5ce 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCompleteFilter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCompleteFilter.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.mylar.tasklist.internal;
+import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskFilter;
import org.eclipse.mylar.tasklist.ITaskListElement;
@@ -20,16 +21,24 @@ import org.eclipse.mylar.tasklist.ITaskListElement;
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 (element instanceof ITask) {
+ ITask task = (ITask)element;
+ if (task.isActive()) {
+ return true;
+ }
+ return !task.isCompleted();
+ } else if(element instanceof IQueryHit){
+ if(((IQueryHit)element).hasCorrespondingActivatableTask()){
+ ITask task = ((IQueryHit)element).getOrCreateCorrespondingTask();
if (task.isActive()) {
return true;
}
}
- ITaskListElement t = (ITaskListElement)element;
- return !t.isCompleted();
+ IQueryHit hit = (IQueryHit)element;
+ return !hit.isCompleted();
+ } else if(element instanceof ITaskListElement){
+ ITaskListElement taskElement = (ITaskListElement)element;
+ return !taskElement.isCompleted();
}
return false;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java
index bd716e0bf..82a1ed764 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java
@@ -17,7 +17,9 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
+import org.eclipse.mylar.tasklist.IQuery;
+import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskListElement;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
@@ -31,7 +33,8 @@ public class TaskList implements Serializable {
private static final long serialVersionUID = 3618984485791021105L;
private List<ITask> rootTasks = new ArrayList<ITask>();
- private List<AbstractCategory> categories = new ArrayList<AbstractCategory>();
+ private List<ICategory> categories = new ArrayList<ICategory>();
+ private List<IQuery> queries = new ArrayList<IQuery>();
private transient List<ITask> activeTasks = new ArrayList<ITask>();
public void addRootTask(ITask task) {
@@ -45,20 +48,34 @@ public class TaskList implements Serializable {
rootTasks.add(task);
}
- public void addCategory(AbstractCategory cat) {
+ public void addCategory(ICategory cat) {
categories.add(cat);
if (MylarTasklistPlugin.getDefault() != null) {
MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
+ public void addQuery(IQuery query) {
+ queries.add(query);
+ if (MylarTasklistPlugin.getDefault() != null) {
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
+ }
+ }
+
/**
* XXX Only public so that other externalizers can use it
*/
- public void internalAddCategory(AbstractCategory cat) {
+ public void internalAddCategory(ICategory cat) {
categories.add(cat);
}
+ /**
+ * XXX Only public so that other externalizers can use it
+ */
+ public void internalAddQuery(IQuery query) {
+ queries.add(query);
+ }
+
public void setActive(ITask task, boolean active, boolean isStalled) {
task.setActive(active, isStalled);
if (active && !activeTasks.contains(task)) {
@@ -97,28 +114,48 @@ public class TaskList implements Serializable {
return false;
}
- public void deleteCategory(AbstractCategory category) {
+ public void deleteCategory(ICategory category) {
categories.remove(category);
if (MylarTasklistPlugin.getDefault() != null) {
MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
+ public void deleteQuery(IQuery query) {
+ queries.remove(query);
+ if (MylarTasklistPlugin.getDefault() != null) {
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
+ }
+ }
+
public ITask getTaskForHandle(String handle) {
ITask t = null;
- for (AbstractCategory cat : categories) {
+ for (ICategory cat : categories) {
if ((t = findTaskHelper(cat.getChildren(), handle)) != null) {
return t;
}
}
+ for (IQuery query : queries) {
+ if ((t = findTaskHelper(query.getChildren(), handle)) != null) {
+ return t;
+ }
+ }
return findTaskHelper(rootTasks, handle);
}
private ITask findTaskHelper(List<? extends ITaskListElement> elements, String handle) {
for (ITaskListElement element : elements) {
- if (element.getHandle() == handle && element.hasCorrespondingActivatableTask()) {
- return element.getOrCreateCorrespondingTask();
- }
+ if(element instanceof ITask){
+ if(element.getHandle() == handle)
+ return (ITask)element;
+ } else if(element instanceof IQueryHit){
+ IQueryHit hit = (IQueryHit)element;
+ if (hit.getHandle() == handle && hit.hasCorrespondingActivatableTask()) {
+ return hit.getOrCreateCorrespondingTask();
+ }
+ }
+
+ // for subtasks
if(element instanceof ITask){
ITask searchTask = (ITask)element;
ITask t = findTaskHelper(searchTask.getChildren(), handle);
@@ -138,9 +175,13 @@ public class TaskList implements Serializable {
return rootTasks;
}
- public List<AbstractCategory> getCategories() {
+ public List<ICategory> getCategories() {
return categories;
}
+
+ public List<IQuery> getQueries(){
+ return queries;
+ }
public int findLargestTaskHandle() {
int max = 0;
@@ -171,13 +212,14 @@ public class TaskList implements Serializable {
public List<Object> getRoots() {
List<Object> roots = new ArrayList<Object>();
for (ITask t : rootTasks) roots.add(t);
- for (AbstractCategory cat : categories) roots.add(cat);
+ for (ICategory cat : categories) roots.add(cat);
+ for (IQuery query : queries) roots.add(query);
return roots;
}
public List<TaskCategory> getTaskCategories() {
List<TaskCategory> cats = new ArrayList<TaskCategory>();
- for (AbstractCategory cat : categories) {
+ for (ICategory cat : categories) {
if (cat instanceof TaskCategory) {
cats.add((TaskCategory)cat);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListExternalizer.java
index 44eb9a94d..a55ebaf39 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListExternalizer.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListExternalizer.java
@@ -35,7 +35,8 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.mylar.core.MylarPlugin;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
+import org.eclipse.mylar.tasklist.IQuery;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskHandler;
import org.eclipse.mylar.tasklist.ITaskListExternalizer;
@@ -100,10 +101,11 @@ public class TaskListExternalizer {
externalizer.createRegistry(doc, root);
}
- for (AbstractCategory category : tlist.getCategories()) {
+ for (ICategory category : tlist.getCategories()) {
Element element = null;
for (ITaskListExternalizer externalizer : externalizers) {
- if (externalizer.canCreateElementFor(category)) element = externalizer.createCategoryElement(category, doc, root);
+ if (externalizer.canCreateElementFor(category))
+ element = externalizer.createCategoryElement(category, doc, root);
}
if (element == null && defaultExternalizer.canCreateElementFor(category)) {
defaultExternalizer.createCategoryElement(category, doc, root);
@@ -111,6 +113,19 @@ public class TaskListExternalizer {
MylarPlugin.log("Did not externalize: " + category, this);
}
}
+
+ for (IQuery query: tlist.getQueries()) {
+ Element element = null;
+ for (ITaskListExternalizer externalizer : externalizers) {
+ if (externalizer.canCreateElementFor(query)) element = externalizer.createQueryElement(query, doc, root);
+ }
+ if (element == null && defaultExternalizer.canCreateElementFor(query)) {
+ defaultExternalizer.createQueryElement(query, doc, root);
+ } else if(element == null){
+ MylarPlugin.log("Did not externalize: " + query, this);
+ }
+ }
+
for (ITask task : tlist.getRootTasks()) {
try {
Element element = null;
@@ -189,10 +204,6 @@ public class TaskListExternalizer {
}
}
-// private void writeTask(ITask task, Document doc, Element parent) {
-//
-// }
-
public void readTaskList(TaskList tlist, File inFile) {
initExtensions();
MylarTasklistPlugin.getDefault().restoreTaskHandlerState();
@@ -495,7 +506,7 @@ public class TaskListExternalizer {
externalizer.createRegistry(doc, root);
}
- for (AbstractCategory category : tlist.getCategories()) {
+ for (ICategory category : tlist.getCategories()) {
Element element = null;
for (ITaskListExternalizer externalizer : externalizers) {
if (externalizer.canCreateElementFor(category)) element = externalizer.createCategoryElement(category, doc, root);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/CompletedTaskCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/CompletedTaskCollector.java
index 7724ee301..0a422387b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/CompletedTaskCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/CompletedTaskCollector.java
@@ -11,9 +11,10 @@
package org.eclipse.mylar.tasklist.report.internal;
-import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.mylar.tasklist.ITask;
@@ -22,7 +23,7 @@ import org.eclipse.mylar.tasklist.ITask;
*/
public class CompletedTaskCollector implements ITasksCollector {
- private List<ITask> completedTasks = new ArrayList<ITask>();
+ private Map<String, ITask> completedTasks = new HashMap<String, ITask>();
private Date cutOffDate = null;
private long DAY = 24*3600*1000;
@@ -35,12 +36,12 @@ public class CompletedTaskCollector implements ITasksCollector {
}
public void consumeTask(ITask task) {
- if (task.isCompleted() && task.getEndDate() != null && task.getEndDate().compareTo(cutOffDate) > 0) {
- completedTasks.add(task);
+ if (task.isCompleted() && task.getEndDate() != null && task.getEndDate().compareTo(cutOffDate) > 0 && !completedTasks.containsKey(task.getHandle())) {
+ completedTasks.put(task.getHandle(), task);
}
}
- public List<ITask> getTasks() {
- return completedTasks;
+ public Collection<ITask> getTasks() {
+ return completedTasks.values();
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ITasksCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ITasksCollector.java
index 5197d9d10..86c0a5948 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ITasksCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/ITasksCollector.java
@@ -11,7 +11,7 @@
package org.eclipse.mylar.tasklist.report.internal;
-import java.util.List;
+import java.util.Collection;
import org.eclipse.mylar.tasklist.ITask;
@@ -22,5 +22,5 @@ public interface ITasksCollector {
public abstract void consumeTask(ITask task);
- public abstract List<ITask> getTasks();
+ public abstract Collection<ITask> getTasks();
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java
index bddd1155f..8bc16042c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/internal/TaskReportGenerator.java
@@ -48,16 +48,15 @@ public class TaskReportGenerator {
for (TaskCategory cat : tasklist.getTaskCategories()) {
List<? extends ITaskListElement> sub = cat.getChildren();
for (int j = 0; j < sub.size(); j++) {
- if (sub.get(j) instanceof ITaskListElement) {
- ITaskListElement element = (ITaskListElement) sub.get(j);
- if (element.hasCorrespondingActivatableTask()) {
- for (ITasksCollector collector : collectors) {
- collector.consumeTask(element.getOrCreateCorrespondingTask());
- }
- }
+ if (sub.get(j) instanceof ITask) {
+ ITask element = (ITask) sub.get(j);
+ for (ITasksCollector collector : collectors) {
+ collector.consumeTask(element);
+ }
}
}
}
+
// TODO need to support handling things in the bugzilla registry
for (ITasksCollector collector : collectors) {
tasks.addAll(collector.getTasks());
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameSorter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameSorter.java
index e148e930a..2f8aea521 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameSorter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/report/ui/PlanningGameSorter.java
@@ -65,7 +65,7 @@ public class PlanningGameSorter extends ViewerSorter {
}
private int compareDescription(ITask task1, ITask task2) {
- return task1.getLabel().compareTo(task2.getLabel());
+ return task1.getDescription(false).compareTo(task2.getDescription(false));
}
private int comparePriority(ITask task1, ITask task2) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskEditorInput.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskEditorInput.java
index 244cbdbc5..49613e517 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskEditorInput.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskEditorInput.java
@@ -33,7 +33,7 @@ public class TaskEditorInput implements IEditorInput {
public TaskEditorInput(ITask task) {
this.task = task;
id = task.getHandle();
- label = task.getLabel();
+ label = task.getDescription(true);
}
/* (non-Javadoc)
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java
index ccbef55d8..a3788c30a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java
@@ -158,7 +158,7 @@ public class TaskSummaryEditor extends EditorPart {
public void taskPropertyChanged(ITask updatedTask, String property) {
if (task != null && updatedTask.getHandle().equals(task.getHandle())) {
if (property.equals("Description") && !description.isDisposed()) {
- description.setText(task.getLabel());
+ description.setText(task.getDescription(false));
} else if (property.equals("Path") && !pathText.isDisposed()) {
pathText.setText("<Mylar_Dir>/" + task.getPath());
}
@@ -214,7 +214,7 @@ public class TaskSummaryEditor extends EditorPart {
@Override
public void doSave(IProgressMonitor monitor) {
String label = description.getText();
- task.setLabel(label);
+ task.setDescription(label);
String note = notes.getText();
task.setNotes(note);
task.setEstimatedTime(estimated.getSelection());
@@ -341,11 +341,11 @@ public class TaskSummaryEditor extends EditorPart {
Label l = toolkit.createLabel(container, "Description:");
l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- description = toolkit.createText(container,task.getLabel(), SWT.BORDER);
+ description = toolkit.createText(container, task.getDescription(true), SWT.BORDER);
TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
td.colspan = 2;
description.setLayoutData(td);
- if (!task.canEditDescription()) {
+ if (!task.isDirectlyModifiable()) {
description.setEnabled(false);
} else {
description.addModifyListener(new ModifyListener() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java
index fe7e08ba4..a7d37758b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TasksReminderDialog.java
@@ -243,7 +243,7 @@ public class TasksReminderDialog extends Dialog {
}
private int compareDescription(ITask task1, ITask task2) {
- return task1.getLabel().compareTo(task2.getLabel());
+ return task1.getDescription(false).compareTo(task2.getDescription(false));
}
private int comparePriority(ITask task1, ITask task2) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListLabelProvider.java
index 2a6087949..b5829c08a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListLabelProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListLabelProvider.java
@@ -17,7 +17,8 @@ import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
+import org.eclipse.mylar.tasklist.IQuery;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskListElement;
import org.eclipse.swt.graphics.Color;
@@ -45,7 +46,7 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
case 1:
return "";
case 2:
- if (element instanceof AbstractCategory) {
+ if (element instanceof ICategory || element instanceof IQuery) {
return "";
}
return element.getPriority();
@@ -69,13 +70,13 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
return null;
}
if (columnIndex == 0) {
- if (element instanceof AbstractCategory) {
+ if (element instanceof ICategory || element instanceof IQuery) {
return ((ITaskListElement)element).getIcon();
} else {
return ((ITaskListElement)element).getStatusIcon();
}
} else if (columnIndex == 1) {
- if (element instanceof AbstractCategory) {
+ if (element instanceof ICategory || element instanceof IQuery) {
return null;
}
return ((ITaskListElement)element).getIcon();
@@ -98,7 +99,7 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
// Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle());
// if (highlighter != null) return highlighter.getHighlightColor();
// }
- } else if (element instanceof AbstractCategory) {
+ } else if (element instanceof ICategory || element instanceof IQuery) {
return backgroundColor;
}
return null;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
index b17814a37..bca3f7500 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
@@ -48,7 +48,9 @@ import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.Window;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.dt.MylarWebRef;
-import org.eclipse.mylar.tasklist.AbstractCategory;
+import org.eclipse.mylar.tasklist.ICategory;
+import org.eclipse.mylar.tasklist.IQuery;
+import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskFilter;
import org.eclipse.mylar.tasklist.ITaskHandler;
@@ -334,12 +336,15 @@ public class TaskListView extends ViewPart {
return getFilteredChildrenFor(parent).toArray();
}
public boolean hasChildren(Object parent) {
- if (parent instanceof AbstractCategory) {
- AbstractCategory cat = (AbstractCategory)parent;
+ if (parent instanceof ICategory) {
+ ICategory cat = (ICategory)parent;
return cat.getChildren() != null && cat.getChildren().size() > 0;
} else if (parent instanceof Task) {
Task t = (Task) parent;
return t.getChildren() != null && t.getChildren().size() > 0;
+ } else if (parent instanceof IQuery) {
+ IQuery t = (IQuery) parent;
+ return t.getChildren() != null && t.getChildren().size() > 0;
}
return false;
}
@@ -351,8 +356,14 @@ public class TaskListView extends ViewPart {
if (!filter(list.get(i))) {
filteredRoots.add(list.get(i));
}
- } else if (list.get(i) instanceof AbstractCategory) {
- if (selectCategory((AbstractCategory)list.get(i))) {
+ } else if (list.get(i) instanceof ICategory) {
+ if(((ICategory)list.get(i)).isArchive())
+ continue;
+ if (selectCategory((ICategory)list.get(i))) {
+ filteredRoots.add(list.get(i));
+ }
+ } else if (list.get(i) instanceof IQuery) {
+ if (selectQuery((IQuery)list.get(i))) {
filteredRoots.add(list.get(i));
}
}
@@ -363,7 +374,22 @@ public class TaskListView extends ViewPart {
}
}
- private boolean selectCategory(AbstractCategory cat) {
+ private boolean selectQuery(IQuery 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;
+ }
+
+ private boolean selectCategory(ICategory cat) {
+ if(cat.isArchive())
+ return false;
List<? extends ITaskListElement> list = cat.getChildren();
if (list.size() == 0) {
return true;
@@ -380,8 +406,10 @@ public class TaskListView extends ViewPart {
if (((Text) tree.getFilterControl()).getText() == ""
|| ((Text) tree.getFilterControl()).getText().startsWith(FILTER_LABEL)) {
List<Object> children = new ArrayList<Object>();
- if (parent instanceof AbstractCategory) {
- List<? extends ITaskListElement> list = ((AbstractCategory) parent)
+ if (parent instanceof ICategory) {
+ if(((ICategory)parent).isArchive())
+ return children;
+ List<? extends ITaskListElement> list = ((ICategory) parent)
.getChildren();
for (int i = 0; i < list.size(); i++) {
if (!filter(list.get(i))) {
@@ -389,7 +417,16 @@ public class TaskListView extends ViewPart {
}
}
return children;
- } else if (parent instanceof Task) {
+ } else if (parent instanceof IQuery) {
+ List<? extends ITaskListElement> list = ((IQuery) 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)) {
@@ -400,10 +437,13 @@ public class TaskListView extends ViewPart {
}
} else {
List<Object> children = new ArrayList<Object>();
- if (parent instanceof AbstractCategory) {
- children.addAll(((AbstractCategory) parent).getChildren());
+ if (parent instanceof ICategory) {
+ children.addAll(((ICategory) parent).getChildren());
return children;
- } else if (parent instanceof Task) {
+ } else if (parent instanceof IQuery) {
+ children.addAll(((IQuery) parent).getChildren());
+ return children;
+ }else if (parent instanceof Task) {
children.addAll(((Task) parent).getChildren());
return children;
}
@@ -469,8 +509,12 @@ public class TaskListView extends ViewPart {
if (element instanceof ITaskListElement) {
final ITaskListElement taskListElement = (ITaskListElement)element;
ITask task = null;
- if(taskListElement.hasCorrespondingActivatableTask()){
- task = taskListElement.getOrCreateCorrespondingTask();
+ if(taskListElement instanceof ITask){
+ task = (ITask) taskListElement;
+ } else if(taskListElement instanceof IQueryHit){
+ if(((IQueryHit)taskListElement).hasCorrespondingActivatableTask()){
+ task = ((IQueryHit)taskListElement).getOrCreateCorrespondingTask();
+ }
}
switch (columnIndex) {
case 0:
@@ -487,8 +531,20 @@ public class TaskListView extends ViewPart {
case 3:
return taskListElement.getDescription(true);
}
- } else if (element instanceof AbstractCategory) {
- AbstractCategory cat = (AbstractCategory) element;
+ } else if (element instanceof ICategory) {
+ ICategory cat = (ICategory) element;
+ switch (columnIndex) {
+ case 0:
+ return new Boolean(false);
+ case 1:
+ return "";
+ case 2:
+ return "";
+ case 3:
+ return cat.getDescription(true);
+ }
+ }else if (element instanceof IQuery) {
+ IQuery cat = (IQuery) element;
switch (columnIndex) {
case 0:
return new Boolean(false);
@@ -510,8 +566,23 @@ public class TaskListView extends ViewPart {
int columnIndex = -1;
try {
columnIndex = Arrays.asList(columnNames).indexOf(property);
- if (((TreeItem) element).getData() instanceof AbstractCategory) {
- AbstractCategory cat = (AbstractCategory)((TreeItem) element).getData();
+ if (((TreeItem) element).getData() instanceof ICategory) {
+ ICategory cat = (ICategory)((TreeItem) element).getData();
+ switch (columnIndex) {
+ case 0:
+// getViewer().setSelection(null);
+ break;
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ cat.setDescription(((String) value).trim());
+// getViewer().setSelection(null);
+ break;
+ }
+ } else if (((TreeItem) element).getData() instanceof IQuery) {
+ IQuery cat = (IQuery)((TreeItem) element).getData();
switch (columnIndex) {
case 0:
// getViewer().setSelection(null);
@@ -529,12 +600,18 @@ public class TaskListView extends ViewPart {
final ITaskListElement taskListElement = (ITaskListElement) ((TreeItem) element).getData();
ITask task = null;
- if(taskListElement.hasCorrespondingActivatableTask()){
- task = taskListElement.getOrCreateCorrespondingTask();
+ if(taskListElement instanceof ITask){
+ task = (ITask) taskListElement;
+ } else if(taskListElement instanceof IQueryHit){
+ if(((IQueryHit)taskListElement).hasCorrespondingActivatableTask()){
+ task = ((IQueryHit)taskListElement).getOrCreateCorrespondingTask();
+ }
}
switch (columnIndex) {
case 0:
- task = taskListElement.getOrCreateCorrespondingTask();
+ if(taskListElement instanceof IQueryHit){
+ task = ((IQueryHit)taskListElement).getOrCreateCorrespondingTask();
+ }
if (task != null) {
if (task.isActive()) {
new TaskDeactivateAction(task, INSTANCE).run();
@@ -556,7 +633,7 @@ public class TaskListView extends ViewPart {
break;
case 3:
if (task.isDirectlyModifiable()) {
- task.setLabel(((String) value).trim());
+ task.setDescription(((String) value).trim());
MylarTasklistPlugin.getTaskListManager()
.taskPropertyChanged(task, columnNames[3]);
// getViewer().setSelection(null);
@@ -598,24 +675,24 @@ public class TaskListView extends ViewPart {
*/
@Override
public int compare(Viewer compareViewer, Object o1, Object o2) {
- if (o1 instanceof AbstractCategory) {
- if (o2 instanceof AbstractCategory) {
- return ((AbstractCategory)o1).getDescription(false).compareTo(
- ((AbstractCategory)o2).getDescription(false));
+ if (o1 instanceof ICategory || o1 instanceof IQuery) {
+ if (o2 instanceof ICategory|| o2 instanceof IQuery) {
+ return ((ITaskListElement)o1).getDescription(false).compareTo(
+ ((ITaskListElement)o2).getDescription(false));
} else {
return -1;
}
} else if(o1 instanceof ITaskListElement){
- if (o2 instanceof AbstractCategory) {
+ if (o2 instanceof ICategory || o2 instanceof IQuery) {
return -1;
} else if(o2 instanceof ITaskListElement) {
ITaskListElement element1 = (ITaskListElement) o1;
ITaskListElement element2 = (ITaskListElement) o2;
- if (element1.isCompleted() && element2.isCompleted()) {
- return element1.getPriority().compareTo(element2.getPriority());
- }
- if (element1.isCompleted()) return 1;
- if (element2.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();
@@ -628,7 +705,14 @@ public class TaskListView extends ViewPart {
} else if (column == columnNames[2]) {
return element1.getPriority().compareTo(element2.getPriority());
} else if (column == columnNames[3]) {
- return element1.getDescription(true).compareTo(element2.getDescription(true));
+ String c1 = element1.getStringForSortingDescription();
+ String c2 = element2.getStringForSortingDescription();
+ try{
+ return new Integer(c1).compareTo(new Integer(c2));
+ } catch (Exception e){}
+
+ return c1.compareTo(c2);
+
} else {
return 0;
}
@@ -1039,15 +1123,21 @@ public class TaskListView extends ViewPart {
} else if(action instanceof RenameAction){
action.setEnabled(true);
}
- } else if(element instanceof TaskCategory) {
+ } else if(element instanceof ICategory) {
if(action instanceof MarkTaskCompleteAction){
action.setEnabled(false);
} else if(action instanceof MarkTaskIncompleteAction){
action.setEnabled(false);
} else if(action instanceof DeleteAction){
- action.setEnabled(true);
+ if(((ICategory)element).isArchive())
+ action.setEnabled(false);
+ else
+ action.setEnabled(true);
} else if(action instanceof CreateTaskAction){
- action.setEnabled(true);
+ if(((ICategory)element).isArchive())
+ action.setEnabled(false);
+ else
+ action.setEnabled(true);
} else if(action instanceof GoIntoAction){
TaskCategory cat = (TaskCategory) element;
if(cat.getChildren().size() > 0){
@@ -1060,7 +1150,10 @@ public class TaskListView extends ViewPart {
} else if(action instanceof CopyDescriptionAction){
action.setEnabled(true);
} else if(action instanceof RenameAction){
- action.setEnabled(true);
+ if(((ICategory)element).isArchive())
+ action.setEnabled(false);
+ else
+ action.setEnabled(true);
}
} else {
action.setEnabled(true);

Back to the top