Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-07-13 22:51:57 +0000
committersminto2005-07-13 22:51:57 +0000
commit792f9199babba524f290b6e9545531d9e5ecdec1 (patch)
tree806da4db862a4d36cdf49066c3310ff9a2d0ce38 /org.eclipse.mylyn.bugzilla.ui
parentfc8c2c1e3760f3c060d0174d37958e6037f7dd07 (diff)
downloadorg.eclipse.mylyn.tasks-792f9199babba524f290b6e9545531d9e5ecdec1.tar.gz
org.eclipse.mylyn.tasks-792f9199babba524f290b6e9545531d9e5ecdec1.tar.xz
org.eclipse.mylyn.tasks-792f9199babba524f290b6e9545531d9e5ecdec1.zip
fixed Bug# 103594 make query categories work again
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java16
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java49
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaResultCollector.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCategorySearchOperation.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java56
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java45
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java38
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java55
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java175
12 files changed, 399 insertions, 59 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
index 0942c6b86..4c00f1f0a 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
@@ -37,11 +37,12 @@ public class BugzillaUiPlugin extends AbstractUIPlugin implements IStartup {
BugzillaPlugin.setResultEditorMatchAdapter(new BugzillaResultMatchAdapter());
bugzillaProvider = new BugzillaContentProvider();
bugzillaTaskListManager = new BugzillaTaskListManager();
+ MylarTasksPlugin.getDefault().setContributor(new TaskListActionContributor());
MylarTasksPlugin.getDefault().getTaskListExternalizer().addExternalizer(
new BugzillaTaskExternalizer()
);
- MylarTasksPlugin.getDefault().setContributor(new TaskListActionContributor());
+
}
});
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java
index 0fe3623ab..272139ffc 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java
@@ -18,7 +18,7 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
-import org.eclipse.mylar.tasks.TaskCategory;
+import org.eclipse.mylar.tasks.internal.TaskCategory;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
/**
@@ -65,8 +65,20 @@ public class CreateBugzillaTaskAction extends Action {
// return;
// }
- ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>");
+ ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>", true);
Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement();
+
+ if(MylarTasksPlugin.getDefault().getContributor().acceptsItem(newTask)){
+
+ BugzillaTask newTask2 = (BugzillaTask)MylarTasksPlugin.getDefault().getContributor().taskAdded(newTask);
+ if(newTask2 == newTask){
+ ((BugzillaTask)newTask).scheduleDownloadReport();
+ } else {
+ newTask = newTask2;
+ }
+ } else {
+ ((BugzillaTask)newTask).scheduleDownloadReport();
+ }
if (selectedObject instanceof TaskCategory){
((TaskCategory)selectedObject).addTask(newTask);
} else {
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
index ce9c1c35e..0bc52c406 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
@@ -19,6 +19,7 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
+import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaHit;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaQueryCategory;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
@@ -45,8 +46,8 @@ public class RefreshBugzillaAction extends Action {
public void run() {
ISelection selection = this.view.getViewer().getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
- final BugzillaQueryCategory cat = (BugzillaQueryCategory) obj;
if (obj instanceof BugzillaQueryCategory) {
+ final BugzillaQueryCategory cat = (BugzillaQueryCategory) obj;
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws CoreException {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@@ -68,6 +69,6 @@ public class RefreshBugzillaAction extends Action {
// Handle the wrapped exception
MylarPlugin.log(e, e.getMessage());
}
- }
+ }
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
index e98e95464..a34bd3cd0 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
@@ -12,22 +12,18 @@
package org.eclipse.mylar.bugzilla.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
-import org.eclipse.mylar.bugzilla.core.BugReport;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask;
import org.eclipse.mylar.tasks.AbstractCategory;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
-import org.eclipse.mylar.tasks.TaskCategory;
+import org.eclipse.mylar.tasks.internal.TaskCategory;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -77,33 +73,30 @@ public class RefreshBugzillaReportsAction extends Action {
refreshTasksAndQueries();
+// XXX refactored active search
// clear the caches
- Set<String> cachedHandles = new HashSet<String>();
-
- // XXX refactored
+// Set<String> cachedHandles = new HashSet<String>();
// cachedHandles.addAll(MylarTasksPlugin.getDefault().getStructureBridge().getCachedHandles());
// cachedHandles.addAll(MylarTasksPlugin.getReferenceProvider().getCachedHandles());
// MylarTasksPlugin.getDefault().getStructureBridge().clearCache();
// MylarTasksPlugin.getReferenceProvider().clearCachedReports();
// BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge();
- monitor.beginTask("Downloading Bugs", cachedHandles.size());
- for (String key : cachedHandles) {
- try {
- String[] parts = key.split(";");
- final int id = Integer.parseInt(parts[1]);
- BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id);
- if (bug != null) {
- // XXX refactored
- throw new RuntimeException("unimplemented");
+// monitor.beginTask("Downloading Bugs", cachedHandles.size());
+// for (String key : cachedHandles) {
+// try {
+// String[] parts = key.split(";");
+// final int id = Integer.parseInt(parts[1]);
+// BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id);
+// if (bug != null) {
// bridge.cache(key, bug);
- }
- } catch (Exception e) {
- }
-
- monitor.worked(1);
- }
- monitor.done();
+// }
+// } catch (Exception e) {
+// }
+//
+// monitor.worked(1);
+// }
+// monitor.done();
RefreshBugzillaReportsAction.this.view.getViewer().refresh();
}
};
@@ -136,7 +129,13 @@ public class RefreshBugzillaReportsAction extends Action {
((BugzillaTask) task).refresh();
}
}
- RefreshBugzillaReportsAction.this.view.refreshChildren(((TaskCategory) cat).getChildren());
+ if (((TaskCategory) cat).getChildren() != null) {
+ for (ITask child : ((TaskCategory) cat).getChildren()) {
+ if (child instanceof BugzillaTask) {
+ ((BugzillaTask)child).refresh();
+ }
+ }
+ }
} else if (cat instanceof BugzillaQueryCategory) {
final BugzillaQueryCategory bqc = (BugzillaQueryCategory) cat;
PlatformUI.getWorkbench().getDisplay().syncExec(
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
index 5bc986752..0d6c92ec3 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
@@ -106,12 +106,10 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
public static final Font TITLE_FONT = JFaceResources.getHeaderFont();
+ // TODO: don't use hard-coded font
public static final Font TEXT_FONT = JFaceResources.getDefaultFont();
-
public static final Font COMMENT_FONT = new Font(null, "Courier New", 9, SWT.NORMAL);
- public static final Font URL_FONT = new Font(null, "Courier New", 10, SWT.BOLD);
-
public static final Font HEADER_FONT = JFaceResources.getDefaultFont();
public static final int DESCRIPTION_WIDTH = 79 * 7;
@@ -1143,7 +1141,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
protected void setGeneralTitleText() {
String text = getTitleString();
generalTitleText.setText(text);
- generalTitleText.setFont(URL_FONT);
+ generalTitleText.setFont(TEXT_FONT);
if(this instanceof ExistingBugEditor){
generalTitleText.setUnderlined(true);
generalTitleText.setForeground(new Color(Display.getCurrent(), 0, 0, 255));
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaResultCollector.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaResultCollector.java
index 8429dcf2f..aadf97d64 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaResultCollector.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaResultCollector.java
@@ -141,10 +141,8 @@ public class BugzillaResultCollector implements IBugzillaSearchResultCollector {
private String getFormattedMatchesString(int count) {
// if only 1 match, return the singular match string
String name = "";
-
- // XXX refactored
-// if(operation instanceof BugzillaMylarSearchOperation)
-// name = " - " + ((BugzillaMylarSearchOperation)operation).getName();
+ if(operation.getName() != null)
+ name = " - " + operation.getName();
if (count == 1)
return MATCH + name;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCategorySearchOperation.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCategorySearchOperation.java
index b27c5c498..a2962d844 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCategorySearchOperation.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCategorySearchOperation.java
@@ -136,4 +136,8 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
public void addResultsListener(ICategorySearchListener listener){
listeners.add(listener);
}
+
+ public String getName() {
+ return null;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java
index d68ea337b..0252cda1a 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java
@@ -13,8 +13,12 @@ package org.eclipse.mylar.bugzilla.ui.tasks;
import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
+import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
+import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.ITaskListElement;
import org.eclipse.mylar.tasks.TaskListImages;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
/**
@@ -26,16 +30,14 @@ public class BugzillaHit implements ITaskListElement {
private String priority;
private int id;
private BugzillaTask task;
+ private String status;
- public BugzillaHit(String description, String priority, int id, BugzillaTask task) {
+ public BugzillaHit(String description, String priority, int id, BugzillaTask task, String status) {
this.description = description;
this.priority = priority;
this.id = id;
this.task = task;
- }
-
- public boolean isTask(){
- return task != null;
+ this.status = status;
}
public BugzillaTask getAssociatedTask(){
@@ -47,7 +49,7 @@ public class BugzillaHit implements ITaskListElement {
}
public Image getIcon() {
- if(isTask()){
+ if(hasCorrespondingActivatableTask()){
return task.getIcon();
} else {
return BugzillaImages.getImage(BugzillaImages.BUG);
@@ -55,7 +57,7 @@ public class BugzillaHit implements ITaskListElement {
}
public Image getStatusIcon() {
- if (isTask()) {
+ if (hasCorrespondingActivatableTask()) {
return task.getStatusIcon();
} else {
return TaskListImages.getImage(TaskListImages.TASK_INACTIVE);
@@ -93,4 +95,44 @@ public class BugzillaHit implements ITaskListElement {
public String getBugUrl() {
return BugzillaRepository.getBugUrl(id);
}
+
+ public boolean isDirectlyModifiable() {
+ return false;
+ }
+
+ public ITask getCorrespondingActivatableTask() {
+ if(task == null){
+ task = new BugzillaTask(this);
+ BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().addToBugzillaTaskRegistry(task);
+ }
+ return task;
+ }
+
+ public boolean hasCorrespondingActivatableTask() {
+ return getAssociatedTask() != null;
+ }
+
+ public boolean isActivatable() {
+ return true;
+ }
+
+ public boolean isDragAndDropEnabled() {
+ return true;
+ }
+
+ public Color getForeground() {
+ if ((task != null && task.isCompleted()) || status.startsWith("RESO")){
+ return GRAY_VERY_LIGHT;
+ } else {
+ return null;
+ }
+ }
+
+ public Font getFont(){
+ BugzillaTask task = getAssociatedTask();
+ if(task != null){
+ if (task.isActive()) return BOLD;
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java
index f95d385e7..46cf12b3f 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java
@@ -30,7 +30,11 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.search.BugzillaResultCollector;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaCategorySearchOperation.ICategorySearchListener;
import org.eclipse.mylar.tasks.AbstractCategory;
+import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.ITaskListElement;
import org.eclipse.mylar.tasks.TaskListImages;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
@@ -52,7 +56,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(), null));
+ addHit(new BugzillaHit(hit.getId() + ": " + hit.getDescription(), hit.getPriority(), hit.getId(), null, hit.getState()));
}
}
@@ -84,7 +88,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
return url;
}
- public List<BugzillaHit> getHits() {
+ public List<BugzillaHit> getChildren() {
return hits;
}
@@ -162,4 +166,41 @@ public class BugzillaQueryCategory extends AbstractCategory {
}
return highestPriority;
}
+
+ public ITask getCorrespondingActivatableTask() {
+ return null;
+ }
+
+ public boolean hasCorrespondingActivatableTask() {
+ return false;
+ }
+
+ public boolean isDirectlyModifiable() {
+ return false;
+ }
+
+ public boolean isActivatable() {
+ return false;
+ }
+
+ public boolean isDragAndDropEnabled() {
+ return false;
+ }
+
+ public Color getForeground() {
+ return null;
+ }
+
+ public Font getFont() {
+ for (ITaskListElement child : getChildren()) {
+ if (child instanceof BugzillaHit){
+ BugzillaHit hit = (BugzillaHit) child;
+ BugzillaTask task = hit.getAssociatedTask();
+ if(task != null && task.isActive()){
+ return BOLD;
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java
index ed0ea7035..b398368aa 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java
@@ -40,6 +40,7 @@ import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
import org.eclipse.mylar.tasks.TaskListImages;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbench;
@@ -91,16 +92,14 @@ public class BugzillaTask extends Task {
public BugzillaTask(String id, String label) {
super(id, label);
isDirty = false;
- GetBugReportJob job = new GetBugReportJob("Downloading from Bugzilla server...");
- job.schedule();
+ scheduleDownloadReport();
}
public BugzillaTask(String id, String label, boolean noDownload) {
super(id, label);
isDirty = false;
if (!noDownload) {
- GetBugReportJob job = new GetBugReportJob("Downloading from Bugzilla server...");
- job.schedule();
+ scheduleDownloadReport();
}
}
@@ -269,7 +268,7 @@ public class BugzillaTask extends Task {
try {
// try to open an editor on the input bug
//page.openEditor(input, IBugzillaConstants.EXISTING_BUG_EDITOR_ID);
- page.openEditor(input, "org.eclipse.mylar.tasks.ui.bugzillaTaskEditor");
+ page.openEditor(input, "org.eclipse.mylar.bugzilla.ui.tasks.bugzillaTaskEditor");
}
catch (PartInitException ex) {
MylarPlugin.log(ex, "couldn't open");
@@ -483,6 +482,7 @@ public class BugzillaTask extends Task {
return -1;
}
+ @Override
public Image getIcon() {
return TaskListImages.getImage(BugzillaImages.TASK_BUGZILLA);
}
@@ -491,11 +491,39 @@ public class BugzillaTask extends Task {
return BugzillaRepository.getBugUrl(getBugId(handle));
}
+ @Override
public boolean canEditDescription() {
return false;
}
+ @Override
public String getDeleteConfirmationMessage() {
return "Remove this report from the task list, and discard any task context or local notes?";
}
+
+ @Override
+ public boolean isDirectlyModifiable() {
+ return false;
+ }
+
+ @Override
+ public boolean participatesInTaskHandles() {
+ return false;
+ }
+
+ @Override
+ public Font getFont(){
+ Font f = super.getFont();
+ if(f != null) return f;
+
+ if (getState() != BugzillaTask.BugTaskState.FREE) {
+ return ITALIC;
+ }
+ return null;
+ }
+
+ public void scheduleDownloadReport() {
+ GetBugReportJob job = new GetBugReportJob("Downloading from Bugzilla server...");
+ job.schedule();
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java
index 67a6d810a..f3bfa2a54 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java
@@ -13,17 +13,23 @@ package org.eclipse.mylar.bugzilla.ui.tasks;
import java.util.Date;
+import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask.BugTaskState;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.AbstractCategory;
import org.eclipse.mylar.tasks.ITask;
-import org.eclipse.mylar.tasks.TaskList;
-import org.eclipse.mylar.tasks.util.DefaultTaskListExternalizer;
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
+import org.eclipse.mylar.tasks.internal.DefaultTaskListExternalizer;
+import org.eclipse.mylar.tasks.internal.TaskList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
+ * The wierd thing here is that the registry gets read in as a normal
+ * category, but gets written out by createRegistry
+ *
* @author Mik Kersten and Ken Sueda
*/
public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
@@ -33,22 +39,53 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
private static final String DIRTY = "Dirty";
private static final String URL = "URL";
private static final String DESCRIPTION = "Description";
-
+
+ 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_TASK = "BugzillaReport";
@Override
+ public void createRegistry(Document doc, Node parent) {
+ Element node = doc.createElement(BUGZILLA_TASK_REGISTRY);
+ for (BugzillaTask task : BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().getBugzillaTaskRegistry().values()) {
+ try {
+ createTaskElement(task, doc, node);
+ } catch (Exception e) {
+ MylarPlugin.log(e, e.getMessage());
+ }
+
+ }
+ parent.appendChild(node);
+ }
+
+ @Override
public boolean canReadCategory(Node node) {
- return node.getNodeName().equals(getCategoryTagName());
+ return node.getNodeName().equals(getCategoryTagName())
+ || node.getNodeName().equals(BUGZILLA_TASK_REGISTRY);
}
@Override
- public void readCategory(Node node, TaskList tlist) {
+ public void readCategory(Node node, TaskList taskList) {
Element e = (Element) node;
- BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute(DESCRIPTION), e.getAttribute(URL));
- tlist.addCategory(cat);
+ if (e.getNodeName().equals(BUGZILLA_TASK_REGISTRY)) {
+ readRegistry(node, taskList);
+ } else {
+ BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute(DESCRIPTION), e.getAttribute(URL));
+ taskList.addCategory(cat);
+ }
}
+ public void readRegistry(Node node, TaskList taskList) {
+ NodeList list = node.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node child = list.item(i);
+ ITask task = readTask(child, taskList, null, null);
+ if(task instanceof BugzillaTask){
+ BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().addToBugzillaTaskRegistry((BugzillaTask)task);
+ }
+ }
+ }
+
public boolean canCreateElementFor(AbstractCategory category) {
return category instanceof BugzillaQueryCategory;
}
@@ -110,6 +147,10 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
if (task.readBugReport() == false) {
MylarPlugin.log("Failed to read bug report", null);
}
+
+ if(MylarTasksPlugin.getDefault().getContributor() != null && MylarTasksPlugin.getDefault().getContributor().acceptsItem(task)){
+ task = (BugzillaTask)MylarTasksPlugin.getDefault().getContributor().taskAdded(task);
+ }
return task;
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java
index 3ab8638c7..9bfa4eaa6 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java
@@ -15,12 +15,28 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure;
+import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
+import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
+import org.eclipse.mylar.bugzilla.ui.ViewBugzillaAction;
import org.eclipse.mylar.bugzilla.ui.actions.CreateBugzillaQueryCategoryAction;
import org.eclipse.mylar.bugzilla.ui.actions.CreateBugzillaTaskAction;
import org.eclipse.mylar.bugzilla.ui.actions.RefreshBugzillaAction;
import org.eclipse.mylar.bugzilla.ui.actions.RefreshBugzillaReportsAction;
+import org.eclipse.mylar.core.MylarPlugin;
+import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.ITaskListActionContributor;
+import org.eclipse.mylar.tasks.ITaskListElement;
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
+import org.eclipse.mylar.tasks.internal.TaskCategory;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.internal.Workbench;
/**
* @author Mik Kersten and Ken Sueda
@@ -40,5 +56,164 @@ public class TaskListActionContributor implements ITaskListActionContributor {
actions.add(new CreateBugzillaTaskAction(view));
actions.add(new RefreshBugzillaAction(view));
return actions;
+ }
+
+ public void taskActivated(ITask task) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void taskDeactivated(ITask task) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void itemDeleted(ITaskListElement element) {
+ if (element instanceof BugzillaQueryCategory) {
+ boolean deleteConfirmed = MessageDialog.openQuestion(
+ Workbench.getInstance().getActiveWorkbenchWindow().getShell(),
+ "Confirm delete",
+ "Delete the selected query and all contained tasks?");
+ if (!deleteConfirmed)
+ return;
+ BugzillaQueryCategory cat = (BugzillaQueryCategory) element;
+ MylarTasksPlugin.getTaskListManager().deleteCategory(cat);
+ } else if (element instanceof BugzillaTask) {
+ BugzillaTask task = (BugzillaTask) element;
+ if (task.isActive()) {
+ MessageDialog.openError(Workbench.getInstance()
+ .getActiveWorkbenchWindow().getShell(), "Delete failed",
+ "Task must be deactivated in order to delete.");
+ return;
+ }
+
+ String message = task.getDeleteConfirmationMessage();
+ boolean deleteConfirmed = MessageDialog.openQuestion(
+ Workbench.getInstance().getActiveWorkbenchWindow().getShell(),
+ "Confirm delete", message);
+ if (!deleteConfirmed)
+ return;
+
+ task.removeReport();
+ MylarTasksPlugin.getTaskListManager().deleteTask(task);
+ MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath());
+ IWorkbenchPage page = MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ // if we couldn't get the page, get out of here
+ if (page == null)
+ return;
+ try {
+ TaskListView.getDefault().closeTaskEditors(task, page);
+ } catch (Exception e) {
+ MylarPlugin.log(e, " deletion failed");
+ }
+ }
+ // XXX inform can't delete hits???
+ }
+
+ public void taskCompleted(ITask task) {
+ // TODO can't do this
+ }
+
+ public void itemOpened(ITaskListElement element) {
+
+ if (element instanceof BugzillaTask) {
+ BugzillaTask t = (BugzillaTask) element;
+ MylarTasksPlugin.Report_Open_Mode mode = MylarTasksPlugin.getDefault().getReportMode();
+ if (mode == MylarTasksPlugin.Report_Open_Mode.EDITOR) {
+ t.openTaskInEditor();
+ } else if (mode == MylarTasksPlugin.Report_Open_Mode.INTERNAL_BROWSER) {
+ BugzillaUITools.openUrl(t.getBugUrl());
+ } else {
+ // not supported
+ }
+ }
+ else if (element instanceof BugzillaQueryCategory){
+ BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell());
+ if(sqd.open() == Dialog.OK){
+ BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)element;
+ queryCategory.setDescription(sqd.getName());
+ queryCategory.setUrl(sqd.getUrl());
+
+ queryCategory.refreshBugs();
+ TaskListView.getDefault().getViewer().refresh();
+ }
+ } else if(element instanceof BugzillaHit){
+ BugzillaHit hit = (BugzillaHit)element;
+ MylarTasksPlugin.Report_Open_Mode mode = MylarTasksPlugin.getDefault().getReportMode();
+ if (mode == MylarTasksPlugin.Report_Open_Mode.EDITOR) {
+ if(hit.hasCorrespondingActivatableTask()){
+ hit.getAssociatedTask().openTaskInEditor();
+ } else {
+ BugzillaOpenStructure open = new BugzillaOpenStructure(((BugzillaHit)element).getServerName(), ((BugzillaHit)element).getID(),-1);
+ List<BugzillaOpenStructure> selectedBugs = new ArrayList<BugzillaOpenStructure>();
+ selectedBugs.add(open);
+ ViewBugzillaAction viewBugs = new ViewBugzillaAction("Display bugs in editor", selectedBugs);
+ viewBugs.schedule();
+ }
+ } else if (mode == MylarTasksPlugin.Report_Open_Mode.INTERNAL_BROWSER) {
+ BugzillaUITools.openUrl(hit.getBugUrl());
+ } else {
+ // not supported
+ }
+ }
+
+ }
+
+ public boolean acceptsItem(ITaskListElement element) {
+ return element instanceof BugzillaTask || element instanceof BugzillaHit || element instanceof BugzillaQueryCategory;
+ }
+
+ public void dropItem(ITaskListElement element, TaskCategory cat) {
+ if (element instanceof BugzillaHit) {
+ BugzillaHit bh = (BugzillaHit) element;
+ if (bh.getAssociatedTask() != null) {
+ bh.getAssociatedTask().setCategory(cat);
+ cat.addTask(bh.getAssociatedTask());
+ } else {
+ BugzillaTask bt = new BugzillaTask(bh);
+ bh.setAssociatedTask(bt);
+ bt.setCategory(cat);
+ cat.addTask(bt);
+ BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().addToBugzillaTaskRegistry(bt);
+ }
+ }
+ }
+
+ public void taskClosed(ITask element, IWorkbenchPage page) {
+ try{
+ IEditorInput input = null;
+ if (element instanceof BugzillaTask) {
+ input = new BugzillaTaskEditorInput((BugzillaTask)element);
+ }
+ IEditorPart editor = page.findEditor(input);
+
+ if (editor != null) {
+ page.closeEditor(editor, false);
+ }
+ } catch (Exception e){
+ MylarPlugin.log(e, "Error while trying to close a bugzilla task");
+ }
+ }
+
+ public ITask taskAdded(ITask newTask) {
+ if(newTask instanceof BugzillaTask){
+ BugzillaTask bugTask = BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().getFromBugzillaTaskRegistry(newTask.getHandle());
+ if(bugTask == null){
+ BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().addToBugzillaTaskRegistry((BugzillaTask)newTask);
+ bugTask = (BugzillaTask)newTask;
+ }
+ return bugTask;
+ }
+ return null;
+ }
+
+ public void restoreState(TaskListView taskListView) {
+ if (MylarTasksPlugin.getDefault().refreshOnStartUpEnabled()) {
+ RefreshBugzillaReportsAction refresh = new RefreshBugzillaReportsAction(taskListView);
+ refresh.setShowProgress(false);
+ refresh.run();
+ refresh.setShowProgress(true);
+ }
}
}

Back to the top