Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2012-06-04 18:15:28 -0400
committerGerrit Code Review @ Eclipse.org2013-05-08 03:29:28 -0400
commita3474b6cc09d546b76aee19a21b003d54f8dd782 (patch)
treebc9142276bee75ec4fa7e99556fea57cca3fbb40 /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal
parente83de18edfd3c3538882d1296b7f365cbc3d80ca (diff)
downloadorg.eclipse.mylyn.tasks-a3474b6cc09d546b76aee19a21b003d54f8dd782.tar.gz
org.eclipse.mylyn.tasks-a3474b6cc09d546b76aee19a21b003d54f8dd782.tar.xz
org.eclipse.mylyn.tasks-a3474b6cc09d546b76aee19a21b003d54f8dd782.zip
NEW - bug 250865: scheduling information incorrect when local time zone
changes https://bugs.eclipse.org/bugs/show_bug.cgi?id=250865 Change-Id: I0ae81f95cb228c7966037e9aa89ff5aa23a520f1
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java64
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java6
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WeekDateRange.java2
3 files changed, 57 insertions, 15 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java
index ef3a36547..905051710 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java
@@ -14,6 +14,7 @@ package org.eclipse.mylyn.internal.tasks.core;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
@@ -135,15 +136,45 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
@Override
public Collection<ITask> getChildren() {
-
// TODO: Cache this information until the next modification to pertinent data
-
+ Calendar now = Calendar.getInstance();
+ // extend range to include tasks scheduled for this container in different time zones
+ // timezones range from UTC-12 to UTC+14, but we will ignore UTC+12 to +14 since we can't distinguish them from UTC-12 to -10
+ // use minutes to allow for partial hour timezone offsets
+ int offsetInMinutes = range.getStartDate().getTimeZone().getOffset(now.getTimeInMillis()) / 1000 / 60;
+ if (offsetInMinutes > 11 * 60) {
+ // when in UTC+12 to +14, show tasks scheduled in those time zones in the correct bin. This causes tasks scheduled in other time
+ // zones to show a day late; tasks scheduled in other time zones for WeekDateRanges may not show at all
+ offsetInMinutes = -(24 * 60 - offsetInMinutes);
+ }
+ int minutesForwardToDateline = 11 * 60 - offsetInMinutes;
+ int minutesBackwardToDateline = 23 * 60 - minutesForwardToDateline;
+ Calendar start = Calendar.getInstance();
+ start.setTimeInMillis(range.getStartDate().getTimeInMillis());
+ start.add(Calendar.MINUTE, -minutesForwardToDateline);
+ Calendar end = Calendar.getInstance();
+ end.setTimeInMillis(range.getEndDate().getTimeInMillis());
+ end.add(Calendar.MINUTE, minutesBackwardToDateline);
+ // All tasks scheduled for this date range
+ Set<ITask> tasks = activityManager.getScheduledTasks(start, end);
+ if (range instanceof WeekDateRange) {
+ // remove tasks not scheduled for the week container itself, except for 2 weeks, in which case only remove
+ // if they will show under future
+ for (Iterator<ITask> iterator = tasks.iterator(); iterator.hasNext();) {
+ ITask task = iterator.next();
+ if (task instanceof AbstractTask) {
+ DateRange scheduledDate = ((AbstractTask) task).getScheduledForDate();
+ if (!(scheduledDate instanceof WeekDateRange)
+ && (TaskActivityUtil.getNextWeek().next().compareTo(range) != 0 || scheduledDate.getEndDate()
+ .after(end))) {
+ iterator.remove();
+ }
+ }
+ }
+ }
Set<ITask> children = new HashSet<ITask>();
-
Calendar cal = TaskActivityUtil.getCalendar();
-
- // All tasks scheduled for this date range
- for (ITask task : activityManager.getScheduledTasks(range)) {
+ for (ITask task : tasks) {
if (!task.isCompleted() || isCompletedToday(task)) {
if (isDueBeforeScheduled(task) && activityManager.isOwnedByUser(task)) {
@@ -168,7 +199,12 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
// Add due tasks if not the This Week container, and not scheduled for earlier date
if (!TaskActivityUtil.getCurrentWeek().equals(range) && !TaskActivityUtil.getNextWeek().equals(range)) {
- for (ITask task : getTasksDueThisWeek()) {
+ // tasks are due at the start of a day, so only search in the range of times that correspond to
+ // the start of the day in some time zone
+ Calendar endDueSearch = Calendar.getInstance();
+ endDueSearch.setTimeInMillis(range.getStartDate().getTimeInMillis());
+ endDueSearch.add(Calendar.MINUTE, minutesBackwardToDateline);
+ for (ITask task : activityManager.getDueTasks(start, endDueSearch)) {
if (isScheduledBeforeDue(task)) {
continue;
}
@@ -185,11 +221,19 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
addChild(children, task);
}
}
+ // add tasks whose scheduled date starts before today and ends today
+ Calendar searchFrom = Calendar.getInstance();
+ searchFrom.setTimeInMillis(start.getTimeInMillis());
+ searchFrom.add(Calendar.DAY_OF_MONTH, -1);
+ for (ITask task : activityManager.getScheduledTasks(searchFrom, end)) {
+ if (isScheduledForADay(task)) {
+ addChild(children, task);
+ }
+ }
for (ITask task : activityManager.getOverDueTasks()) {
addChild(children, task);
}
- // if not scheduled or due in future, and is active, place in today bin
ITask activeTask = activityManager.getActiveTask();
if (activeTask != null && !children.contains(activeTask)) {
addChild(children, activeTask);
@@ -216,10 +260,6 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
return range instanceof WeekDateRange && ((WeekDateRange) range).isThisWeek();
}
- private Set<ITask> getTasksDueThisWeek() {
- return activityManager.getDueTasks(range.getStartDate(), range.getEndDate());
- }
-
private boolean isScheduledForAWeek(ITask task) {
return task instanceof AbstractTask && ((AbstractTask) task).getScheduledForDate() instanceof WeekDateRange;
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java
index 5e7573fd0..b4c77a409 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java
@@ -20,6 +20,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -404,11 +405,12 @@ public class TaskActivityManager implements ITaskActivityManager {
DateRange endRange = new DateRange(endExclusive);
SortedMap<DateRange, Set<ITask>> result = scheduledTasks.subMap(startRange, endRange);
- for (DateRange range : result.keySet()) {
+ for (Entry<DateRange, Set<ITask>> entry : result.entrySet()) {
+ DateRange range = entry.getKey();
if (start.compareTo(range.getStartDate()) > 0 || end.compareTo(range.getEndDate()) < 0) {
continue;
}
- resultingTasks.addAll(result.get(range));
+ resultingTasks.addAll(entry.getValue());
}
}
return resultingTasks;
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WeekDateRange.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WeekDateRange.java
index 7c3b398c6..24a471a03 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WeekDateRange.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WeekDateRange.java
@@ -115,7 +115,7 @@ public class WeekDateRange extends DateRange {
return this.includes(cal);
}
- private boolean isWeekAfterNext() {
+ boolean isWeekAfterNext() {
return TaskActivityUtil.getNextWeek().next().compareTo(this) == 0;
}

Back to the top