Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcvs2git2009-01-19 22:14:00 -0500
committercvs2git2009-01-19 22:14:00 -0500
commitf95597b1fd63ee3ee4518eb4bbde5f2a443669d1 (patch)
tree7df8de8eaae5f76676cce29d751ab0c872c3b0e7
parent011f1f30d2851fc8e7fe3748dffb80b563b087b7 (diff)
downloadorg.eclipse.mylyn.tasks-f95597b1fd63ee3ee4518eb4bbde5f2a443669d1.tar.gz
org.eclipse.mylyn.tasks-f95597b1fd63ee3ee4518eb4bbde5f2a443669d1.tar.xz
org.eclipse.mylyn.tasks-f95597b1fd63ee3ee4518eb4bbde5f2a443669d1.zip
This commit was manufactured by cvs2svn to create tag 'R_3_0_4_e_3_3'.R_3_0_4_e_3_3
Sprout from e_3_3_m_3_0_x 2009-01-20 03:13:59 UTC spingel 'NEW - bug 221939: [releng] manage branches' Cherrypick from e_3_4_m_3_0_x 2009-01-20 01:03:02 UTC spingel 'NEW - bug 221939: [releng] manage branches': org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF org.eclipse.mylyn.sdk-feature/feature.xml org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DateRange.java org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DayDateRange.java org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityUtil.java org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WeekDateRange.java org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ScheduleTaskMenuContributor.java org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorPlanningPart.java org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListInterestFilter.java org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskScheduleContentProvider.java org.eclipse.mylyn.test-feature/feature.xml org.eclipse.mylyn.trac-feature/feature.xml org.eclipse.mylyn.trac.core/META-INF/MANIFEST.MF org.eclipse.mylyn.trac.ui/META-INF/MANIFEST.MF Delete: org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java
-rw-r--r--org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.mylyn.sdk-feature/feature.xml2
-rw-r--r--org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF2
-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.java134
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DayDateRange.java86
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ScheduledTaskContainer.java34
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java8
-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.java83
-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.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java7
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java106
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java1006
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java54
-rw-r--r--org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF2
-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/actions/TaskSelectionDialog.java7
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java11
-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
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java9
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListInterestFilter.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskScheduleContentProvider.java9
-rw-r--r--org.eclipse.mylyn.test-feature/feature.xml2
-rw-r--r--org.eclipse.mylyn.trac-feature/feature.xml6
-rw-r--r--org.eclipse.mylyn.trac.core/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.mylyn.trac.ui/META-INF/MANIFEST.MF2
30 files changed, 297 insertions, 1355 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
index 129a2464f..07700a237 100644
--- a/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Bugzilla Connector Core
Bundle-SymbolicName: org.eclipse.mylyn.bugzilla.core;singleton:=true
-Bundle-Version: 3.0.2.qualifier
+Bundle-Version: 3.0.4.qualifier
Bundle-Activator: org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.mylyn.tasks.core;bundle-version="[3.0.0,4.0.0)",
diff --git a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF
index 0c1efda27..a93e5d9ee 100644
--- a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Bugzilla Connector UI
Bundle-SymbolicName: org.eclipse.mylyn.bugzilla.ui; singleton:=true
-Bundle-Version: 3.0.2.qualifier
+Bundle-Version: 3.0.4.qualifier
Bundle-Activator: org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin
Bundle-Vendor: Eclipse.org
Require-Bundle: org.eclipse.ui,
diff --git a/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF
index 91c55190f..e881b22be 100644
--- a/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Help
Bundle-SymbolicName: org.eclipse.mylyn.help.ui;singleton:=true
-Bundle-Version: 3.0.2.qualifier
+Bundle-Version: 3.0.4.qualifier
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Eclipse.org
Require-Bundle: org.eclipse.core.runtime,
diff --git a/org.eclipse.mylyn.sdk-feature/feature.xml b/org.eclipse.mylyn.sdk-feature/feature.xml
index e1c568f97..0fc3274ec 100644
--- a/org.eclipse.mylyn.sdk-feature/feature.xml
+++ b/org.eclipse.mylyn.sdk-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.mylyn.sdk_feature"
label="Mylyn SDK"
- version="3.0.2.qualifier"
+ version="3.0.4.qualifier"
provider-name="Eclipse.org"
plugin="org.eclipse.mylyn">
diff --git a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
index 7f1477f53..ba4e13792 100644
--- a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Tasks Core
Bundle-SymbolicName: org.eclipse.mylyn.tasks.core;singleton:=true
-Bundle-Version: 3.0.2.qualifier
+Bundle-Version: 3.0.4.qualifier
Bundle-Vendor: Eclipse.org
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime,
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 af4e0d87e..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
@@ -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,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 = "This Week";
-
- private static final String DESCRIPTION_NEXT_WEEK = "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;
@@ -74,115 +65,42 @@ public class DateRange implements Comparable<DateRange> {
*/
@Override
public String toString() {
- 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 || 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;
+ return toString(true);
}
- 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;
+ public String toString(boolean useDayOfWeekForNextWeek) {
+ return DateFormat.getDateInstance(DateFormat.MEDIUM).format(startDate.getTime());
+ /* + " to "+ DateFormat.getDateInstance(DateFormat.MEDIUM).format(endDate.getTime());*/
}
- 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..6ad489dab
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/DayDateRange.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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) {
+ // bug 248683
+ long diff = (calEnd.getTimeInMillis() - calStart.getTimeInMillis()) - (DAY - 1);
+ return Math.abs(diff) <= 60 * 60 * 1000;
+ }
+}
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 dcf494f82..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
@@ -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
@@ -32,11 +32,11 @@ public class ScheduledTaskContainer extends AbstractTaskContainer {
private final DateRange range;
public ScheduledTaskContainer(TaskActivityManager activityManager, DateRange range, String summary) {
- super(summary == null ? range.toString() : summary);
+ super(summary == null ? range.toString(false) : summary);
this.activityManager = activityManager;
this.range = range;
if (summary == null) {
- this.summary = range.toString();
+ this.summary = range.toString(false);
} else {
this.summary = summary;
}
@@ -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 399502381..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
@@ -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
@@ -328,7 +328,7 @@ public class TaskActivityManager implements ITaskActivityManager {
Set<ITask> result = scheduledTasks.get(range);
if (result != null && !result.isEmpty()) {
resultingTasks.addAll(result);
- } else {
+ } 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..aa3d77eea 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 = "This Week";
+
+ private static final String DESCRIPTION_NEXT_WEEK = "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,12 @@ public class WeekDateRange extends DateRange {
}
}
}
- return null;
+ throw new IllegalArgumentException("Valid day values are 1 - 7");
+ }
+
+ public static boolean isWeekRange(Calendar calStart, Calendar calEnd) {
+ // bug 248683
+ long diff = (calEnd.getTimeInMillis() - calStart.getTimeInMillis()) - (DAY * 7 - 1);
+ return Math.abs(diff) <= 60 * 60 * 1000;
}
}
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.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
index 98f06e000..90ee70549 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.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
@@ -46,15 +46,16 @@ public class ScheduledPresentationTest extends TestCase {
}
public void testWeekStartChange() {
+ TaskListInterestFilter filter = new TaskListInterestFilter();
TasksUiPlugin.getTaskActivityManager().setWeekStartDay(Calendar.MONDAY);
DateRange lastDay = TaskActivityUtil.getCurrentWeek().getDayOfWeek(Calendar.SUNDAY);
AbstractTask task1 = new LocalTask("task 1", "Task 1");
TasksUiPlugin.getTaskList().addTask(task1);
TasksUiPlugin.getTaskActivityManager().setScheduledFor(task1, lastDay);
- assertTrue(TaskListInterestFilter.isInterestingForThisWeek(null, task1));
+ assertTrue(filter.isInterestingForThisWeek(null, task1));
TasksUiPlugin.getTaskActivityManager().setWeekStartDay(Calendar.SUNDAY);
- assertFalse(TaskListInterestFilter.isInterestingForThisWeek(null, task1));
+ assertFalse(filter.isInterestingForThisWeek(null, task1));
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java
deleted file mode 100644
index e665caa02..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * 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.tasks.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
-import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
-import org.eclipse.mylyn.tasks.tests.connector.MockTask;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-
-/**
- * @author Shawn Minto
- */
-public class TaskActivityListenerTest extends TestCase {
-
- private class MockTaskActivationListener extends TaskActivationAdapter {
-
- private boolean hasActivated = false;
-
- private boolean hasPreActivated = false;
-
- private boolean hasDeactivated = false;
-
- private boolean hasPreDeactivated = false;
-
- public void reset() {
- hasActivated = false;
- hasPreActivated = false;
-
- hasDeactivated = false;
- hasPreDeactivated = false;
-
- }
-
- @Override
- public void preTaskActivated(ITask task) {
- assertFalse(hasActivated);
- hasPreActivated = true;
- }
-
- @Override
- public void preTaskDeactivated(ITask task) {
- assertFalse(hasDeactivated);
- hasPreDeactivated = true;
- }
-
- @Override
- public void taskActivated(ITask task) {
- assertTrue(hasPreActivated);
- hasActivated = true;
- }
-
- @Override
- public void taskDeactivated(ITask task) {
- assertTrue(hasPreDeactivated);
- hasDeactivated = true;
- }
-
- }
-
- private ITaskActivityManager taskActivityManager;
-
- @Override
- protected void setUp() throws Exception {
- taskActivityManager = TasksUi.getTaskActivityManager();
- taskActivityManager.deactivateActiveTask();
- }
-
- public void testTaskActivation() {
- MockTask task = new MockTask("test:activation");
- MockTaskActivationListener listener = new MockTaskActivationListener();
- try {
- taskActivityManager.addActivationListener(listener);
- try {
- taskActivityManager.activateTask(task);
- assertTrue(listener.hasPreActivated);
- assertTrue(listener.hasActivated);
- assertFalse(listener.hasPreDeactivated);
- assertFalse(listener.hasDeactivated);
-
- listener.reset();
- } finally {
- taskActivityManager.deactivateTask(task);
- }
- assertFalse(listener.hasPreActivated);
- assertFalse(listener.hasActivated);
- assertTrue(listener.hasPreDeactivated);
- assertTrue(listener.hasDeactivated);
- } finally {
- TasksUiPlugin.getTaskActivityManager().removeActivationListener(listener);
- }
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
deleted file mode 100644
index f44f0b8f3..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*******************************************************************************
-* 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.tasks.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContext;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
-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.ITaskList;
-import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
-import org.eclipse.mylyn.internal.tasks.core.LocalTask;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
-import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
-import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
-import org.eclipse.mylyn.internal.tasks.core.TaskList;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
-import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
-import org.eclipse.mylyn.internal.tasks.ui.RefactorRepositoryUrlOperation;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListManager;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
-import org.eclipse.mylyn.monitor.core.InteractionEvent;
-import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.ITaskContainer;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.tests.connector.MockAttributeFactory;
-import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
-import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryQuery;
-import org.eclipse.mylyn.tasks.tests.connector.MockTask;
-
-/**
- * @author Mik Kersten
- */
-public class TaskListManagerTest extends TestCase {
-
- private TaskListManager manager;
-
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- TasksUiPlugin.getDefault().getPreferenceStore().setValue(
- ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, false);
- manager = TasksUiPlugin.getTaskListManager();
- for (TaskRepository repository : TasksUiPlugin.getRepositoryManager().getAllRepositories()) {
- TasksUiPlugin.getRepositoryManager().removeRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
- manager.resetTaskList();
- assertEquals(0, manager.getTaskList().getAllTasks().size());
-// manager.readExistingOrCreateNewList();
- TasksUiPlugin.getExternalizationManager().save(true);
- TasksUiPlugin.getDefault().reloadDataDirectory();
-
- repository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL);
- TasksUiPlugin.getRepositoryManager().addRepository(repository);
-
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- TasksUiPlugin.getRepositoryManager().removeRepository(repository,
- TasksUiPlugin.getDefault().getRepositoriesFilePath());
- manager.resetTaskList();
- TasksUiPlugin.getExternalizationManager().save(true);
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- }
-
- public void testUncategorizedTasksNotLost() throws CoreException {
- MockRepositoryQuery query = new MockRepositoryQuery("Test");
- manager.getTaskList().addQuery(query);
- MockTask task = new MockTask("1");
- manager.getTaskList().addTask(task, query);
- manager.getTaskList().addTask(task, manager.getTaskList().getDefaultCategory());
- assertTrue(query.contains(task.getHandleIdentifier()));
- assertTrue(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
-
- TasksUiPlugin.getExternalizationManager().requestSave();
- manager.resetTaskList();
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- assertFalse(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
- TasksUiPlugin.getDefault().reloadDataDirectory();
-
- assertTrue(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
-
- }
-
- public void testQueryAndCategoryNameClash() {
- TaskCategory category = new TaskCategory("TestClash");
- manager.getTaskList().addCategory(category);
- assertTrue(manager.getTaskList().getCategories().contains(category));
- assertEquals(2, manager.getTaskList().getCategories().size());
-
- MockRepositoryQuery query = new MockRepositoryQuery("TestClash");
- manager.getTaskList().addQuery(query);
- assertTrue(manager.getTaskList().getCategories().contains(category));
- assertEquals(2, manager.getTaskList().getCategories().size());
-
- manager.getTaskList().deleteCategory(category);
- }
-
- public void testUniqueTaskID() {
- LocalTask task1 = TasksUiInternal.createNewLocalTask("label");
- manager.getTaskList().addTask(task1);
- LocalTask task2 = TasksUiInternal.createNewLocalTask("label");
- manager.getTaskList().addTask(task2);
- assertEquals(2, manager.getTaskList().getLastLocalTaskId());
- manager.getTaskList().deleteTask(task2);
- LocalTask task3 = TasksUiInternal.createNewLocalTask("label");
- manager.getTaskList().addTask(task3);
- assertTrue(task3.getHandleIdentifier() + " should end with 3", task3.getHandleIdentifier().endsWith("3"));
- assertEquals(3, manager.getTaskList().getLastLocalTaskId());
-
- assertEquals(2, manager.getTaskList().getAllTasks().size());
- manager.saveTaskList();
- manager.resetTaskList();
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- assertEquals(0, manager.getTaskList().getLastLocalTaskId());
- manager.readExistingOrCreateNewList();
- assertEquals(2, manager.getTaskList().getAllTasks().size());
- assertEquals(3, manager.getTaskList().getLastLocalTaskId());
- ITask task4 = TasksUiInternal.createNewLocalTask("label");
- assertTrue(task4.getHandleIdentifier() + " should end with 4", task4.getHandleIdentifier().endsWith("4"));
- }
-
- public void testSingleTaskDeletion() {
- MockTask task = new MockTask("1");
- task.setLastReadTimeStamp("now");
- manager.getTaskList().addTask(task,
- manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
- assertEquals(1, manager.getTaskList().getAllTasks().size());
- manager.getTaskList().deleteTask(task);
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- manager.getTaskList().addTask(task,
- manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
- assertEquals(1, manager.getTaskList().getAllTasks().size());
-
- manager.saveTaskList();
-
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getAllTasks().size());
-
- manager.getTaskList().deleteTask(task);
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- manager.saveTaskList();
- assertEquals(0, manager.getTaskList().getAllTasks().size());
-
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- }
-
- private void runRepositoryUrlOperation(String oldUrl, String newUrl) {
- try {
- new RefactorRepositoryUrlOperation(oldUrl, newUrl).run(new NullProgressMonitor());
- } catch (Exception e) {
- fail();
- }
- }
-
- public void testMigrateTaskContextFiles() throws IOException {
- File fileA = ContextCorePlugin.getContextStore().getFileForContext("http://a-1");
- fileA.createNewFile();
- fileA.deleteOnExit();
- assertTrue(fileA.exists());
- runRepositoryUrlOperation("http://a", "http://b");
- File fileB = ContextCorePlugin.getContextStore().getFileForContext("http://b-1");
- assertTrue(fileB.exists());
- assertFalse(fileA.exists());
- }
-
- public void testMigrateQueryUrlHandles() {
- RepositoryQuery query = new MockRepositoryQuery("mquery");
- query.setRepositoryUrl("http://foo.bar");
- query.setUrl("http://foo.bar/b");
- manager.getTaskList().addQuery(query);
- assertTrue(manager.getTaskList().getRepositoryQueries("http://foo.bar").size() > 0);
- runRepositoryUrlOperation("http://foo.bar", "http://bar.baz");
- assertTrue(manager.getTaskList().getRepositoryQueries("http://foo.bar").size() == 0);
- assertTrue(manager.getTaskList().getRepositoryQueries("http://bar.baz").size() > 0);
- IRepositoryQuery changedQuery = manager.getTaskList().getRepositoryQueries("http://bar.baz").iterator().next();
- assertEquals("http://bar.baz/b", changedQuery.getUrl());
- }
-
- public void testMigrateQueryHandles() {
- RepositoryQuery query = new MockRepositoryQuery("mquery");
- query.setRepositoryUrl("http://a");
- manager.getTaskList().addQuery(query);
- runRepositoryUrlOperation("http://a", "http://b");
- assertFalse(manager.getTaskList().getRepositoryQueries("http://b").isEmpty());
- assertTrue(manager.getTaskList().getRepositoryQueries("http://a").isEmpty());
- }
-
-// public void testMigrateQueryHits() {
-// AbstractRepositoryQuery query = new MockRepositoryQuery("mquery",
-// manager.getTaskList());
-// query.setRepositoryUrl("http://a");
-// manager.getTaskList().addQuery(query);
-// AbstractQueryHit hit = new MockQueryHit(manager.getTaskList(), "http://a",
-// "", "123");
-// query.addHit(hit);
-// runRepositoryUrlOperation("http://a", "http://b");
-// assertNotNull(manager.getTaskList().getQueryHit("http://b-123"));
-// assertEquals("http://b-123", hit.getHandleIdentifier());
-// }
-
- public void testMigrateTaskHandles() {
- AbstractTask task = new MockTask("http://a", "123");
- AbstractTask task2 = new MockTask("http://other", "other");
- manager.getTaskList().addTask(task);
- manager.getTaskList().addTask(task2);
-
- RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(), task.getConnectorKind(),
- task.getRepositoryUrl(), task.getTaskId(), task.getTaskKind());
- TasksUiPlugin.getTaskDataStorageManager().setNewTaskData(taskData);
- assertNotNull(TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
- task.getTaskId()));
-
- RepositoryTaskData taskData2 = new RepositoryTaskData(new MockAttributeFactory(), task2.getConnectorKind(),
- task2.getRepositoryUrl(), task2.getTaskId(), task2.getTaskKind());
- taskData2.setNewComment("TEST");
- TasksUiPlugin.getTaskDataStorageManager().setNewTaskData(taskData2);
- assertNotNull(TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task2.getRepositoryUrl(),
- task2.getTaskId()));
- assertEquals("TEST", TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task2.getRepositoryUrl(),
- task2.getTaskId()).getNewComment());
-
- runRepositoryUrlOperation("http://a", "http://b");
- assertNull(manager.getTaskList().getTask("http://a-123"));
- assertNotNull(manager.getTaskList().getTask("http://b-123"));
- assertNotNull(TasksUiPlugin.getTaskDataStorageManager().getNewTaskData("http://b", "123"));
- RepositoryTaskData otherData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(
- task2.getRepositoryUrl(), task2.getTaskId());
- assertNotNull(otherData);
- assertEquals("TEST", otherData.getNewComment());
- }
-
- public void testMigrateTaskHandlesWithExplicitSet() {
- AbstractTask task = new MockTask("http://a", "123");
- task.setUrl("http://a/task/123");
- manager.getTaskList().addTask(task);
- runRepositoryUrlOperation("http://a", "http://b");
- assertNull(manager.getTaskList().getTask("http://a-123"));
- assertNotNull(manager.getTaskList().getTask("http://b-123"));
- assertEquals("http://b/task/123", task.getUrl());
- }
-
- public void testRefactorMetaContextHandles() {
- String firstUrl = "http://repository1.com/bugs";
- String secondUrl = "http://repository2.com/bugs";
- AbstractTask task1 = new MockTask(firstUrl, "1");
- AbstractTask task2 = new MockTask(firstUrl, "2");
- manager.getTaskList().addTask(task1);
- manager.getTaskList().addTask(task2);
- Calendar startDate = Calendar.getInstance();
- Calendar endDate = Calendar.getInstance();
- endDate.add(Calendar.MINUTE, 5);
-
- Calendar startDate2 = Calendar.getInstance();
- startDate2.add(Calendar.MINUTE, 15);
- Calendar endDate2 = Calendar.getInstance();
- endDate2.add(Calendar.MINUTE, 25);
-
- ContextCorePlugin.getContextManager().resetActivityMetaContext();
- InteractionContext metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- assertEquals(0, metaContext.getInteractionHistory().size());
-
- ContextCorePlugin.getContextManager().processActivityMetaContextEvent(
- new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task1.getHandleIdentifier(), "origin",
- null, InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startDate.getTime(),
- endDate.getTime()));
-
- ContextCorePlugin.getContextManager().processActivityMetaContextEvent(
- new InteractionEvent(InteractionEvent.Kind.ATTENTION,
- InteractionContextManager.ACTIVITY_STRUCTUREKIND_TIMING, task2.getHandleIdentifier(), "origin",
- null, InteractionContextManager.ACTIVITY_DELTA_ADDED, 1f, startDate2.getTime(),
- endDate2.getTime()));
-
- assertEquals(2, metaContext.getInteractionHistory().size());
- assertEquals(60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task1));
- assertEquals(2 * 60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(task2));
- runRepositoryUrlOperation(firstUrl, secondUrl);
- metaContext = ContextCorePlugin.getContextManager().getActivityMetaContext();
- assertEquals(2, metaContext.getInteractionHistory().size());
- assertEquals(60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(new MockTask(secondUrl, "1")));
- assertEquals(2 * 60 * 1000 * 5, TasksUiPlugin.getTaskActivityManager().getElapsedTime(
- new MockTask(secondUrl, "2")));
- assertEquals(secondUrl + "-1", metaContext.getInteractionHistory().get(0).getStructureHandle());
- }
-
- public void testIsActiveToday() {
- AbstractTask task = new LocalTask("1", "task-1");
- assertFalse(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
-
- task.setScheduledForDate(TaskActivityUtil.getCurrentWeek().getToday());
- assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
-
- task.setReminded(true);
- assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
- task.setReminded(true);
-
-// Calendar inAnHour = Calendar.getInstance();
-// inAnHour.set(Calendar.HOUR_OF_DAY, inAnHour.get(Calendar.HOUR_OF_DAY) + 1);
-// inAnHour.getTime();
-// task.setScheduledForDate(inAnHour.getTime());
-// Calendar tomorrow = Calendar.getInstance();
-// TaskActivityUtil.snapToNextDay(tomorrow);
-// assertEquals(-1, inAnHour.compareTo(tomorrow));
-// assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
- }
-
- public void testScheduledForToday() {
- AbstractTask task = new LocalTask("1", "task-1");
- task.setScheduledForDate(TaskActivityUtil.getCurrentWeek().getToday());
- assertTrue(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
- task.setScheduledForDate(TaskActivityUtil.getCurrentWeek().getToday().next());
- assertFalse(TasksUiPlugin.getTaskActivityManager().isScheduledForToday(task));
- }
-
- public void testSchedulePastEndOfMonth() {
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.MONTH, Calendar.SEPTEMBER);
- calendar.set(Calendar.DAY_OF_MONTH, 30);
- TaskActivityUtil.snapForwardNumDays(calendar, 1);
- assertEquals("Should be October", Calendar.OCTOBER, calendar.get(Calendar.MONTH));
- }
-
- public void testIsCompletedToday() {
- ITask task = new LocalTask("1", "task 1");
- task.setCompletionDate(new Date());
- assertTrue(TasksUiPlugin.getTaskActivityManager().isCompletedToday(task));
-
- MockTask mockTask = new MockTask("1");
- mockTask.setOwner("unknown");
- manager.getTaskList().addTask(mockTask);
- mockTask.setCompletionDate(new Date());
- assertFalse("completed: " + mockTask.getCompletionDate(), TasksUiPlugin.getTaskActivityManager()
- .isCompletedToday(mockTask));
-
- mockTask = new MockTask("2");
- manager.getTaskList().addTask(mockTask);
- mockTask.setCompletionDate(new Date());
- repository.setAuthenticationCredentials("testUser", "testPassword");
- mockTask.setOwner("testUser");
- assertTrue(TasksUiPlugin.getTaskActivityManager().isCompletedToday(mockTask));
-
- }
-
- public void testMoveCategories() {
-// assertEquals(0, manager.getTaskList()
-// .getOrphanContainer(LocalRepositoryConnector.REPOSITORY_URL)
-// .getChildren()
-// .size());
-
- assertTrue(manager.getTaskList().getDefaultCategory().isEmpty());
-
- AbstractTask task1 = new LocalTask("t1", "t1");
-
- TaskCategory cat1 = new TaskCategory("cat1");
- manager.getTaskList().addCategory(cat1);
- TaskCategory cat2 = new TaskCategory("cat2");
- manager.getTaskList().addCategory(cat2);
-
- manager.getTaskList().addTask(task1, cat1);
- assertEquals(1, manager.getTaskList().getContainerForHandle("cat1").getChildren().size());
- assertEquals(0, manager.getTaskList().getContainerForHandle("cat2").getChildren().size());
-
- manager.getTaskList().addTask(task1, cat2);
- assertEquals(0, manager.getTaskList().getContainerForHandle("cat1").getChildren().size());
- assertEquals(1, manager.getTaskList().getContainerForHandle("cat2").getChildren().size());
- }
-
- public void testMoveToRoot() {
-// assertEquals(0, manager.getTaskList()
-// .getOrphanContainer(LocalRepositoryConnector.REPOSITORY_URL)
-// .getChildren()
-// .size());
- assertTrue(manager.getTaskList().getDefaultCategory().isEmpty());
-
- AbstractTask task1 = new LocalTask("t1", "t1");
- manager.getTaskList().addTask(task1,
- manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
- assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
- assertEquals(manager.getTaskList().getDefaultCategory(), TaskCategory.getParentTaskCategory(task1));
-
- TaskCategory cat1 = new TaskCategory("c1");
- manager.getTaskList().addCategory(cat1);
-
- manager.getTaskList().addTask(task1, cat1);
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
- assertEquals(cat1, TaskCategory.getParentTaskCategory(task1));
-
- manager.getTaskList().addTask(task1,
- manager.getTaskList().getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
- assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
- assertEquals(0, cat1.getChildren().size());
- assertEquals(manager.getTaskList().getDefaultCategory(), TaskCategory.getParentTaskCategory(task1));
- }
-
- public void testCategoryPersistance() {
- MockTask task = new MockTask("1");
- TaskCategory category = new TaskCategory("cat");
- manager.getTaskList().addCategory(category);
- manager.getTaskList().addTask(task, category);
- assertNotNull(manager.getTaskList());
- assertEquals(2, manager.getTaskList().getCategories().size());
-
- manager.saveTaskList();
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals("" + manager.getTaskList().getCategories(), 2, manager.getTaskList().getCategories().size());
- assertEquals(1, manager.getTaskList().getAllTasks().size());
- }
-
- public void testDeleteCategory() {
- assertNotNull(manager.getTaskList());
- assertEquals(1, manager.getTaskList().getCategories().size());
- TaskCategory category = new TaskCategory("cat");
- manager.getTaskList().addCategory(category);
- assertEquals(2, manager.getTaskList().getCategories().size());
- manager.getTaskList().deleteCategory(category);
- assertEquals(1, manager.getTaskList().getCategories().size());
- }
-
- public void testDeleteCategoryMovesTasksToRoot() {
- AbstractTask task = new MockTask("delete");
- TaskCategory category = new TaskCategory("cat");
- manager.getTaskList().addCategory(category);
- manager.getTaskList().addTask(task, category);
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
- manager.getTaskList().deleteCategory(category);
- manager.getTaskList().getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL);
- }
-
- public void testRenameCategory() {
-
- assertNotNull(manager.getTaskList());
-
- TaskCategory category = new TaskCategory("cat");
- manager.getTaskList().addCategory(category);
- assertEquals(2, manager.getTaskList().getCategories().size());
- String newDesc = "newDescription";
- manager.getTaskList().renameContainer(category, newDesc);
- AbstractTaskCategory container = manager.getTaskList().getContainerForHandle(newDesc);
- assertNotNull(container);
- assertEquals(newDesc, container.getSummary());
- manager.getTaskList().deleteCategory(container);
- assertEquals(1, manager.getTaskList().getCategories().size());
- }
-
- public void testDeleteCategoryAfterRename() {
- String newDesc = "newDescription";
- assertNotNull(manager.getTaskList());
- assertEquals(1, manager.getTaskList().getCategories().size());
- TaskCategory category = new TaskCategory("cat");
- manager.getTaskList().addCategory(category);
- assertEquals(2, manager.getTaskList().getCategories().size());
- manager.getTaskList().renameContainer(category, newDesc);
- manager.getTaskList().deleteCategory(category);
- assertEquals(1, manager.getTaskList().getCategories().size());
- }
-
- public void testCreateSameCategoryName() {
- assertNotNull(manager.getTaskList());
- assertEquals(1, manager.getTaskList().getCategories().size());
- TaskCategory category = new TaskCategory("cat");
- manager.getTaskList().addCategory(category);
- assertEquals(2, manager.getTaskList().getCategories().size());
- TaskCategory category2 = new TaskCategory("cat");
- manager.getTaskList().addCategory(category2);
- assertEquals(2, manager.getTaskList().getCategories().size());
- ITaskContainer container = manager.getTaskList().getContainerForHandle("cat");
- assertEquals(container, category);
- }
-
- public void testDeleteRootTask() {
- AbstractTask task = new LocalTask("1", "label");
- manager.getTaskList().addTask(task);
- manager.getTaskList().deleteTask(task);
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
- }
-
- public void testDeleteFromCategory() {
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
- //assertEquals(0, manager.getTaskList().getArchiveContainer().getChildren().size());
- assertEquals(1, manager.getTaskList().getCategories().size());
-
- AbstractTask task = new LocalTask("1", "label");
- TaskCategory category = new TaskCategory("handleAndDescription");
- manager.getTaskList().addTask(task);
- assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
-
- manager.getTaskList().addCategory(category);
- manager.getTaskList().addTask(task, category);
- assertEquals(2, manager.getTaskList().getCategories().size());
- assertEquals(1, category.getChildren().size());
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
- assertEquals(1, manager.getTaskList().getAllTasks().size());
-
- manager.getTaskList().deleteTask(task);
- assertEquals(0, manager.getTaskList().getAllTasks().size());
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
- assertEquals(0, category.getChildren().size());
- }
-
- public void testDeleteRepositoryTask() {
- String repositoryUrl = "http://somewhere.com";
- repository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND, repositoryUrl);
- TasksUiPlugin.getRepositoryManager().addRepository(repository);
- MockTask task = new MockTask(repositoryUrl, "1");
- TaskList taskList = TasksUiPlugin.getTaskList();
- taskList.addTask(task, manager.getTaskList().getDefaultCategory());
- MockRepositoryQuery query = new MockRepositoryQuery("query");
- taskList.addQuery(query);
- taskList.addTask(task, query);
- assertEquals(1, taskList.getAllTasks().size());
- assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
- taskList.deleteTask(task);
- assertEquals(0, taskList.getAllTasks().size());
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
- }
-
- public void testCreate() {
- MockTask repositoryTask = new MockTask("1");
- repositoryTask.setLastReadTimeStamp("now");
- manager.getTaskList().addTask(repositoryTask, manager.getTaskList().getDefaultCategory());
- assertEquals(1, manager.getTaskList().getDefaultCategory().getChildren().size());
- manager.saveTaskList();
-
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList().getAllTasks().size());
- }
-
- public void testCreateAndMove() throws CoreException {
- MockTask repositoryTask = new MockTask("1");
- repositoryTask.setLastReadTimeStamp("now");
- manager.getTaskList().addTask(repositoryTask);
- assertEquals(1, manager.getTaskList().getAllTasks().size());
- TasksUiPlugin.getExternalizationManager().requestSave();
- TasksUiPlugin.getDefault().reloadDataDirectory();
- assertEquals(1, manager.getTaskList().getAllTasks().size());
- assertEquals(1, manager.getTaskList()
- .getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL)
- .getChildren()
- .size());
-
- }
-
- public void testArchiveRepositoryTaskExternalization() {
- MockTask repositoryTask = new MockTask("1");
- repositoryTask.setLastReadTimeStamp("now");
- manager.getTaskList().addTask(repositoryTask);
- assertEquals(1, manager.getTaskList()
- .getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL)
- .getChildren()
- .size());
- manager.saveTaskList();
-
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
- assertEquals(1, manager.getTaskList()
- .getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL)
- .getChildren()
- .size());
- }
-
- public void testRepositoryTasksAndCategoriesMultiRead() {
- TaskCategory cat1 = new TaskCategory("Category 1");
- manager.getTaskList().addCategory(cat1);
-
- MockTask reportInCat1 = new MockTask("123");
- manager.getTaskList().addTask(reportInCat1, cat1);
- assertEquals(cat1, TaskCategory.getParentTaskCategory(reportInCat1));
-
- manager.saveTaskList();
- assertNotNull(manager.getTaskList());
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
-
- // read once
- Set<AbstractTaskCategory> readCats = manager.getTaskList().getTaskCategories();
- assertTrue(manager.getTaskList().getCategories().contains(cat1));
- Iterator<AbstractTaskCategory> iterator = readCats.iterator();
-
- boolean found = false;
- while (iterator.hasNext()) {
- ITaskContainer readCat1 = iterator.next();
- if (cat1.equals(readCat1)) {
- found = true;
- assertEquals(1, readCat1.getChildren().size());
- }
- }
- if (!found) {
- fail(" Category not found afer tasklist read");
- }
-
- manager.saveTaskList();
- assertNotNull(manager.getTaskList());
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
-
- // read again
- readCats = manager.getTaskList().getTaskCategories();
- assertTrue(manager.getTaskList().getCategories().contains(cat1));
-
- iterator = readCats.iterator();
- found = false;
- while (iterator.hasNext()) {
- ITaskContainer readCat1 = iterator.next();
- if (cat1.equals(readCat1)) {
- found = true;
- assertEquals(1, readCat1.getChildren().size());
- }
- }
- if (!found) {
- fail(" Category not found afer tasklist read");
- }
- }
-
- public void testSubTaskExternalization() {
- Set<AbstractTask> rootTasks = new HashSet<AbstractTask>();
- AbstractTask task1 = new LocalTask("1", "task1");
- manager.getTaskList().addTask(task1);
- rootTasks.add(task1);
-
- AbstractTask sub2 = new LocalTask("2", "sub 2");
- manager.getTaskList().addTask(sub2, task1);
- assertEquals(1, task1.getChildren().size());
- assertTrue(rootTasks.containsAll(manager.getTaskList().getDefaultCategory().getChildren()));
-
- manager.saveTaskList();
- assertNotNull(manager.getTaskList());
- manager.resetTaskList();
- manager.readExistingOrCreateNewList();
-
- assertNotNull(manager.getTaskList());
-
- // XXX: This should pass once sub tasks are handled properly
-// assertTrue(rootTasks.containsAll(manager.getTaskList().getOrphanContainer(
-// LocalRepositoryConnector.REPOSITORY_URL).getChildren()));
-
- Collection<ITask> readList = manager.getTaskList().getDefaultCategory().getChildren();
- for (ITask task : readList) {
- if (task.equals(task1)) {
- assertEquals(task1.getSummary(), task.getSummary());
- assertEquals(1, ((ITaskContainer) task).getChildren().size());
- }
- }
- }
-
- public void testCreationAndExternalization() throws CoreException {
- Set<AbstractTask> rootTasks = new HashSet<AbstractTask>();
- AbstractTask task1 = TasksUiInternal.createNewLocalTask("task 1");
- rootTasks.add(task1);
- assertEquals(1, manager.getTaskList().getAllTasks().size());
-
- AbstractTask sub1 = TasksUiInternal.createNewLocalTask("sub 1");
- manager.getTaskList().addTask(sub1, task1);
- assertEquals(4, manager.getTaskList().getRootElements().size());
-
- //manager.getTaskList().moveToContainer(sub1, manager.getTaskList().getArchiveContainer());
-
- AbstractTask task2 = TasksUiInternal.createNewLocalTask("task 2");
- rootTasks.add(task2);
- assertEquals(3, manager.getTaskList().getAllTasks().size());
-
- Set<TaskCategory> categories = new HashSet<TaskCategory>();
- Set<AbstractTask> cat1Contents = new HashSet<AbstractTask>();
- TaskCategory cat1 = new TaskCategory("Category 1");
- manager.getTaskList().addCategory(cat1);
- categories.add(cat1);
- assertEquals(5, manager.getTaskList().getRootElements().size());
-
- AbstractTask task3 = TasksUiInternal.createNewLocalTask("task 3");
- manager.getTaskList().addTask(task3, cat1);
- cat1Contents.add(task3);
- assertEquals(4, manager.getTaskList().getAllTasks().size());
- assertEquals(cat1, TaskCategory.getParentTaskCategory(task3));
- AbstractTask sub2 = TasksUiInternal.createNewLocalTask("sub 2");
- assertEquals(5, manager.getTaskList().getAllTasks().size());
- manager.getTaskList().addTask(sub2, task3);
- //manager.getTaskList().moveToContainer(sub2, manager.getTaskList().getArchiveContainer());
-
- AbstractTask task4 = TasksUiInternal.createNewLocalTask("task 4");
- manager.getTaskList().addTask(task4, cat1);
- cat1Contents.add(task4);
- assertEquals(6, manager.getTaskList().getAllTasks().size());
-
- MockTask reportInCat1 = new MockTask("123");
- manager.getTaskList().addTask(reportInCat1, cat1);
- assertEquals(cat1, TaskCategory.getParentTaskCategory(reportInCat1));
- cat1Contents.add(reportInCat1);
- assertEquals(7, manager.getTaskList().getAllTasks().size());
-
- assertEquals(5, manager.getTaskList().getRootElements().size());
-
- TasksUiPlugin.getExternalizationManager().requestSave();
- TasksUiPlugin.getDefault().reloadDataDirectory();
-
- Collection<ITask> readList = manager.getTaskList().getDefaultCategory().getChildren();
- for (ITask task : readList) {
- if (task.equals(task1)) {
- assertEquals(task1.getSummary(), task.getSummary());
- assertEquals(1, ((AbstractTaskContainer) task).getChildren().size());
- }
- }
-
- Set<AbstractTaskCategory> readCats = manager.getTaskList().getTaskCategories();
- assertTrue(manager.getTaskList().getCategories().contains(cat1));
- Iterator<AbstractTaskCategory> iterator = readCats.iterator();
- boolean found = false;
- while (iterator.hasNext()) {
- ITaskContainer readCat1 = iterator.next();
- if (cat1.equals(readCat1)) {
- found = true;
- for (ITask task : readCat1.getChildren()) {
- assertTrue(cat1Contents.contains(task));
- }
- }
- }
- if (!found) {
- fail(" Category not found afer tasklist read");
- }
- }
-
- public void testExternalizationOfHandlesWithDash() throws CoreException {
- AbstractTask task1 = TasksUiInternal.createNewLocalTask("task 1");
- manager.getTaskList().addTask(task1, manager.getTaskList().getDefaultCategory());
-
- TasksUiPlugin.getExternalizationManager().requestSave();
- TasksUiPlugin.getDefault().reloadDataDirectory();
- assertTrue(manager.getTaskList().getDefaultCategory().getChildren().contains(task1));
- }
-
- public void testgetQueriesAndHitsForHandle() {
- TaskList taskList = manager.getTaskList();
-
- MockTask hit1 = new MockTask("1");
- MockTask hit2 = new MockTask("2");
- MockTask hit3 = new MockTask("3");
-
- MockTask hit1twin = new MockTask("1");
- MockTask hit2twin = new MockTask("2");
- MockTask hit3twin = new MockTask("3");
-
- MockRepositoryQuery query1 = new MockRepositoryQuery("query1");
- MockRepositoryQuery query2 = new MockRepositoryQuery("query2");
-
- taskList.addQuery(query1);
- taskList.addQuery(query2);
- taskList.addTask(hit1, query1);
- taskList.addTask(hit2, query1);
- taskList.addTask(hit3, query1);
-
- assertEquals(3, query1.getChildren().size());
-
- taskList.addTask(hit1twin, query2);
- taskList.addTask(hit2twin, query2);
- taskList.addTask(hit3twin, query2);
-
- assertEquals(3, query2.getChildren().size());
-
- Set<AbstractTaskContainer> queriesReturned = hit1.getParentContainers();
- assertNotNull(queriesReturned);
- assertEquals(2, queriesReturned.size());
- assertTrue(queriesReturned.contains(query1));
- assertTrue(queriesReturned.contains(query2));
- }
-
-// public void testQueryHitHasParent() {
-// TaskList taskList = manager.getTaskList();
-//
-// MockQueryHit hit1 = new MockQueryHit(taskList,
-// MockRepositoryConnector.REPOSITORY_URL, "description1", "1");
-// assertNull(hit1.getParent());
-// MockRepositoryQuery query1 = new MockRepositoryQuery("query1",
-// manager.getTaskList());
-// query1.addHit(hit1);
-// assertEquals(query1, hit1.getParent());
-//
-// }
-
- public void testUpdateQueryHits() {
- ITaskList taskList = manager.getTaskList();
-
- MockTask hit1 = new MockTask("1");
- MockTask hit2 = new MockTask("2");
- MockTask hit3 = new MockTask("3");
-
- MockTask hit1twin = new MockTask("1");
- MockTask hit2twin = new MockTask("2");
- MockTask hit3twin = new MockTask("3");
-
- MockRepositoryQuery query1 = new MockRepositoryQuery("query1");
- taskList.addQuery(query1);
-
- taskList.addTask(hit1, query1);
- taskList.addTask(hit2, query1);
- taskList.addTask(hit3, query1);
-
- taskList.addTask(hit1twin, query1);
- taskList.addTask(hit2twin, query1);
- taskList.addTask(hit3twin, query1);
-
- assertEquals(3, query1.getChildren().size());
- for (ITask child : query1.getChildren()) {
- taskList.removeFromContainer(query1, child);
- }
- assertEquals(0, query1.getChildren().size());
- taskList.addTask(hit1, query1);
- taskList.addTask(hit2, query1);
- assertEquals(2, query1.getChildren().size());
- hit1.setNotified(true);
-
- taskList.addTask(hit1twin, query1);
- taskList.addTask(hit2twin, query1);
- taskList.addTask(hit3twin, query1);
- assertEquals(3, query1.getChildren().size());
- assertTrue(query1.getChildren().contains(hit1twin));
- assertTrue(query1.getChildren().contains(hit2twin));
- assertTrue(query1.getChildren().contains(hit3twin));
- for (ITask hit : query1.getChildren()) {
- if (hit.equals(hit1twin)) {
- assertTrue(((AbstractTask) hit).isNotified());
- } else {
- assertFalse(((AbstractTask) hit).isNotified());
- }
- }
- }
-
- public void testgetRepositoryTasks() {
-
- String repositoryUrl = "https://bugs.eclipse.org/bugs";
-
- String bugNumber = "106939";
-
- MockTask task1 = new MockTask(repositoryUrl, bugNumber);
- manager.getTaskList().addTask(task1);
-
- MockTask task2 = new MockTask("https://unresolved", bugNumber);
- manager.getTaskList().addTask(task2);
-
- TaskList taskList = manager.getTaskList();
- assertEquals(2, taskList.getAllTasks().size());
- Set<ITask> tasksReturned = taskList.getTasks(repositoryUrl);
- assertNotNull(tasksReturned);
- assertEquals(1, tasksReturned.size());
- assertTrue(tasksReturned.contains(task1));
- }
-
- public void testAllTasksDeactivation() {
- AbstractTask task1 = new LocalTask("task1", "description1");
- AbstractTask task2 = new LocalTask("task2", "description2");
- TaskList taskList = manager.getTaskList();
- taskList.addTask(task1);
- taskList.addTask(task2);
- assertNull(manager.getActiveTask());
-
- manager.activateTask(task2);
- assertEquals(task2, manager.getActiveTask());
-
- manager.deactivateAllTasks();
- assertNull(manager.getActiveTask());
- }
-
- public void testMarkTaskRead() {
- // TODO reimplement
-// String repositoryUrl = "http://mylyn.eclipse.org/bugs222";
-// MockTask task1 = new MockTask(repositoryUrl, "1");
-// MockTask task2 = new MockTask(repositoryUrl, "2");
-// task1.setSynchronizationState(SynchronizationState.INCOMING);
-// task2.setSynchronizationState(SynchronizationState.INCOMING);
-// List<ITaskElement> elements = new ArrayList<ITaskElement>();
-// elements.add(task1);
-// elements.add(task2);
-// MarkTaskReadAction readAction = new MarkTaskReadAction(elements);
-// readAction.run();
-// assertEquals(SynchronizationState.SYNCHRONIZED, task1.getSynchronizationState());
-// assertEquals(SynchronizationState.SYNCHRONIZED, task2.getSynchronizationState());
-//
-// manager.getTaskList().reset();
-// MockTask hit1 = new MockTask("1");
-// MockTask hit2 = new MockTask("2");
-// MockRepositoryQuery query = new MockRepositoryQuery("summary");
-// manager.getTaskList().addQuery(query);
-// manager.getTaskList().addTask(hit1, query);
-// manager.getTaskList().addTask(hit2, query);
-//
-// elements.clear();
-// elements.add(query);
-// readAction = new MarkTaskReadAction(elements);
-// readAction.run();
-// assertEquals(2, query.getChildren().size());
-// for (ITaskElement element : query.getChildren()) {
-// if (element instanceof MockTask) {
-// MockTask mockTask = (MockTask) element;
-// assertEquals(SynchronizationState.SYNCHRONIZED, mockTask.getSynchronizationState());
-// }
-// }
-
- }
-
- public void testMarkUnRead() {
- // TODO reimplement
-// String repositoryUrl = "http://mylyn.eclipse.org/bugs222";
-// MockTask task1 = new MockTask(repositoryUrl, "1");
-// MockTask task2 = new MockTask(repositoryUrl, "2");
-// assertEquals(SynchronizationState.SYNCHRONIZED, task1.getSynchronizationState());
-// assertEquals(SynchronizationState.SYNCHRONIZED, task2.getSynchronizationState());
-// List<ITaskElement> elements = new ArrayList<ITaskElement>();
-// elements.add(task1);
-// elements.add(task2);
-// MarkTaskUnreadAction unreadAction = new MarkTaskUnreadAction(elements);
-// unreadAction.run();
-// assertEquals(SynchronizationState.INCOMING, task1.getSynchronizationState());
-// assertEquals(SynchronizationState.INCOMING, task2.getSynchronizationState());
-//
-// manager.getTaskList().reset();
-// MockTask hit1 = new MockTask("1");
-// MockTask hit2 = new MockTask("2");
-// MockRepositoryQuery query = new MockRepositoryQuery("summary");
-// manager.getTaskList().addQuery(query);
-// manager.getTaskList().addTask(hit1, query);
-// manager.getTaskList().addTask(hit2, query);
-//
-// elements.clear();
-// elements.add(query);
-// MarkTaskReadAction readAction = new MarkTaskReadAction(elements);
-// readAction.run();
-// assertEquals(2, query.getChildren().size());
-// for (ITaskElement element : query.getChildren()) {
-// if (element instanceof MockTask) {
-// MockTask mockTask = (MockTask) element;
-// assertEquals(SynchronizationState.SYNCHRONIZED, mockTask.getSynchronizationState());
-// } else {
-// fail();
-// }
-// }
-//
-// unreadAction = new MarkTaskUnreadAction(elements);
-// unreadAction.run();
-// assertEquals(2, query.getChildren().size());
-// for (ITaskElement element : query.getChildren()) {
-// if (element instanceof MockTask) {
-// MockTask mockTask = (MockTask) element;
-// assertEquals(SynchronizationState.INCOMING, mockTask.getSynchronizationState());
-// } else {
-// fail();
-// }
-// }
- }
-
- public void testQueryHitsNotDropped() {
- MockTask task1 = new MockTask("1");
- MockTask task2 = new MockTask("2");
- task1.setLastReadTimeStamp("today");
- task2.setLastReadTimeStamp("today");
- MockRepositoryQuery query = new MockRepositoryQuery("summary");
- manager.getTaskList().addQuery(query);
- manager.getTaskList().addTask(task1, query);
- manager.getTaskList().addTask(task2, query);
- //assertEquals(0, manager.getTaskList().getArchiveContainer().getChildren().size());
- assertEquals(2, query.getChildren().size());
- TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
- MockRepositoryConnector.REPOSITORY_URL);
- Set<RepositoryQuery> queries = new HashSet<RepositoryQuery>();
- queries.add(query);
- TasksUiInternal.synchronizeQueries(new MockRepositoryConnector(), repository, queries, null, true);
- //assertEquals(2, manager.getTaskList().getArchiveContainer().getChildren().size());
- assertEquals(0, query.getChildren().size());
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java
deleted file mode 100644
index 776ab6a81..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockAttributeFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
-* 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.tasks.tests.connector;
-
-import java.util.Date;
-
-import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractAttributeFactory;
-
-/**
- * @author Rob Elves
- */
-public class MockAttributeFactory extends AbstractAttributeFactory {
-
- private static final long serialVersionUID = 7713746838934802731L;
-
- @Override
- public boolean isHidden(String key) {
- // ignore
- return false;
- }
-
- @Override
- public String getName(String key) {
- // ignore
- return key;
- }
-
- @Override
- public boolean isReadOnly(String key) {
- // ignore
- return false;
- }
-
- @Override
- public String mapCommonAttributeKey(String key) {
- return key;
- }
-
- @Override
- public Date getDateForAttributeType(String attributeKey, String dateString) {
- // ignore
- return null;
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
index 8b03931d7..9e15c2ca5 100644
--- a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Tasks UI
Bundle-SymbolicName: org.eclipse.mylyn.tasks.ui;singleton:=true
-Bundle-Version: 3.0.2.qualifier
+Bundle-Version: 3.0.4.qualifier
Bundle-Activator: org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.compare,
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/actions/TaskSelectionDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java
index 3e3588bbd..1906a5915 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java
@@ -18,6 +18,7 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -381,7 +382,7 @@ public class TaskSelectionDialog extends FilteredItemsSelectionDialog {
/**
* Mylyn's task activation history
*/
- private final List<AbstractTask> history;
+ private final LinkedHashSet<AbstractTask> history;
private final TaskHistoryItemsComparator itemsComparator;
@@ -429,8 +430,8 @@ public class TaskSelectionDialog extends FilteredItemsSelectionDialog {
public TaskSelectionDialog(Shell parent) {
super(parent);
this.taskActivationHistory = TasksUiPlugin.getTaskActivityManager().getTaskActivationHistory();
- this.history = new ArrayList<AbstractTask>(taskActivationHistory.getPreviousTasks());
- this.itemsComparator = new TaskHistoryItemsComparator(this.history);
+ this.history = new LinkedHashSet<AbstractTask>(taskActivationHistory.getPreviousTasks());
+ this.itemsComparator = new TaskHistoryItemsComparator(new ArrayList<AbstractTask>(history));
this.needsCreateTask = true;
this.labelProvider = new TaskElementLabelProvider(false);
this.showCompletedTasksAction = new ShowCompletedTasksAction();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java
index dc9af7a2e..a60fabf58 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java
@@ -229,12 +229,13 @@ public class RepositoryTextViewerConfiguration extends TextSourceViewerConfigura
@Override
public void hideHyperlinks() {
- Control cursorControl = sourceViewer.getTextWidget().getDisplay().getCursorControl();
- if (cursorControl != null) {
- cursorControl.setToolTipText(null);
+ if (currentTaskHyperlink != null) {
+ Control cursorControl = sourceViewer.getTextWidget().getDisplay().getCursorControl();
+ if (cursorControl != null) {
+ cursorControl.setToolTipText(null);
+ }
+ currentTaskHyperlink = null;
}
- currentTaskHyperlink = null;
-
super.hideHyperlinks();
}
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);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
index 6146e1326..e17543b9e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
@@ -41,6 +41,7 @@ import org.eclipse.mylyn.internal.tasks.ui.TaskTransfer;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.QueryImportAction;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskScheduleContentProvider.Unscheduled;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskContainer;
@@ -209,8 +210,12 @@ public class TaskListDropAdapter extends ViewerDropAdapter {
}
} else if (currentTarget instanceof ScheduledTaskContainer) {
ScheduledTaskContainer container = (ScheduledTaskContainer) currentTarget;
- TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task,
- container.getDateRange());
+ if (container instanceof Unscheduled) {
+ TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task, null);
+ } else {
+ TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task,
+ container.getDateRange());
+ }
} else if (currentTarget == null) {
TasksUiInternal.getTaskList().addTask(newTask, TasksUiPlugin.getTaskList().getDefaultCategory());
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListInterestFilter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListInterestFilter.java
index efac2757c..37a19ede6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListInterestFilter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListInterestFilter.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
@@ -23,6 +23,7 @@ import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.mylyn.internal.tasks.ui.AbstractTaskListFilter;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskScheduleContentProvider.Unscheduled;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskContainer;
@@ -120,26 +121,37 @@ public class TaskListInterestFilter extends AbstractTaskListFilter {
return false;
}
- private static boolean shouldShowInFocusedWorkweekDateContainer(Object parent, ITask task) {
+ private boolean shouldShowInFocusedWorkweekDateContainer(Object parent, ITask task) {
if (parent instanceof ScheduledTaskContainer) {
+
ScheduledTaskContainer container = (ScheduledTaskContainer) parent;
- if (container.isWeekDay() || container.isPresent()) {
- return true;
+
+ if (container instanceof Unscheduled) {
+ return false;
}
-// if (!TasksUiPlugin.getTaskActivityManager().isWeekDay((ScheduledTaskContainer) parent)) {
-// return false;
-// }
- if (TasksUiPlugin.getTaskActivityManager().isOverdue(task)
- || TasksUiPlugin.getTaskActivityManager().isPastReminder((AbstractTask) task)) {
+
+ if (isDateRangeInteresting(container)) {
return true;
}
+// if (container.isWeekDay() || container.isPresent()) {
+// return true;
+// }
+//
+//// if (!TasksUiPlugin.getTaskActivityManager().isWeekDay((ScheduledTaskContainer) parent)) {
+//// return false;
+//// }
+// if (TasksUiPlugin.getTaskActivityManager().isOverdue(task)
+// || TasksUiPlugin.getTaskActivityManager().isPastReminder((AbstractTask) task)) {
+// return true;
+// }
+
}
return false;
}
- public static boolean isInterestingForThisWeek(Object parent, AbstractTask task) {
+ public boolean isInterestingForThisWeek(Object parent, AbstractTask task) {
if (parent instanceof ScheduledTaskContainer) {
return shouldShowInFocusedWorkweekDateContainer(parent, task);
} else {
@@ -151,7 +163,7 @@ public class TaskListInterestFilter extends AbstractTaskListFilter {
}
}
- public static boolean hasChanges(Object parent, ITask task) {
+ public boolean hasChanges(Object parent, ITask task) {
if (parent instanceof ScheduledTaskContainer && !(parent instanceof TaskScheduleContentProvider.Unscheduled)) {
if (!shouldShowInFocusedWorkweekDateContainer(parent, task)) {
return false;
@@ -160,7 +172,7 @@ public class TaskListInterestFilter extends AbstractTaskListFilter {
return hasChangesHelper(parent, task);
}
- private static boolean hasChangesHelper(Object parent, ITask task) {
+ private boolean hasChangesHelper(Object parent, ITask task) {
if (task.getSynchronizationState().isOutgoing()) {
return true;
} else if (task.getSynchronizationState().isIncoming()) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskScheduleContentProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskScheduleContentProvider.java
index f2c33d9c6..41fd163e0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskScheduleContentProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskScheduleContentProvider.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
@@ -65,6 +65,7 @@ public class TaskScheduleContentProvider extends TaskListContentProvider impleme
Set<AbstractTaskContainer> containers = new HashSet<AbstractTaskContainer>();
WeekDateRange week = TaskActivityUtil.getCurrentWeek();
+ WeekDateRange nextWeek = TaskActivityUtil.getNextWeek();
timer.cancel();
timer = new Timer();
@@ -75,7 +76,11 @@ public class TaskScheduleContentProvider extends TaskListContentProvider impleme
}
containers.add(new ScheduledTaskContainer(TasksUiPlugin.getTaskActivityManager(), week));
- ScheduledTaskContainer nextWeekContainer = new ScheduledTaskContainer(taskActivityManager, week.next());
+ for (DateRange day : nextWeek.getDaysOfWeek()) {
+ containers.add(new ScheduledTaskContainer(TasksUiPlugin.getTaskActivityManager(), day));
+ }
+
+ ScheduledTaskContainer nextWeekContainer = new ScheduledTaskContainer(taskActivityManager, nextWeek);
containers.add(nextWeekContainer);
ScheduledTaskContainer twoWeeksContainer = new ScheduledTaskContainer(taskActivityManager, week.next()
diff --git a/org.eclipse.mylyn.test-feature/feature.xml b/org.eclipse.mylyn.test-feature/feature.xml
index dab751488..6cb03d86c 100644
--- a/org.eclipse.mylyn.test-feature/feature.xml
+++ b/org.eclipse.mylyn.test-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.mylyn.test_feature"
label="Mylyn Test Feature"
- version="3.0.2.qualifier"
+ version="3.0.4.qualifier"
plugin="org.eclipse.mylyn">
<description url="http://eclipse.org/mylyn">
diff --git a/org.eclipse.mylyn.trac-feature/feature.xml b/org.eclipse.mylyn.trac-feature/feature.xml
index e23598eb0..2d88dbc21 100644
--- a/org.eclipse.mylyn.trac-feature/feature.xml
+++ b/org.eclipse.mylyn.trac-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.mylyn.trac_feature"
label="Mylyn Connector: Trac"
- version="3.0.2.qualifier"
+ version="3.0.4.qualifier"
provider-name="Eclipse.org"
plugin="org.eclipse.mylyn">
@@ -84,14 +84,14 @@ Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in t
id="org.eclipse.mylyn.trac.ui"
download-size="0"
install-size="0"
- version="3.0.2.qualifier"
+ version="3.0.4.qualifier"
unpack="false"/>
<plugin
id="org.eclipse.mylyn.trac.core"
download-size="0"
install-size="0"
- version="3.0.2.qualifier"
+ version="3.0.4.qualifier"
unpack="false"/>
<plugin
diff --git a/org.eclipse.mylyn.trac.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.core/META-INF/MANIFEST.MF
index 907bdb8a5..a6cbd0a81 100644
--- a/org.eclipse.mylyn.trac.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Trac Connector Core
Bundle-SymbolicName: org.eclipse.mylyn.trac.core;singleton:=true
-Bundle-Version: 3.0.2.qualifier
+Bundle-Version: 3.0.4.qualifier
Bundle-Vendor: Eclipse.org
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.mylyn.context.core;bundle-version="[3.0.0,4.0.0)",
diff --git a/org.eclipse.mylyn.trac.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.ui/META-INF/MANIFEST.MF
index 9153bf2b3..f5b50416a 100644
--- a/org.eclipse.mylyn.trac.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Trac Connector UI
Bundle-SymbolicName: org.eclipse.mylyn.trac.ui;singleton:=true
-Bundle-Version: 3.0.2.qualifier
+Bundle-Version: 3.0.4.qualifier
Bundle-Activator: org.eclipse.mylyn.internal.trac.ui.TracUiPlugin
Bundle-Vendor: Eclipse.org
Require-Bundle: org.eclipse.core.runtime,

Back to the top