Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-08-24 16:24:56 -0400
committersminto2005-08-24 16:24:56 -0400
commitfd27f7c53abf451b8242faac38ab3d1ae49d7503 (patch)
tree52ca0001e4cf616d2d1273e33528bb9af486d9a1
parentcdda66c5587f330392bd2411189ca05797612b04 (diff)
downloadorg.eclipse.mylyn.tasks-fd27f7c53abf451b8242faac38ab3d1ae49d7503.tar.gz
org.eclipse.mylyn.tasks-fd27f7c53abf451b8242faac38ab3d1ae49d7503.tar.xz
org.eclipse.mylyn.tasks-fd27f7c53abf451b8242faac38ab3d1ae49d7503.zip
added support for custom queries and externalizing queries properly
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/plugin.xml12
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateCustomBugzillaQueryAction.java97
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQuery.java9
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java49
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java24
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskListExternalizer.java16
-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/TaskListExternalizer.java66
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java2
9 files changed, 260 insertions, 43 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
index 0fbb4454a..2f9682674 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
@@ -141,6 +141,18 @@
toolbarPath="mylar"
tooltip="Add Bugzilla Query">
</action>
+
+ <action
+ class="org.eclipse.mylar.bugzilla.ui.actions.CreateCustomBugzillaQueryAction"
+ enablesFor="*"
+ icon="icons/etool16/category-query-new.gif"
+ id="org.eclipse.mylar.bugzilla.tasklist.addCustomQuery"
+ label="Add Custom Bugzilla Query"
+ style="push"
+ toolbarPath="mylar"
+ tooltip="Add Custom Bugzilla Query">
+ </action>
+
<action
class="org.eclipse.mylar.bugzilla.ui.actions.CreateNewBugzillaTaskAction"
enablesFor="*"
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateCustomBugzillaQueryAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateCustomBugzillaQueryAction.java
new file mode 100644
index 000000000..0863db12d
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateCustomBugzillaQueryAction.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.bugzilla.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
+import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaCustomQuery;
+import org.eclipse.mylar.core.MylarPlugin;
+import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
+import org.eclipse.mylar.tasklist.ui.views.TaskListView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.progress.IProgressService;
+
+/**
+ * @author Mik Kersten and Ken Sueda
+ */
+public class CreateCustomBugzillaQueryAction extends Action implements IViewActionDelegate {
+
+ public static final String ID = "org.eclipse.mylar.tasklist.actions.create.bug.query";
+
+ public CreateCustomBugzillaQueryAction() {
+ setText("Add Custom Bugzilla Query");
+ setToolTipText("Add Custom Bugzilla Query");
+ setId(ID);
+ setImageDescriptor(BugzillaImages.CATEGORY_QUERY_NEW);
+ }
+
+ @Override
+ public void run() {
+
+ InputDialog d = new InputDialog(Display.getCurrent().getActiveShell(), "Name the query", "Name the query", "", null);
+ d.open();
+ String name = d.getValue();
+
+ d = new InputDialog(Display.getCurrent().getActiveShell(), "MaxHits", "MaxHits", "", null);
+ d.open();
+ String maxHits = d.getValue();
+
+ d = new InputDialog(Display.getCurrent().getActiveShell(), "URL", "URL", "", null);
+ d.open();
+ String url = d.getValue();
+
+ // TODO make this work properly
+ final BugzillaCustomQuery queryCategory = new BugzillaCustomQuery(name,
+ url, maxHits);
+
+ MylarTasklistPlugin.getTaskListManager().addQuery(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");
+ }
+ if (TaskListView.getDefault() != null)
+ TaskListView.getDefault().getViewer().refresh();
+
+ }
+
+ public void init(IViewPart view) {
+
+ }
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQuery.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQuery.java
new file mode 100644
index 000000000..d9dbf9f7c
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQuery.java
@@ -0,0 +1,9 @@
+package org.eclipse.mylar.bugzilla.ui.tasklist;
+
+
+public class BugzillaCustomQuery extends BugzillaQueryCategory{
+
+ public BugzillaCustomQuery(String description, String maxHits, String queryString) {
+ super(description, maxHits, queryString);
+ }
+}
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 516b32249..41e60710b 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
@@ -41,12 +41,15 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
private static final String BUGZILLA = "Bugzilla";
private static final String LAST_DATE = "LastDate";
private static final String DIRTY = "Dirty";
- private static final String URL = "URL";
private static final String DESCRIPTION = "Description";
- private static final String MAX_HITS = "MaxHits";
+ private static final String URL = "URL";
private static final String BUGZILLA_TASK_REGISTRY = "BugzillaTaskRegistry" + TAG_CATEGORY;
private static final String TAG_BUGZILLA_CATEGORY = "BugzillaQuery" + TAG_CATEGORY;
+
+ private static final String TAG_BUGZILLA_QUERY = "Bugzilla" + TAG_QUERY;
+ private static final String TAG_BUGZILLA_CUSTOM_QUERY = "BugzillaCustom" + TAG_QUERY;
+
private static final String TAG_TASK = "BugzillaReport";
@Override
@@ -80,12 +83,38 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
}
}
+ public String getQueryTagNameForElement(IQuery query) {
+ if(query instanceof BugzillaQueryCategory){
+ return TAG_BUGZILLA_QUERY;
+ } else if(query instanceof BugzillaCustomQuery){
+ return TAG_BUGZILLA_CUSTOM_QUERY;
+ }
+ return "";
+ }
+
+ public boolean canReadQuery(Node node) {
+ return node.getNodeName().equals(TAG_BUGZILLA_CUSTOM_QUERY) || node.getNodeName().equals(TAG_BUGZILLA_QUERY);
+ }
+
+ public void readQuery(Node node, TaskList tlist) throws MylarExternalizerException {
+ Element e = (Element) node;
+ IQuery cat = null;
+ if(node.getNodeName().equals(TAG_BUGZILLA_CUSTOM_QUERY)){
+ cat = new BugzillaCustomQuery(e.getAttribute(NAME), e.getAttribute(QUERY_STRING), e.getAttribute(MAX_HITS));
+ } else if(node.getNodeName().equals(TAG_BUGZILLA_QUERY)){
+ cat = new BugzillaQueryCategory(e.getAttribute(NAME), e.getAttribute(QUERY_STRING), e.getAttribute(MAX_HITS));
+ }
+ if(cat != null){
+ tlist.internalAddQuery(cat);
+ }
+ }
+
public void readRegistry(Node node, TaskList taskList) throws MylarExternalizerException {
boolean hasCaughtException = false;
NodeList list = node.getChildNodes();
TaskCategory cat = new TaskCategory("Bugzilla Archive");
cat.setIsArchive(true);
- taskList.addCategory(cat);
+ taskList.internalAddCategory(cat);
BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().setTaskRegistyCategory(cat);
for (int i = 0; i < list.getLength(); i++) {
try {
@@ -103,23 +132,9 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
if (hasCaughtException) throw new MylarExternalizerException("Failed to restore all tasks");
}
- public boolean canCreateElementFor(IQuery query) {
- return query instanceof BugzillaQueryCategory;
- }
-
public boolean canCreateElementFor(ICategory cat) {
return false;
}
-
- 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.getQueryString());
- node.setAttribute(MAX_HITS, ""+queryCategory.getMaxHits());
- parent.appendChild(node);
- return node;
- }
public boolean canCreateElementFor(ITask task) {
return task instanceof BugzillaTask;
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 b5b820622..7246651e6 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
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure;
@@ -106,8 +107,27 @@ public class BugzillaTaskHandler implements ITaskHandler {
} else {
// not supported
}
- }
- else if (element instanceof BugzillaQueryCategory){
+ }else if (element instanceof BugzillaCustomQuery){
+ BugzillaCustomQuery queryCategory = (BugzillaCustomQuery)element;
+
+ InputDialog d = new InputDialog(Display.getCurrent().getActiveShell(), "Name the query", "Name the query", queryCategory.getDescription(false), null);
+ d.open();
+ queryCategory.setDescription(d.getValue());
+
+ d = new InputDialog(Display.getCurrent().getActiveShell(), "MaxHits", "MaxHits", queryCategory.getMaxHits()+"", null);
+ d.open();
+ int maxHits = -1;
+ try{
+ maxHits = Integer.parseInt(d.getValue());
+ } catch(Exception e){}
+ queryCategory.setMaxHits(maxHits);
+
+ d = new InputDialog(Display.getCurrent().getActiveShell(), "URL", "URL", queryCategory.getQueryString(), null);
+ d.open();
+ queryCategory.setQueryString(d.getValue());
+ new RefreshBugzillaAction(queryCategory).run();
+
+ } else if (element instanceof BugzillaQueryCategory){
BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)element;
BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell(), queryCategory.getQueryString(), queryCategory.getDescription(false), queryCategory.getMaxHits()+"");
if(sqd.open() == Dialog.OK){
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 254f7d4e9..eaacc9c5f 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,11 +34,9 @@ public interface ITaskListExternalizer {
public abstract String getTaskTagName();
- public abstract boolean canCreateElementFor(ICategory category);
-
- public abstract boolean canCreateElementFor(IQuery category);
+ public abstract String getQueryTagNameForElement(IQuery query);
- public abstract Element createQueryElement(IQuery query, Document doc, Element parent);
+ public abstract boolean canCreateElementFor(ICategory category);
/**
* @return the element that was created, null if failed
@@ -59,4 +57,14 @@ public interface ITaskListExternalizer {
public abstract boolean canReadTask(Node node);
public abstract ITask readTask(Node node, TaskList tlist, ICategory category, ITask parent) throws MylarExternalizerException;
+
+
+
+ public abstract boolean canCreateElementFor(IQuery category);
+
+ public abstract Element createQueryElement(IQuery query, Document doc, Element parent);
+
+ public abstract boolean canReadQuery(Node node);
+
+ public abstract void readQuery(Node node, TaskList tlist) throws MylarExternalizerException;
}
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 052e02ff4..41d74d6b4 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
@@ -31,6 +31,10 @@ import org.w3c.dom.NodeList;
*/
public class DefaultTaskListExternalizer implements ITaskListExternalizer {
+ public static final String TAG_QUERY = "Query";
+ public static final String MAX_HITS = "MaxHits";
+ public static final String QUERY_STRING = "QueryString";
+
public static final String LABEL = "Label";
public static final String HANDLE = "Handle";
public static final String TAG_CATEGORY = "Category";
@@ -286,12 +290,28 @@ public class DefaultTaskListExternalizer implements ITaskListExternalizer {
public boolean canCreateElementFor(IQuery category) {
- // TODO Auto-generated method stub
- return false;
+ return true;
}
public Element createQueryElement(IQuery query, Document doc, Element parent) {
- // TODO Auto-generated method stub
- return null;
+ Element node = doc.createElement(getQueryTagNameForElement(query));
+ node.setAttribute(NAME, query.getDescription(false));
+ node.setAttribute(MAX_HITS, query.getMaxHits()+"");
+ node.setAttribute(QUERY_STRING, query.getQueryString());
+ parent.appendChild(node);
+ return node;
+ }
+
+ public boolean canReadQuery(Node node) {
+ return false;
+ }
+
+ public void readQuery(Node node, TaskList tlist) throws MylarExternalizerException {
+ // doesn't know how to read any queries
+
+ }
+
+ public String getQueryTagNameForElement(IQuery query) {
+ return "";
}
}
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 a55ebaf39..1802606b6 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
@@ -63,19 +63,6 @@ public class TaskListExternalizer {
TaskListExtensionReader.initExtensions(externalizers, defaultExternalizer);
}
-// public void addExternalizer(ITaskListExternalizer externalizer) {
-// externalizers.add(externalizer);
-// defaultExternalizer.setExternalizers(externalizers);
-// MylarTasklistPlugin.getTaskListManager().getTaskList().clear();
-// readTaskList(MylarTasklistPlugin.getTaskListManager().getTaskList(), MylarTasklistPlugin.getTaskListManager().getTaskListFile());
-// if(MylarTasklistPlugin.getDefault().getContributor() != null){
-// MylarTasklistPlugin.getDefault().getContributor().restoreState(TaskListView.getDefault());
-// if (TaskListView.getDefault() != null) {
-// TaskListView.getDefault().getViewer().refresh();
-// }
-// }
-// }
-
public void removeExternalizer(ITaskListExternalizer externalizer) {
externalizers.remove(externalizer);
}
@@ -251,7 +238,21 @@ public class TaskListExternalizer {
// MylarPlugin.log("Did not read: " +
// child.getNodeName(), this);
}
- } else {
+ } else if (child.getNodeName().endsWith(DefaultTaskListExternalizer.TAG_QUERY)) {
+ for (ITaskListExternalizer externalizer : externalizers) {
+ if (externalizer.canReadQuery(child)) {
+ externalizer.readQuery(child, tlist);
+ wasRead = true;
+ break;
+ }
+ }
+ if (!wasRead && defaultExternalizer.canReadCategory(child)) {
+ defaultExternalizer.readQuery(child, tlist);
+ } else {
+ // MylarPlugin.log("Did not read: " +
+ // child.getNodeName(), this);
+ }
+ }else {
for (ITaskListExternalizer externalizer : externalizers) {
if (externalizer.canReadTask(child)) {
// TODO add the tasks properly
@@ -375,7 +376,42 @@ public class TaskListExternalizer {
-
+ /*
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
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 bca3f7500..22d95b2ea 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
@@ -1099,7 +1099,7 @@ public class TaskListView extends ViewPart {
private void updateActionEnablement(Action action, ITaskListElement element){
- if(element instanceof Task){
+ if(element instanceof ITask){
if(action instanceof MarkTaskCompleteAction){
if(element.isCompleted()){
action.setEnabled(false);

Back to the top