Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-06-30 13:50:03 -0400
committersminto2005-06-30 13:50:03 -0400
commited24c259fd090108714fb01210b37826e87a4c9c (patch)
treebcc1cc060b58668df6d449c72ad603bace263e6d /org.eclipse.mylyn.tasks.ui
parentac843cd922778caa1e2c52383febdf367ac56cdc (diff)
downloadorg.eclipse.mylyn.tasks-ed24c259fd090108714fb01210b37826e87a4c9c.tar.gz
org.eclipse.mylyn.tasks-ed24c259fd090108714fb01210b37826e87a4c9c.tar.xz
org.eclipse.mylyn.tasks-ed24c259fd090108714fb01210b37826e87a4c9c.zip
Fixed Bug #101911: Support bugzilla queries
Applied Patch from Bugzilla Bug# 101899: problems with task list refresh
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/AbstractCategory.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java39
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java15
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java8
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java13
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java31
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java171
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java182
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java29
12 files changed, 376 insertions, 154 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
index 751cb0fc5..599106aba 100644
--- 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
@@ -34,7 +34,7 @@ public class AbstractCategory implements ITaskListElement {
return priority;
}
- public String getDescription() {
+ public String getDescription(boolean label) {
return description;
}
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
index 96fe8ab9d..f768eca1d 100644
--- 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
@@ -12,6 +12,7 @@
package org.eclipse.mylar.tasks;
import org.eclipse.mylar.bugzilla.BugzillaImages;
+import org.eclipse.mylar.ui.MylarImages;
import org.eclipse.swt.graphics.Image;
/**
@@ -22,25 +23,48 @@ public class BugzillaHit implements ITaskListElement {
private String description;
private String priority;
private int id;
+ private BugzillaTask task;
- public BugzillaHit(String description, String priority, int id) {
+ public BugzillaHit(String description, String priority, int id, BugzillaTask task) {
this.description = description;
this.priority = priority;
this.id = id;
+ this.task = task;
}
+
+ public boolean isTask(){
+ return task != null;
+ }
+
+ public BugzillaTask getAssociatedTask(){
+ return task;
+ }
+
+ public void setAssociatedTask(BugzillaTask task){
+ this.task = task;
+ }
+
public Image getIcon() {
- return BugzillaImages.getImage(BugzillaImages.BUG);
+ if(isTask()){
+ return task.getIcon();
+ } else {
+ return BugzillaImages.getImage(BugzillaImages.BUG);
+ }
}
public Image getStatusIcon() {
- return null;
+ if (isTask()) {
+ return task.getStatusIcon();
+ } else {
+ return MylarImages.getImage(MylarImages.TASK_INACTIVE);
+ }
}
public String getPriority() {
return priority;
}
- public String getDescription() {
+ public String getDescription(boolean label) {
return description;
}
@@ -52,11 +76,16 @@ public class BugzillaHit implements ITaskListElement {
}
public String getServerName() {
// TODO need the right server name - get from the handle
- return "<UNKNOWN>";
+ return "Bugzilla";
}
public int getID() {
return id;
}
+ public String getIDString() {
+ Integer bugId = new Integer(this.id);
+ return bugId.toString();
+ }
+
}
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
index 0730e47b8..2858c3236 100644
--- 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
@@ -51,7 +51,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
for(BugzillaSearchHit hit: collector.getResults()){
// HACK need the server name and handle properly
- addHit(new BugzillaHit(hit.getId() + ": " + hit.getDescription(), hit.getPriority(), hit.getId()));
+ addHit(new BugzillaHit(hit.getId() + ": " + hit.getDescription(), hit.getPriority(), hit.getId(), null));
}
}
@@ -64,16 +64,17 @@ public class BugzillaQueryCategory extends AbstractCategory {
this.url = url;
}
- public String getDescription() {
- if (hits.size() > 0) {
- return super.getDescription();
+ public String getDescription(boolean label) {
+ if (hits.size() > 0 || !label) {
+ return super.getDescription(label);
} else if (!hasBeenRefreshed) {
- return super.getDescription() + " <needs refresh>";
+ return super.getDescription(label) + " <needs refresh>";
} else {
- return super.getDescription() + " <no hits>";
+ return super.getDescription(label) + " <no hits>";
}
}
+
public Image getIcon() {
return MylarImages.getImage(MylarImages.CATEGORY_QUERY);
}
@@ -87,6 +88,8 @@ public class BugzillaQueryCategory extends AbstractCategory {
}
public void addHit(BugzillaHit hit) {
+ BugzillaTask task = MylarTasksPlugin.getTaskListManager().getTaskList().getFromBugzillaTaskRegistry(hit.getHandle());
+ hit.setAssociatedTask(task);
hits.add(hit);
}
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 f05dbe9de..9385f7666 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
@@ -101,7 +101,11 @@ public class BugzillaTask extends Task {
}
}
- @Override
+ public BugzillaTask(BugzillaHit hit) {
+ this(hit.getHandle(), hit.getDescription(false));
+ }
+
+ @Override
public String getLabel() {
return MylarTasksPlugin.getDefault().getBugzillaProvider().getBugzillaDescription(this);
}
@@ -371,6 +375,8 @@ public class BugzillaTask extends Task {
@Override
public String getToolTipText() {
+ if(lastRefresh == null)
+ return "";
// Get the current time.
Date timeNow = new Date();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java
index fb132f3e6..b8b0a5927 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITaskListElement.java
@@ -23,7 +23,7 @@ public interface ITaskListElement {
public abstract String getPriority();
- public abstract String getDescription();
+ public abstract String getDescription(boolean label);
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 59fddb211..e9509c4e8 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
@@ -284,7 +284,7 @@ public class Task implements ITask, ITaskListElement {
return MylarImages.getImage(MylarImages.TASK);
}
- public String getDescription() {
+ public String getDescription(boolean label) {
return getLabel();
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java
index 5bb302ed2..5562381d1 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java
@@ -39,7 +39,16 @@ public class TaskCategory extends AbstractCategory implements Serializable {
}
public void addTask(ITask task) {
- tasks.add(task);
+ if(task instanceof BugzillaTask){
+ BugzillaTask bugTask = MylarTasksPlugin.getTaskListManager().getTaskList().getFromBugzillaTaskRegistry(task.getHandle());
+ if(bugTask == null){
+ MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry((BugzillaTask)task);
+ } else {
+ task = bugTask;
+ }
+ }
+ tasks.add(task);
+
}
public void removeTask(ITask task) {
@@ -55,7 +64,7 @@ public class TaskCategory extends AbstractCategory implements Serializable {
if (object == null) return false;
if (object instanceof TaskCategory) {
TaskCategory compare = (TaskCategory)object;
- return this.getDescription().equals(compare.getDescription());
+ return this.getDescription(false).equals(compare.getDescription(false));
} 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 37e48da0b..e7c525052 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
@@ -15,7 +15,9 @@ package org.eclipse.mylar.tasks;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
@@ -29,8 +31,35 @@ public class TaskList implements Serializable {
private List<AbstractCategory> categories = new ArrayList<AbstractCategory>();
private transient List<ITask> activeTasks = new ArrayList<ITask>();
+ // XXX we never delete anything from this registry
+ private Map<String, BugzillaTask> bugzillaTaskRegistry = new HashMap<String, BugzillaTask>();
+
+ public void addToBugzillaTaskRegistry(BugzillaTask task){
+ if(bugzillaTaskRegistry.get(task.getHandle()) == null){
+ bugzillaTaskRegistry.put(task.getHandle(), task);
+ }
+ }
+
+ public BugzillaTask getFromBugzillaTaskRegistry(String handle){
+ return bugzillaTaskRegistry.get(handle);
+ }
+
+ public Map<String, BugzillaTask> getBugzillaTaskRegistry(){
+ return bugzillaTaskRegistry;
+ }
+
public void addRootTask(ITask task) {
- rootTasks.add(task);
+ if(task instanceof BugzillaTask){
+ BugzillaTask bugTask = bugzillaTaskRegistry.get(task.getHandle());
+ if(bugTask == null){
+ bugzillaTaskRegistry.put(task.getHandle(), (BugzillaTask)task);
+ rootTasks.add(task);
+ } else {
+ rootTasks.add(bugTask);
+ }
+ } else {
+ rootTasks.add(task);
+ }
}
public void addCategory(AbstractCategory cat) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java
index f79e3f627..1b1e5f5ad 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java
@@ -282,7 +282,8 @@ public class TaskSummaryEditor extends EditorPart {
createTaskSection(parent, toolkit);
createNotesSection(parent, toolkit);
createPlanningGameSection(parent, toolkit);
- createRelatedLinksSection(parent, toolkit);
+ createRelatedLinksSection(parent, toolkit);
+ createDetailsSection(parent, toolkit);
} catch (SWTException e) {
MylarPlugin.log(e, "content failed");
}
@@ -326,80 +327,21 @@ public class TaskSummaryEditor extends EditorPart {
refreshTaskListView(task);
}
});
-
- l = toolkit.createLabel(container, "Task Handle:");
- l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- Text handle = toolkit.createText(container, task.getHandle(), SWT.BORDER);
- td = new TableWrapData(TableWrapData.FILL_GRAB);
- td.colspan = 2;
- handle.setLayoutData(td);
- handle.setEditable(false);
- handle.setEnabled(false);
-
-
- Label l2 = toolkit.createLabel(container, "Task context path:");
- l2.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- pathText = toolkit.createText(container, "<Mylar_Dir>/"+task.getPath()+".xml", SWT.BORDER);
- pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- pathText.setEditable(false);
- pathText.setEnabled(false);
-
- browse = toolkit.createButton(container, "Change", SWT.PUSH | SWT.CENTER);
- if (task.isActive()) {
- browse.setEnabled(false);
- } else {
- browse.setEnabled(true);
- }
- browse.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- if (task.isActive()) {
- MessageDialog.openInformation(
- Display.getDefault().getActiveShell(),
- "Task Message",
- "Task can not be active when changing taskscape");
- } else {
- FileDialog dialog = new FileDialog(Display.getDefault()
- .getActiveShell(), SWT.OPEN);
- String[] ext = { "*.xml" };
- dialog.setFilterExtensions(ext);
-
- String mylarDir = MylarPlugin.getTaskscapeManager()
- .getMylarDir()
- + "/";
- mylarDir = mylarDir.replaceAll("\\\\", "/");
- // mylarDir = formatPath(mylarDir);
- dialog.setFilterPath(formatPath(mylarDir));
-
- String res = dialog.open();
- if (res != null) {
- res = formatPath(res);
- res = RelativePathUtil.findRelativePath(mylarDir, res);
- pathText.setText("<MylarDir>/" + res + ".xml");
- task.setPath(res);
- }
- }
- }
- });
- toolkit.createLabel(container, "");
- l = toolkit.createLabel(container, "Go to Mylar Preferences to change <Mylar_Dir>");
- l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
}
- private String formatPath(String path) {
- if (path == null) return "";
- StringBuffer result = new StringBuffer(path.length() + 10);
- for (int i = 0; i < path.length(); i++) {
- if (path.charAt(i) == '\\'){
- result.append('/');
- } else {
- result.append(path.charAt(i));
- }
- }
-
- return result.toString();
- }
+// private String formatPath(String path) {
+// if (path == null) return "";
+// StringBuffer result = new StringBuffer(path.length() + 10);
+// for (int i = 0; i < path.length(); i++) {
+// if (path.charAt(i) == '\\'){
+// result.append('/');
+// } else {
+// result.append(path.charAt(i));
+// }
+// }
+//
+// return result.toString();
+// }
private void createNotesSection(Composite parent, FormToolkit toolkit) {
Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
@@ -483,7 +425,7 @@ public class TaskSummaryEditor extends EditorPart {
}
private void createRelatedLinksSection(Composite parent, FormToolkit toolkit) {
- Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
+ Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
section.setText("Related Links");
section.setLayout(new TableWrapLayout());
section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
@@ -597,6 +539,87 @@ public class TaskSummaryEditor extends EditorPart {
}
});
}
+
+ private void createDetailsSection(Composite parent, FormToolkit toolkit) {
+ Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
+ section.setText("Mylar Task Details");
+ section.setLayout(new TableWrapLayout());
+ section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.addExpansionListener(new IExpansionListener() {
+ public void expansionStateChanging(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+ public void expansionStateChanged(ExpansionEvent e) {
+ sform.reflow(true);
+ }
+ });
+
+ Composite container = toolkit.createComposite(section);
+ section.setClient(container);
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.numColumns = 3;
+ container.setLayout(layout);
+
+ Label l = toolkit.createLabel(container, "Task Handle:");
+ l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+ Text handle = toolkit.createText(container, task.getHandle(), SWT.BORDER);
+ TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
+ td.colspan = 2;
+ handle.setLayoutData(td);
+ handle.setEditable(false);
+ handle.setEnabled(false);
+
+
+ Label l2 = toolkit.createLabel(container, "Task context path:");
+ l2.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+ pathText = toolkit.createText(container, "<Mylar_Dir>/"+task.getPath()+".xml", SWT.BORDER);
+ pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ pathText.setEditable(false);
+ pathText.setEnabled(false);
+
+ browse = toolkit.createButton(container, "Change", SWT.PUSH | SWT.CENTER);
+ if (task.isActive()) {
+ browse.setEnabled(false);
+ } else {
+ browse.setEnabled(true);
+ }
+ browse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+
+ if (task.isActive()) {
+ MessageDialog.openInformation(
+ Display.getDefault().getActiveShell(),
+ "Task Message",
+ "Task can not be active when changing taskscape");
+ } else {
+ FileDialog dialog = new FileDialog(Display.getDefault()
+ .getActiveShell(), SWT.OPEN);
+ String[] ext = { "*.xml" };
+ dialog.setFilterExtensions(ext);
+
+ String mylarDir = MylarPlugin.getTaskscapeManager()
+ .getMylarDir()
+ + "/";
+ mylarDir = mylarDir.replaceAll("\\\\", "/");
+ // mylarDir = formatPath(mylarDir);
+ dialog.setFilterPath(mylarDir);
+
+ String res = dialog.open();
+ if (res != null) {
+ res = res.replaceAll("\\\\", "/");
+ res = RelativePathUtil.findRelativePath(mylarDir, res);
+ pathText.setText("<MylarDir>/" + res + ".xml");
+ task.setPath(res);
+ }
+ }
+ }
+ });
+ toolkit.createLabel(container, "");
+ l = toolkit.createLabel(container, "Go to Mylar Preferences to change <Mylar_Dir>");
+ l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+ }
+
private void refreshTaskListView(ITask task) {
if (TaskListView.getDefault() != null) TaskListView.getDefault().notifyTaskDataChanged(task);
}
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 9c4cf0028..c3af29a34 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
@@ -18,6 +18,9 @@ import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
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.ITask;
import org.eclipse.mylar.tasks.ITaskListElement;
import org.eclipse.mylar.tasks.TaskCategory;
@@ -46,7 +49,7 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
case 2:
return element.getPriority();
case 3:
- return element.getDescription();
+ return element.getDescription(true);
case 4:
return element.getHandle();
}
@@ -70,6 +73,24 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
if (child.isActive())
return UiUtil.BOLD;
}
+ }else if (element instanceof BugzillaHit) {
+ BugzillaHit hit = (BugzillaHit)element;
+ BugzillaTask task = hit.getAssociatedTask();
+ if(task != null){
+ if (task.isActive()) return UiUtil.BOLD;
+ if (task.isCompleted()) return UiUtil.ITALIC;
+ }
+ } else if (element instanceof BugzillaQueryCategory) {
+ BugzillaQueryCategory cat = (BugzillaQueryCategory) element;
+ for (ITaskListElement child : cat.getHits()) {
+ if (child instanceof BugzillaHit){
+ BugzillaHit hit = (BugzillaHit) child;
+ BugzillaTask task = hit.getAssociatedTask();
+ if(task != null && task.isActive()){
+ return UiUtil.BOLD;
+ }
+ }
+ }
}
return null;
}
@@ -93,7 +114,14 @@ 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 AbstractCategory) {
+ } else if (element instanceof BugzillaHit) {
+ BugzillaHit hit = (BugzillaHit)element;
+ BugzillaTask task = hit.getAssociatedTask();
+ if(task != null){
+ Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle());
+ if (highlighter != null) return highlighter.getHighlightColor();
+ }
+ }else if (element instanceof AbstractCategory) {
return backgroundColor;
}
return null;
@@ -103,6 +131,10 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP
if (element instanceof ITask) {
ITask task = (ITask)element;
if (task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT;
+ } else if (element instanceof BugzillaHit) {
+ BugzillaHit hit = (BugzillaHit)element;
+ BugzillaTask task = hit.getAssociatedTask();
+ if (task != null && task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT;
}
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 b9f009f30..64ad81a47 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
@@ -41,11 +41,9 @@ 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;
@@ -243,11 +241,16 @@ public class TaskListView extends ViewPart {
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();
+ BugzillaHit hit = (BugzillaHit)obj;
+ if(hit.isTask()){
+ hit.getAssociatedTask().openTaskInEditor();
+ } else {
+ 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);
}
@@ -262,8 +265,14 @@ public class TaskListView extends ViewPart {
@Override
public void run() {
Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
- if (selectedObject != null) {
- MylarPlugin.getTaskscapeManager().taskDeleted(((Task)selectedObject).getHandle(), ((Task)selectedObject).getPath());
+ if (selectedObject != null && selectedObject instanceof ITask) {
+ MylarPlugin.getTaskscapeManager().taskDeleted(((ITask)selectedObject).getHandle(), ((Task)selectedObject).getPath());
+ viewer.refresh();
+ } else if (selectedObject != null && selectedObject instanceof BugzillaHit) {
+ BugzillaTask task = ((BugzillaHit)selectedObject).getAssociatedTask();
+ if(task != null){
+ MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath());
+ }
viewer.refresh();
}
}
@@ -301,6 +310,13 @@ public class TaskListView extends ViewPart {
Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
if (selectedObject instanceof Task){
((Task)selectedObject).setCompleted(false);
+ } else if (selectedObject instanceof BugzillaHit){
+ BugzillaHit hit = (BugzillaHit)selectedObject;
+ BugzillaTask task = hit.getAssociatedTask();
+ if(task != null){
+ task.setCompleted(false);
+ viewer.refresh();
+ }
}
viewer.refresh();
}
@@ -318,6 +334,13 @@ public class TaskListView extends ViewPart {
if (selectedObject instanceof Task){
((Task)selectedObject).setCompleted(true);
viewer.refresh(selectedObject);
+ } else if (selectedObject instanceof BugzillaHit){
+ BugzillaHit hit = (BugzillaHit)selectedObject;
+ BugzillaTask task = hit.getAssociatedTask();
+ if(task != null){
+ task.setCompleted(true);
+ viewer.refresh();
+ }
}
}
}
@@ -431,15 +454,16 @@ public class TaskListView extends ViewPart {
return;
}
+ // XXX we don't care about duplicates since we use a registrey
// Check the existing tasks to see if the id is used already.
// This is to prevent the creation of mutliple Bugzilla tasks
// for the same Bugzilla report.
- boolean doesIdExistAlready = false;
- doesIdExistAlready = lookForId("Bugzilla-" + bugId);
- if (doesIdExistAlready) {
- showMessage("A Bugzilla task with ID Bugzilla-" + bugId + " already exists.");
- return;
- }
+// boolean doesIdExistAlready = false;
+// doesIdExistAlready = lookForId("Bugzilla-" + bugId);
+// if (doesIdExistAlready) {
+// showMessage("A Bugzilla task with ID Bugzilla-" + bugId + " already exists.");
+// return;
+// }
ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>");
Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
@@ -852,7 +876,7 @@ public class TaskListView extends ViewPart {
case 3: return true;
case 4: return false;
}
- } else if (element instanceof ITaskListElement){
+ } else if (element instanceof BugzillaHit){
if (columnIndex == 0) {
return true;
}else {
@@ -889,24 +913,29 @@ public class TaskListView extends ViewPart {
case 2:
return "";
case 3:
- return cat.getDescription();
+ return cat.getDescription(true);
case 4:
return "";
}
- } else if (element instanceof ITaskListElement) {
- ITaskListElement e = (ITaskListElement) element;
+ } else if (element instanceof BugzillaHit) {
+ BugzillaHit hit = (BugzillaHit) element;
+ ITask task = hit.getAssociatedTask();
switch (columnIndex) {
case 0:
- return new Boolean(false);
+ if(task == null){
+ return new Boolean(true);
+ } else {
+ return new Boolean(task.isCompleted());
+ }
case 1:
return "";
case 2:
- String priorityString = e.getPriority().substring(1);
+ String priorityString = hit.getPriority().substring(1);
return new Integer(priorityString);
case 3:
- return e.getDescription();
+ return hit.getDescription(true);
case 4:
- return e.getHandle();
+ return hit.getHandle();
}
}
return "";
@@ -961,22 +990,36 @@ public class TaskListView extends ViewPart {
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;
-// }
+ } else if (((TreeItem) element).getData() instanceof BugzillaHit) {
+ BugzillaHit hit = (BugzillaHit)((TreeItem) element).getData();
+ switch (columnIndex) {
+ case 0:
+ BugzillaTask task = hit.getAssociatedTask();
+ if(task == null){
+ task = new BugzillaTask(hit);
+ hit.setAssociatedTask(task);
+ MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry(task);
+ // TODO move the task to a special folder
+ }
+ if (task.isActive()) {
+ MylarTasksPlugin.getTaskListManager()
+ .deactivateTask(task);
+ } else {
+ MylarTasksPlugin.getTaskListManager().activateTask(
+ task);
+ }
+ viewer.setSelection(null);
+ break;
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ viewer.setSelection(null);
+ break;
+ case 4:
+ break;
+ }
}
viewer.refresh();
} catch (Exception e) {
@@ -1033,15 +1076,15 @@ public class TaskListView extends ViewPart {
}
}
} else if(o1 instanceof BugzillaHit && o2 instanceof BugzillaHit){
- ITaskListElement task1 = (ITaskListElement) o1;
- ITaskListElement task2 = (ITaskListElement) o2;
+ BugzillaHit task1 = (BugzillaHit) o1;
+ BugzillaHit task2 = (BugzillaHit) 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());
+ return task1.getDescription(false).compareTo(task2.getDescription(false));
} else if (column == columnNames[4]){
return task1.getHandle().compareTo(task2.getHandle());
} else {
@@ -1146,20 +1189,6 @@ public class TaskListView extends ViewPart {
});
}
- 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);
@@ -1315,9 +1344,9 @@ public class TaskListView extends ViewPart {
manager.add(moveTaskToRoot);
manager.add(new Separator());
MenuManager subMenuManager = new MenuManager("Choose Highlighter");
+ final Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
for (Iterator<Highlighter> it = MylarUiPlugin.getDefault().getHighlighters().iterator(); it.hasNext();) {
final Highlighter highlighter = it.next();
- final Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
if (selectedObject instanceof Task){
Action action = new Action() {
@@ -1343,6 +1372,43 @@ public class TaskListView extends ViewPart {
}
manager.add(subMenuManager);
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ updateActionEnablement(selectedObject);
+ }
+
+ private void updateActionEnablement(Object sel){
+ if(sel != null && sel instanceof ITaskListElement){
+ if(sel instanceof BugzillaHit){
+ BugzillaTask task = ((BugzillaHit)sel).getAssociatedTask();
+ if(task == null){
+ clearSelectedTaskscapeAction.setEnabled(false);
+ } else {
+ clearSelectedTaskscapeAction.setEnabled(true);
+ }
+ completeTask.setEnabled(false);
+ incompleteTask.setEnabled(false);
+ moveTaskToRoot.setEnabled(false);
+ delete.setEnabled(false);
+ } else if(sel instanceof BugzillaTask){
+ completeTask.setEnabled(false);
+ incompleteTask.setEnabled(false);
+ } else if(sel instanceof AbstractCategory){
+ clearSelectedTaskscapeAction.setEnabled(false);
+ moveTaskToRoot.setEnabled(false);
+ completeTask.setEnabled(false);
+ incompleteTask.setEnabled(false);
+ } else {
+ delete.setEnabled(true);
+ moveTaskToRoot.setEnabled(true);
+ completeTask.setEnabled(true);
+ incompleteTask.setEnabled(true);
+ clearSelectedTaskscapeAction.setEnabled(true);
+ }
+
+ }else {
+ delete.setEnabled(true);
+ moveTaskToRoot.setEnabled(true);
+ clearSelectedTaskscapeAction.setEnabled(false);
+ }
}
private void fillLocalToolBar(IToolBarManager manager) {
@@ -1489,7 +1555,7 @@ public class TaskListView extends ViewPart {
public void notifyTaskDataChanged(ITask task) {
if (viewer.getTree() != null && !viewer.getTree().isDisposed()) {
- viewer.refresh(task);
+ viewer.refresh();
}
}
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 fbaa81e65..0ac234ab8 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
@@ -19,6 +19,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -76,6 +77,8 @@ public class XmlUtil {
Element root = doc.createElement("TaskList");
root.setAttribute("Version", "1.0.1");
+ writeBugzillaRegistry(tlist.getBugzillaTaskRegistry(), doc, root);
+
// iterate through each subtask and externalize those
//
for (AbstractCategory cat : tlist.getCategories()) {
@@ -93,6 +96,15 @@ public class XmlUtil {
return;
}
+ private static void writeBugzillaRegistry(Map<String, BugzillaTask> bugzillaTaskRegistry, Document doc, Element parent) {
+ Element node = doc.createElement("BugzillaTaskRegistry");
+
+ for (BugzillaTask t : bugzillaTaskRegistry.values()) {
+ writeTask(t, doc, node);
+ }
+ parent.appendChild(node);
+ }
+
/**
* Writes an XML file from a DOM.
*
@@ -221,7 +233,7 @@ public class XmlUtil {
private static void writeTaskCategory(TaskCategory cat, Document doc, Element parent) {
Element node = doc.createElement("TaskCategory");
- node.setAttribute("Name", cat.getDescription());
+ node.setAttribute("Name", cat.getDescription(false));
for (ITask t : cat.getChildren()) {
writeTask(t, doc, node);
@@ -231,7 +243,7 @@ public class XmlUtil {
private static void writeQueryCategory(BugzillaQueryCategory cat, Document doc, Element parent) {
Element node = doc.createElement("QueryCategory");
- node.setAttribute("Description", cat.getDescription());
+ node.setAttribute("Description", cat.getDescription(false));
node.setAttribute("URL", cat.getUrl());
parent.appendChild(node);
}
@@ -309,6 +321,8 @@ public class XmlUtil {
if (child.getNodeName().equals("Category") ||
child.getNodeName().equals("TaskCategory")) {
readTaskCategory(child, tlist);
+ } else if (child.getNodeName().equals("BugzillaTaskRegistry")) {
+ readBugzillaRegistry(child, tlist);
} else if (child.getNodeName().equals("QueryCategory")) {
readQueryCategory(child, tlist);
} else {
@@ -324,6 +338,17 @@ public class XmlUtil {
}
}
+ private static void readBugzillaRegistry(Node node, TaskList tlist) {
+ NodeList list = node.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ ITask task = readTask(child, tlist, null, null);
+ if(task instanceof BugzillaTask){
+ tlist.addToBugzillaTaskRegistry((BugzillaTask)task);
+ }
+ }
+ }
+
/**
* Opens the specified XML file and parses it into a DOM Document.
*

Back to the top