Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListPreferenceConstants.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java100
3 files changed, 20 insertions, 98 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListPreferenceConstants.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListPreferenceConstants.java
index 85f00683d..4f576029d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListPreferenceConstants.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListPreferenceConstants.java
@@ -67,5 +67,7 @@ public class TaskListPreferenceConstants {
public static final String PLANNING_ENDHOUR = "org.eclipse.mylar.tasklist.planning.endhour";
public static final String ACTIVATE_ON_OPEN = "org.eclipse.mylar.tasks.ui.activate.onopen";
+
+ public static final String MIGRATED_FROM_06 = "org.eclipse.mylar.tasks.ui.migration.from.06";
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java
index 25c11876f..c8ec0be38 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java
@@ -13,10 +13,7 @@ package org.eclipse.mylar.internal.tasks.ui;
import java.io.File;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylar.context.core.AbstractContextStore;
-import org.eclipse.mylar.context.core.MylarStatusHandler;
-import org.eclipse.mylar.tasks.ui.TaskListDataMigration;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
/**
@@ -24,21 +21,8 @@ import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
*/
public class WorkspaceAwareContextStore extends AbstractContextStore {
- public WorkspaceAwareContextStore() {
- migrateFrom06Format();
- }
-
public File getRootDirectory() {
return new File(TasksUiPlugin.getDefault().getDataDirectory());
}
- private void migrateFrom06Format() {
- File dataDir = new File(TasksUiPlugin.getDefault().getDataDirectory());
- try {
- new TaskListDataMigration(dataDir).run(new NullProgressMonitor());
- } catch (Exception e) {
- MylarStatusHandler.fail(e, "Error occurred while migrating mylar data", false);
- }
- }
-
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
index f25ff524f..3153882f3 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
@@ -29,6 +29,7 @@ import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
@@ -145,8 +146,6 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
private TaskListWriter taskListWriter;
- // private ResourceBundle resourceBundle;
-
private long AUTOMATIC_BACKUP_SAVE_INTERVAL = 1 * 3600 * 1000; // every
private static Date lastBackup = new Date();
@@ -343,9 +342,6 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
if (event.getProperty().equals(TaskListPreferenceConstants.MULTIPLE_ACTIVE_TASKS)) {
TaskListView.getFromActivePerspective().togglePreviousAction(
!getPreferenceStore().getBoolean(TaskListPreferenceConstants.MULTIPLE_ACTIVE_TASKS));
- // TaskListView.getFromActivePerspective().toggleNextAction(
- // !getPreferenceStore().getBoolean(TaskListPreferenceConstants.MULTIPLE_ACTIVE_TASKS));
- // TaskListView.getFromActivePerspective().clearTaskHistory();
getTaskListManager().getTaskActivationHistory().clear();
}
@@ -355,9 +351,6 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
String newDirPath = getDefault().getDataDirectory();
String taskListFilePath = newDirPath + File.separator + DEFAULT_TASK_LIST_FILE;
reloadFromNewFolder(taskListFilePath);
- // if (TaskListView.getFromActivePerspective() != null) {
- // TaskListView.getFromActivePerspective().clearTaskHistory();
- // }
}
}
}
@@ -394,9 +387,10 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
File dataDir = new File(getDataDirectory());
dataDir.mkdirs();
+ migrateContextStoreFrom06Format();
String path = getDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE;
+
File taskListFile = new File(path);
-
taskListManager = new TaskListManager(taskListWriter, taskListFile);
taskRepositoryManager = new TaskRepositoryManager(taskListManager.getTaskList());
synchronizationManager = new RepositorySynchronizationManager();
@@ -449,6 +443,21 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
}
}
+ private void migrateContextStoreFrom06Format() {
+ if (getPreferenceStore().getBoolean(TaskListPreferenceConstants.MIGRATED_FROM_06)) {
+ return;
+ } else {
+ File dataDir = new File(getDataDirectory()); //TasksUiPlugin.getDefault().getDataDirectory());
+ try {
+ new TaskListDataMigration(dataDir).run(new NullProgressMonitor());
+
+ getPreferenceStore().setDefault(TaskListPreferenceConstants.MIGRATED_FROM_06, true);
+ } catch (Exception e) {
+ MylarStatusHandler.fail(e, "Error occurred while migrating mylar data", false);
+ }
+ }
+ }
+
public void earlyStartup() {
// ignore
}
@@ -499,72 +508,6 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
getTaskListManager().getTaskActivationHistory().clear();
}
- // // TODO: delete post 0.6?
- // private void migrateHandlesToRepositorySupport() {
- // boolean migrated = false;
- // getMylarCorePrefs().setDefault(TaskListPreferenceConstants.CONTEXTS_MIGRATED,
- // false);
- // // NOTE: gets/checks preference in both stores to accidental migration
- // if
- // (!(getMylarCorePrefs().getBoolean(TaskListPreferenceConstants.CONTEXTS_MIGRATED)
- // || getPreferenceStore()
- // .getBoolean(TaskListPreferenceConstants.CONTEXTS_MIGRATED))) {
- // try {
- // File dataDir = new
- // File(ContextCorePlugin.getDefault().getDataDirectory());
- // TaskRepository defaultRepository =
- // MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(
- // TaskRepositoryManager.PREFIX_REPOSITORY_OLD.toLowerCase());
- // if (defaultRepository != null) {
- // String repositoryUrl = defaultRepository.getUrl();
- // migrated = true;
- // if (dataDir.exists() && dataDir.isDirectory()) {
- // for (File file : dataDir.listFiles()) {
- // int dotIndex = file.getName().lastIndexOf('.');
- // if (dotIndex != -1) {
- // String oldHandle = file.getName().substring(0, dotIndex);
- // if (oldHandle.startsWith(TaskRepositoryManager.PREFIX_REPOSITORY_OLD)) {
- // String id = AbstractRepositoryTask.getTaskId(oldHandle);
- // String newHandle = AbstractRepositoryTask.getHandle(repositoryUrl, id);
- // File newFile =
- // ContextCorePlugin.getContextManager().getFileForContext(newHandle);
- // file.renameTo(newFile);
- // }
- // }
- // }
- // }
- // for (ITask task : taskListManager.getTaskList().getAllTasks()) {
- // if (task instanceof AbstractRepositoryTask) {
- // String id = AbstractRepositoryTask.getTaskId(task.getHandleIdentifier());
- // String newHandle = AbstractRepositoryTask.getHandle(repositoryUrl, id);
- // task.setHandleIdentifier(newHandle);
- // }
- // }
- //
- // for (AbstractRepositoryQuery query :
- // taskListManager.getTaskList().getQueries()) {
- // query.setRepositoryUrl(repositoryUrl);
- // for (AbstractQueryHit hit : query.getHits()) {
- // hit.setRepositoryUrl(repositoryUrl);
- // }
- // }
- // taskListManager.saveTaskList();
- // taskListManager.readExistingOrCreateNewList();
- // }
- // } catch (Throwable t) {
- // MylarStatusHandler.fail(t, "task list migration failed", true);
- // }
- // }
- // if (migrated) {
- // MylarStatusHandler.log("Migrated context files to repository-aware
- // paths", this);
- // getMylarCorePrefs().setValue(TaskListPreferenceConstants.CONTEXTS_MIGRATED,
- // true);
- // getPreferenceStore().setValue(TaskListPreferenceConstants.CONTEXTS_MIGRATED,
- // true);
- // }
- // }
-
@Override
protected void initializeDefaultPreferences(IPreferenceStore store) {
store.setDefault(MylarPreferenceContstants.PREF_DATA_DIR, getDefaultDataDirectory());
@@ -630,13 +573,6 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
return INSTANCE;
}
- // public static IPreferenceStore getMylarCorePrefs() {
- // // TODO: should be using the task list's prefernece store, but can't
- // // change without migrating because this will cause people to lose
- // // repositories
- // return ContextCorePlugin.getDefault().getPreferenceStore();
- // }
-
private void checkTaskListBackup() {
Date currentTime = new Date();
if (currentTime.getTime() > lastBackup.getTime() + AUTOMATIC_BACKUP_SAVE_INTERVAL) {// TaskListSaveMode.fromStringToLong(getPrefs().getString(SAVE_TASKLIST_MODE)))

Back to the top