Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-06-29 18:46:52 -0400
committermkersten2005-06-29 18:46:52 -0400
commit511f3d313ba97192aa52383783b65536be59e780 (patch)
treeb628fd9940b3113ab714bd3f601d25d8f44379a8 /org.eclipse.mylyn.tasks.ui
parent33af02ad21255c099d31a324f5b60098b8d2e80b (diff)
downloadorg.eclipse.mylyn.tasks-511f3d313ba97192aa52383783b65536be59e780.tar.gz
org.eclipse.mylyn.tasks-511f3d313ba97192aa52383783b65536be59e780.tar.xz
org.eclipse.mylyn.tasks-511f3d313ba97192aa52383783b65536be59e780.zip
Ken's patch for: Bugzilla Bug 101911
Support bugzilla queries
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java60
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java62
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java133
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java28
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java28
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java (renamed from org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java)29
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java54
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java138
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java225
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java69
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java303
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java50
16 files changed, 1008 insertions, 201 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java
new file mode 100644
index 000000000..23c823b42
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Ken Sueda
+ */
+public class AbstractCategory implements ITaskListElement {
+
+ private String priority = "";
+ private String description = "";
+ private String handle = "";
+
+ public AbstractCategory(String description) {
+ this.description = description;
+ }
+
+ public Image getTypeIcon() {
+ return null;
+ }
+
+ public String getPriority() {
+ return priority;
+ }
+
+ public String getDescription() {
+ 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;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java
new file mode 100644
index 000000000..79320b426
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.mylar.bugzilla.BugzillaImages;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Ken Sueda
+ */
+public class BugzillaHit implements ITaskListElement {
+
+ private String description;
+ private String priority;
+ private int id;
+
+ public BugzillaHit(String description, String priority, int id) {
+ this.description = description;
+ this.priority = priority;
+ this.id = id;
+ }
+ public Image getTypeIcon() {
+ return BugzillaImages.getImage(BugzillaImages.BUG);
+ }
+
+ public Image getStatusIcon() {
+ return null;
+ }
+
+ public String getPriority() {
+ return priority;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getHandle() {
+ return getServerName()+"-"+getID();
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public String getServerName() {
+ // TODO need the right server name - get from the handle
+ return "<UNKNOWN>";
+ }
+ public int getID() {
+
+ return id;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java
new file mode 100644
index 000000000..68972d967
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.security.auth.login.LoginException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.mylar.bugzilla.BugzillaPlugin;
+import org.eclipse.mylar.bugzilla.IBugzillaConstants;
+import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit;
+import org.eclipse.mylar.tasks.bugzilla.search.BugzillaCategorySearchOperation;
+import org.eclipse.mylar.tasks.bugzilla.search.BugzillaResultCollector;
+import org.eclipse.mylar.tasks.bugzilla.search.BugzillaCategorySearchOperation.ICategorySearchListener;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Shawn Minto
+ */
+public class BugzillaQueryCategory extends AbstractCategory {
+
+ private static final long serialVersionUID = 5517146402031743253L;
+ private String url;
+ private List<BugzillaHit> hits = new ArrayList<BugzillaHit>();
+
+ public class BugzillaQueryCategorySearchListener implements
+ ICategorySearchListener {
+
+ Map<Integer, BugzillaSearchHit> hits = new HashMap<Integer, BugzillaSearchHit>();
+
+ public void searchCompleted(BugzillaResultCollector collector) {
+
+ for(BugzillaSearchHit hit: collector.getResults()){
+
+ // HACK need the server name and handle properly
+ addHit(new BugzillaHit(hit.getDescription(), hit.getPriority(), hit.getId()));
+ }
+ }
+
+ }
+
+ private ICategorySearchListener listener = new BugzillaQueryCategorySearchListener();
+
+ public BugzillaQueryCategory(String label, String url) {
+ super(label);
+ this.url = url;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public List<BugzillaHit> getHits() {
+ return hits;
+ }
+
+ public void addHit(BugzillaHit hit) {
+ hits.add(hit);
+ }
+
+ public void removeHit(BugzillaHit hit) {
+ hits.remove(hit);
+ }
+
+ public void refreshBugs() {
+ hits.clear();
+ final BugzillaCategorySearchOperation catSearch = new BugzillaCategorySearchOperation(
+ getUrl());
+ catSearch.addResultsListener(listener);
+ final IStatus[] status = new IStatus[1];
+
+ try {
+ // execute the search operation
+ catSearch.execute(new NullProgressMonitor());
+
+ // get the status of the search operation
+ status[0] = catSearch.getStatus();
+
+ // determine if there was an error, if it was cancelled, or if it is
+ // ok
+ if (status[0].getCode() == IStatus.CANCEL) {
+ // it was cancelled, so just return
+ status[0] = Status.OK_STATUS;
+ // return status[0];
+ return;
+ } else if (!status[0].isOK()) {
+ // there was an error, so display an error message
+ PlatformUI.getWorkbench().getDisplay().asyncExec(
+ new Runnable() {
+ public void run() {
+ ErrorDialog.openError(null,
+ "Bugzilla Search Error", null,
+ status[0]);
+ }
+ });
+ status[0] = Status.OK_STATUS;
+ return;
+ // return status[0];
+ }
+ } catch (LoginException e) {
+ // we had a problem while searching that seems like a login info
+ // problem
+ // thrown in BugzillaSearchOperation
+ MessageDialog
+ .openError(
+ null,
+ "Login Error",
+ "Bugzilla could not log you in to get the information you requested since login name or password is incorrect.\nPlease check your settings in the bugzilla preferences. ");
+ BugzillaPlugin.log(new Status(IStatus.ERROR,
+ IBugzillaConstants.PLUGIN_ID, IStatus.OK, "", e));
+ }
+ return;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java
index f3af722dd..f1e5097e7 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java
@@ -36,6 +36,8 @@ import org.eclipse.mylar.bugzilla.offlineReports.OfflineReportsFile;
import org.eclipse.mylar.bugzilla.ui.OfflineView;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput;
+import org.eclipse.mylar.ui.MylarImages;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
@@ -456,4 +458,8 @@ public class BugzillaTask extends Task {
}
return -1;
}
+
+ public Image getTypeIcon() {
+ return MylarImages.getImage(MylarImages.TASK_BUGZILLA);
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
index cb8f5ed0e..7380741d2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java
@@ -91,7 +91,7 @@ public interface ITask extends Serializable {
@Deprecated
public abstract void setIsCategory(boolean b);
- public abstract void setCategory(Category cat);
+ public abstract void setCategory(TaskCategory cat);
- public abstract Category getCategory();
+ public abstract TaskCategory getCategory();
} \ No newline at end of file
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
new file mode 100644
index 000000000..a28ff0215
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Ken Sueda
+ */
+public interface ITaskListElement {
+ public abstract Image getTypeIcon();
+
+ public abstract Image getStatusIcon();
+
+ public abstract String getPriority();
+
+ public abstract String getDescription();
+
+ public abstract String getHandle();
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
index 74f8ab867..47fadb95d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java
@@ -19,6 +19,8 @@ import java.util.List;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.ui.TaskEditorInput;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
+import org.eclipse.mylar.ui.MylarImages;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
@@ -28,7 +30,7 @@ import org.eclipse.ui.internal.Workbench;
/**
* @author Mik Kersten
*/
-public class Task implements ITask {
+public class Task implements ITask, ITaskListElement {
private static final long serialVersionUID = 3545518391537382197L;
private boolean active = false;
@@ -48,7 +50,7 @@ public class Task implements ITask {
private String elapsedTime = "";
private boolean completed;
private RelatedLinks links = new RelatedLinks();
- private Category parentCategory = null;
+ private TaskCategory parentCategory = null;
/**
* null if root
@@ -237,7 +239,6 @@ public class Task implements ITask {
}
public String getElapsedTime() {
- // TODO: removed check for null once xml updated.
if (elapsedTime == null) {
elapsedTime = "";
}
@@ -249,7 +250,6 @@ public class Task implements ITask {
}
public String getEstimatedTime() {
- // TODO: removed check for null once xml updated.
if (estimatedTime == null) {
estimatedTime = "";
}
@@ -272,11 +272,27 @@ public class Task implements ITask {
children.remove(t);
}
- public void setCategory(Category cat) {
+ public void setCategory(TaskCategory cat) {
this.parentCategory = cat;
}
- public Category getCategory() {
+ public TaskCategory getCategory() {
return parentCategory;
}
+
+ public Image getTypeIcon() {
+ return MylarImages.getImage(MylarImages.TASK);
+ }
+
+ public String getDescription() {
+ return getLabel();
+ }
+
+ public Image getStatusIcon() {
+ if (isActive()) {
+ return MylarImages.getImage(MylarImages.TASK_ACTIVE);
+ } else {
+ return MylarImages.getImage(MylarImages.TASK_INACTIVE);
+ }
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java
index 329b6f367..03ecdc3a9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Category.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java
@@ -21,15 +21,14 @@ import java.util.List;
/**
* @author Mik Kersten
*/
-public class Category implements Serializable {
+public class TaskCategory extends AbstractCategory implements Serializable {
private static final long serialVersionUID = 3834024740813027380L;
private List<ITask> tasks = new ArrayList<ITask>();
- private String name = "";
- public Category(String name) {
- this.name = name;
+ public TaskCategory(String description) {
+ super(description);
}
public void addTask(ITask task) {
@@ -40,28 +39,16 @@ public class Category implements Serializable {
tasks.remove(task);
}
- public List<ITask> getTasks() {
+ public List<ITask> getChildren() {
return tasks;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public String getName() {
- return name;
- }
- public void setName(String label) {
- this.name = label;
- }
+ }
@Override
public boolean equals(Object object) {
if (object == null) return false;
- if (object instanceof Category) {
- Category compare = (Category)object;
- return this.getName().equals(compare.getName());
+ if (object instanceof TaskCategory) {
+ TaskCategory compare = (TaskCategory)object;
+ return this.getDescription().equals(compare.getDescription());
} else {
return false;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
index acaaa6708..37e48da0b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java
@@ -26,14 +26,14 @@ public class TaskList implements Serializable {
private static final long serialVersionUID = 3618984485791021105L;
private List<ITask> rootTasks = new ArrayList<ITask>();
- private List<Category> categories = new ArrayList<Category>();
+ private List<AbstractCategory> categories = new ArrayList<AbstractCategory>();
private transient List<ITask> activeTasks = new ArrayList<ITask>();
public void addRootTask(ITask task) {
- rootTasks.add(task);
+ rootTasks.add(task);
}
- public void addCategory(Category cat) {
+ public void addCategory(AbstractCategory cat) {
categories.add(cat);
}
@@ -49,14 +49,13 @@ public class TaskList implements Serializable {
public void deleteTask(ITask task) {
boolean deleted = deleteTaskHelper(rootTasks, task);
if (!deleted) {
- for (Category cat : categories) {
- deleted = deleteTaskHelper(cat.getTasks(), task);
- if (deleted) {
- return;
- }
- }
+ for (TaskCategory cat : getTaskCategories()) {
+ deleted = deleteTaskHelper(cat.getChildren(), task);
+ if (deleted) {
+ return;
+ }
+ }
}
-
}
private boolean deleteTaskHelper(List<ITask> tasks, ITask t) {
@@ -72,10 +71,7 @@ public class TaskList implements Serializable {
return false;
}
- public void deleteCategory(Category category) {
- if (category != null) {
- category.getTasks().clear();
- }
+ public void deleteCategory(AbstractCategory category) {
categories.remove(category);
}
/**
@@ -83,11 +79,11 @@ public class TaskList implements Serializable {
*/
public ITask getTaskForId(String id) {
ITask t = null;
- for (Category cat : categories) {
- if ( (t = findTaskHelper(cat.getTasks(), id)) != null) {
- return t;
- }
- }
+ for (TaskCategory cat : getTaskCategories()) {
+ if ((t = findTaskHelper(cat.getChildren(), id)) != null) {
+ return t;
+ }
+ }
return findTaskHelper(rootTasks, id);
}
@@ -112,15 +108,15 @@ public class TaskList implements Serializable {
return rootTasks;
}
- public List<Category> getCategories() {
+ public List<AbstractCategory> getCategories() {
return categories;
}
public int findLargestTaskHandle() {
int max = 0;
max = Math.max(largestTaskHandleHelper(rootTasks), max);
- for (Category cat : categories) {
- max = Math.max(largestTaskHandleHelper(cat.getTasks()), max);
+ for (TaskCategory cat : getTaskCategories()) {
+ max = Math.max(largestTaskHandleHelper(cat.getChildren()), max);
}
return max;
}
@@ -146,14 +142,24 @@ public class TaskList implements Serializable {
for (ITask t : rootTasks) {
roots.add(t);
}
- for (Category cat : categories) {
+ for (AbstractCategory cat : categories) {
roots.add(cat);
}
return roots;
}
public void createCategory(String description) {
- Category c = new Category(description);
+ TaskCategory c = new TaskCategory(description);
categories.add(c);
}
+
+ public List<TaskCategory> getTaskCategories() {
+ List<TaskCategory> cats = new ArrayList<TaskCategory>();
+ for (AbstractCategory cat : categories) {
+ if (cat instanceof TaskCategory) {
+ cats.add((TaskCategory)cat);
+ }
+ }
+ return cats;
+ }
}
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 02cb72bab..b1dd5f9b0 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
@@ -89,7 +89,7 @@ public class TaskListManager {
taskList.deleteTask(task);
}
- public void deleteCategory(Category cat) {
+ public void deleteCategory(AbstractCategory cat) {
taskList.deleteCategory(cat);
}
@@ -117,8 +117,8 @@ public class TaskListManager {
public void updateTaskscapeReference(String prevDir) {
List<ITask> rootTasks = this.getTaskList().getRootTasks();
- for (Category cat : taskList.getCategories()) {
- updateTaskscapeReferenceHelper(cat.getTasks(), prevDir);
+ for (TaskCategory cat : taskList.getTaskCategories()) {
+ updateTaskscapeReferenceHelper(cat.getChildren(), prevDir);
}
updateTaskscapeReferenceHelper(rootTasks, prevDir);
@@ -156,4 +156,8 @@ public class TaskListManager {
}
this.file = f;
}
+
+ public void activateHit(BugzillaHit hit) {
+
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java
new file mode 100644
index 000000000..5fd74e240
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+/*
+ * Created on Oct 14, 2004
+ */
+package org.eclipse.mylar.tasks.bugzilla.search;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.login.LoginException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylar.bugzilla.search.BugzillaSearchEngine;
+import org.eclipse.mylar.bugzilla.search.BugzillaSearchQuery;
+import org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation;
+import org.eclipse.mylar.core.MylarPlugin;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+
+/**
+ * Bugzilla search operation for Mylar
+ *
+ * @author Shawn Minto
+ */
+public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
+ implements IBugzillaSearchOperation {
+ /** The IMember we are doing the search for */
+
+ public interface ICategorySearchListener {
+ public void searchCompleted(BugzillaResultCollector collector);
+ }
+
+ /** The bugzilla collector for the search */
+ private BugzillaResultCollector collector = null;
+
+ /** The status of the search operation */
+ private IStatus status;
+
+ /** The LoginException that was thrown when trying to do the search */
+ private LoginException loginException = null;
+
+ private String url;
+
+ /**
+ * Constructor
+ *
+ * @param m
+ * The member that we are doing the search for
+ */
+ public BugzillaCategorySearchOperation(String url) {
+ this.url = url;
+ }
+
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ collector = new BugzillaResultCollector();
+ collector.setOperation(this);
+ collector.setProgressMonitor(monitor);
+ search(url, monitor);
+ for(ICategorySearchListener listener: listeners)
+ listener.searchCompleted(collector);
+ }
+
+ /**
+ * Perform the actual search on the Bugzilla server
+ * @param url The url to use for the search
+ * @param searchCollector The collector to put the search results into
+ * @param monitor The progress monitor to use for the search
+ * @return The BugzillaResultCollector with the search results
+ */
+ private BugzillaResultCollector search(String url, IProgressMonitor monitor){
+
+ // set the initial number of matches to 0
+ int matches = 0;
+ // setup the progress monitor and start the search
+ collector.setProgressMonitor(monitor);
+ BugzillaSearchEngine engine = new BugzillaSearchEngine(url);
+ try {
+
+ // perform the search
+ status = engine.search(collector, matches);
+
+ // check the status so that we don't keep searching if there
+ // is a problem
+ if (status.getCode() == IStatus.CANCEL) {
+ MylarPlugin.log("search cancelled", this);
+ return null;
+ } else if (!status.isOK()) {
+ MylarPlugin.log("search error", this);
+ MylarPlugin.log(status);
+ return null;
+ }
+ return collector;
+ } catch (LoginException e) {
+ //save this exception to throw later
+ this.loginException = e;
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getStatus()
+ */
+ public IStatus getStatus() throws LoginException {
+ // if a LoginException was thrown while trying to search, throw this
+ if (loginException == null)
+ return status;
+ else
+ throw loginException;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ public BugzillaSearchQuery getQuery() {
+ return null;
+ }
+
+ public void setQuery(BugzillaSearchQuery newQuery) {}
+
+ private List<ICategorySearchListener> listeners = new ArrayList<ICategorySearchListener>();
+
+ public void addResultsListener(ICategorySearchListener listener){
+ listeners.add(listener);
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java
index bd8b093e9..f1396a849 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java
@@ -36,7 +36,7 @@ import org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.BugzillaTask;
import org.eclipse.mylar.tasks.ITask;
-import org.eclipse.mylar.tasks.Category;
+import org.eclipse.mylar.tasks.TaskCategory;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
import org.eclipse.mylar.tasks.bugzilla.StackTrace;
@@ -159,8 +159,8 @@ public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation
// get all of the root tasks and start the search
List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
searchLocal(tasks, collector, elementName, monitor);
- for (Category cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
- searchLocal(cat.getTasks(), collector, elementName, monitor);
+ for (TaskCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getTaskCategories()) {
+ searchLocal(cat.getChildren(), collector, elementName, monitor);
}
// return the collector
@@ -185,8 +185,8 @@ public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation
// get all of the root tasks and start the search
List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
searchLocal(tasks, collector, elementName, monitor);
- for (Category cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
- searchLocal(cat.getTasks(), collector, elementName, monitor);
+ for (TaskCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getTaskCategories()) {
+ searchLocal(cat.getChildren(), collector, elementName, monitor);
}
// return the collector
return collector;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java
new file mode 100644
index 000000000..98dd92c65
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * 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.ui.views;
+
+import java.io.UnsupportedEncodingException;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.mylar.bugzilla.saveQuery.GetQueryDialog;
+import org.eclipse.mylar.bugzilla.saveQuery.SaveQueryDialog;
+import org.eclipse.mylar.bugzilla.search.BugzillaSearchPage;
+import org.eclipse.search.ui.ISearchPageContainer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkingSet;
+
+/**
+ * @author Shawn Minto
+ */
+public class BugzillaQueryDialog extends Dialog {
+
+ private String url;
+ private String name;
+ private BugzillaSearchOptionPage searchOptionPage;
+
+ BugzillaQueryDialog(Shell parentShell) {
+ super(parentShell);
+ searchOptionPage = new BugzillaSearchOptionPage();
+
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ searchOptionPage.createControl(parent);
+ searchOptionPage.setVisible(true); // called to initialize the values
+ return super.createContents(parent);
+ }
+
+ @Override
+ protected void okPressed(){
+ url = searchOptionPage.getSearchURL();
+ if(url == null || url.equals("")){
+ /*
+ * Should never get here. Every implementation of the Java platform is required
+ * to support the standard charset "UTF-8"
+ */
+ return;
+ }
+ InputDialog getNameDialog = new InputDialog(Display.getCurrent().getActiveShell(), "Bugzilla Query Category Name", "Please enter a name for the bugzilla query category","", new IInputValidator(){
+
+ public String isValid(String newText) {
+ if(newText != null && !newText.equals("")){
+ return null;
+ } else {
+ return "You must enter a name for the category";
+ }
+ }
+
+ });
+ getNameDialog.setBlockOnOpen(true);
+ if(getNameDialog.open() == InputDialog.OK){
+ name = getNameDialog.getValue();
+
+ super.okPressed();
+ } else {
+ super.cancelPressed();
+ }
+ }
+
+ private class BugzillaSearchOptionPage extends BugzillaSearchPage{
+
+ public BugzillaSearchOptionPage(){
+ scontainer = new ISearchPageContainer(){
+ public ISelection getSelection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IRunnableContext getRunnableContext() {
+ return null;
+ }
+
+ public void setPerformActionEnabled(boolean state) {
+ Button ok = BugzillaQueryDialog.this.getButton(Dialog.OK);
+ if(ok != null)
+ ok.setEnabled(state);
+ }
+
+ public int getSelectedScope() {
+ return 0;
+ }
+
+ public void setSelectedScope(int scope) {}
+
+ public boolean hasValidScope() {
+ return true;
+ }
+
+ public IWorkingSet[] getSelectedWorkingSets() {
+ return null;
+ }
+
+ public void setSelectedWorkingSets(IWorkingSet[] workingSets) {}
+ };
+ }
+
+ public String getSearchURL() {
+ try{
+ if(rememberedQuery){
+ return getQueryURL(new StringBuffer(input.getQueryParameters(selIndex)));
+ } else {
+ return getQueryURL(getQueryParameters());
+ }
+ } catch (UnsupportedEncodingException e){
+ /*
+ * Do nothing. Every implementation of the Java platform is required
+ * to support the standard charset "UTF-8"
+ */
+ }
+ return "";
+ }
+
+ @Override
+ protected Control createSaveQuery(Composite control) {
+ GridLayout layout;
+ GridData gd;
+
+ Group group = new Group(control, SWT.NONE);
+ layout = new GridLayout(3, false);
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ gd = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ group.setLayoutData(gd);
+
+ loadButton = new Button(group, SWT.PUSH | SWT.LEFT);
+ loadButton.setText("Saved Queries...");
+ loadButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ GetQueryDialog qd = new GetQueryDialog(getShell(),
+ "Saved Queries", input){
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ Button okButton = super.getButton(IDialogConstants.OK_ID);
+ if(okButton != null)
+ okButton.setText("Select");
+ }
+ };
+
+ if (qd.open() == InputDialog.OK) {
+ selIndex = qd.getSelected();
+ if (selIndex != -1) {
+ rememberedQuery = true;
+ }
+ } else {
+ rememberedQuery = false;
+ }
+ }
+ });
+ loadButton.setEnabled(true);
+ loadButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ saveButton = new Button(group, SWT.PUSH | SWT.LEFT);
+ saveButton.setText("Remember...");
+ saveButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ SaveQueryDialog qd = new SaveQueryDialog(getShell(),
+ "Remember Query");
+ if (qd.open() == InputDialog.OK) {
+ String qName = qd.getText();
+ if (qName != null && qName.compareTo("") != 0) {
+ try {
+ input.add(getQueryParameters().toString(), qName, summaryPattern.getText());
+ }
+ catch (UnsupportedEncodingException e) {
+ /*
+ * Do nothing. Every implementation of the Java platform is required
+ * to support the standard charset "UTF-8"
+ */
+ }
+ }
+ }
+ }
+ });
+ saveButton.setEnabled(true);
+ saveButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ return group;
+ }
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java
index 1f990775b..ac18a5ef8 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java
@@ -17,10 +17,10 @@ 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.tasks.BugzillaTask;
-import org.eclipse.mylar.tasks.Category;
+import org.eclipse.mylar.tasks.AbstractCategory;
import org.eclipse.mylar.tasks.ITask;
-import org.eclipse.mylar.ui.MylarImages;
+import org.eclipse.mylar.tasks.ITaskListElement;
+import org.eclipse.mylar.tasks.TaskCategory;
import org.eclipse.mylar.ui.MylarUiPlugin;
import org.eclipse.mylar.ui.internal.UiUtil;
import org.eclipse.mylar.ui.internal.views.Highlighter;
@@ -36,30 +36,23 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
private Color backgroundColor = null;
public String getColumnText(Object obj, int columnIndex) {
- if (obj instanceof ITask) {
- ITask task = (ITask) obj;
- switch (columnIndex) {
- case 0: return ""; // padding for background
- case 1: return "";
- case 2: return task.getPriority();
- case 3:
- return task.getLabel();
- case 4:
- return task.getHandle();
- }
- } else if (obj instanceof Category) {
- Category cat = (Category) obj;
- switch (columnIndex) {
- case 0: return ""; // padding for background
- case 1: return "";
- case 2: return "";
- case 3:
- return cat.getName();
- case 4:
- return "";
- }
- }
- return null;
+ if (obj instanceof ITaskListElement) {
+ ITaskListElement element = (ITaskListElement) obj;
+ switch (columnIndex) {
+ case 0:
+ return "";
+ case 1:
+ return "";
+ case 2:
+ return element.getPriority();
+ case 3:
+ return element.getDescription();
+ case 4:
+ return element.getHandle();
+ }
+ }
+ System.out.println("Not TaskListElement");
+ return "";
}
public Font getFont(Object element) {
@@ -71,9 +64,9 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
if (child.isActive())
return UiUtil.BOLD;
}
- } else if (element instanceof Category) {
- Category cat = (Category) element;
- for (ITask child : cat.getTasks()) {
+ } else if (element instanceof TaskCategory) {
+ TaskCategory cat = (TaskCategory) element;
+ for (ITask child : cat.getChildren()) {
if (child.isActive())
return UiUtil.BOLD;
}
@@ -83,21 +76,13 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
public Image getColumnImage(Object element, int columnIndex) {
- if (!(element instanceof ITask)) {
+ if (! (element instanceof ITaskListElement)) {
return null;
}
if (columnIndex == 0) {
- if (((ITask) element).isActive()) {
- return MylarImages.getImage(MylarImages.TASK_ACTIVE);
- } else {
- return MylarImages.getImage(MylarImages.TASK_INACTIVE);
- }
+ return ((ITaskListElement)element).getStatusIcon();
} else if (columnIndex == 1) {
- if (element instanceof BugzillaTask) {
- return MylarImages.getImage(MylarImages.TASK_BUGZILLA);
- } else {
- return MylarImages.getImage(MylarImages.TASK);
- }
+ return ((ITaskListElement)element).getTypeIcon();
} else {
return null;
}
@@ -108,7 +93,7 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
ITask task = (ITask)element;
Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle());
if (highlighter != null) return highlighter.getHighlightColor();
- } else if (element instanceof Category) {
+ } else if (element instanceof AbstractCategory) {
return backgroundColor;
}
return null;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
index 24a130996..e609d876c 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
@@ -31,6 +31,7 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CellEditor;
@@ -40,9 +41,11 @@ import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.TreeViewer;
@@ -53,14 +56,20 @@ import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.Window;
import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure;
+import org.eclipse.mylar.bugzilla.ui.ViewBugzillaAction;
import org.eclipse.mylar.core.ITaskscapeListener;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.dt.MylarWebRef;
+import org.eclipse.mylar.tasks.AbstractCategory;
+import org.eclipse.mylar.tasks.BugzillaHit;
+import org.eclipse.mylar.tasks.BugzillaQueryCategory;
import org.eclipse.mylar.tasks.BugzillaTask;
-import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.ITaskListElement;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.TaskCategory;
import org.eclipse.mylar.tasks.MylarTasksPlugin.Priority_Level;
import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge;
import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput;
@@ -82,6 +91,7 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeColumn;
@@ -115,7 +125,7 @@ public class TaskListView extends ViewPart {
private RefreshAction refresh;
private CreateTaskAction createTask;
private CreateCategoryAction createCategory;
- private CreateQueryCategoryAction createQueryCategory;
+ private CreateBugzillaQueryCategoryAction createBugzillaQueryCategory;
private CreateBugzillaTaskAction createBugzillaTask;
// private RenameAction rename;
private DeleteAction delete;
@@ -154,7 +164,7 @@ public class TaskListView extends ViewPart {
Object obj = ((IStructuredSelection)selection).getFirstElement();
if (obj instanceof ITask) {
ITask t = (ITask) obj;
- Category cat = t.getCategory();
+ TaskCategory cat = t.getCategory();
if (cat != null) {
cat.removeTask(t);
t.setCategory(null);
@@ -206,7 +216,7 @@ public class TaskListView extends ViewPart {
if (isChecked()) {
viewer.addFilter(completeFilter);
// filterInCompleteTask.setChecked(false);
- viewer.removeFilter(inCompleteFilter);
+// viewer.removeFilter(inCompleteFilter);
} else {
viewer.removeFilter(completeFilter);
}
@@ -221,6 +231,23 @@ public class TaskListView extends ViewPart {
Object obj = ((IStructuredSelection)selection).getFirstElement();
if (obj instanceof ITask) {
((ITask)obj).openTaskInEditor();
+ } else if (obj instanceof BugzillaQueryCategory){
+
+ BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell());
+ if(sqd.open() == Dialog.OK){
+ BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)obj;
+ queryCategory.setDescription(sqd.getName());
+ queryCategory.setUrl(sqd.getUrl());
+
+ queryCategory.refreshBugs();
+ viewer.refresh();
+ }
+ } else if(obj instanceof BugzillaHit){
+ BugzillaOpenStructure open = new BugzillaOpenStructure(((BugzillaHit)obj).getServerName(), ((BugzillaHit)obj).getID(),-1);
+ List<BugzillaOpenStructure> selectedBugs = new ArrayList<BugzillaOpenStructure>();
+ selectedBugs.add(open);
+ ViewBugzillaAction viewBugs = new ViewBugzillaAction("Display bugs in editor", selectedBugs);
+ viewBugs.schedule();
}
viewer.refresh(obj);
}
@@ -241,7 +268,7 @@ public class TaskListView extends ViewPart {
}
}
}
-
+
// private final class RenameAction extends Action {
// public RenameAction() {
// setText("Rename");
@@ -301,6 +328,7 @@ public class TaskListView extends ViewPart {
setToolTipText("Delete");
setImageDescriptor(MylarImages.REMOVE);
}
+
@Override
public void run() {
boolean deleteConfirmed = MessageDialog.openQuestion(
@@ -324,9 +352,9 @@ public class TaskListView extends ViewPart {
}catch(Exception e){
MylarPlugin.log(e, " deletion failed");
}
- } else if (selectedObject instanceof Category) {
- Category cat = (Category) selectedObject;
- for (ITask task : cat.getTasks()) {
+ } else if (selectedObject instanceof TaskCategory) {
+ TaskCategory cat = (TaskCategory) selectedObject;
+ for (ITask task : cat.getChildren()) {
MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath());
IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page == null)
@@ -337,13 +365,51 @@ public class TaskListView extends ViewPart {
MylarPlugin.log(e, " deletion failed");
}
}
- MylarTasksPlugin.getTaskListManager().deleteCategory((Category)selectedObject);
+ MylarTasksPlugin.getTaskListManager().deleteCategory((TaskCategory)selectedObject);
+ } else if (selectedObject instanceof BugzillaQueryCategory) {
+ BugzillaQueryCategory cat = (BugzillaQueryCategory) selectedObject;
+ MylarTasksPlugin.getTaskListManager().deleteCategory(cat);
}
}
viewer.refresh();
}
}
+ private final class CreateBugzillaQueryCategoryAction extends Action {
+
+ public CreateBugzillaQueryCategoryAction() {
+ setText("Add Bugzilla Query");
+ setToolTipText("Add Bugzilla Query");
+ setImageDescriptor(MylarImages.CATEGORY_QUERY_NEW);
+ }
+
+ @Override
+ public void run() {
+
+ // ask the user for the query string and a name
+
+ BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell());
+ if(sqd.open() == Dialog.OK){
+ final BugzillaQueryCategory queryCategory = new BugzillaQueryCategory(sqd.getName(), sqd.getUrl());
+
+ MylarTasksPlugin.getTaskListManager().getTaskList().addCategory(queryCategory);
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor) throws CoreException {
+ queryCategory.refreshBugs();
+ }
+ };
+
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ try {
+ service.run(true, true, op);
+ } catch (Exception e) {
+ MylarPlugin.log(e, "There was a problem executing the query refresh");
+ }
+ viewer.refresh();
+ }
+ }
+ }
+
private final class CreateBugzillaTaskAction extends Action {
public CreateBugzillaTaskAction() {
setText("Add Bugzilla Report");
@@ -377,8 +443,8 @@ public class TaskListView extends ViewPart {
ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>");
Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Category){
- ((Category)selectedObject).addTask(newTask);
+ if (selectedObject instanceof TaskCategory){
+ ((TaskCategory)selectedObject).addTask(newTask);
} else {
MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask);
}
@@ -408,13 +474,25 @@ public class TaskListView extends ViewPart {
((BugzillaTask)task).refresh();
}
}
- for (Category cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
- for (ITask task : cat.getTasks()) {
- if (task instanceof BugzillaTask) {
- ((BugzillaTask)task).refresh();
- }
+ for (AbstractCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
+ if (cat instanceof TaskCategory) {
+ for (ITask task : ((TaskCategory)cat).getChildren()) {
+ if (task instanceof BugzillaTask) {
+ ((BugzillaTask)task).refresh();
+ }
+ }
+ refreshChildren(((TaskCategory)cat).getChildren());
+ }
+ else if (cat instanceof BugzillaQueryCategory) {
+ final BugzillaQueryCategory bqc = (BugzillaQueryCategory) cat;
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ bqc.refreshBugs();
+ viewer.refresh();
+ }
+ });
}
- refreshChildren(cat.getTasks());
}
// clear the caches
@@ -468,9 +546,9 @@ public class TaskListView extends ViewPart {
Task newTask = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), label);
Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject instanceof Category){
- newTask.setCategory((Category)selectedObject);
- ((Category)selectedObject).addTask(newTask);
+ if (selectedObject instanceof TaskCategory){
+ newTask.setCategory((TaskCategory)selectedObject);
+ ((TaskCategory)selectedObject).addTask(newTask);
}
// else if (selectedObject instanceof Task) {
// ITask t = (ITask) selectedObject;
@@ -498,24 +576,11 @@ public class TaskListView extends ViewPart {
public void run() {
String label = getLabelNameFromUser("Category");
if(label == null) return;
- Category cat = new Category(label);
+ TaskCategory cat = new TaskCategory(label);
MylarTasksPlugin.getTaskListManager().getTaskList().addCategory(cat);
viewer.refresh();
}
- }
-
- private final class CreateQueryCategoryAction extends Action {
- public CreateQueryCategoryAction() {
- setText("Add Bugzilla Query");
- setToolTipText("Add Bugzilla Query");
- setImageDescriptor(MylarImages.CATEGORY_QUERY_NEW);
- }
-
- @Override
- public void run() {
- MylarPlugin.log("not implemented", this);
- }
- }
+ }
private final class PriorityDropDownAction extends Action implements IMenuCreator {
private Menu dropDownMenu = null;
@@ -654,10 +719,8 @@ public class TaskListView extends ViewPart {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof ITask) {
return !((ITask)element).isCompleted();
- } else if (element instanceof Category){
+ } else {
return true;
- } else {
- return false;
}
}
};
@@ -667,11 +730,9 @@ public class TaskListView extends ViewPart {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof ITask) {
return ((ITask)element).isCompleted();
- } else if (element instanceof Category){
- return true;
} else {
- return false;
- }
+ return true;
+ }
}
};
@@ -708,10 +769,8 @@ public class TaskListView extends ViewPart {
}
return false;
}
- } else if (element instanceof Category) {
- return true;
} else {
- return false;
+ return true;
}
}
@@ -731,32 +790,37 @@ public class TaskListView extends ViewPart {
return getChildren(parent);
}
public Object getParent(Object child) {
- if (child instanceof Task) {
- if (((Task)child).getParent() != null) {
- return ((Task)child).getParent();
+ if (child instanceof ITask) {
+ if (((ITask)child).getParent() != null) {
+ return ((ITask)child).getParent();
} else {
- return ((Task)child).getCategory();
+ return ((ITask)child).getCategory();
}
}
return null;
}
public Object [] getChildren(Object parent) {
- if (parent instanceof Category) {
- return ((Category)parent).getTasks().toArray();
+ if (parent instanceof TaskCategory) {
+ return ((TaskCategory)parent).getChildren().toArray();
} else if (parent instanceof Task) {
return ((Task)parent).getChildren().toArray();
+ } else if (parent instanceof BugzillaQueryCategory) {
+ return ((BugzillaQueryCategory) parent).getHits().toArray();
}
return new Object[0];
}
public boolean hasChildren(Object parent) {
- if (parent instanceof Category) {
- Category cat = (Category)parent;
- return cat.getTasks() != null && cat.getTasks().size() > 0;
+ if (parent instanceof TaskCategory) {
+ TaskCategory cat = (TaskCategory)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 BugzillaQueryCategory) {
+ BugzillaQueryCategory cat = (BugzillaQueryCategory)parent;
+ return cat.getHits() != null && cat.getHits().size() > 0;
+ }
return false;
}
}
@@ -778,7 +842,7 @@ public class TaskListView extends ViewPart {
case 3: return !(task instanceof BugzillaTask);
case 4: return false;
}
- } else if (element instanceof Category) {
+ } else if (element instanceof AbstractCategory) {
switch (columnIndex) {
case 0:
case 1:
@@ -787,7 +851,13 @@ public class TaskListView extends ViewPart {
case 3: return true;
case 4: return false;
}
- }
+ } else if (element instanceof ITaskListElement){
+ if (columnIndex == 0) {
+ return true;
+ }else {
+ return false;
+ }
+ }
return false;
}
@@ -808,8 +878,8 @@ public class TaskListView extends ViewPart {
case 4:
return task.getHandle();
}
- } else if (element instanceof Category) {
- Category cat = (Category) element;
+ } else if (element instanceof AbstractCategory) {
+ AbstractCategory cat = (AbstractCategory) element;
switch (columnIndex) {
case 0:
return new Boolean(false);
@@ -818,10 +888,25 @@ public class TaskListView extends ViewPart {
case 2:
return "";
case 3:
- return cat.getName();
+ return cat.getDescription();
case 4:
return "";
}
+ } else if (element instanceof ITaskListElement) {
+ ITaskListElement e = (ITaskListElement) element;
+ switch (columnIndex) {
+ case 0:
+ return new Boolean(false);
+ case 1:
+ return "";
+ case 2:
+ String priorityString = e.getPriority().substring(1);
+ return new Integer(priorityString);
+ case 3:
+ return e.getDescription();
+ case 4:
+ return e.getHandle();
+ }
}
return "";
}
@@ -860,8 +945,8 @@ public class TaskListView extends ViewPart {
case 4:
break;
}
- } else if (((TreeItem) element).getData() instanceof Category) {
- Category cat = (Category)((TreeItem) element).getData();
+ } else if (((TreeItem) element).getData() instanceof AbstractCategory) {
+ AbstractCategory cat = (AbstractCategory)((TreeItem) element).getData();
switch (columnIndex) {
case 0:
viewer.setSelection(null);
@@ -871,12 +956,28 @@ public class TaskListView extends ViewPart {
case 2:
break;
case 3:
- cat.setName(((String) value).trim());
+ cat.setDescription(((String) value).trim());
viewer.setSelection(null);
break;
case 4:
break;
}
+ } else if (((TreeItem) element).getData() instanceof ITaskListElement) {
+//// ITaskListElement e = (ITaskListElement)((TreeItem) element).getData();
+// switch (columnIndex) {
+// case 0:
+// viewer.setSelection(null);
+// break;
+// case 1:
+// break;
+// case 2:
+// break;
+// case 3:
+// viewer.setSelection(null);
+// break;
+// case 4:
+// break;
+// }
}
viewer.refresh();
} catch (Exception e) {
@@ -900,18 +1001,19 @@ public class TaskListView extends ViewPart {
*/
@Override
public int compare(Viewer compareViewer, Object o1, Object o2) {
- if (o1 instanceof Category) {
- if (o2 instanceof Category) {
+ if (o1 instanceof AbstractCategory) {
+ if (o2 instanceof AbstractCategory) {
return 0;
} else {
return -1;
}
- } else {
- if (o2 instanceof Category) {
+ } else if(o1 instanceof ITask){
+ if (o2 instanceof AbstractCategory) {
return -1;
- } else {
+ } else if(o2 instanceof ITask) {
+
ITask task1 = (ITask) o1;
- ITask task2 = (ITask) o2;
+ ITask task2 = (ITask) o2;
if (task1.isCompleted()) return 1;
if (task2.isCompleted()) return -1;
@@ -931,7 +1033,25 @@ public class TaskListView extends ViewPart {
return 0;
}
}
- }
+ } else if(o1 instanceof BugzillaHit && o2 instanceof BugzillaHit){
+ ITaskListElement task1 = (ITaskListElement) o1;
+ ITaskListElement task2 = (ITaskListElement) o2;
+
+ if (column == columnNames[1]) {
+ return 0;
+ } else if (column == columnNames[2]) {
+ return task1.getPriority().compareTo(task2.getPriority());
+ } else if (column == columnNames[3]) {
+ return task1.getDescription().compareTo(task2.getDescription());
+ } else if (column == columnNames[4]){
+ return task1.getHandle().compareTo(task2.getHandle());
+ } else {
+ return 0;
+ }
+ } else{
+ return 0;
+ }
+ return 0;
}
}
@@ -1025,9 +1145,22 @@ public class TaskListView extends ViewPart {
// don't care if the control is moved
}
});
-
}
-
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ if(event.getSelection() instanceof IStructuredSelection){
+ IStructuredSelection sel = (IStructuredSelection)event.getSelection();
+ if(sel.getFirstElement() instanceof BugzillaHit){
+ delete.setEnabled(false);
+ }else {
+ delete.setEnabled(true);
+ }
+ }
+ }
+
+ });
CellEditor[] editors = new CellEditor[columnNames.length];
TextCellEditor textEditor = new TextCellEditor(viewer.getTree());
((Text) textEditor.getControl()).setOrientation(SWT.LEFT_TO_RIGHT);
@@ -1103,9 +1236,9 @@ public class TaskListView extends ViewPart {
MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks().remove(source);
}
- if (getCurrentTarget() instanceof Category) {
- ((Category) getCurrentTarget()).addTask(source);
- source.setCategory((Category)getCurrentTarget());
+ if (getCurrentTarget() instanceof TaskCategory) {
+ ((TaskCategory) getCurrentTarget()).addTask(source);
+ source.setCategory((TaskCategory)getCurrentTarget());
} else if (getCurrentTarget() instanceof ITask) {
ITask target = (ITask) getCurrentTarget();
source.setCategory(null);
@@ -1126,7 +1259,7 @@ public class TaskListView extends ViewPart {
.getSelection()).getFirstElement();
if (selectedObject instanceof ITask) {
if (getCurrentTarget() != null &&
- (getCurrentTarget() instanceof ITask || getCurrentTarget() instanceof Category)) {
+ (getCurrentTarget() instanceof ITask || getCurrentTarget() instanceof TaskCategory)) {
return true;
} else {
return false;
@@ -1214,16 +1347,18 @@ public class TaskListView extends ViewPart {
}
private void fillLocalToolBar(IToolBarManager manager) {
- manager.add(createTask);
+ manager.add(createTask);
manager.add(createCategory);
manager.add(new Separator());
manager.add(createBugzillaTask);
- manager.add(createQueryCategory);
- manager.add(refresh);
+
+ manager.add(createBugzillaQueryCategory);
+ manager.add(refresh);
manager.add(new Separator());
manager.add(filterCompleteTask);
// manager.add(filterInCompleteTask);
manager.add(filterOnPriority);
+
}
/**
@@ -1233,9 +1368,9 @@ public class TaskListView extends ViewPart {
private void makeActions() {
refresh = new RefreshAction();
createTask = new CreateTaskAction();
- createCategory = new CreateCategoryAction();
- createBugzillaTask = new CreateBugzillaTaskAction();
- createQueryCategory = new CreateQueryCategoryAction();
+ createCategory = new CreateCategoryAction();
+ createBugzillaQueryCategory = new CreateBugzillaQueryCategoryAction();
+ createBugzillaTask = new CreateBugzillaTaskAction();
delete = new DeleteAction();
completeTask = new MarkTaskCompleteAction();
incompleteTask = new MarkTaskIncompleteAction();
@@ -1265,8 +1400,8 @@ public class TaskListView extends ViewPart {
return true;
}
}
- for (Category cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
- for (ITask task : cat.getTasks()) {
+ for (TaskCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getTaskCategories()) {
+ for (ITask task : cat.getChildren()) {
if (task.getHandle().equals(taskId)) {
return true;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
index a4dc6b2ef..fbaa81e65 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java
@@ -34,10 +34,12 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.mylar.core.MylarPlugin;
+import org.eclipse.mylar.tasks.AbstractCategory;
+import org.eclipse.mylar.tasks.BugzillaQueryCategory;
import org.eclipse.mylar.tasks.BugzillaTask;
-import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.TaskCategory;
import org.eclipse.mylar.tasks.TaskList;
import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState;
import org.w3c.dom.Document;
@@ -76,8 +78,12 @@ public class XmlUtil {
// iterate through each subtask and externalize those
//
- for (Category cat : tlist.getCategories()) {
- writeCategory(cat, doc, root);
+ for (AbstractCategory cat : tlist.getCategories()) {
+ if (cat instanceof TaskCategory) {
+ writeTaskCategory((TaskCategory)cat, doc, root);
+ } else if (cat instanceof BugzillaQueryCategory) {
+ writeQueryCategory((BugzillaQueryCategory)cat, doc, root);
+ }
}
for (ITask task : tlist.getRootTasks()) {
writeTask(task, doc, root);
@@ -213,16 +219,23 @@ public class XmlUtil {
// return;
// }
- private static void writeCategory(Category cat, Document doc, Element parent) {
- Element node = doc.createElement("Category");
- node.setAttribute("Name", cat.getName());
+ private static void writeTaskCategory(TaskCategory cat, Document doc, Element parent) {
+ Element node = doc.createElement("TaskCategory");
+ node.setAttribute("Name", cat.getDescription());
- for (ITask t : cat.getTasks()) {
+ for (ITask t : cat.getChildren()) {
writeTask(t, doc, node);
}
parent.appendChild(node);
}
+ private static void writeQueryCategory(BugzillaQueryCategory cat, Document doc, Element parent) {
+ Element node = doc.createElement("QueryCategory");
+ node.setAttribute("Description", cat.getDescription());
+ node.setAttribute("URL", cat.getUrl());
+ parent.appendChild(node);
+ }
+
private static void writeTask(ITask task, Document doc, Element parent) {
Element node = doc.createElement("Task");
node.setAttribute("Path", task.getPath());
@@ -293,8 +306,11 @@ public class XmlUtil {
NodeList list = root.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node child = list.item(i);
- if (child.getNodeName().equals("Category")) {
- readCategory(child, tlist);
+ if (child.getNodeName().equals("Category") ||
+ child.getNodeName().equals("TaskCategory")) {
+ readTaskCategory(child, tlist);
+ } else if (child.getNodeName().equals("QueryCategory")) {
+ readQueryCategory(child, tlist);
} else {
tlist.addRootTask(readTask(child, tlist, null, null));
}
@@ -437,9 +453,9 @@ public class XmlUtil {
// return t;
// }
- private static void readCategory(Node node, TaskList tlist) {
+ private static void readTaskCategory(Node node, TaskList tlist) {
Element e = (Element) node;
- Category cat = new Category(e.getAttribute("Name"));
+ TaskCategory cat = new TaskCategory(e.getAttribute("Name"));
tlist.addCategory(cat);
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
@@ -448,7 +464,13 @@ public class XmlUtil {
}
}
- private static ITask readTask(Node node, TaskList tlist, Category cat, ITask parent) {
+ private static void readQueryCategory(Node node, TaskList tlist) {
+ Element e = (Element) node;
+ BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute("Description"), e.getAttribute("URL"));
+ tlist.addCategory(cat);
+ }
+
+ private static ITask readTask(Node node, TaskList tlist, TaskCategory cat, ITask parent) {
Element e = (Element) node;
ITask t;
String handle = e.getAttribute("Handle");
@@ -524,7 +546,7 @@ public class XmlUtil {
String label = e.getAttribute("Label");
if (e.getAttribute("IsCategory").compareTo("true") == 0) {
- Category c = new Category(label);
+ TaskCategory c = new TaskCategory(label);
NodeList list = e.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node child = list.item(i);
@@ -582,7 +604,7 @@ public class XmlUtil {
}
}
}
- private static void readSubTasksToNewFormat(Node node, TaskList tlist, Category cat) {
+ private static void readSubTasksToNewFormat(Node node, TaskList tlist, TaskCategory cat) {
Element e = (Element) node;
ITask t;
String handle = e.getAttribute("Handle");

Back to the top