Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-06-21 07:21:45 +0000
committermkersten2007-06-21 07:21:45 +0000
commit6cd01592a9b4eca75ae9da74675a39ed13be29d6 (patch)
treee2f8b214dfd835aff593c33f28f1ae99ddae098d /org.eclipse.mylyn.bugzilla.ui
parent814d5a58aa59225467a9f8c5f018770dd5c53e83 (diff)
downloadorg.eclipse.mylyn.tasks-6cd01592a9b4eca75ae9da74675a39ed13be29d6.tar.gz
org.eclipse.mylyn.tasks-6cd01592a9b4eca75ae9da74675a39ed13be29d6.tar.xz
org.eclipse.mylyn.tasks-6cd01592a9b4eca75ae9da74675a39ed13be29d6.zip
NEW - bug 166609: [api] improve task externalization API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=166609
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/plugin.xml2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskListFactory.java (renamed from org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java)88
2 files changed, 39 insertions, 51 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
index c397116a2..9d4be60f0 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
@@ -20,7 +20,7 @@
overlayIcon="icons/eview16/overlay-bugzilla.gif"/>
<externalizer
- class="org.eclipse.mylyn.internal.bugzilla.ui.tasklist.BugzillaTaskExternalizer"
+ class="org.eclipse.mylyn.internal.bugzilla.ui.tasklist.BugzillaTaskListFactory"
id="org.eclipse.mylyn.bugzilla.tasklist.externalizer"/>
</extension>
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskListFactory.java
index 47fa04ed6..fe2a76e87 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskListFactory.java
@@ -11,22 +11,21 @@
package org.eclipse.mylyn.internal.bugzilla.ui.tasklist;
+import java.util.HashSet;
+import java.util.Set;
+
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
-import org.eclipse.mylyn.tasks.core.DelegatingTaskExternalizer;
import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.core.AbstractTaskListFactory;
import org.eclipse.mylyn.tasks.core.TaskExternalizationException;
-import org.eclipse.mylyn.tasks.core.TaskList;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
/**
* @author Mik Kersten
*/
-public class BugzillaTaskExternalizer extends DelegatingTaskExternalizer {
+public class BugzillaTaskListFactory extends AbstractTaskListFactory {
private static final String KEY_SEVERITY = "bugzilla.severity";
@@ -41,7 +40,30 @@ public class BugzillaTaskExternalizer extends DelegatingTaskExternalizer {
private static final String TAG_BUGZILLA_REPORT = "BugzillaReport";
@Override
- public String getQueryTagNameForElement(AbstractRepositoryQuery query) {
+ public String getTaskElementName() {
+ return TAG_BUGZILLA_REPORT;
+ }
+
+ @Override
+ public Set<String> getQueryElementNames() {
+ Set<String> names = new HashSet<String>();
+ names.add(TAG_BUGZILLA_QUERY);
+ names.add(TAG_BUGZILLA_CUSTOM_QUERY);
+ return names;
+ }
+
+ @Override
+ public boolean canCreate(AbstractRepositoryQuery category) {
+ return category instanceof BugzillaRepositoryQuery;
+ }
+
+ @Override
+ public boolean canCreate(AbstractTask task) {
+ return task instanceof BugzillaTask;
+ }
+
+ @Override
+ public String getQueryElementName(AbstractRepositoryQuery query) {
if (query instanceof BugzillaRepositoryQuery) {
if (((BugzillaRepositoryQuery) query).isCustomQuery()) {
return TAG_BUGZILLA_CUSTOM_QUERY;
@@ -49,54 +71,26 @@ public class BugzillaTaskExternalizer extends DelegatingTaskExternalizer {
return TAG_BUGZILLA_QUERY;
}
}
- return "";
+ return null;
}
@Override
- public boolean canReadQuery(Node node) {
- return node.getNodeName().equals(TAG_BUGZILLA_CUSTOM_QUERY) || node.getNodeName().equals(TAG_BUGZILLA_QUERY);
- }
-
- @Override
- public AbstractRepositoryQuery readQuery(Node node, TaskList taskList) throws TaskExternalizationException {
- Element element = (Element) node;
- BugzillaRepositoryQuery query = new BugzillaRepositoryQuery(element.getAttribute(KEY_REPOSITORY_URL), element
- .getAttribute(KEY_QUERY_STRING), element.getAttribute(KEY_NAME));
- if (node.getNodeName().equals(TAG_BUGZILLA_CUSTOM_QUERY)) {
+ public AbstractRepositoryQuery createQuery(String repositoryUrl, String queryString, String label, Element element) throws TaskExternalizationException {
+ BugzillaRepositoryQuery query = new BugzillaRepositoryQuery(repositoryUrl, queryString, label);
+ if (element.getNodeName().equals(TAG_BUGZILLA_CUSTOM_QUERY)) {
query.setCustomQuery(true);
}
- if (element.getAttribute(KEY_LAST_REFRESH) != null && !element.getAttribute(KEY_LAST_REFRESH).equals("")) {
- query.setLastRefreshTimeStamp(element.getAttribute(KEY_LAST_REFRESH));
- }
return query;
}
-
+
@Override
- public Element createTaskElement(AbstractTask task, Document doc, Element parent) {
- Element node = super.createTaskElement(task, doc, parent);
- node.setAttribute(KEY_SEVERITY, ((BugzillaTask) task).getSeverity());
- node.setAttribute(KEY_PRODUCT, ((BugzillaTask) task).getProduct());
- return node;
- }
-
- @Override
- public boolean canCreateElementFor(AbstractRepositoryQuery category) {
- return category instanceof BugzillaRepositoryQuery;
- }
-
- @Override
- public boolean canCreateElementFor(AbstractTask task) {
- return task instanceof BugzillaTask;
+ public void setAdditionalAttributes(AbstractTask task, Element element) {
+ element.setAttribute(KEY_SEVERITY, ((BugzillaTask) task).getSeverity());
+ element.setAttribute(KEY_PRODUCT, ((BugzillaTask) task).getProduct());
}
@Override
- public boolean canReadTask(Node node) {
- return node.getNodeName().equals(getTaskTagName());
- }
-
- @Override
- public AbstractTask createTask(String repositoryUrl, String taskId, String summary, Element element, TaskList taskList,
- AbstractTaskContainer category, AbstractTask parent) throws TaskExternalizationException {
+ public AbstractTask createTask(String repositoryUrl, String taskId, String summary, Element element) throws TaskExternalizationException {
BugzillaTask task = new BugzillaTask(repositoryUrl, taskId, summary);
if (element.hasAttribute(KEY_SEVERITY)) {
task.setSeverity(element.getAttribute(KEY_SEVERITY));
@@ -106,10 +100,4 @@ public class BugzillaTaskExternalizer extends DelegatingTaskExternalizer {
}
return task;
}
-
- @Override
- public String getTaskTagName() {
- return TAG_BUGZILLA_REPORT;
- }
-
}

Back to the top