Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-12-12 20:14:33 +0000
committermkersten2005-12-12 20:14:33 +0000
commit7595eee5bca5acc3004862830a8fd7a286cd30f2 (patch)
tree65af113c2c642db3cbb24fd6f741f565cb9e2d0b
parentccc8871db5eb3592c9fdb0ed9e13186dd5001905 (diff)
downloadorg.eclipse.mylyn.tasks-7595eee5bca5acc3004862830a8fd7a286cd30f2.tar.gz
org.eclipse.mylyn.tasks-7595eee5bca5acc3004862830a8fd7a286cd30f2.tar.xz
org.eclipse.mylyn.tasks-7595eee5bca5acc3004862830a8fd7a286cd30f2.zip
Completed: Bug 120374: task activity time reportes is too high
https://bugs.eclipse.org/bugs/show_bug.cgi?id=120374
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java3
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/CompletedTaskCollector.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ITaskCollector.java (renamed from org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ITasksCollector.java)2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/InProgressTaskCollector.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ReminderRequiredCollector.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/TaskReportGenerator.java41
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ui/TaskPlannerEditorInput.java36
7 files changed, 61 insertions, 27 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java
index 98372cd60..d9f68bae2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java
@@ -445,8 +445,6 @@ public class MylarTaskListPlugin extends AbstractUIPlugin implements IStartup {
}
private void checkReminders() {
- // if (getPrefs().getBoolean(REMINDER_CHECK)) {
- // getPrefs().setValue(REMINDER_CHECK, false);
final TaskReportGenerator parser = new TaskReportGenerator(MylarTaskListPlugin.getTaskListManager().getTaskList());
parser.addCollector(new ReminderRequiredCollector());
parser.collectTasks();
@@ -459,7 +457,6 @@ public class MylarTaskListPlugin extends AbstractUIPlugin implements IStartup {
}
});
}
- // }
}
public static void setPriorityLevel(PriorityLevel pl) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/CompletedTaskCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/CompletedTaskCollector.java
index 8facaf718..ec42915d4 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/CompletedTaskCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/CompletedTaskCollector.java
@@ -22,7 +22,7 @@ import org.eclipse.mylar.tasklist.ITask;
/**
* @author Ken Sueda
*/
-public class CompletedTaskCollector implements ITasksCollector {
+public class CompletedTaskCollector implements ITaskCollector {
private Map<String, ITask> completedTasks = new HashMap<String, ITask>();
private Date periodStartDate;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ITasksCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ITaskCollector.java
index f4c0c0390..127cd37aa 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ITasksCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ITaskCollector.java
@@ -18,7 +18,7 @@ import org.eclipse.mylar.tasklist.ITask;
/**
* @author Ken Sueda
*/
-public interface ITasksCollector {
+public interface ITaskCollector {
public abstract void consumeTask(ITask task);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/InProgressTaskCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/InProgressTaskCollector.java
index 5792f1654..047169b34 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/InProgressTaskCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/InProgressTaskCollector.java
@@ -18,7 +18,7 @@ import org.eclipse.mylar.tasklist.ITask;
* @author Wesley Coelho (Adapted from CompletedTaskCollector by Key Sueda)
* @author Mik Kersten
*/
-public class InProgressTaskCollector implements ITasksCollector {
+public class InProgressTaskCollector implements ITaskCollector {
private Map<String, ITask> inProgressTasks = new HashMap<String, ITask>();
private Date periodStartDate ;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ReminderRequiredCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ReminderRequiredCollector.java
index f5d178187..2da4d4f3a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ReminderRequiredCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ReminderRequiredCollector.java
@@ -20,7 +20,7 @@ import org.eclipse.mylar.tasklist.ITask;
/**
* @author Ken Sueda
*/
-public class ReminderRequiredCollector implements ITasksCollector {
+public class ReminderRequiredCollector implements ITaskCollector {
private List<ITask> tasks = new ArrayList<ITask>();
private Date curr = null;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/TaskReportGenerator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/TaskReportGenerator.java
index e0164d799..c0fab102e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/TaskReportGenerator.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/TaskReportGenerator.java
@@ -11,9 +11,14 @@
package org.eclipse.mylar.tasklist.internal.planner;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.mylar.core.util.ErrorLogger;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
import org.eclipse.mylar.tasklist.internal.TaskList;
@@ -21,49 +26,69 @@ import org.eclipse.mylar.tasklist.ui.ITaskListElement;
/**
* @author Ken Sueda
+ * @author Mik Kersten
*/
-public class TaskReportGenerator {
+public class TaskReportGenerator implements IRunnableWithProgress {
// NOTE: might want a map of tasks instead of a flattened list of tasks
- private List<ITasksCollector> collectors = new ArrayList<ITasksCollector>();
+ private List<ITaskCollector> collectors = new ArrayList<ITaskCollector>();
private List<ITask> tasks = new ArrayList<ITask>();
private TaskList tasklist = null;
+ private boolean finished;
public TaskReportGenerator(TaskList tlist) {
tasklist = tlist;
}
- public void addCollector(ITasksCollector collector) {
+ public void addCollector(ITaskCollector collector) {
collectors.add(collector);
}
public void collectTasks() {
+ try {
+ run(new NullProgressMonitor());
+ } catch (InvocationTargetException e) {
+ // operation was canceled
+ } catch (InterruptedException e) {
+ ErrorLogger.log(e, "Could not collect tasks");
+ }
+ }
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
List<ITask> roots = tasklist.getRootTasks();
+ monitor.beginTask("Mylar Task Planner", 1 + tasklist.getCategories().size());
for(int i = 0; i < roots.size(); i++) {
ITask task = (ITask) roots.get(i);
- for (ITasksCollector collector : collectors) {
+ for (ITaskCollector collector : collectors) {
collector.consumeTask(task);
- }
+ }
+ monitor.worked(1);
}
for (TaskCategory cat : tasklist.getTaskCategories()) {
List<? extends ITaskListElement> sub = cat.getChildren();
for (int j = 0; j < sub.size(); j++) {
if (sub.get(j) instanceof ITask) {
ITask element = (ITask) sub.get(j);
- for (ITasksCollector collector : collectors) {
+ for (ITaskCollector collector : collectors) {
collector.consumeTask(element);
}
}
}
+ monitor.worked(1);
}
- // TODO need to support handling things in the bugzilla registry
- for (ITasksCollector collector : collectors) {
+ for (ITaskCollector collector : collectors) {
tasks.addAll(collector.getTasks());
}
+ finished = true;
+ monitor.done();
}
public List<ITask> getAllCollectedTasks() {
return tasks;
}
+
+ public boolean isFinished() {
+ return finished;
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ui/TaskPlannerEditorInput.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ui/TaskPlannerEditorInput.java
index fe24744c6..643fe4a1c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ui/TaskPlannerEditorInput.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/planner/ui/TaskPlannerEditorInput.java
@@ -11,19 +11,23 @@
package org.eclipse.mylar.tasklist.internal.planner.ui;
+import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylar.core.util.ErrorLogger;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.internal.TaskList;
import org.eclipse.mylar.tasklist.internal.planner.CompletedTaskCollector;
-import org.eclipse.mylar.tasklist.internal.planner.ITasksCollector;
+import org.eclipse.mylar.tasklist.internal.planner.ITaskCollector;
import org.eclipse.mylar.tasklist.internal.planner.InProgressTaskCollector;
import org.eclipse.mylar.tasklist.internal.planner.TaskReportGenerator;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
/**
* @author Ken Sueda
@@ -33,8 +37,8 @@ public class TaskPlannerEditorInput implements IEditorInput {
private List<ITask> completedTasks = null;
private List<ITask> inProgressTasks = null;
-
- private TaskReportGenerator parser = null;
+
+ private TaskReportGenerator taskReportGenerator = null;
private int prevDaysToReport = -1;
@@ -52,22 +56,30 @@ public class TaskPlannerEditorInput implements IEditorInput {
+ Calendar.getInstance().get(Calendar.SECOND) * 1000;
reportStartDate = new Date(today - offsetToday - lastDay);
- parser = new TaskReportGenerator(tlist);
+ taskReportGenerator = new TaskReportGenerator(tlist);
+
+ ITaskCollector completedTaskCollector = new CompletedTaskCollector(reportStartDate);
+ taskReportGenerator.addCollector(completedTaskCollector);
- ITasksCollector completedTaskCollector = new CompletedTaskCollector(reportStartDate);
- parser.addCollector(completedTaskCollector);
+ ITaskCollector inProgressTaskCollector = new InProgressTaskCollector(reportStartDate);
+ taskReportGenerator.addCollector(inProgressTaskCollector);
- ITasksCollector inProgressTaskCollector = new InProgressTaskCollector(reportStartDate);
- parser.addCollector(inProgressTaskCollector);
+ try {
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ service.run(true, true, taskReportGenerator);
- parser.collectTasks();
+ while (!taskReportGenerator.isFinished()) Thread.sleep(1000);
+ } catch (InvocationTargetException e) {
+ // operation was canceled
+ } catch (InterruptedException e) {
+ ErrorLogger.log(e, "Could not generate report");
+ }
+// taskReportGenerator.collectTasks();
completedTasks = completedTaskCollector.getTasks();
inProgressTasks = inProgressTaskCollector.getTasks();
}
- // IEditorInput interface methods
-
public boolean exists() {
return true;
}
@@ -119,7 +131,7 @@ public class TaskPlannerEditorInput implements IEditorInput {
}
public TaskReportGenerator getReportGenerator() {
- return parser;
+ return taskReportGenerator;
}
public boolean createdDuringReportPeriod(ITask task) {

Back to the top