Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-06-22 16:03:47 -0400
committersminto2005-06-22 16:03:47 -0400
commitfb2ce921ffc2bd524b59e8b84328cd148c7f9190 (patch)
treefa901a4835ae49a677ca66fc4d7c7077b0477647 /org.eclipse.mylyn.tasks.ui
parent7ad04320d212147bf864d231a93d0f37fae2c6b2 (diff)
downloadorg.eclipse.mylyn.tasks-fb2ce921ffc2bd524b59e8b84328cd148c7f9190.tar.gz
org.eclipse.mylyn.tasks-fb2ce921ffc2bd524b59e8b84328cd148c7f9190.tar.xz
org.eclipse.mylyn.tasks-fb2ce921ffc2bd524b59e8b84328cd148c7f9190.zip
Repairing Active Search:
- cache bugzilla results - update refresh in ui
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java17
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java131
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java40
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java158
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java19
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java17
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java82
7 files changed, 400 insertions, 64 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
index 14e024a9d..e4fdcea01 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
@@ -53,7 +53,9 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
/** The bridge between Bugzilla and mylar */
private static BugzillaMylarBridge bridge = null;
- private static BugzillaStructureBridge structureBridge = new BugzillaStructureBridge();
+ private BugzillaStructureBridge structureBridge;
+
+ private static BugzillaReferencesProvider referencesProvider = new BugzillaReferencesProvider();
private static ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() {
@@ -118,9 +120,11 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
public void run() {
-
+
+ structureBridge = new BugzillaStructureBridge();
+
MylarPlugin.getDefault().addBridge(structureBridge);
- MylarPlugin.getTaskscapeManager().addListener(new BugzillaReferencesProvider());
+ MylarPlugin.getTaskscapeManager().addListener(referencesProvider);
MylarUiPlugin.getDefault().addAdapter(BugzillaStructureBridge.EXTENSION, new BugzillaUiBridge());
MylarPlugin.getDefault().getSelectionMonitors().add(new BugzillaEditingMonitor());
@@ -218,7 +222,12 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
this.bugzillaProvider = bugzillaProvider;
}
- public static BugzillaStructureBridge getStructureBridge() {
+ public BugzillaStructureBridge getStructureBridge() {
return structureBridge;
}
+
+ public static BugzillaReferencesProvider getReferenceProvider() {
+ return referencesProvider;
+
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java
new file mode 100644
index 000000000..7da0be56e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 University Of British Columbia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylar.tasks.bugzilla;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.mylar.bugzilla.BugzillaPlugin;
+import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
+
+/**
+ * COPIED FROM @see org.eclipse.mylar.bugzilla.offlineReports.OfflineReportsFile
+ *
+ * @author Shawn Minto
+ */
+public class BugzillaCacheFile {
+
+ private File file;
+
+ private ArrayList<IBugzillaBug> list = new ArrayList<IBugzillaBug>();
+
+ protected int latestNewBugId = 0;
+
+ public BugzillaCacheFile(File file) throws ClassNotFoundException, IOException {
+ this.file = file;
+ if (file.exists()) {
+ readFile();
+ }
+ }
+
+ public void add(IBugzillaBug entry) {
+ // add the entry to the list and write the file to disk
+ list.add(entry);
+ writeFile();
+ }
+
+ public void update() {
+ writeFile();
+ }
+
+ public int getNextOfflineBugId() {
+ latestNewBugId++;
+ return latestNewBugId;
+ }
+
+ public int find(int id) {
+ for (int i = 0; i < list.size(); i++) {
+ IBugzillaBug currBug = list.get(i);
+ if (currBug != null && (currBug.getId() == id) && !currBug.isLocallyCreated())
+ return i;
+ }
+ return -1;
+ }
+
+ public ArrayList<IBugzillaBug> elements() {
+ return list;
+ }
+
+ private void writeFile() {
+ try {
+ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
+
+ // Write the size of the list so that we can read it back in easier
+ out.writeInt(list.size());
+
+ out.writeInt(latestNewBugId);
+
+ // write each element in the array list
+ for (int i = 0; i < list.size(); i++) {
+ Object item = list.get(i);
+ out.writeObject(item);
+ }
+ out.close();
+ }
+ catch (IOException e) {
+ // put up a message and log the error if there is a problem writing to the file
+ MessageDialog.openError(null,
+ "I/O Error",
+ "Bugzilla could not write to offline reports file.");
+ BugzillaPlugin.log(e);
+ }
+ }
+
+ private void readFile() throws ClassNotFoundException, IOException {
+ ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
+
+ // get the number of offline reports in the file
+ int size = in.readInt();
+
+ // get the bug id of the most recently created offline report
+ latestNewBugId = in.readInt();
+
+ // read in each of the offline reports in the file
+ for (int nX = 0; nX < size; nX++) {
+ IBugzillaBug item = (IBugzillaBug) in.readObject();
+ // add the offline report to the offlineReports list
+ list.add(item);
+ }
+ in.close();
+ }
+
+ public void remove(List<IBugzillaBug> sel) {
+ list.removeAll(sel);
+
+ // rewrite the file so that the data is persistant
+ writeFile();
+ }
+
+ public void removeAll() {
+ list.clear();
+
+ // rewrite the file so that the data is persistant
+ writeFile();
+ }
+}
+
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java
index 04a557dee..6b810f142 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java
@@ -13,8 +13,11 @@
*/
package org.eclipse.mylar.tasks.bugzilla;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
@@ -25,6 +28,7 @@ import org.eclipse.mylar.core.model.ITaskscapeNode;
import org.eclipse.mylar.core.search.IActiveSearchListener;
import org.eclipse.mylar.core.search.IMylarSearchOperation;
import org.eclipse.mylar.core.search.RelationshipProvider;
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearch;
@@ -76,11 +80,16 @@ public class BugzillaReferencesProvider extends RelationshipProvider {
public void searchCompleted(List<?> nodes) {
Iterator<?> itr = nodes.iterator();
+ BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge();
+
while(itr.hasNext()) {
Object o = itr.next();
if(o instanceof BugzillaReportNode){
BugzillaReportNode bugzillaNode = (BugzillaReportNode)o;
- incrementInterest(degreeOfSeparation, BugzillaStructureBridge.EXTENSION, bugzillaNode.getElementHandle());
+ String handle = bugzillaNode.getElementHandle();
+ if(bridge.getCached(handle) == null)
+ cache(handle, bugzillaNode);
+ incrementInterest(degreeOfSeparation, BugzillaStructureBridge.EXTENSION, handle);
}
}
gathered = true;
@@ -94,7 +103,7 @@ public class BugzillaReferencesProvider extends RelationshipProvider {
search.run(new NullProgressMonitor());
}
- @Override
+ @Override
protected String getSourceId() {
return ID;
}
@@ -103,4 +112,31 @@ public class BugzillaReferencesProvider extends RelationshipProvider {
public String getName() {
return NAME;
}
+
+ /*
+ *
+ * STUFF FOR TEMPORARILY CACHING A PROXY REPORT
+ *
+ * TODO remove the proxys and update the BugzillaStructureBridge cache so that on restart,
+ * we dont have to get all of the bugs
+ *
+ */
+ private static final Map<String, BugzillaReportNode> reports = new HashMap<String, BugzillaReportNode>();
+
+ public BugzillaReportNode getCached(String handle){
+ return reports.get(handle);
+ }
+
+ protected void cache(String handle, BugzillaReportNode bugzillaNode) {
+ reports.put(handle, bugzillaNode);
+ }
+
+ public void clearCachedReports(){
+ reports.clear();
+ }
+
+ public Collection<? extends String> getCachedHandles() {
+ return reports.keySet();
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java
index a774fa336..272e8c2fd 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java
@@ -13,15 +13,32 @@
*/
package org.eclipse.mylar.tasks.bugzilla;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
+import org.eclipse.mylar.bugzilla.search.BugzillaSearchHit;
import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor;
import org.eclipse.mylar.bugzilla.ui.outline.BugzillaOutlineNode;
import org.eclipse.mylar.bugzilla.ui.outline.BugzillaReportSelection;
import org.eclipse.mylar.bugzilla.ui.outline.BugzillaTools;
import org.eclipse.mylar.core.IMylarStructureBridge;
+import org.eclipse.mylar.core.MylarPlugin;
+import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.progress.IProgressService;
import org.eclipse.ui.views.markers.internal.ProblemMarker;
@@ -35,6 +52,7 @@ public class BugzillaStructureBridge implements IMylarStructureBridge {
public BugzillaStructureBridge() {
super();
+ readCacheFile();
}
/**
@@ -54,42 +72,72 @@ public class BugzillaStructureBridge implements IMylarStructureBridge {
return null;
}
- public Object getObjectForHandle(String handle) {
+ private BugReport result;
+
+ public Object getObjectForHandle(final String handle) {
+ result = null;
+
String [] parts = handle.split(";");
if (parts.length >= 2){
-// String server = parts[0]; TODO add back in when we deal with multiple servers
- int id = Integer.parseInt(parts[1]);
+ String server = parts[0];
+ final int id = Integer.parseInt(parts[1]);
+
+ String bugHandle = server + ";" + id;
+
int commentNumber = -1;
if(parts.length == 3){
commentNumber = Integer.parseInt(parts[2]);
}
- try{
- // get the bugzillaOutlineNode for the element
- IEditorPart editorPart = null;
- try{
- editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- }catch(NullPointerException e){
- // do nothing, this just means that there is no active page
- }
- if(editorPart != null && editorPart instanceof AbstractBugEditor){
- AbstractBugEditor abe = ((AbstractBugEditor)editorPart);
- BugzillaOutlineNode node = abe.getModel();
- return findNode(node, commentNumber);
- }
-
- // TODO There is a huge slowdown here always getting the object - maybe make bugzilla store the bug for a while in memory or as temp ofline?
- BugzillaOutlineNode node = BugzillaOutlineNode.parseBugReport(BugzillaRepository.getInstance().getCurrentBug(id));
- return findNode(node, commentNumber);
- }catch(Exception e){
- return null;
+
+ // get the bugzillaOutlineNode for the element
+ IEditorPart editorPart = null;
+ try{
+ editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ }catch(NullPointerException e){
+ // do nothing, this just means that there is no active page
+ }
+ if(editorPart != null && editorPart instanceof AbstractBugEditor){
+ AbstractBugEditor abe = ((AbstractBugEditor)editorPart);
+ BugzillaOutlineNode node = abe.getModel();
+ return findNode(node, commentNumber);
}
+
+ // try to get from the cache, if it doesn't exist, startup an operation to get it
+ result = getFromCache(bugHandle);
+ if(result == null){
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("Downloading Bug# " + id, IProgressMonitor.UNKNOWN);
+ try {
+ result = BugzillaRepository.getInstance().getCurrentBug(id);
+ }catch(Exception e){
+ result = null;
+ }
+ }};
+
+ // Use the progess service to execute the runnable
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ try {
+ service.run(false, false, op);
+ } catch (InvocationTargetException e) {
+ // Operation was canceled
+ } catch (InterruptedException e) {
+ // Handle the wrapped exception
+ }
+
+ if(result != null)
+ cache(bugHandle, result);
+ }
+
+ BugzillaOutlineNode node = BugzillaOutlineNode.parseBugReport(result);
+ return findNode(node, commentNumber);
}
else{
return null;
}
}
-
- private BugzillaOutlineNode findNode(BugzillaOutlineNode startNode, int commentNumber){
+
+ private BugzillaOutlineNode findNode(BugzillaOutlineNode startNode, int commentNumber){
if(commentNumber == -1){
return startNode;
@@ -111,6 +159,11 @@ public class BugzillaStructureBridge implements IMylarStructureBridge {
}
public String getParentHandle(String handle) {
+
+ //check so that we don't need to try to get the parent if we are already at the bug report
+ if(!handle.matches(".*;.*;.*"))
+ return null;
+
BugzillaOutlineNode bon = (BugzillaOutlineNode)getObjectForHandle(handle);
if(bon != null && bon.getParent() != null)
return BugzillaTools.getHandle(bon.getParent());
@@ -133,6 +186,9 @@ public class BugzillaStructureBridge implements IMylarStructureBridge {
if(object instanceof BugzillaOutlineNode){
BugzillaOutlineNode b = (BugzillaOutlineNode)object;
return BugzillaTools.getName(b);
+ } else if (object instanceof BugzillaReportNode){
+ BugzillaSearchHit hit = ((BugzillaReportNode)object).getHit();
+ return hit.getServer() + ": Bug#: " + hit.getId() + ": " + hit.getDescription();
}
return "";
}
@@ -165,4 +221,58 @@ public class BugzillaStructureBridge implements IMylarStructureBridge {
public String getResourceExtension(String elementHandle) {
return getResourceExtension();
}
+
+ /*
+ *
+ * STUFF FOR CACHING BUG REPORTS
+ *
+ */
+
+ // bug report cache
+ private Map<String, BugReport> cache = new HashMap<String, BugReport>();
+
+ public void cache(String handle, BugReport report) {
+ cache.put(handle, report);
+ cacheFile.add(report);
+ }
+
+ public void clearCache(){
+ cache.clear();
+ cacheFile.removeAll();
+ }
+
+ private BugReport getFromCache(String bugHandle) {
+ return cache.get(bugHandle);
+ }
+
+ public Set<String> getCachedHandles(){
+ return cache.keySet();
+ }
+
+ private BugzillaCacheFile cacheFile;
+
+ private IPath getCacheFile() {
+ IPath stateLocation = Platform.getPluginStateLocation(MylarTasksPlugin.getDefault());
+ IPath configFile = stateLocation.append("offlineReports");
+ return configFile;
+ }
+
+ private void readCacheFile() {
+ IPath cachPath = getCacheFile();
+
+ try {
+ cacheFile = new BugzillaCacheFile(cachPath.toFile());
+ ArrayList<IBugzillaBug> cached = cacheFile.elements();
+ for(IBugzillaBug bug: cached){
+ if(bug instanceof BugReport)
+ cache.put(BugzillaTools.getHandle(bug), (BugReport)bug);
+ }
+ } catch (Exception e) {
+ MylarPlugin.log(e, "occurred while restoring saved offline Bugzilla reports.");
+ }
+ }
+
+ public BugReport getCached(String handle) {
+ return cache.get(handle);
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java
index 4e59546d5..dea6339ee 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java
@@ -24,7 +24,6 @@ import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.mylar.core.search.IActiveSearchListener;
import org.eclipse.mylar.core.search.IMylarSearchOperation;
-import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge;
import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
import org.eclipse.mylar.tasks.bugzilla.Util;
@@ -73,16 +72,16 @@ public class BugzillaMylarSearch implements IMylarSearchOperation {
// search on them
for(IMember m : members){
- // FIXME: decide whether to do leave the caching in for now or not
+ // FIXME: decide whether to do leave the caching of searches in for now or not
// check if we have the info cached
- List<BugzillaReportNode> landmarkDoi = MylarTasksPlugin.getBridge()
- .getFromLandmarksHash(m, scope);
-
- if (landmarkDoi != null) {
- //TODO decide when to queue up and do a refresh search
- notifySearchCompleted(landmarkDoi);
- continue;
- }
+// List<BugzillaReportNode> landmarkDoi = MylarTasksPlugin.getBridge()
+// .getFromLandmarksHash(m, scope);
+
+// if (landmarkDoi != null) {
+// //TODO decide when to queue up and do a refresh search
+// notifySearchCompleted(landmarkDoi);
+// continue;
+// }
// create a search operation so that we can search
BugzillaMylarSearchOperation op = new BugzillaMylarSearchOperation(
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java
index a60e03546..01a2f5791 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java
@@ -15,8 +15,10 @@ package org.eclipse.mylar.tasks.bugzilla.ui;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.core.model.ITaskscapeNode;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
+import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
import org.eclipse.mylar.ui.MylarImages;
import org.eclipse.swt.graphics.Image;
@@ -34,10 +36,17 @@ public class BugzillaNodeLabelProvider implements ILabelProvider {
*/
public String getText(Object element) {
ITaskscapeNode node = (ITaskscapeNode)element;
- String name = MylarTasksPlugin.getStructureBridge().getName(
- MylarTasksPlugin.getStructureBridge().getObjectForHandle(node.getElementHandle())
- );
- return name;
+
+ // try to get from the cache before downloading
+ Object report;
+ BugzillaReportNode reportNode = MylarTasksPlugin.getReferenceProvider().getCached(node.getElementHandle());
+ BugReport cachedReport = MylarTasksPlugin.getDefault().getStructureBridge().getCached(node.getElementHandle());
+ if(reportNode != null && cachedReport == null){
+ report = reportNode;
+ } else{
+ report = MylarTasksPlugin.getDefault().getStructureBridge().getObjectForHandle(node.getElementHandle());
+ }
+ return MylarTasksPlugin.getDefault().getStructureBridge().getName(report);
}
public void addListener(ILabelProviderListener listener) {
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 7dc995324..65dfa12e4 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
@@ -11,12 +11,17 @@
package org.eclipse.mylar.tasks.ui.views;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import javax.security.auth.login.LoginException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -42,6 +47,8 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerDropAdapter;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.Window;
+import org.eclipse.mylar.bugzilla.core.BugReport;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.mylar.core.ITaskscapeListener;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.dt.MylarWebRef;
@@ -50,6 +57,7 @@ import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge;
import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput;
import org.eclipse.mylar.ui.MylarImages;
import org.eclipse.mylar.ui.MylarUiPlugin;
@@ -80,9 +88,12 @@ import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.part.DrillDownAdapter;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.progress.IProgressService;
/**
* @author Mik Kersten
@@ -609,27 +620,58 @@ public class TaskListView extends ViewPart {
private void makeActions() {
refresh = new Action() {
-
+
@Override
- public void run() {
-// Object[] expanded = viewer.getExpandedElements();
-// for (int i = 0; i < expanded.length; i++) {
-// Object element = expanded[i];
-// if (element instanceof BugzillaTask) {
-// ((BugzillaTask)element).refresh();
-// }
-// }
-
- List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
-
- for (ITask task : tasks) {
- if (task instanceof BugzillaTask) {
- ((BugzillaTask)task).refresh();
- }
- refreshChildren(task.getChildren());
- }
-
- viewer.refresh();
+ public void run() {
+ // TODO background?
+ // perform the update in an operation so that we get a progress monitor
+ // update the structure bridge cache with the reference provider cached bugs
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor) throws CoreException {
+
+ List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
+
+ for (ITask task : tasks) {
+ if (task instanceof BugzillaTask) {
+ ((BugzillaTask)task).refresh();
+ }
+ refreshChildren(task.getChildren());
+ }
+
+ // clear the caches
+ 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)
+ bridge.cache(key, bug);
+ }catch(Exception e){}
+
+ monitor.worked(1);
+ }
+ monitor.done();
+ viewer.refresh();
+ }
+ };
+
+ // Use the progess service to execute the runnable
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ try {
+ service.run(true, false, op);
+ } catch (InvocationTargetException e) {
+ // Operation was canceled
+ } catch (InterruptedException e) {
+ // Handle the wrapped exception
+ }
}
};
refresh.setText("Refresh all Bugzilla reports");

Back to the top