Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java32
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskList.java13
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizationParticipant.java3
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskList06DataMigrationTest.java9
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java17
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java18
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListManager.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java64
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java253
11 files changed, 225 insertions, 201 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
index 3811c39b0..0529a11df 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
@@ -8,6 +8,8 @@
package org.eclipse.mylyn.internal.tasks.core;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
/**
* @author Rob Elves
*/
@@ -29,4 +31,34 @@ public interface ITasksCoreConstants {
public static final String DEFAULT_TASK_LIST_FILE = PREFIX_TASKLIST + FILE_EXTENSION;
+ public static final String CONTEXTS_DIRECTORY = "contexts";
+
+ public static final TaskListSchedulingRule TASKLIST_SCHEDULING_RULE = new TaskListSchedulingRule();
+
+ public static final ISchedulingRule ROOT_SCHEDULING_RULE = new RootSchedulingRule();
+
+ static class TaskListSchedulingRule extends RootSchedulingRule {
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ if (rule instanceof TaskListSchedulingRule) {
+ return true;
+ }
+ return super.isConflicting(rule);
+ }
+ }
+
+ static class RootSchedulingRule implements ISchedulingRule {
+
+ public boolean contains(ISchedulingRule rule) {
+ return isConflicting(rule);
+ }
+
+ public boolean isConflicting(ISchedulingRule rule) {
+ if (rule instanceof RootSchedulingRule) {
+ return true;
+ }
+ return false;
+ }
+ }
+
}
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 5f6acd5a6..f91608912 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
@@ -46,17 +46,6 @@ public class TaskList implements ISchedulingRule, ITaskList {
private static ILock lock = Job.getJobManager().newLock();
- private static ISchedulingRule TASK_LIST_RULE = new ISchedulingRule() {
-
- public boolean contains(ISchedulingRule rule) {
- return isConflicting(rule);
- }
-
- public boolean isConflicting(ISchedulingRule rule) {
- return rule == TASK_LIST_RULE;
- }
- };
-
private Map<String, AbstractTaskCategory> categories;
private final Set<ITaskListChangeListener> changeListeners = new CopyOnWriteArraySet<ITaskListChangeListener>();
@@ -700,6 +689,6 @@ public class TaskList implements ISchedulingRule, ITaskList {
}
public static ISchedulingRule getSchedulingRule() {
- return TASK_LIST_RULE;
+ return ITasksCoreConstants.TASKLIST_SCHEDULING_RULE;
}
}
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 0c81a3bc1..9a9307c42 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
@@ -70,15 +70,14 @@ public class TaskListExternalizationParticipant implements IExternalizationParti
switch (context.getKind()) {
case SAVE:
ITaskListRunnable saveRunnable = new ITaskListRunnable() {
-
public void execute(IProgressMonitor monitor) throws CoreException {
+ //System.err.println(">>> saving");
taskListWriter.writeTaskList(taskList, taskListFile);
synchronized (TaskListExternalizationParticipant.this) {
dirty = false;
}
}
};
-
taskList.run(saveRunnable, monitor);
break;
case LOAD:
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskList06DataMigrationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskList06DataMigrationTest.java
index 5e715e23f..420fe7d31 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskList06DataMigrationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskList06DataMigrationTest.java
@@ -24,7 +24,6 @@ import org.eclipse.mylyn.internal.monitor.core.util.ZipFileUtil;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.WorkspaceAwareContextStore;
/**
* Tests unused code that was live up to Mylyn 1.0.1, {@link TasksUiPlugin}
@@ -87,7 +86,7 @@ public class TaskList06DataMigrationTest extends TestCase {
oldContextFile2.createNewFile();
File oldContextFile3 = new File(sourceDirFile, contextFileName3);
oldContextFile3.createNewFile();
- File contextFolder = new File(sourceDirFile, WorkspaceAwareContextStore.CONTEXTS_DIRECTORY);
+ File contextFolder = new File(sourceDirFile, ITasksCoreConstants.CONTEXTS_DIRECTORY);
assertTrue(!contextFolder.exists());
assertTrue(migrator.migrateTaskContextData(new NullProgressMonitor()));
assertFalse(oldContextFile1.exists());
@@ -103,7 +102,7 @@ public class TaskList06DataMigrationTest extends TestCase {
File oldActivityFile = new File(sourceDirFile, IInteractionContextManager.OLD_CONTEXT_HISTORY_FILE_NAME
+ IInteractionContextManager.CONTEXT_FILE_EXTENSION_OLD);
oldActivityFile.createNewFile();
- File contextFolder = new File(sourceDirFile, WorkspaceAwareContextStore.CONTEXTS_DIRECTORY);
+ File contextFolder = new File(sourceDirFile, ITasksCoreConstants.CONTEXTS_DIRECTORY);
assertTrue(!contextFolder.exists());
assertTrue(migrator.migrateActivityData(new NullProgressMonitor()));
assertFalse(oldActivityFile.exists());
@@ -234,7 +233,7 @@ class TaskListDataMigration implements IRunnableWithProgress {
try {
monitor.beginTask("Task Context Migration", contextFiles.size());
- File contextsFolder = new File(dataDirectory, WorkspaceAwareContextStore.CONTEXTS_DIRECTORY);
+ File contextsFolder = new File(dataDirectory, ITasksCoreConstants.CONTEXTS_DIRECTORY);
if (!contextsFolder.exists()) {
if (!contextsFolder.mkdir()) {
throw new Exception(
@@ -271,7 +270,7 @@ class TaskListDataMigration implements IRunnableWithProgress {
return false;
}
- File contextsFolder = new File(dataDirectory, WorkspaceAwareContextStore.CONTEXTS_DIRECTORY);
+ File contextsFolder = new File(dataDirectory, ITasksCoreConstants.CONTEXTS_DIRECTORY);
if (!contextsFolder.exists()) {
if (!contextsFolder.mkdir()) {
throw new Exception("Could not create contexts folder. Check read/write permission on data directory.");
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java
index 14d74033d..0c77891c3 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListBackupManagerTest.java
@@ -44,7 +44,7 @@ public class TaskListBackupManagerTest extends TestCase {
}
public void testAutoBackupDisabled() throws InterruptedException {
- TaskListBackupManager backupManager = TasksUiPlugin.getDefault().getBackupManager();
+ TaskListBackupManager backupManager = TasksUiPlugin.getBackupManager();
TasksUiPlugin.getDefault().getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_SCHEDULE, 1);
TasksUiPlugin.getDefault().getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_LAST, 0f);
assertEquals(0, TasksUiPlugin.getDefault().getPreferenceStore().getLong(TasksUiPreferenceConstants.BACKUP_LAST));
@@ -54,14 +54,13 @@ public class TaskListBackupManagerTest extends TestCase {
}
public void testAutoBackupEnabled() throws InterruptedException, InvocationTargetException, IOException {
- TaskListBackupManager backupManager = TasksUiPlugin.getDefault().getBackupManager();
+ TaskListBackupManager backupManager = TasksUiPlugin.getBackupManager();
String backupFolder = TasksUiPlugin.getDefault().getBackupFolderPath();
File backupFileFolder = new File(backupFolder);
deleteBackupFolder(backupFileFolder);
- TasksUiPlugin.getDefault().getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_SCHEDULE, 1);
- TasksUiPlugin.getDefault().getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_LAST, 0f);
backupManager.backupNow(true);
- assertFalse(TasksUiPlugin.getDefault().getPreferenceStore().getLong(TasksUiPreferenceConstants.BACKUP_LAST) == 0);
+ Thread.sleep(3000);
+ backupManager.backupNow(true);
assertTrue(backupFileFolder.exists());
assertTrue(backupFileFolder.isDirectory());
assertTrue(backupFileFolder.listFiles(new FilenameFilter() {
@@ -72,10 +71,9 @@ public class TaskListBackupManagerTest extends TestCase {
return false;
}
- }).length == 1);
+ }).length == 2);
// Test removal of old backups
- TasksUiPlugin.getDefault().getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_MAXFILES, 0);
TasksUiPlugin.getBackupManager().removeOldBackups();
assertTrue(backupFileFolder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
@@ -85,10 +83,7 @@ public class TaskListBackupManagerTest extends TestCase {
return false;
}
- }).length == 0);
-
- // TODO: Test that OLDEST backups are deleted first.
-
+ }).length == 1);
}
private void deleteBackupFolder(File backupFileFolder) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java
index f66f755c3..d5755aa81 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java
@@ -14,7 +14,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
-import java.util.HashSet;
import java.util.Locale;
import java.util.SortedMap;
import java.util.Timer;
@@ -36,7 +35,6 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.internal.context.core.ContextPreferenceContstants;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.mylyn.internal.tasks.ui.util.TaskDataExportOperation;
-import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
@@ -71,7 +69,7 @@ public class TaskListBackupManager implements IPropertyChangeListener {
public TaskListBackupManager(String backupFolderPath) {
this.backupFolderPath = backupFolderPath;
- start(30 * MINUTE);//HOUR
+ start(7000);//HOUR
}
public void start(long delay) {
@@ -98,10 +96,10 @@ public class TaskListBackupManager implements IPropertyChangeListener {
backupFolder.mkdir();
}
- String backkupFilePath = backupFolderPath + File.separator + getBackupFileName();
+// String backkupFilePath = backupFolderPath + File.separator + getBackupFileName();
+ TasksUiPlugin.getExternalizationManager().requestSave();
if (!synchronous) {
-
ExportJob export = new ExportJob(backupFolderPath, getBackupFileName());
export.addJobChangeListener(new JobChangeAdapter() {
@@ -115,12 +113,14 @@ public class TaskListBackupManager implements IPropertyChangeListener {
} else {
- final TaskDataExportOperation backupJob = new TaskDataExportOperation(destination, true, true, false,
- false, backkupFilePath, new HashSet<AbstractTask>());
+ final TaskDataExportOperation backupJob = new TaskDataExportOperation(destination, true,
+ getBackupFileName());
+// final TaskDataExportOperation backupJob = new TaskDataExportOperation(destination, true, true, false,
+// false, backkupFilePath, new HashSet<AbstractTask>());
IProgressService service = PlatformUI.getWorkbench().getProgressService();
try {
- service.run(true, false, backupJob);
+ service.run(false, true, backupJob);
// TasksUiPlugin.getDefault().getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_LAST,
// new Date().getTime());
@@ -307,7 +307,7 @@ public class TaskListBackupManager implements IPropertyChangeListener {
if (event.getProperty().equals(ContextPreferenceContstants.PREF_DATA_DIR)) {
if (event.getNewValue() instanceof String) {
backupFolderPath = (String) event.getNewValue();
- System.err.println(">>> backup path changed: " + backupFolderPath);
+ //System.err.println(">>> backup path changed: " + backupFolderPath);
}
}
}
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 56d89ca41..da7920c24 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
@@ -22,7 +22,6 @@ import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
@@ -32,6 +31,7 @@ import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContext;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.tasks.core.RepositoryTaskHandleUtil;
@@ -176,8 +176,7 @@ public class TaskListManager implements ITaskListManager {
taskList.refactorRepositoryUrl(oldUrl, newUrl);
refactorMetaContextHandles(oldUrl, newUrl);
- File dataDir = new File(TasksUiPlugin.getDefault().getDataDirectory(),
- WorkspaceAwareContextStore.CONTEXTS_DIRECTORY);
+ File dataDir = new File(TasksUiPlugin.getDefault().getDataDirectory(), ITasksCoreConstants.CONTEXTS_DIRECTORY);
if (dataDir.exists() && dataDir.isDirectory()) {
for (File file : dataDir.listFiles()) {
int dotIndex = file.getName().lastIndexOf(".xml");
@@ -274,6 +273,7 @@ public class TaskListManager implements ITaskListManager {
}
TasksUiPlugin.getExternalizationManager().load(taskListSaveParticipant);
+ taskListInitialized = true;
// IProgressService service = PlatformUI.getWorkbench().getProgressService();
// TaskListModifyOperation modOperation = new TaskListModifyOperation() {
@@ -387,7 +387,9 @@ public class TaskListManager implements ITaskListManager {
}
public void deactivateTask(AbstractTask task) {
- Assert.isNotNull(task);
+ if (task == null) {
+ return;
+ }
if (task.isActive() && task == activeTask) {
// notify that a task is about to be deactivated
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 afa98b4b6..3a81e9948 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
@@ -718,7 +718,7 @@ public class TasksUiPlugin extends AbstractUIPlugin {
store.setDefault(TasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, true);
store.setDefault(TasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_MILISECONDS, "" + (20 * 60 * 1000));
- store.setDefault(TasksUiPreferenceConstants.BACKUP_SCHEDULE, 1);
+ //store.setDefault(TasksUiPreferenceConstants.BACKUP_SCHEDULE, 1);
store.setDefault(TasksUiPreferenceConstants.BACKUP_MAXFILES, 20);
store.setDefault(TasksUiPreferenceConstants.BACKUP_LAST, 0f);
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 51058e760..7d947a12a 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
@@ -11,14 +11,13 @@ package org.eclipse.mylyn.internal.tasks.ui;
import java.io.File;
import org.eclipse.mylyn.context.core.AbstractContextStore;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
/**
* @author Mik Kersten
*/
public class WorkspaceAwareContextStore extends AbstractContextStore {
- public static final String CONTEXTS_DIRECTORY = "contexts";
-
private File rootDirectory;
private File contextDirectory;
@@ -30,7 +29,7 @@ public class WorkspaceAwareContextStore extends AbstractContextStore {
rootDirectory.mkdir();
}
- contextDirectory = new File(rootDirectory, CONTEXTS_DIRECTORY);
+ contextDirectory = new File(rootDirectory, ITasksCoreConstants.CONTEXTS_DIRECTORY);
if (!contextDirectory.exists()) {
contextDirectory.mkdir();
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
index 8aed325af..cbed75616 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/preferences/TasksUiPreferencePage.java
@@ -93,7 +93,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
private Button notificationEnabledButton = null;
- private Text backupScheduleTimeText;
+// private Text backupScheduleTimeText;
private Text backupFolderText;
@@ -180,7 +180,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
// TasksUiPlugin.getTaskListManager().copyDataDirContentsTo(taskDirectory);
// TasksUiPlugin.getDefault().setDataDirectory(taskDirectory);
// } else if (taskDataDirectoryAction == LOAD_EXISTING) {
- TasksUiPlugin.getDefault().getBackupManager().backupNow(true);
+ TasksUiPlugin.getBackupManager().backupNow(true);
TasksUiPlugin.getDefault().setDataDirectory(taskDirectory);
} else if (taskDataDirectoryAction == IDialogConstants.CANCEL_ID) {
@@ -189,7 +189,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
}
getPreferenceStore().setValue(TasksUiPreferenceConstants.NOTIFICATIONS_ENABLED,
notificationEnabledButton.getSelection());
- getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_SCHEDULE, backupScheduleTimeText.getText());
+ //getPreferenceStore().setValue(TasksUiPreferenceConstants.BACKUP_SCHEDULE, backupScheduleTimeText.getText());
getPreferenceStore().setValue(TasksUiPreferenceConstants.EDITOR_TASKS_RICH, useRichEditor.getSelection());
@@ -219,7 +219,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
taskDirectoryText.setText(TasksUiPlugin.getDefault().getDefaultDataDirectory());
notificationEnabledButton.setSelection(getPreferenceStore().getBoolean(
TasksUiPreferenceConstants.NOTIFICATIONS_ENABLED));
- backupScheduleTimeText.setText(getPreferenceStore().getString(TasksUiPreferenceConstants.BACKUP_SCHEDULE));
+ //backupScheduleTimeText.setText(getPreferenceStore().getString(TasksUiPreferenceConstants.BACKUP_SCHEDULE));
backupFolderText.setText(TasksUiPlugin.getDefault().getBackupFolderPath());
useRichEditor.setSelection(getPreferenceStore().getBoolean(TasksUiPreferenceConstants.EDITOR_TASKS_RICH));
@@ -260,7 +260,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
notificationEnabledButton.setSelection(getPreferenceStore().getDefaultBoolean(
TasksUiPreferenceConstants.NOTIFICATIONS_ENABLED));
- backupScheduleTimeText.setText(getPreferenceStore().getDefaultString(TasksUiPreferenceConstants.BACKUP_SCHEDULE));
+ //backupScheduleTimeText.setText(getPreferenceStore().getDefaultString(TasksUiPreferenceConstants.BACKUP_SCHEDULE));
useRichEditor.setSelection(getPreferenceStore().getDefaultBoolean(TasksUiPreferenceConstants.EDITOR_TASKS_RICH));
@@ -403,22 +403,22 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
backupComposite.setLayout(gridLayout);
backupComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- label = new Label(backupComposite, SWT.NULL);
- label.setText("Backup every");
- backupScheduleTimeText = new Text(backupComposite, SWT.BORDER | SWT.RIGHT);
- final GridData gridData_1 = new GridData();
- gridData_1.widthHint = 13;
- backupScheduleTimeText.setLayoutData(gridData_1);
-
- backupScheduleTimeText.setText("" + getPreferenceStore().getInt(TasksUiPreferenceConstants.BACKUP_SCHEDULE));
- backupScheduleTimeText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateRefreshGroupEnablements();
- }
- });
-
- label = new Label(backupComposite, SWT.NONE);
- label.setText("days to");
+// label = new Label(backupComposite, SWT.NULL);
+// label.setText("Backup every");
+// backupScheduleTimeText = new Text(backupComposite, SWT.BORDER | SWT.RIGHT);
+// final GridData gridData_1 = new GridData();
+// gridData_1.widthHint = 13;
+// backupScheduleTimeText.setLayoutData(gridData_1);
+//
+// backupScheduleTimeText.setText("" + getPreferenceStore().getInt(TasksUiPreferenceConstants.BACKUP_SCHEDULE));
+// backupScheduleTimeText.addModifyListener(new ModifyListener() {
+// public void modifyText(ModifyEvent e) {
+// updateRefreshGroupEnablements();
+// }
+// });
+//
+// label = new Label(backupComposite, SWT.NONE);
+// label.setText("days to");
String backupDirectory = TasksUiPlugin.getDefault().getBackupFolderPath();// getPreferenceStore().getString(TaskListPreferenceConstants.BACKUP_FOLDER);
backupDirectory = backupDirectory.replaceAll(BACKSLASH_MULTI, FORWARDSLASH);
@@ -434,7 +434,7 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
@Override
public void widgetSelected(SelectionEvent e) {
- TasksUiPlugin.getDefault().getBackupManager().backupNow(true);
+ TasksUiPlugin.getBackupManager().backupNow(true);
}
});
}
@@ -663,16 +663,16 @@ public class TasksUiPreferencePage extends PreferencePage implements IWorkbenchP
public void updateRefreshGroupEnablements() {
String errorMessage = null;
- try {
- long number = Integer.parseInt(backupScheduleTimeText.getText());
- if (number <= 0) {
- errorMessage = "Backup schedule time must be > 0";
- } else if (backupFolderText.getText() == "") {
- errorMessage = "Backup destination folder must be specified";
- }
- } catch (NumberFormatException e) {
- errorMessage = "Backup schedule time must be valid integer";
- }
+// try {
+// long number = Integer.parseInt(backupScheduleTimeText.getText());
+// if (number <= 0) {
+// errorMessage = "Backup schedule time must be > 0";
+// } else if (backupFolderText.getText() == "") {
+// errorMessage = "Backup destination folder must be specified";
+// }
+// } catch (NumberFormatException e) {
+// errorMessage = "Backup schedule time must be valid integer";
+// }
if (enableBackgroundSynch.getSelection()) {
try {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java
index 4490e67af..8e7834409 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java
@@ -21,20 +21,19 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.monitor.core.util.ZipFileUtil;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.WorkspaceAwareContextStore;
import org.eclipse.mylyn.monitor.core.StatusHandler;
import org.eclipse.mylyn.tasks.core.AbstractTask;
-import org.eclipse.mylyn.tasks.ui.TaskListModifyOperation;
import org.eclipse.mylyn.tasks.ui.TasksUi;
/**
@@ -44,8 +43,10 @@ import org.eclipse.mylyn.tasks.ui.TasksUi;
* @author Wesley Coelho
* @author Mik Kersten
* @author Rob Elves
+ *
+ * TODO: Move into internal.tasks.core
*/
-public class TaskDataExportOperation extends TaskListModifyOperation {
+public class TaskDataExportOperation implements IRunnableWithProgress {
private static final String JOB_LABEL = "Exporting Mylyn Task Data";
@@ -73,8 +74,9 @@ public class TaskDataExportOperation extends TaskListModifyOperation {
}
/** export specified data */
- public TaskDataExportOperation(String destinationDirectory, boolean exportTaskList, boolean exportActivationHistory,
- boolean exportTaskContexts, boolean zipIt, String zipFileName, Collection<AbstractTask> taskContextsToExport) {
+ public TaskDataExportOperation(String destinationDirectory, boolean exportTaskList,
+ boolean exportActivationHistory, boolean exportTaskContexts, boolean zipIt, String zipFileName,
+ Collection<AbstractTask> taskContextsToExport) {
this.zipFileName = zipFileName;
this.zip = zipIt;
this.exportTaskList = exportTaskList;
@@ -84,9 +86,7 @@ public class TaskDataExportOperation extends TaskListModifyOperation {
this.tasks = taskContextsToExport;
}
- @Override
- protected void operations(IProgressMonitor monitor) throws CoreException, InvocationTargetException,
- InterruptedException {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
int jobSize = 1; // 1 for repositories.xml
if (exportTaskList) {
jobSize++;
@@ -97,7 +97,6 @@ public class TaskDataExportOperation extends TaskListModifyOperation {
if (exportTaskContexts) {
jobSize += tasks.size();
}
- monitor.beginTask(JOB_LABEL, jobSize);
// List of files to add to the zip archive
List<File> filesToZip = new ArrayList<File>();
@@ -105,147 +104,157 @@ public class TaskDataExportOperation extends TaskListModifyOperation {
// Map of file paths used to avoid duplicates
Map<String, String> filesToZipMap = new HashMap<String, String>();
- // Create folders in zip file before contained files
- String sourceContextsPath = TasksUiPlugin.getDefault().getDataDirectory() + File.separator
- + WorkspaceAwareContextStore.CONTEXTS_DIRECTORY;
- File contextsDirectory = new File(sourceContextsPath);
- // if(contextsDirectory.exists()) {
- // filesToZip.add(contextsDirectory);
- // }
-
- if (true) {
- // Repositories always exported
- TasksUiPlugin.getRepositoryManager().saveRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
-
- String sourceRepositoriesPath = TasksUiPlugin.getDefault().getDataDirectory() + File.separator
- + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE;
- File sourceRepositoriesFile = new File(sourceRepositoriesPath);
- if (sourceRepositoriesFile.exists()) {
- File destRepositoriesFile = new File(destinationDirectory + File.separator
- + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE);
-
- if (zip) {
- filesToZip.add(sourceRepositoriesFile);
- } else if (!destRepositoriesFile.equals(sourceRepositoriesFile)) {
- if (destRepositoriesFile.exists()) {
- destRepositoriesFile.delete();
- }
- if (!copy(sourceRepositoriesFile, destRepositoriesFile)) {
- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- "Could not export repositories file", new Exception()));
+ try {
+ monitor.beginTask(JOB_LABEL, jobSize);
+ Job.getJobManager().beginRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE, monitor);
+
+ // Create folders in zip file before contained files
+ String sourceContextsPath = TasksUiPlugin.getDefault().getDataDirectory() + File.separator
+ + ITasksCoreConstants.CONTEXTS_DIRECTORY;
+ File contextsDirectory = new File(sourceContextsPath);
+ // if(contextsDirectory.exists()) {
+ // filesToZip.add(contextsDirectory);
+ // }
+
+ if (true) {
+ // Repositories always exported
+// TasksUiPlugin.getRepositoryManager().saveRepositories(
+// TasksUiPlugin.getDefault().getRepositoriesFilePath());
+
+ String sourceRepositoriesPath = TasksUiPlugin.getDefault().getDataDirectory() + File.separator
+ + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE;
+ File sourceRepositoriesFile = new File(sourceRepositoriesPath);
+ if (sourceRepositoriesFile.exists()) {
+ File destRepositoriesFile = new File(destinationDirectory + File.separator
+ + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE);
+
+ if (zip) {
+ filesToZip.add(sourceRepositoriesFile);
+ } else if (!destRepositoriesFile.equals(sourceRepositoriesFile)) {
+ if (destRepositoriesFile.exists()) {
+ destRepositoriesFile.delete();
+ }
+ if (!copy(sourceRepositoriesFile, destRepositoriesFile)) {
+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
+ "Could not export repositories file", new Exception()));
+ }
+ monitor.worked(1);
}
- monitor.worked(1);
}
+
}
- }
+ if (exportTaskList) {
+// TasksUiPlugin.getTaskListManager().saveTaskList();
- if (exportTaskList) {
- TasksUiPlugin.getTaskListManager().saveTaskList();
-
- String sourceTaskListPath = TasksUiPlugin.getDefault().getDataDirectory() + File.separator
- + ITasksCoreConstants.DEFAULT_TASK_LIST_FILE;
- File sourceTaskListFile = new File(sourceTaskListPath);
- if (sourceTaskListFile.exists()) {
- File destTaskListFile = new File(destinationDirectory + File.separator
- + ITasksCoreConstants.DEFAULT_TASK_LIST_FILE);
-
- if (zip) {
- filesToZip.add(sourceTaskListFile);
- } else if (!destTaskListFile.equals(sourceTaskListFile)) {
- if (destTaskListFile.exists()) {
- destTaskListFile.delete();
- }
- if (!copy(sourceTaskListFile, destTaskListFile)) {
- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- "Could not export task list file", new Exception()));
+ String sourceTaskListPath = TasksUiPlugin.getDefault().getDataDirectory() + File.separator
+ + ITasksCoreConstants.DEFAULT_TASK_LIST_FILE;
+ File sourceTaskListFile = new File(sourceTaskListPath);
+ if (sourceTaskListFile.exists()) {
+ File destTaskListFile = new File(destinationDirectory + File.separator
+ + ITasksCoreConstants.DEFAULT_TASK_LIST_FILE);
+
+ if (zip) {
+ filesToZip.add(sourceTaskListFile);
+ } else if (!destTaskListFile.equals(sourceTaskListFile)) {
+ if (destTaskListFile.exists()) {
+ destTaskListFile.delete();
+ }
+ if (!copy(sourceTaskListFile, destTaskListFile)) {
+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
+ "Could not export task list file", new Exception()));
+ }
+ monitor.worked(1);
}
- monitor.worked(1);
}
- }
- }
+ }
- if (exportActivationHistory) {
- try {
- File sourceActivationHistoryFile = new File(contextsDirectory,
- IInteractionContextManager.CONTEXT_HISTORY_FILE_NAME
- + IInteractionContextManager.CONTEXT_FILE_EXTENSION);
+ if (exportActivationHistory) {
+ try {
+ File sourceActivationHistoryFile = new File(contextsDirectory,
+ IInteractionContextManager.CONTEXT_HISTORY_FILE_NAME
+ + IInteractionContextManager.CONTEXT_FILE_EXTENSION);
- if (sourceActivationHistoryFile.exists()) {
+ if (sourceActivationHistoryFile.exists()) {
- ContextCore.getContextManager().saveActivityContext();
+ ContextCore.getContextManager().saveActivityContext();
- File destActivationHistoryFile = new File(destinationDirectory + File.separator
- + IInteractionContextManager.CONTEXT_HISTORY_FILE_NAME
- + IInteractionContextManager.CONTEXT_FILE_EXTENSION);
+ File destActivationHistoryFile = new File(destinationDirectory + File.separator
+ + IInteractionContextManager.CONTEXT_HISTORY_FILE_NAME
+ + IInteractionContextManager.CONTEXT_FILE_EXTENSION);
- if (zip) {
- filesToZip.add(sourceActivationHistoryFile);
- } else if (!destActivationHistoryFile.equals(sourceActivationHistoryFile)) {
- if (destActivationHistoryFile.exists()) {
- destActivationHistoryFile.delete();
+ if (zip) {
+ filesToZip.add(sourceActivationHistoryFile);
+ } else if (!destActivationHistoryFile.equals(sourceActivationHistoryFile)) {
+ if (destActivationHistoryFile.exists()) {
+ destActivationHistoryFile.delete();
+ }
+ copy(sourceActivationHistoryFile, destActivationHistoryFile);
+ monitor.worked(1);
}
- copy(sourceActivationHistoryFile, destActivationHistoryFile);
- monitor.worked(1);
}
+ } catch (RuntimeException e) {
+ // FIXME what is caught here?
+ StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
+ "Could not export activity history context file", e));
}
- } catch (RuntimeException e) {
- // FIXME what is caught here?
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- "Could not export activity history context file", e));
}
- }
- if (exportTaskContexts) {
- // Prevent many repeated error messages
- boolean errorDisplayed = false;
- for (AbstractTask task : tasks) {
+ if (exportTaskContexts) {
+ // Prevent many repeated error messages
+ boolean errorDisplayed = false;
+ for (AbstractTask task : tasks) {
- if (!ContextCore.getContextManager().hasContext(task.getHandleIdentifier())) {
- continue; // Tasks without a context have no file to
- // copy
- }
+ if (!ContextCore.getContextManager().hasContext(task.getHandleIdentifier())) {
+ continue; // Tasks without a context have no file to
+ // copy
+ }
- File sourceTaskContextFile = ContextCore.getContextManager().getFileForContext(
- task.getHandleIdentifier());
+ File sourceTaskContextFile = ContextCore.getContextManager().getFileForContext(
+ task.getHandleIdentifier());
- File destTaskFile = new File(destinationDirectory + File.separator + sourceTaskContextFile.getName());
+ File destTaskFile = new File(destinationDirectory + File.separator
+ + sourceTaskContextFile.getName());
- if (zip) {
- if (!filesToZipMap.containsKey(task.getHandleIdentifier())) {
- filesToZip.add(sourceTaskContextFile);
- filesToZipMap.put(task.getHandleIdentifier(), null);
- }
- } else if (!sourceTaskContextFile.equals(destTaskFile)) {
- if (destTaskFile.exists()) {
- destTaskFile.delete();
- }
- if (!copy(sourceTaskContextFile, destTaskFile) && !errorDisplayed) {
- Exception e = new Exception("Export Exception: " + sourceTaskContextFile.getPath() + " -> "
- + destTaskFile.getPath());
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- "Could not export one or more task context files", e));
- errorDisplayed = true;
+ if (zip) {
+ if (!filesToZipMap.containsKey(task.getHandleIdentifier())) {
+ filesToZip.add(sourceTaskContextFile);
+ filesToZipMap.put(task.getHandleIdentifier(), null);
+ }
+ } else if (!sourceTaskContextFile.equals(destTaskFile)) {
+ if (destTaskFile.exists()) {
+ destTaskFile.delete();
+ }
+ if (!copy(sourceTaskContextFile, destTaskFile) && !errorDisplayed) {
+ Exception e = new Exception("Export Exception: " + sourceTaskContextFile.getPath() + " -> "
+ + destTaskFile.getPath());
+ StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
+ "Could not export one or more task context files", e));
+ errorDisplayed = true;
+ }
+ monitor.worked(1);
}
- monitor.worked(1);
}
}
- }
- if (zip && filesToZip.size() > 0) {
- try {
- destZipFile = new File(destinationDirectory + File.separator + zipFileName);
- if (destZipFile.exists()) {
- destZipFile.delete();
+ if (zip && filesToZip.size() > 0) {
+ try {
+ destZipFile = new File(destinationDirectory + File.separator + zipFileName);
+ if (destZipFile.exists()) {
+ destZipFile.delete();
+ }
+ ZipFileUtil.createZipFile(destZipFile, filesToZip, TasksUiPlugin.getDefault().getDataDirectory(),
+ monitor);
+ } catch (Exception e) {
+ StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not create zip file",
+ e));
}
- ZipFileUtil.createZipFile(destZipFile, filesToZip, TasksUiPlugin.getDefault().getDataDirectory(),
- monitor);
- } catch (Exception e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not create zip file", e));
}
+ } finally {
+ Job.getJobManager().endRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE);
+ monitor.done();
}
- monitor.done();
}
private boolean copy(File src, File dst) {

Back to the top