Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-10-03 14:27:16 -0400
committerspingel2008-10-03 14:27:16 -0400
commit6aae891a6f74ee09fd4726d8ec043a145f1e999f (patch)
tree30c069b3d72e04416523f61491d93544cea345ff
parent413341b0de8a28e754a1fe664188cbd677a5d935 (diff)
downloadorg.eclipse.mylyn.tasks-6aae891a6f74ee09fd4726d8ec043a145f1e999f.tar.gz
org.eclipse.mylyn.tasks-6aae891a6f74ee09fd4726d8ec043a145f1e999f.tar.xz
org.eclipse.mylyn.tasks-6aae891a6f74ee09fd4726d8ec043a145f1e999f.zip
248683: NPE in DateRange.isWeekAfterNext()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=248683
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DateRange.java128
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DayDateRange.java84
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java28
-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/TaskActivityUtil.java8
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WeekDateRange.java81
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java14
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorPlanningPart.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java5
11 files changed, 220 insertions, 145 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
index 2ec55caaa..aa6fd8642 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
@@ -397,7 +397,7 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
*/
@Deprecated
public boolean isPastReminder() {
- if (isCompleted() || scheduledForDate == null || !getScheduledForDate().isDay()) {
+ if (isCompleted() || scheduledForDate == null || !(getScheduledForDate() instanceof DayDateRange)) {
return false;
} else {
if (/*!internalIsFloatingScheduledDate() && */scheduledForDate.getEndDate().compareTo(
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DateRange.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DateRange.java
index 7d3ca39e8..90533ef2a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DateRange.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DateRange.java
@@ -21,16 +21,7 @@ import org.eclipse.core.runtime.Assert;
* @since 3.0
*/
public class DateRange implements Comparable<DateRange> {
-
- private static final long DAY = 1000 * 60 * 60 * 24;
-
- private static final String DESCRIPTION_PREVIOUS_WEEK = "Previous Week";
-
- private static final String DESCRIPTION_THIS_WEEK = "Someday This Week";
-
- private static final String DESCRIPTION_NEXT_WEEK = "Someday Next Week";
-
- private static final String DESCRIPTION_WEEK_AFTER_NEXT = "Two Weeks";
+ protected static final long DAY = 1000 * 60 * 60 * 24;
private final Calendar startDate;
@@ -78,115 +69,38 @@ public class DateRange implements Comparable<DateRange> {
}
public String toString(boolean useDayOfWeekForNextWeek) {
- boolean isThisWeek = TaskActivityUtil.getCurrentWeek().includes(this);
- Calendar endNextWeek = TaskActivityUtil.getCalendar();
- endNextWeek.add(Calendar.DAY_OF_YEAR, 7);
- boolean isNextWeek = TaskActivityUtil.getNextWeek().includes(this) && this.before(endNextWeek);
- if (isDay() && (isThisWeek || (useDayOfWeekForNextWeek && isNextWeek))) {
- String day = "";
- switch (getStartDate().get(Calendar.DAY_OF_WEEK)) {
- case Calendar.MONDAY:
- day = "Monday";
- break;
- case Calendar.TUESDAY:
- day = "Tuesday";
- break;
- case Calendar.WEDNESDAY:
- day = "Wednesday";
- break;
- case Calendar.THURSDAY:
- day = "Thursday";
- break;
- case Calendar.FRIDAY:
- day = "Friday";
- break;
- case Calendar.SATURDAY:
- day = "Saturday";
- break;
- case Calendar.SUNDAY:
- day = "Sunday";
- break;
- }
- if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == getStartDate().get(Calendar.DAY_OF_WEEK)) {
- return day + " - Today";
- } else {
- return day;
- }
- } else if (isThisWeek()) {
- return DESCRIPTION_THIS_WEEK;
- } else if (isNextWeek()) {
- return DESCRIPTION_NEXT_WEEK;
- } else if (isWeekAfterNext()) {
- return DESCRIPTION_WEEK_AFTER_NEXT;
- } else if (isPreviousWeek()) {
- return DESCRIPTION_PREVIOUS_WEEK;
- }
return DateFormat.getDateInstance(DateFormat.MEDIUM).format(startDate.getTime());
/* + " to "+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(endDate.getTime());*/
}
- private boolean isWeekAfterNext() {
- return TaskActivityUtil.getCurrentWeek().next().next().compareTo(this) == 0;
- }
-
- public DateRange next() {
- if (isDay()) {
- return create(Calendar.DAY_OF_YEAR, 1);
- } else if (isWeek()) {
- return create(Calendar.WEEK_OF_YEAR, 1);
- }
- return null;
- }
-
- public DateRange previous() {
- if (isDay()) {
- return create(Calendar.DAY_OF_YEAR, -1);
- } else if (isWeek()) {
- return create(Calendar.WEEK_OF_YEAR, -1);
- }
- return null;
- }
-
- private DateRange create(int field, int multiplier) {
- Calendar previousStart = (Calendar) getStartDate().clone();
- Calendar previousEnd = (Calendar) getEndDate().clone();
- previousStart.add(field, 1 * multiplier);
- previousEnd.add(field, 1 * multiplier);
- return new DateRange(previousStart, previousEnd);
- }
-
- private boolean isNextWeek() {
- return TaskActivityUtil.getCurrentWeek().next().compareTo(this) == 0;
- }
-
- public boolean isThisWeek() {
- if (isWeek()) {
- return this.includes(Calendar.getInstance());
- }
- return false;
- }
-
- private boolean isPreviousWeek() {
- if (isWeek()) {
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.WEEK_OF_YEAR, -1);
- return this.includes(cal);
- }
- return false;
- }
+// protected DateRange create(int field, int multiplier) {
+// Calendar previousStart = (Calendar) getStartDate().clone();
+// Calendar previousEnd = (Calendar) getEndDate().clone();
+// previousStart.add(field, 1 * multiplier);
+// previousEnd.add(field, 1 * multiplier);
+// return new DateRange(previousStart, previousEnd);
+// }
- public boolean isDay() {
- return ((getEndDate().getTimeInMillis() - getStartDate().getTimeInMillis()) == DAY - 1);
- }
+// public boolean isDay() {
+// return ((getEndDate().getTimeInMillis() - getStartDate().getTimeInMillis()) == DAY - 1);
+// }
+//
+// public boolean isWeek() {
+// return ((getEndDate().getTimeInMillis() - getStartDate().getTimeInMillis()) == (DAY * 7) - 1);
+// }
- public boolean isWeek() {
- return ((getEndDate().getTimeInMillis() - getStartDate().getTimeInMillis()) == (DAY * 7) - 1);
+ public boolean isPresent() {
+ return this.getStartDate().before(Calendar.getInstance()) && this.getEndDate().after(Calendar.getInstance());
}
public boolean isPast() {
return getEndDate().compareTo(Calendar.getInstance()) < 0;
}
+ public boolean isFuture() {
+ return !isPresent() && this.getStartDate().after(Calendar.getInstance());
+ }
+
public boolean isBefore(DateRange scheduledDate) {
return this.getEndDate().compareTo(scheduledDate.getStartDate()) < 0;
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DayDateRange.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DayDateRange.java
new file mode 100644
index 000000000..0112a5fb3
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DayDateRange.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.core;
+
+import java.util.Calendar;
+
+/**
+ * @author Rob Elves
+ */
+public class DayDateRange extends DateRange {
+
+ public DayDateRange(Calendar startDate, Calendar endDate) {
+ super(startDate, endDate);
+ }
+
+ public DayDateRange next() {
+ return create(Calendar.DAY_OF_YEAR, 1);
+ }
+
+ public DayDateRange previous() {
+ return create(Calendar.DAY_OF_YEAR, -1);
+ }
+
+ protected DayDateRange create(int field, int multiplier) {
+ Calendar previousStart = (Calendar) getStartDate().clone();
+ Calendar previousEnd = (Calendar) getEndDate().clone();
+ previousStart.add(field, 1 * multiplier);
+ previousEnd.add(field, 1 * multiplier);
+ return new DayDateRange(previousStart, previousEnd);
+ }
+
+ @Override
+ public String toString(boolean useDayOfWeekForNextWeek) {
+ boolean isThisWeek = TaskActivityUtil.getCurrentWeek().includes(this);
+ Calendar endNextWeek = TaskActivityUtil.getCalendar();
+ endNextWeek.add(Calendar.DAY_OF_YEAR, 7);
+ boolean isNextWeek = TaskActivityUtil.getNextWeek().includes(this) && this.before(endNextWeek);
+ if (isThisWeek || (useDayOfWeekForNextWeek && isNextWeek)) {
+ String day = "";
+ switch (getStartDate().get(Calendar.DAY_OF_WEEK)) {
+ case Calendar.MONDAY:
+ day = "Monday";
+ break;
+ case Calendar.TUESDAY:
+ day = "Tuesday";
+ break;
+ case Calendar.WEDNESDAY:
+ day = "Wednesday";
+ break;
+ case Calendar.THURSDAY:
+ day = "Thursday";
+ break;
+ case Calendar.FRIDAY:
+ day = "Friday";
+ break;
+ case Calendar.SATURDAY:
+ day = "Saturday";
+ break;
+ case Calendar.SUNDAY:
+ day = "Sunday";
+ break;
+ }
+ if (isPresent()) {
+ return day + " - Today";
+ } else {
+ return day;
+ }
+ }
+ return super.toString(useDayOfWeekForNextWeek);
+ }
+
+ public static boolean isDayRange(Calendar calStart, Calendar calEnd) {
+ return ((calEnd.getTimeInMillis() - calStart.getTimeInMillis()) == DAY - 1);
+ }
+}
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 b80e4d5af..271c53dda 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
@@ -54,14 +54,16 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
return range.getStartDate().before(Calendar.getInstance()) && range.getEndDate().after(Calendar.getInstance());
}
- public boolean isWeekDay() {
- return TaskActivityUtil.getCurrentWeek().isCurrentWeekDay(range);
- }
+// public boolean isWeekDay() {
+// return TaskActivityUtil.getCurrentWeek().isCurrentWeekDay(range);
+// }
- public boolean isToday() {
- return isPresent()
- && range.getStartDate().get(Calendar.DAY_OF_YEAR) == range.getEndDate().get(Calendar.DAY_OF_YEAR);
- }
+// public boolean isToday() {
+// if (range instanceof DayDateRange) {
+// return ((DayDateRange) range).isToday();
+// }
+// return false;
+// }
// public Collection<ITask> getChildren() {
// Set<ITask> children = new HashSet<ITask>();
@@ -131,7 +133,7 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
}
// Add due tasks if not the This Week container
- if (!(range instanceof WeekDateRange && isPresent())) {
+ if (!(range instanceof WeekDateRange && ((WeekDateRange) range).isPresent())) {
for (ITask task : activityManager.getDueTasks(range.getStartDate(), range.getEndDate())) {
if (activityManager.isOwnedByUser(task)) {
children.add(task);
@@ -140,9 +142,10 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
}
// All over due/scheduled tasks are present in the Today folder
- if (isToday()) {
+ if ((range instanceof DayDateRange) && ((DayDateRange) range).isPresent()) {
for (ITask task : activityManager.getOverScheduledTasks()) {
- if (task instanceof AbstractTask && !((AbstractTask) task).getScheduledForDate().isWeek()) {
+ if (task instanceof AbstractTask
+ && !(((AbstractTask) task).getScheduledForDate() instanceof WeekDateRange)) {
children.add(task);
}
}
@@ -154,9 +157,10 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
}
}
- if (range.isThisWeek()) {
+ if (range instanceof WeekDateRange && ((WeekDateRange) range).isThisWeek()) {
for (ITask task : activityManager.getOverScheduledTasks()) {
- if (task instanceof AbstractTask && ((AbstractTask) task).getScheduledForDate().isWeek()) {
+ if (task instanceof AbstractTask
+ && ((AbstractTask) task).getScheduledForDate() instanceof WeekDateRange) {
children.add(task);
}
}
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 dc63957b8..11ea2b788 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
@@ -328,7 +328,7 @@ public class TaskActivityManager implements ITaskActivityManager {
Set<ITask> result = scheduledTasks.get(range);
if (result != null && !result.isEmpty()) {
resultingTasks.addAll(result);
- } else if (!range.isWeek()) {
+ } else if (!(range instanceof WeekDateRange)) {
return getScheduledTasks(range.getStartDate(), range.getEndDate());
}
}
@@ -627,7 +627,7 @@ public class TaskActivityManager implements ITaskActivityManager {
if (date == null || isComplete) {
return false;
} else {
- if (date.getEndDate().compareTo(TaskActivityUtil.getCalendar()) < 0 && date.isDay()) {
+ if (date.getEndDate().compareTo(TaskActivityUtil.getCalendar()) < 0 && date instanceof DayDateRange) {
return true;
} else {
return false;
@@ -733,7 +733,7 @@ public class TaskActivityManager implements ITaskActivityManager {
private boolean isSheduledForPastWeek(DateRange range) {
if (range != null) {
- return range.isWeek() && range.isPast();
+ return (range instanceof WeekDateRange && range.isPast());
}
return false;
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java
index 340840ba1..b69923f11 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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
@@ -239,7 +239,7 @@ public class TaskActivityUtil {
return new WeekDateRange(weekStart, weekEnd);
}
- public static DateRange getWeekOf(Date date) {
+ public static WeekDateRange getWeekOf(Date date) {
Calendar weekStart = getCalendar();
weekStart.setTime(date);
Calendar weekEnd = getCalendar();
@@ -250,7 +250,7 @@ public class TaskActivityUtil {
return new WeekDateRange(weekStart, weekEnd);
}
- public static DateRange getDayOf(Date date) {
+ public static DayDateRange getDayOf(Date date) {
Calendar dayStart = getCalendar();
dayStart.setTime(date);
Calendar dayEnd = getCalendar();
@@ -258,6 +258,6 @@ public class TaskActivityUtil {
snapStartOfDay(dayStart);
snapEndOfDay(dayEnd);
- return new DateRange(dayStart, dayEnd);
+ return new DayDateRange(dayStart, dayEnd);
}
}
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 787d06773..331bceb77 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
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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
@@ -20,7 +20,15 @@ import java.util.List;
*/
public class WeekDateRange extends DateRange {
- private final List<DateRange> days = new ArrayList<DateRange>();
+ private static final String DESCRIPTION_WEEK_AFTER_NEXT = "Two Weeks";
+
+ private static final String DESCRIPTION_PREVIOUS_WEEK = "Previous Week";
+
+ private static final String DESCRIPTION_THIS_WEEK = "Someday This Week";
+
+ private static final String DESCRIPTION_NEXT_WEEK = "Someday Next Week";
+
+ private final List<DayDateRange> days = new ArrayList<DayDateRange>();
public WeekDateRange(Calendar startDate, Calendar endDate) {
super(startDate, endDate);
@@ -36,7 +44,7 @@ public class WeekDateRange extends DateRange {
return remainingDays;
}
- public List<DateRange> getDaysOfWeek() {
+ public List<DayDateRange> getDaysOfWeek() {
if (days.isEmpty()) {
for (int x = TaskActivityUtil.getStartDay(); x < (TaskActivityUtil.getStartDay() + 7); x++) {
Calendar dayStart = TaskActivityUtil.getCalendar();
@@ -55,7 +63,7 @@ public class WeekDateRange extends DateRange {
dayEnd.set(Calendar.DAY_OF_WEEK, x);
}
- days.add(new DateRange(dayStart, dayEnd));
+ days.add(new DayDateRange(dayStart, dayEnd));
}
}
return days;
@@ -64,10 +72,10 @@ public class WeekDateRange extends DateRange {
/**
* @return today's DayDateRange, null if does not exist (now > endDate)
*/
- public DateRange getToday() {
- DateRange today = null;
+ public DayDateRange getToday() {
+ DayDateRange today = null;
Calendar now = TaskActivityUtil.getCalendar();
- for (DateRange range : getDaysOfWeek()) {
+ for (DayDateRange range : getDaysOfWeek()) {
if (range.includes(now)) {
today = range;
break;
@@ -78,7 +86,7 @@ public class WeekDateRange extends DateRange {
TaskActivityUtil.snapStartOfDay(todayStart);
Calendar todayEnd = TaskActivityUtil.getCalendar();
TaskActivityUtil.snapEndOfDay(todayEnd);
- today = new DateRange(todayStart, todayEnd);
+ today = new DayDateRange(todayStart, todayEnd);
}
return today;
}
@@ -90,6 +98,57 @@ public class WeekDateRange extends DateRange {
return getDaysOfWeek().contains(range);
}
+ private boolean isNextWeek() {
+ return TaskActivityUtil.getNextWeek().compareTo(this) == 0;
+ }
+
+ public boolean isThisWeek() {
+ //if (isWeek()) {
+ return this.includes(Calendar.getInstance());
+ //}
+ //return false;
+ }
+
+ private boolean isPreviousWeek() {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.WEEK_OF_YEAR, -1);
+ return this.includes(cal);
+ }
+
+ private boolean isWeekAfterNext() {
+ return TaskActivityUtil.getNextWeek().next().compareTo(this) == 0;
+ }
+
+ public WeekDateRange next() {
+ return create(Calendar.WEEK_OF_YEAR, 1);
+ }
+
+ public WeekDateRange previous() {
+ return create(Calendar.WEEK_OF_YEAR, -1);
+ }
+
+ protected WeekDateRange create(int field, int multiplier) {
+ Calendar previousStart = (Calendar) getStartDate().clone();
+ Calendar previousEnd = (Calendar) getEndDate().clone();
+ previousStart.add(field, 1 * multiplier);
+ previousEnd.add(field, 1 * multiplier);
+ return new WeekDateRange(previousStart, previousEnd);
+ }
+
+ @Override
+ public String toString(boolean useDayOfWeekForNextWeek) {
+ if (isWeekAfterNext()) {
+ return DESCRIPTION_WEEK_AFTER_NEXT;
+ } else if (isThisWeek()) {
+ return DESCRIPTION_THIS_WEEK;
+ } else if (isNextWeek()) {
+ return DESCRIPTION_NEXT_WEEK;
+ } else if (isPreviousWeek()) {
+ return DESCRIPTION_PREVIOUS_WEEK;
+ }
+ return super.toString(useDayOfWeekForNextWeek);
+ }
+
public DateRange getDayOfWeek(int dayNum) {
if (dayNum > 0 && dayNum <= 7) {
for (DateRange day : getDaysOfWeek()) {
@@ -98,6 +157,10 @@ public class WeekDateRange extends DateRange {
}
}
}
- return null;
+ throw new IllegalArgumentException("Valid day values are 1 - 7");
+ }
+
+ public static boolean isWeekRange(Calendar calStart, Calendar calEnd) {
+ return ((calEnd.getTimeInMillis() - calStart.getTimeInMillis()) == (DAY * 7) - 1);
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java
index 9a3a4dacf..f0cfe8271 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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
@@ -34,7 +34,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskCategory;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
-import org.eclipse.mylyn.internal.tasks.core.DateRange;
+import org.eclipse.mylyn.internal.tasks.core.DayDateRange;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
@@ -47,6 +47,7 @@ import org.eclipse.mylyn.internal.tasks.core.TaskExternalizationException;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
import org.eclipse.mylyn.internal.tasks.core.UncategorizedTaskContainer;
+import org.eclipse.mylyn.internal.tasks.core.WeekDateRange;
import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractTaskListFactory;
import org.eclipse.mylyn.tasks.core.AbstractTaskListMigrator;
import org.eclipse.mylyn.tasks.core.IAttributeContainer;
@@ -615,7 +616,14 @@ public final class DelegatingTaskExternalizer {
calStart.setTime(startDate);
Calendar calEnd = TaskActivityUtil.getCalendar();
calEnd.setTime(endDate);
- task.setScheduledForDate(new DateRange(calStart, calEnd));
+ if (DayDateRange.isDayRange(calStart, calEnd)) {
+ task.setScheduledForDate(new DayDateRange(calStart, calEnd));
+ } else if (WeekDateRange.isWeekRange(calStart, calEnd)) {
+ task.setScheduledForDate(new WeekDateRange(calStart, calEnd));
+ } else {
+ // Neither week nor day found, default to today
+ task.setScheduledForDate(TaskActivityUtil.getDayOf(new Date()));
+ }
}
}
if (element.hasAttribute(KEY_REMINDED) && element.getAttribute(KEY_REMINDED).compareTo(VAL_TRUE) == 0) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java
index 042a5e28a..e7fd0e88a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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
@@ -121,7 +121,7 @@ public class ScheduleTaskMenuContributor implements IDynamicSubMenuContributor {
subMenuManager.add(action);
// Special case: This Week holds previous weeks' scheduled tasks
if (singleTaskSelection != null && singleTaskSelection.getScheduledForDate() != null
- && singleTaskSelection.getScheduledForDate().isWeek()
+ && singleTaskSelection.getScheduledForDate() instanceof WeekDateRange
&& singleTaskSelection.getScheduledForDate().isBefore(week)) {
// Tasks scheduled for 'someday' float into this week
action.setChecked(true);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorPlanningPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorPlanningPart.java
index 7795f1469..c16d4faef 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorPlanningPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorPlanningPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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
@@ -21,6 +21,7 @@ import org.eclipse.mylyn.commons.core.DateUtil;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.provisional.commons.ui.DatePicker;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
+import org.eclipse.mylyn.internal.tasks.core.DayDateRange;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
@@ -128,7 +129,7 @@ public class TaskEditorPlanningPart extends AbstractTaskEditorPart {
if (scheduleDatePicker != null && scheduleDatePicker.getScheduledDate() != null) {
if (task.getScheduledForDate() == null
|| (task.getScheduledForDate() != null && !scheduleDatePicker.getScheduledDate().equals(
- task.getScheduledForDate())) || (task).getScheduledForDate().isDay()) {
+ task.getScheduledForDate())) || (task).getScheduledForDate() instanceof DayDateRange) {
TasksUiPlugin.getTaskActivityManager().setScheduledFor(task, scheduleDatePicker.getScheduledDate());
(task).setReminded(false);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java
index da0564947..3095c8c4e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 Tasktop Technologies 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
@@ -34,6 +34,7 @@ import org.eclipse.mylyn.internal.provisional.commons.ui.AbstractRetrieveTitleFr
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.provisional.commons.ui.DatePicker;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
+import org.eclipse.mylyn.internal.tasks.core.DayDateRange;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
@@ -281,7 +282,7 @@ public class TaskPlanningEditor extends TaskFormPage {
if (scheduleDatePicker != null && scheduleDatePicker.getScheduledDate() != null) {
if (task.getScheduledForDate() == null
|| (task.getScheduledForDate() != null && !scheduleDatePicker.getScheduledDate().equals(
- task.getScheduledForDate())) || (task).getScheduledForDate().isDay()) {
+ task.getScheduledForDate())) || (task).getScheduledForDate() instanceof DayDateRange) {
TasksUiPlugin.getTaskActivityManager().setScheduledFor(task, scheduleDatePicker.getScheduledDate());
(task).setReminded(false);
}

Back to the top