Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java4
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskActivityManager.java229
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskList.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/UncategorizedTaskContainer.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java24
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/ExternalizationManager.java5
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizationParticipant.java29
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java24
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/QueryExportImportTest.java23
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListManager.java225
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java84
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java93
17 files changed, 250 insertions, 511 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
index 7d277a5dc..d9ae48d93 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java
@@ -24,8 +24,8 @@ import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITask;
@@ -60,7 +60,7 @@ public abstract class AbstractBugzillaTest extends TestCase {
ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, false);
TasksUiPlugin.getTaskDataStorageManager().clear();
manager = TasksUiPlugin.getRepositoryManager();
- TasksUiPlugin.getTaskListManager().resetTaskList();//getTaskList().reset();
+ TasksUiPlugin.getDefault().reloadDataDirectory();
manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
}
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 4bde20331..68d262067 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
@@ -29,6 +29,7 @@ import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
+import org.eclipse.mylyn.tasks.core.ITaskListChangeListener;
/**
* Manages task elapsed time, scheduling, due dates, and the date ranges
@@ -66,9 +67,21 @@ public class TaskActivityManager implements ITaskActivityManager {
private int startDay = Calendar.MONDAY;
+ private final ITaskListChangeListener TASKLIST_CHANGE_LISTENER = new ITaskListChangeListener() {
+
+ public void containersChanged(Set<TaskContainerDelta> containers) {
+ for (TaskContainerDelta taskContainerDelta : containers) {
+ if (taskContainerDelta.getKind() == TaskContainerDelta.Kind.ROOT) {
+ reloadPlanningData();
+ }
+ }
+ }
+ };
+
public TaskActivityManager(TaskRepositoryManager repositoryManager, TaskList taskList) {
this.taskList = taskList;
this.repositoryManager = repositoryManager;
+ this.taskList.addChangeListener(TASKLIST_CHANGE_LISTENER);
clear();
}
@@ -744,218 +757,4 @@ public class TaskActivityManager implements ITaskActivityManager {
Assert.isNotNull(task);
return task.equals(getActiveTask());
}
-}
-
-//public ScheduledTaskContainer getActivityToday() {
-//for (ScheduledTaskContainer container : scheduleWeekDays) {
-// if (container.isToday()) {
-// return container;
-// }
-//}
-//return null;
-//}
-//
-//public ScheduledTaskContainer getActivityContainer(Calendar calendar, boolean isFloating) {
-//if (calendar == null) {
-// return null;
-//}
-//if (isPastReminder(calendar.getTime(), false)) {
-// return getActivityToday();
-//}
-//
-//if (!isFloating) {
-// for (ScheduledTaskContainer container : scheduleWeekDays) {
-// if (container.includes(calendar)) {
-// return container;
-// }
-// }
-//} else {
-// if (scheduledThisWeek.includes(calendar)) {
-// return scheduledThisWeek;
-// } else if (scheduledNextWeek.includes(calendar)) {
-// return scheduledNextWeek;
-// } else {
-// return scheduledFuture;
-// }
-//}
-//
-//return null;
-//}
-
-//public List<ScheduledTaskContainer> getDateRanges() {
-// return scheduleContainers;
-//}
-//
-//public List<ScheduledTaskContainer> getActivityWeekDays() {
-// return scheduleWeekDays;
-//}
-//
-//public boolean isWeekDay(ScheduledTaskContainer dateRangeTaskContainer) {
-// return scheduleWeekDays.contains(dateRangeTaskContainer);
-//}
-//
-///** public for testing */
-//public ScheduledTaskContainer getActivityThisWeek() {
-// return scheduledThisWeek;
-//}
-//
-///** public for testing * */
-//public ScheduledTaskContainer getActivityPast() {
-// return scheduledPast;
-//}
-//
-///** public for testing */
-//public ScheduledTaskContainer getActivityFuture() {
-// return scheduledFuture;
-//}
-//
-///** public for testing */
-//public ScheduledTaskContainer getActivityNextWeek() {
-// return scheduledNextWeek;
-//}
-//
-///** public for testing */
-//public ScheduledTaskContainer getActivityPrevious() {
-// return scheduledPrevious;
-//}
-//
-//public Date getStartTime() {
-// return startTime;
-//}
-
-///**
-// * TODO: move to activity manager
-// */
-//private void setupCalendarRanges() {
-//
-// scheduleContainers.clear();
-// scheduleWeekDays.clear();
-//
-// int startDay = getWeekStartDay();
-// //int endDay = TaskActivityManager.getInstance().getEndDay();
-// // scheduledStartHour =
-// // TasksUiPlugin.getDefault().getPreferenceStore().getInt(
-// // TaskListPreferenceConstants.PLANNING_STARTHOUR);
-//
-//// scheduledEndHour = TasksUiPlugin.getDefault().getPreferenceStore().getInt(
-//// TasksUiPreferenceConstants.PLANNING_ENDHOUR);
-//
-// Calendar pastStart = TaskActivityUtil.getCalendar();
-// pastStart.setTimeInMillis(0);
-//// pastStart.setFirstDayOfWeek(startDay);
-//// pastStart.setTime(startTime);
-//// pastStart.add(Calendar.WEEK_OF_YEAR, NUM_WEEKS_PAST_START);
-//// TaskActivityUtil.snapToStartOfWeek(pastStart);
-// Calendar pastEnd = TaskActivityUtil.getStartOfCurrentWeek();
-// pastEnd.setFirstDayOfWeek(startDay);
-// pastEnd.setTime(startTime);
-// pastEnd.add(Calendar.WEEK_OF_YEAR, NUM_WEEKS_PAST_END);
-// TaskActivityUtil.snapEndOfWeek(pastEnd);
-// scheduledPast = new ScheduledTaskContainer(this, pastStart.getTime(), pastEnd.getTime(), DESCRIPTION_PAST);
-// //scheduleContainers.add(scheduledPast);
-//
-// scheduleWeekDays.clear();
-// for (int x = startDay; x < (startDay + 7); x++) {
-// Calendar dayStart = TaskActivityUtil.getCalendar();
-// Calendar dayEnd = TaskActivityUtil.getCalendar();
-//
-// if (x > 7) {
-// dayStart.set(Calendar.DAY_OF_WEEK, x % 7);
-// dayEnd.set(Calendar.DAY_OF_WEEK, x % 7);
-// } else {
-// dayStart.set(Calendar.DAY_OF_WEEK, x);
-// dayEnd.set(Calendar.DAY_OF_WEEK, x);
-// }
-//
-// TaskActivityUtil.snapStartOfDay(dayStart);
-// TaskActivityUtil.snapEndOfDay(dayEnd);
-//
-// String summary = "<unknown>";
-// switch (dayStart.get(Calendar.DAY_OF_WEEK)) {
-// case Calendar.MONDAY:
-// summary = "Monday";
-// break;
-// case Calendar.TUESDAY:
-// summary = "Tuesday";
-// break;
-// case Calendar.WEDNESDAY:
-// summary = "Wednesday";
-// break;
-// case Calendar.THURSDAY:
-// summary = "Thursday";
-// break;
-// case Calendar.FRIDAY:
-// summary = "Friday";
-// break;
-// case Calendar.SATURDAY:
-// summary = "Saturday";
-// break;
-// case Calendar.SUNDAY:
-// summary = "Sunday";
-// break;
-// }
-// ScheduledTaskContainer day = new ScheduledTaskContainer(this, dayStart, dayEnd, summary);
-// scheduleWeekDays.add(day);
-// scheduleContainers.add(day);
-// }
-//
-// Calendar currentBegin = TaskActivityUtil.getCalendar();
-// currentBegin.setTime(startTime);
-// TaskActivityUtil.snapStartOfWorkWeek(currentBegin);
-// Calendar currentEnd = TaskActivityUtil.getCalendar();
-// currentEnd.setTime(startTime);
-// TaskActivityUtil.snapEndOfWeek(currentEnd);
-// scheduledThisWeek = new ScheduledTaskContainer(this, currentBegin, currentEnd, DESCRIPTION_THIS_WEEK);
-// scheduledThisWeek.setCaptureFloating(true);
-// //scheduleContainers.add(scheduledThisWeek);
-//
-//// GregorianCalendar currentBegin = new GregorianCalendar();
-//// currentBegin.setFirstDayOfWeek(startDay);
-//// currentBegin.setTime(startTime);
-//// TaskActivityUtil.snapStartOfWorkWeek(currentBegin);
-//// GregorianCalendar currentEnd = new GregorianCalendar();
-//// currentEnd.setFirstDayOfWeek(startDay);
-//// currentEnd.setTime(startTime);
-//// TaskActivityUtil.snapEndOfWeek(currentEnd);
-//// scheduledThisWeek = new ScheduledTaskContainer(this, currentBegin, currentEnd, DESCRIPTION_THIS_WEEK);
-//// scheduledThisWeek.setCaptureFloating(true);
-//// //scheduleContainers.add(scheduledThisWeek);
-//
-// Calendar nextStart = TaskActivityUtil.getCalendar();
-// nextStart.setTime(startTime);
-// nextStart.add(Calendar.WEEK_OF_YEAR, NUM_WEEKS_NEXT);
-// TaskActivityUtil.snapStartOfWorkWeek(nextStart);
-// Calendar nextEnd = TaskActivityUtil.getCalendar();
-// nextEnd.setTime(startTime);
-// nextEnd.add(Calendar.WEEK_OF_YEAR, NUM_WEEKS_NEXT);
-// TaskActivityUtil.snapEndOfWeek(nextEnd);
-// scheduledNextWeek = new ScheduledTaskContainer(this, nextStart.getTime(), nextEnd.getTime(),
-// DESCRIPTION_NEXT_WEEK);
-// scheduledNextWeek.setCaptureFloating(true);
-// scheduleContainers.add(scheduledNextWeek);
-//
-// Calendar futureStart = TaskActivityUtil.getCalendar();
-// futureStart.setTime(startTime);
-// futureStart.add(Calendar.WEEK_OF_YEAR, NUM_WEEKS_FUTURE_START);
-// TaskActivityUtil.snapStartOfWorkWeek(futureStart);
-// Calendar futureEnd = TaskActivityUtil.getCalendar();
-// futureEnd.setTime(startTime);
-// futureEnd.add(Calendar.YEAR, 1);
-// TaskActivityUtil.snapEndOfWeek(futureEnd);
-// scheduledFuture = new ScheduledTaskContainer(this, futureStart.getTime(), futureEnd.getTime(),
-// DESCRIPTION_FUTURE);
-// scheduledFuture.setCaptureFloating(true);
-// scheduleContainers.add(scheduledFuture);
-//
-// Calendar previousStart = TaskActivityUtil.getCalendar();
-// previousStart.setTime(startTime);
-// previousStart.add(Calendar.WEEK_OF_YEAR, NUM_WEEKS_PREVIOUS_START);
-// TaskActivityUtil.snapStartOfWorkWeek(previousStart);
-// Calendar previousEnd = TaskActivityUtil.getCalendar();
-// previousEnd.setTime(startTime);
-// previousEnd.add(Calendar.WEEK_OF_YEAR, NUM_WEEKS_PREVIOUS_END);
-// TaskActivityUtil.snapEndOfWeek(previousEnd);
-// scheduledPrevious = new ScheduledTaskContainer(this, previousStart.getTime(), previousEnd.getTime(),
-// DESCRIPTION_PREVIOUS_WEEK);
-// //scheduleContainers.add(scheduledPrevious);
-//} \ No newline at end of file
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskList.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskList.java
index f793d9c23..59f142d59 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskList.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskList.java
@@ -605,7 +605,7 @@ public class TaskList implements ISchedulingRule, ITaskList {
queries = new ConcurrentHashMap<String, RepositoryQuery>();
defaultCategory = new UncategorizedTaskContainer();
-
+
maxLocalTaskId = 0;
categories.put(defaultCategory.getHandleIdentifier(), defaultCategory);
} finally {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/UncategorizedTaskContainer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/UncategorizedTaskContainer.java
index 716760cb5..9ddf63baf 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/UncategorizedTaskContainer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/UncategorizedTaskContainer.java
@@ -19,7 +19,7 @@ public class UncategorizedTaskContainer extends AbstractTaskCategory {
public static final String LABEL = "Uncategorized";
- public static final String HANDLE = "uncategorized";
+ public static final String HANDLE = LABEL;
public UncategorizedTaskContainer() {
super(HANDLE);
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 149b97682..eb4762bdc 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
@@ -192,17 +192,13 @@ public final class DelegatingTaskExternalizer {
}
public Element createCategoryElement(ITaskElement category, Document doc, Element parent) {
- if (category instanceof UncategorizedTaskContainer) {
- return parent;
- } else {
- Element node = doc.createElement(getCategoryTagName());
- node.setAttribute(DelegatingTaskExternalizer.KEY_NAME, category.getSummary());
- parent.appendChild(node);
- for (ITask task : category.getChildren()) {
- createTaskReference(KEY_TASK_REFERENCE, task, doc, node);
- }
- return node;
+ Element node = doc.createElement(getCategoryTagName());
+ node.setAttribute(DelegatingTaskExternalizer.KEY_NAME, category.getSummary());
+ parent.appendChild(node);
+ for (ITask task : category.getChildren()) {
+ createTaskReference(KEY_TASK_REFERENCE, task, doc, node);
}
+ return node;
}
public Element createTaskElement(AbstractTask task, Document doc, Element parent) {
@@ -370,8 +366,12 @@ public final class DelegatingTaskExternalizer {
Element element = (Element) node;
AbstractTaskCategory category = null;
if (element.hasAttribute(KEY_NAME)) {
- category = new TaskCategory(element.getAttribute(KEY_NAME));
- taskList.addCategory((TaskCategory) category);
+ String handle = element.getAttribute(KEY_NAME);
+ category = taskList.getContainerForHandle(handle);
+ if (category == null) {
+ category = new TaskCategory(element.getAttribute(KEY_NAME));
+ taskList.addCategory((TaskCategory) category);
+ }
} else {
// LEGACY: registry categories did not have names
// category = taskList.getArchiveContainer();
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/ExternalizationManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/ExternalizationManager.java
index ec811d91d..426fdea25 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/ExternalizationManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/ExternalizationManager.java
@@ -60,12 +60,13 @@ public class ExternalizationManager {
}
public void reLoad() {
+ reset();
for (IExternalizationParticipant participant : externalizationParticipants) {
load(participant);
}
}
- public void load(IExternalizationParticipant participant) {
+ private void load(IExternalizationParticipant participant) {
try {
saveDisabled = true;
IExternalizationContext loadContext = new LoadContext(rootFolderPath, participant);
@@ -142,7 +143,7 @@ public class ExternalizationManager {
return loadStatus;
}
- public void reset() {
+ private void reset() {
saveDisabled = false;
loadStatus = null;
if (saveJob != null) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizationParticipant.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizationParticipant.java
index c1bd29e92..b004ec8c7 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizationParticipant.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizationParticipant.java
@@ -19,9 +19,13 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.core.ITaskListRunnable;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
+import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer;
import org.eclipse.mylyn.tasks.core.ITaskListChangeListener;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
/**
* @author Rob Elves
@@ -39,11 +43,14 @@ public class TaskListExternalizationParticipant extends AbstractExternalizationP
private boolean dirty;
+ private final TaskRepositoryManager taskRepositoryManager;
+
public TaskListExternalizationParticipant(TaskList taskList, TaskListExternalizer taskListExternalizer,
- ExternalizationManager manager) {
+ ExternalizationManager manager, TaskRepositoryManager repositoryManager) {
this.manager = manager;
this.taskList = taskList;
this.taskListWriter = taskListExternalizer;
+ this.taskRepositoryManager = repositoryManager;
}
@Override
@@ -75,7 +82,10 @@ public class TaskListExternalizationParticipant extends AbstractExternalizationP
}
private void resetAndLoad() throws CoreException {
+ resetTaskList();
taskListWriter.readTaskList(taskList, taskListFile);
+
+ // TODO: fire ROOT event
}
private boolean recover() {
@@ -94,6 +104,23 @@ public class TaskListExternalizationParticipant extends AbstractExternalizationP
taskList.run(loadRunnable, monitor);
}
+ /**
+ * public for tests
+ */
+ public void resetTaskList() {
+ taskList.reset();
+ prepareOrphanContainers();
+ }
+
+ private void prepareOrphanContainers() {
+ for (TaskRepository repository : taskRepositoryManager.getAllRepositories()) {
+ if (!repository.getConnectorKind().equals(LocalRepositoryConnector.CONNECTOR_KIND)) {
+ taskList.addUnmatchedContainer(new UnmatchedTaskContainer(repository.getConnectorKind(),
+ repository.getRepositoryUrl()));
+ }
+ }
+ }
+
@Override
public void save(String rootPath, IProgressMonitor monitor) throws CoreException {
final File taskListFile = getFile(rootPath);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java
index 907eced87..d459a8d9a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java
@@ -120,7 +120,7 @@ public class TaskListExternalizer {
delagatingExternalizer.createTaskElement(task, doc, root);
}
- // create the categorie nodes...
+ // create the category nodes...
for (ITaskElement category : taskList.getCategories()) {
delagatingExternalizer.createCategoryElement(category, doc, root);
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java
index facc8c361..af20ba1b5 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java
@@ -12,10 +12,10 @@ import java.util.Set;
import junit.framework.TestCase;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
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.TaskCategory;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
@@ -52,8 +52,7 @@ public class OrphanedTasksTest extends TestCase {
* y New local tasks should automatically be created in the Local orphaned folder
*/
public void testAddLocalTask() {
- Set<ITask> tasks = TasksUiPlugin.getTaskList().getTasks(
- LocalRepositoryConnector.REPOSITORY_URL);
+ Set<ITask> tasks = TasksUiPlugin.getTaskList().getTasks(LocalRepositoryConnector.REPOSITORY_URL);
assertTrue(tasks.isEmpty());
ITask localTask = TasksUiInternal.createNewLocalTask("Task 1");
assertNotNull(localTask);
@@ -185,7 +184,7 @@ public class OrphanedTasksTest extends TestCase {
assertEquals(1, taskList.getCategories().size());
assertFalse(taskList.getDefaultCategory().isEmpty());
// save tasklist, restore tasklist
- TasksUiPlugin.getTaskListManager().saveTaskList();
+ TasksUiPlugin.getExternalizationManager().saveNow(null);
TasksUiPlugin.getTaskListManager().resetTaskList();
TasksUiPlugin.getTaskListManager().readExistingOrCreateNewList();
assertEquals(1, taskList.getCategories().size());
@@ -236,15 +235,13 @@ public class OrphanedTasksTest extends TestCase {
MockRepositoryQuery mockQuery = new MockRepositoryQuery("mock query");
TasksUiPlugin.getTaskList().addQuery(mockQuery);
TasksUiPlugin.getTaskList().addTask(mockTask, mockQuery);
- Set<ITask> tasks = TasksUiPlugin.getTaskList().getTasks(
- MockRepositoryConnector.REPOSITORY_URL);
+ Set<ITask> tasks = TasksUiPlugin.getTaskList().getTasks(MockRepositoryConnector.REPOSITORY_URL);
assertFalse(tasks.isEmpty());
RepositoryQuery query = (RepositoryQuery) mockTask.getParentContainers().iterator().next();
assertEquals(mockQuery, query);
assertFalse(query.isEmpty());
- assertTrue(TasksUiPlugin.getTaskList().getUnmatchedContainer(
- MockRepositoryConnector.REPOSITORY_URL).isEmpty());
+ assertTrue(TasksUiPlugin.getTaskList().getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL).isEmpty());
}
public void testMoveRepositoryTask() {
@@ -338,15 +335,18 @@ public class OrphanedTasksTest extends TestCase {
assertTrue(taskList.getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL).contains(
mockTask.getHandleIdentifier()));
assertTrue(mockTask.contains(mockTask2.getHandleIdentifier()));
- assertFalse(taskList.getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL).contains(
- mockTask2.getHandleIdentifier()));
+
+ // True since mockTask is contained and has mockTask2 as a subtask
+// assertFalse(taskList.getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL).contains(
+// mockTask2.getHandleIdentifier()));
taskList.removeFromContainer(mockQuery, mockTask3);
assertTrue(taskList.getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL).contains(
mockTask3.getHandleIdentifier()));
assertTrue(mockTask3.contains(mockTask2.getHandleIdentifier()));
- assertFalse(taskList.getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL).contains(
- mockTask2.getHandleIdentifier()));
+ // True since mockTask is contained and has mockTask2 as a subtask
+// assertFalse(taskList.getUnmatchedContainer(MockRepositoryConnector.REPOSITORY_URL).contains(
+// mockTask2.getHandleIdentifier()));
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/QueryExportImportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/QueryExportImportTest.java
index d63f50177..e2e1803aa 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/QueryExportImportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/QueryExportImportTest.java
@@ -23,11 +23,12 @@ import java.util.zip.ZipInputStream;
import junit.framework.TestCase;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractTaskListFactory;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.actions.QueryImportAction;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryQuery;
@@ -119,7 +120,8 @@ public class QueryExportImportTest extends TestCase {
queries.add(query3);
// run tested functionality
- TasksUiPlugin.getTaskListManager().insertQueries(queries);
+ QueryImportAction action = new QueryImportAction();
+ action.insertQueries(queries);
// extract results
Set<RepositoryQuery> queriesSet = TasksUiPlugin.getTaskList().getQueries();
@@ -156,7 +158,8 @@ public class QueryExportImportTest extends TestCase {
queries.add(query3);
// run tested functionality
- TasksUiPlugin.getTaskListManager().insertQueries(queries);
+ QueryImportAction action = new QueryImportAction();
+ action.insertQueries(queries);
// extract results
Set<RepositoryQuery> queriesSet = TasksUiPlugin.getTaskList().getQueries();
@@ -200,7 +203,8 @@ public class QueryExportImportTest extends TestCase {
queries.add(query5);
// run tested functionality
- TasksUiPlugin.getTaskListManager().insertQueries(queries);
+ QueryImportAction action = new QueryImportAction();
+ action.insertQueries(queries);
// extract results
Set<RepositoryQuery> queriesSet = TasksUiPlugin.getTaskList().getQueries();
@@ -236,7 +240,8 @@ public class QueryExportImportTest extends TestCase {
queries.add(query2);
// run tested functionality
- List<RepositoryQuery> badQueries = TasksUiPlugin.getTaskListManager().insertQueries(queries);
+ QueryImportAction action = new QueryImportAction();
+ List<RepositoryQuery> badQueries = action.insertQueries(queries);
// extract results
Set<RepositoryQuery> queriesSet = TasksUiPlugin.getTaskList().getQueries();
@@ -293,15 +298,15 @@ public class QueryExportImportTest extends TestCase {
assertTrue("There are currently no repositories defined", TasksUiPlugin.getRepositoryManager().getRepository(
MockRepositoryConnector.REPOSITORY_URL) == null);
- List<RepositoryQuery> resultQueries = TasksUiPlugin.getTaskListManager()
- .getTaskListWriter()
- .readQueries(outFile);
+ List<RepositoryQuery> resultQueries = TasksUiPlugin.getTaskListManager().getTaskListWriter().readQueries(
+ outFile);
Set<TaskRepository> repositories = TasksUiPlugin.getTaskListManager().getTaskListWriter().readRepositories(
outFile);
TasksUiPlugin.getRepositoryManager().insertRepositories(repositories,
TasksUiPlugin.getDefault().getRepositoriesFilePath());
- TasksUiPlugin.getTaskListManager().insertQueries(resultQueries);
+ QueryImportAction action = new QueryImportAction();
+ action.insertQueries(resultQueries);
// extract results
Set<RepositoryQuery> queriesSet = TasksUiPlugin.getTaskList().getQueries();
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
index 39d46a061..67be91efc 100644
--- 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
@@ -36,10 +36,10 @@ 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.ITasksUiPreferenceConstants;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
@@ -101,7 +101,7 @@ public class TaskListManagerTest extends TestCase {
assertTrue(query.contains(task.getHandleIdentifier()));
assertTrue(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
- TasksUiPlugin.getExternalizationManager().saveNow(null);
+ TasksUiPlugin.getExternalizationManager().requestSave();
manager.resetTaskList();
assertEquals(0, manager.getTaskList().getAllTasks().size());
assertFalse(manager.getTaskList().getDefaultCategory().contains(task.getHandleIdentifier()));
@@ -687,7 +687,7 @@ public class TaskListManagerTest extends TestCase {
AbstractTask sub1 = TasksUiInternal.createNewLocalTask("sub 1");
manager.getTaskList().addTask(sub1, task1);
- assertEquals(3, manager.getTaskList().getRootElements().size());
+ assertEquals(4, manager.getTaskList().getRootElements().size());
//manager.getTaskList().moveToContainer(sub1, manager.getTaskList().getArchiveContainer());
@@ -700,7 +700,7 @@ public class TaskListManagerTest extends TestCase {
TaskCategory cat1 = new TaskCategory("Category 1");
manager.getTaskList().addCategory(cat1);
categories.add(cat1);
- assertEquals(4, manager.getTaskList().getRootElements().size());
+ assertEquals(5, manager.getTaskList().getRootElements().size());
AbstractTask task3 = TasksUiInternal.createNewLocalTask("task 3");
manager.getTaskList().addTask(task3, cat1);
@@ -723,7 +723,7 @@ public class TaskListManagerTest extends TestCase {
cat1Contents.add(reportInCat1);
assertEquals(7, manager.getTaskList().getAllTasks().size());
- assertEquals(4, manager.getTaskList().getRootElements().size());
+ assertEquals(5, manager.getTaskList().getRootElements().size());
TasksUiPlugin.getExternalizationManager().requestSave();
TasksUiPlugin.getDefault().reloadDataDirectory();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java
index 42aea61f0..75e38bd38 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/ActivityExternalizationParticipant.java
@@ -36,6 +36,7 @@ public class ActivityExternalizationParticipant extends AbstractExternalizationP
setDirty(false);
break;
case LOAD:
+ ContextCore.getContextManager().loadActivityMetaContext();
break;
case SNAPSHOT:
break;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java
index c95c944bb..2cae783bf 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RefactorRepositoryUrlOperation.java
@@ -58,10 +58,10 @@ public class RefactorRepositoryUrlOperation extends TaskListModifyOperation {
refactorOfflineHandles(oldUrl, newUrl);
getTaskList().refactorRepositoryUrl(oldUrl, newUrl);
refactorMetaContextHandles(oldUrl, newUrl);
- TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
refactorContextFileNames();
TasksUiPlugin.getExternalizationManager()
.saveNow(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
+ TasksUiPlugin.getTaskActivityMonitor().reloadActivityTime();
} finally {
monitor.done();
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListManager.java
index 1ca6cfe44..ee1724b29 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListManager.java
@@ -8,27 +8,15 @@
package org.eclipse.mylyn.internal.tasks.ui;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizationParticipant;
-import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
import org.eclipse.mylyn.internal.tasks.ui.util.TaskListElementImporter;
-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
@@ -44,40 +32,23 @@ import org.eclipse.mylyn.tasks.ui.TasksUi;
*/
public class TaskListManager {
- private static final long SECOND = 1000;
-
- private static final long MINUTE = 60 * SECOND;
-
- private static final long ROLLOVER_DELAY = 30 * MINUTE;
-
- private final List<ITaskActivityListener> taskActivationListeners = new ArrayList<ITaskActivityListener>();
-
- private final TaskListExternalizer taskListWriter;
-
-// private TaskListSaveManager taskListSaveManager;
-
-// private AbstractTask activeTask;
-
- private TaskListExternalizationParticipant taskListSaveParticipant;
-
private final TaskListElementImporter importer;
private final TaskList taskList;
- public TaskListManager(TaskList taskList, TaskListExternalizer taskListWriter, TaskListElementImporter importer) {
+ private final TaskListExternalizationParticipant participant;
+
+ public TaskListManager(TaskList taskList, TaskListExternalizationParticipant participant,
+ TaskListElementImporter importer) {
this.taskList = taskList;
- this.taskListWriter = taskListWriter;
this.importer = importer;
+ this.participant = participant;
}
- public ITaskList resetTaskList() {
- deactivateAllTasks();
- //resetAndRollOver();
- taskList.reset();
- prepareOrphanContainers();
- return taskList;
- }
-
+ /**
+ * @deprecated moved to TasksUiPlugin
+ */
+ @Deprecated
private void prepareOrphanContainers() {
for (TaskRepository repository : TasksUi.getRepositoryManager().getAllRepositories()) {
if (!repository.getConnectorKind().equals(LocalRepositoryConnector.CONNECTOR_KIND)) {
@@ -91,98 +62,34 @@ public class TaskListManager {
return importer;
}
- public boolean readExistingOrCreateNewList() {
- prepareOrphanContainers();
- if (taskListSaveParticipant == null) {
- taskListSaveParticipant = new TaskListExternalizationParticipant(taskList, taskListWriter,
- TasksUiPlugin.getExternalizationManager());
- }
-
- TasksUiPlugin.getExternalizationManager().load(taskListSaveParticipant);
- TasksUiPlugin.getExternalizationManager().addParticipant(taskListSaveParticipant);
- taskList.addChangeListener(taskListSaveParticipant);
- TasksUiPlugin.getTaskActivityManager().reloadPlanningData();
- return true;
- }
-
- public TaskList getTaskList() {
+ /**
+ * @deprecated
+ */
+ @Deprecated
+ public ITaskList resetTaskList() {
+ participant.resetTaskList();
return taskList;
}
/**
- * Imports Queries to the TaskList and synchronize them with the repository. If the imported query have the name
- * that overlaps with the existing one, the the suffix [x] is added, where x is a number starting from 1.
- *
- * @param queries
- * to insert
- * @return the list queries, which were not inserted since because the related repository was not found.
+ * @deprecated use TasksUiPlugin.reloadDataDirectory()
*/
- public List<RepositoryQuery> insertQueries(List<RepositoryQuery> queries) {
- List<RepositoryQuery> badQueries = new ArrayList<RepositoryQuery>();
-
- for (RepositoryQuery query : queries) {
-
- TaskRepository repository = TasksUi.getRepositoryManager().getRepository(query.getConnectorKind(),
- query.getRepositoryUrl());
- if (repository == null) {
- badQueries.add(query);
- continue;
- }
-
- String handle = resolveIdentifiersConflict(query);
- query.setHandleIdentifier(handle);
-
- // add query
- TasksUiInternal.getTaskList().addQuery(query);
-
- AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
- repository.getConnectorKind());
- if (connector != null) {
- TasksUiInternal.synchronizeQuery(connector, query, null, true);
- }
-
+ @Deprecated
+ public boolean readExistingOrCreateNewList() {
+ try {
+ TasksUiPlugin.getDefault().reloadDataDirectory();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
-
- return badQueries;
+ return true;
}
/**
- * Utility method that checks, if there is already a query with the same identifier.
- *
- * @param query
- * @return a handle, that is not in conflict with any existed one in the system. If there were no conflict in the
- * beginning, then the query's own identifier is returned. If there were, then the suffix [x] is applied the
- * query's identifier, where x is a number.
- * @since 2.1
+ * TODO: move this to TasksUIPlugin
*/
- public String resolveIdentifiersConflict(RepositoryQuery query) {
- String patternStr = "\\[(\\d+)\\]$"; // all string that end with [x], where x is a number
- Pattern pattern = Pattern.compile(patternStr);
-
- // resolve name conflict
- Set<RepositoryQuery> existingQueries = getTaskList().getQueries();
- Map<String, RepositoryQuery> queryMap = new HashMap<String, RepositoryQuery>();
- for (RepositoryQuery existingQuery : existingQueries) {
- queryMap.put(existingQuery.getHandleIdentifier(), existingQuery);
- }
-
- // suggest a new handle if needed
- String handle = query.getHandleIdentifier();
-
- while (queryMap.get(handle) != null) {
- Matcher matcher = pattern.matcher(handle);
- boolean matchFound = matcher.find();
- if (matchFound) {
- // increment index
- int index = Integer.parseInt(matcher.group(1));
- index++;
- handle = matcher.replaceAll("[" + index + "]");
- } else {
- handle += "[1]";
- }
- }
-
- return handle;
+ public TaskList getTaskList() {
+ return taskList;
}
/**
@@ -244,80 +151,4 @@ public class TaskListManager {
public void deactivateTask(ITask task) {
TasksUi.getTaskActivityManager().deactivateTask(task);
}
-
-// public TaskActivationHistory getTaskActivationHistory() {
-// return taskActivityHistory;
-//}
-
-//protected void setTaskListSaveManager(TaskListSaveManager taskListSaveManager) {
-// this.taskListSaveManager = taskListSaveManager;
-// this.taskList.addChangeListener(taskListSaveManager);
-//}
-
-///**
-// * Creates a new local task and schedules for today
-// *
-// * @param summary
-// * if null DEFAULT_SUMMARY (New Task) used.
-// */
-//public LocalTask createNewLocalTask(String summary) {
-// if (summary == null) {
-// summary = LocalRepositoryConnector.DEFAULT_SUMMARY;
-// }
-// LocalTask newTask = new LocalTask("" + taskList.getNextLocalTaskId(), summary);
-// newTask.setPriority(PriorityLevel.P3.toString());
-// TasksUi.getTaskList().addTask(newTask);
-//
-// TasksUiPlugin.getTaskActivityManager().scheduleNewTask(newTask);
-//
-// Object selectedObject = null;
-// TaskListView view = TaskListView.getFromActivePerspective();
-// if (view != null) {
-// selectedObject = ((IStructuredSelection) view.getViewer().getSelection()).getFirstElement();
-// }
-// if (selectedObject instanceof TaskCategory) {
-// taskList.addTask(newTask, (TaskCategory) selectedObject);
-// } else if (selectedObject instanceof AbstractTask) {
-// AbstractTask task = (AbstractTask) selectedObject;
-//
-// AbstractTaskContainer container = TaskCategory.getParentTaskCategory(task);
-//
-// if (container instanceof TaskCategory) {
-// taskList.addTask(newTask, container);
-// } else if (view != null && view.getDrilledIntoCategory() instanceof TaskCategory) {
-// taskList.addTask(newTask, view.getDrilledIntoCategory());
-// } else {
-// taskList.addTask(newTask, TasksUiPlugin.getTaskList().getDefaultCategory());
-// }
-// } else if (view != null && view.getDrilledIntoCategory() instanceof TaskCategory) {
-// taskList.addTask(newTask, view.getDrilledIntoCategory());
-// } else {
-// if (view != null && view.getDrilledIntoCategory() != null) {
-// MessageDialog.openInformation(Display.getCurrent().getActiveShell(), ITasksUiConstants.TITLE_DIALOG,
-// "The new task has been added to the root of the list, since tasks can not be added to a query.");
-// }
-// taskList.addTask(newTask, TasksUiPlugin.getTaskList().getDefaultCategory());
-// }
-// return newTask;
-//}
-
-// /**
-// * public for testing TODO: Move to TaskActivityManager
-// */
-// private void resetAndRollOver() {
-// resetAndRollOver(TaskActivityUtil.getCalendar().getTime());
-// }
-//
-// private void resetAndRollOver(Date startDate) {
-// if (taskList.isInitialized()) {
-// TasksUiPlugin.getTaskActivityManager().clear();
-// List<InteractionEvent> events = ContextCore.getContextManager()
-// .getActivityMetaContext()
-// .getInteractionHistory();
-// for (InteractionEvent event : events) {
-// TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(event);
-// }
-// TasksUiPlugin.getTaskActivityManager().reloadTimingData();
-// }
-// }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
index c41980cae..21141c5cf 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
@@ -70,6 +70,7 @@ import org.eclipse.mylyn.internal.tasks.core.data.TaskDataStore;
import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractLegacyRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationParticipant;
+import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizationParticipant;
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotification;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotificationQueryIncoming;
@@ -90,6 +91,7 @@ import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.AbstractTaskRepositoryLinkProvider;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorFactory;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
import org.eclipse.swt.graphics.Image;
@@ -166,8 +168,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
private ITaskHighlighter highlighter;
- private boolean initialized = false;
-
private final Map<String, Image> brandingIcons = new HashMap<String, Image>();
private final Map<String, ImageDescriptor> overlayIcons = new HashMap<String, ImageDescriptor>();
@@ -367,6 +367,8 @@ public class TasksUiPlugin extends AbstractUIPlugin {
private IProxyChangeListener proxyChangeListener;
+ private TaskListExternalizationParticipant taskListSaveParticipant;
+
private static TaskList taskList;
private static TasksModel tasksModel;
@@ -399,7 +401,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
break;
}
}
- taskActivityMonitor.reloadActivityTime();
+ //taskActivityMonitor.reloadActivityTime();
} catch (Throwable t) {
StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
"Could not initialize task activity", t));
@@ -431,10 +433,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
monitor.worked(1);
try {
- //taskListSaveManager = new TaskListSaveManager();
- //taskListManager.setTaskListSaveManager(taskListSaveManager);
-
- //ContextCorePlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER);
getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER);
@@ -497,17 +495,24 @@ public class TasksUiPlugin extends AbstractUIPlugin {
externalizationManager = new ExternalizationManager(getDataDirectory());
repositoryManager = new TaskRepositoryManager();
+ IExternalizationParticipant repositoryParticipant = new RepositoryExternalizationParticipant(
+ externalizationManager, repositoryManager);
+ externalizationManager.addParticipant(repositoryParticipant);
taskList = new TaskList();
tasksModel = new TasksModel(taskList, repositoryManager);
taskListExternalizer = new TaskListExternalizer(tasksModel);
TaskListElementImporter taskListImporter = new TaskListElementImporter(repositoryManager, tasksModel);
+ taskListSaveParticipant = new TaskListExternalizationParticipant(taskList, taskListExternalizer,
+ externalizationManager, repositoryManager);
+ //externalizationManager.load(taskListSaveParticipant);
+ externalizationManager.addParticipant(taskListSaveParticipant);
+ taskList.addChangeListener(taskListSaveParticipant);
+
taskActivityManager = new TaskActivityManager(repositoryManager, taskList);
- IExternalizationParticipant participant = new RepositoryExternalizationParticipant(externalizationManager,
- repositoryManager);
- taskListManager = new TaskListManager(taskList, taskListExternalizer, taskListImporter);
+ taskListManager = new TaskListManager(taskList, taskListSaveParticipant, taskListImporter);
// initialize
updateTaskActivityManager();
@@ -535,9 +540,6 @@ public class TasksUiPlugin extends AbstractUIPlugin {
// NOTE: initializing extensions in start(..) has caused race
// conditions previously
TasksUiExtensionReader.initStartupExtensions(taskListExternalizer, taskListImporter);
- externalizationManager.load(participant);
- externalizationManager.addParticipant(participant);
- //repositoryManager.readRepositories(getRepositoriesFilePath());
// instantiates taskDataManager
File root = new File(this.getDataDirectory() + '/' + FOLDER_OFFLINE);
@@ -558,19 +560,11 @@ public class TasksUiPlugin extends AbstractUIPlugin {
}
}
- loadTemplateRepositories();
-
tasksJobFactory = new TaskJobFactory(taskListManager.getTaskList(), taskDataManager, repositoryManager,
tasksModel);
- // NOTE: task list must be read before Task List view can be initialized
taskActivityManager.addActivityListener(CONTEXT_TASK_ACTIVITY_LISTENER);
- // readExistingOrCreateNewList() must be called after repositories have been read in
- taskListManager.readExistingOrCreateNewList();
-
- initialized = true;
-
taskActivityMonitor = new TaskActivityMonitor(taskActivityManager, ContextCore.getContextManager());
taskActivityMonitor.start();
@@ -597,7 +591,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
ActivityExternalizationParticipant ACTIVITY_EXTERNALIZTAION_PARTICIPANT = new ActivityExternalizationParticipant();
externalizationManager.addParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
taskActivityManager.addActivityListener(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);
-
+ loadDataSources();
new TasksUiInitializationJob().schedule();
} catch (Exception e) {
StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Task list initialization failed", e));
@@ -733,8 +727,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
public void setDataDirectory(final String newPath, IProgressMonitor monitor) throws CoreException {
externalizationManager.saveNow(monitor);
- //getBackupManager().backupNow(true);
- // TODO: save repositories, activity
+ // TODO: backup now?
//TasksUiPlugin.getBackupManager().backupNow(true);
loadDataDirectory(newPath);
getPreferenceStore().setValue(ContextPreferenceContstants.PREF_DATA_DIR, newPath);
@@ -748,10 +741,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
}
/**
- * Only support task data versions post 0.7
- *
- * @throws CoreException
- * @throws InterruptedException
+ * Load's data sources from <code>newPath</code> and executes with progress
*/
private synchronized void loadDataDirectory(final String newPath) throws CoreException {
@@ -760,28 +750,16 @@ public class TasksUiPlugin extends AbstractUIPlugin {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
- monitor.beginTask("Set Data Directory", IProgressMonitor.UNKNOWN);
+ monitor.beginTask("Load Data Directory", IProgressMonitor.UNKNOWN);
Job.getJobManager().beginRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE,
new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled()) {
throw new InterruptedException();
}
- externalizationManager.reset();
+ TasksUi.getTaskActivityManager().deactivateActiveTask();
externalizationManager.setRootFolderPath(newPath);
- taskActivityManager.clear();
-// getRepositoryManager().readRepositories(
-// newPath + File.separator + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE);
- loadTemplateRepositories();
-
- getTaskListManager().resetTaskList();
-// getTaskListManager().setTaskListFile(
-// new File(newPath + File.separator + ITasksCoreConstants.DEFAULT_TASK_LIST_FILE));
-
- ContextCore.getContextManager().loadActivityMetaContext();
-
- getTaskListManager().readExistingOrCreateNewList();
- taskActivityMonitor.reloadActivityTime();
+ loadDataSources();
} finally {
Job.getJobManager().endRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE);
monitor.done();
@@ -806,6 +784,20 @@ public class TasksUiPlugin extends AbstractUIPlugin {
}
+ /**
+ * called on startup and when the mylyn data structures are reloaded from disk
+ */
+ private void loadDataSources() {
+ externalizationManager.reLoad();
+ // TODO: Move management of template repositories to TaskRepositoryManager
+ loadTemplateRepositories();
+
+ taskActivityManager.clear();
+ ContextCore.getContextManager().loadActivityMetaContext();
+ taskActivityMonitor.reloadActivityTime();
+ taskActivityManager.reloadPlanningData();
+ }
+
@Override
protected void initializeDefaultPreferences(IPreferenceStore store) {
store.setDefault(ContextPreferenceContstants.PREF_DATA_DIR, getDefaultDataDirectory());
@@ -971,9 +963,9 @@ public class TasksUiPlugin extends AbstractUIPlugin {
return overlayIcons.get(repositoryType);
}
- public boolean isInitialized() {
- return initialized;
- }
+// public boolean isInitialized() {
+// return initialized;
+// }
public IHyperlinkDetector[] getTaskHyperlinkDetectors() {
return hyperlinkDetectors.toArray(new IHyperlinkDetector[1]);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java
index bed678656..d413a9e17 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java
@@ -87,7 +87,7 @@ public class QueryCloneAction extends Action implements IViewActionDelegate {
if (clonedQueries.size() > 0) {
for (RepositoryQuery query : clonedQueries) {
- String handle = TasksUiPlugin.getTaskListManager().resolveIdentifiersConflict(query);
+ String handle = QueryImportAction.resolveIdentifiersConflict(query);
query.setHandleIdentifier(handle);
AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(query.getConnectorKind());
TasksUiInternal.openEditQueryDialog(connectorUi, query);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java
index e47a4bed5..25d8e5ea5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java
@@ -10,17 +10,25 @@ package org.eclipse.mylyn.internal.tasks.ui.actions;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewActionDelegate;
@@ -59,9 +67,8 @@ public class QueryImportAction extends Action implements IViewActionDelegate {
File file = new File(path);
if (file.isFile()) {
try {
- List<RepositoryQuery> queries = TasksUiPlugin.getTaskListManager()
- .getTaskListWriter()
- .readQueries(file);
+ List<RepositoryQuery> queries = TasksUiPlugin.getTaskListManager().getTaskListWriter().readQueries(
+ file);
Set<TaskRepository> repositories = TasksUiPlugin.getTaskListManager()
.getTaskListWriter()
.readRepositories(file);
@@ -87,7 +94,7 @@ public class QueryImportAction extends Action implements IViewActionDelegate {
public void importQueries(List<RepositoryQuery> queries, Set<TaskRepository> repositories, Shell shell) {
TasksUiPlugin.getRepositoryManager().insertRepositories(repositories,
TasksUiPlugin.getDefault().getRepositoriesFilePath());
- List<RepositoryQuery> badQueries = TasksUiPlugin.getTaskListManager().insertQueries(queries);
+ List<RepositoryQuery> badQueries = insertQueries(queries);
// notify user about importing
String message = "The following queries were imported successfully: ";
@@ -107,4 +114,80 @@ public class QueryImportAction extends Action implements IViewActionDelegate {
MessageDialog.openInformation(shell, "Query Import Completed", message);
}
+ /**
+ * Imports Queries to the TaskList and synchronize them with the repository. If the imported query have the name
+ * that overlaps with the existing one, the the suffix [x] is added, where x is a number starting from 1.
+ *
+ * @param queries
+ * to insert
+ * @return the list queries, which were not inserted since because the related repository was not found.
+ */
+ public List<RepositoryQuery> insertQueries(List<RepositoryQuery> queries) {
+ List<RepositoryQuery> badQueries = new ArrayList<RepositoryQuery>();
+
+ for (RepositoryQuery query : queries) {
+
+ TaskRepository repository = TasksUi.getRepositoryManager().getRepository(query.getConnectorKind(),
+ query.getRepositoryUrl());
+ if (repository == null) {
+ badQueries.add(query);
+ continue;
+ }
+
+ String handle = resolveIdentifiersConflict(query);
+ query.setHandleIdentifier(handle);
+
+ // add query
+ TasksUiInternal.getTaskList().addQuery(query);
+
+ AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
+ repository.getConnectorKind());
+ if (connector != null) {
+ TasksUiInternal.synchronizeQuery(connector, query, null, true);
+ }
+
+ }
+
+ return badQueries;
+ }
+
+ /**
+ * Utility method that checks, if there is already a query with the same identifier.
+ *
+ * @param query
+ * @return a handle, that is not in conflict with any existed one in the system. If there were no conflict in the
+ * beginning, then the query's own identifier is returned. If there were, then the suffix [x] is applied the
+ * query's identifier, where x is a number.
+ * @since 2.1
+ */
+ public static String resolveIdentifiersConflict(RepositoryQuery query) {
+ String patternStr = "\\[(\\d+)\\]$"; // all string that end with [x], where x is a number
+ Pattern pattern = Pattern.compile(patternStr);
+
+ // resolve name conflict
+ Set<RepositoryQuery> existingQueries = TasksUiPlugin.getTaskListManager().getTaskList().getQueries();
+ Map<String, RepositoryQuery> queryMap = new HashMap<String, RepositoryQuery>();
+ for (RepositoryQuery existingQuery : existingQueries) {
+ queryMap.put(existingQuery.getHandleIdentifier(), existingQuery);
+ }
+
+ // suggest a new handle if needed
+ String handle = query.getHandleIdentifier();
+
+ while (queryMap.get(handle) != null) {
+ Matcher matcher = pattern.matcher(handle);
+ boolean matchFound = matcher.find();
+ if (matchFound) {
+ // increment index
+ int index = Integer.parseInt(matcher.group(1));
+ index++;
+ handle = matcher.replaceAll("[" + index + "]");
+ } else {
+ handle += "[1]";
+ }
+ }
+
+ return handle;
+ }
+
}

Back to the top