Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-08-17 18:45:00 -0400
committermkersten2005-08-17 18:45:00 -0400
commit470d766e5073f0b4f0861e9be6599624c5020c2b (patch)
tree31a3262c85e97c5e318aa67ebdb94cb3d0535128
parent404f8e0ac74a9afd95f374ffb6c1c6ebefdb8dff (diff)
downloadorg.eclipse.mylyn.tasks-470d766e5073f0b4f0861e9be6599624c5020c2b.tar.gz
org.eclipse.mylyn.tasks-470d766e5073f0b4f0861e9be6599624c5020c2b.tar.xz
org.eclipse.mylyn.tasks-470d766e5073f0b4f0861e9be6599624c5020c2b.zip
Fix for Bug #106930: Task list is loosing its content after each restart
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java107
1 files changed, 55 insertions, 52 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java
index e6b6a623a..f479fec5d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java
@@ -42,6 +42,8 @@ import org.osgi.framework.BundleContext;
/**
* @author Mik Kersten
+ *
+ * TODO: this class is in serious need of refactoring
*/
public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
@@ -172,71 +174,29 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
}
};
-
+
private static ShellListener SHELL_LISTENER = new ShellListener() {
- private void saveState() {
- taskListManager.saveTaskList();
- for(ITask task : taskListManager.getTaskList().getActiveTasks()) {
- MylarPlugin.getContextManager().saveContext(task.getHandle(), task.getPath());
- }
- lastSave = new Date();
- plugin.getPreferenceStore().setValue(PREVIOUS_SAVE_DATE, lastSave.getTime());
- }
-
- private void checkTaskListSave() {
- if (getPrefs().contains(PREVIOUS_SAVE_DATE)) {
- lastSave = new Date(getPrefs().getLong(PREVIOUS_SAVE_DATE));
- } else {
- lastSave = new Date();
- getPrefs().setValue(PREVIOUS_SAVE_DATE, lastSave.getTime());
- }
- Date currentTime = new Date();
- if (currentTime.getTime() > lastSave.getTime() + TaskListSaveMode.fromStringToLong(getPrefs().getString(SAVE_TASKLIST_MODE))) {
- taskListManager.saveTaskList();
- lastSave = new Date();
- plugin.getPreferenceStore().setValue(PREVIOUS_SAVE_DATE, lastSave.getTime());
- } else {
-// System.out.println("Tasklist not saved auto yet");
-// System.out.println("Save time: " + new Date(
-// lastSave.getTime() +
-// TaskListSaveMode.fromStringToLong(getPrefs().getString(SAVE_TASKLIST_MODE))).toString());
- }
- }
-
- private void checkReminders() {
-// if (getPrefs().getBoolean(REMINDER_CHECK)) {
-// getPrefs().setValue(REMINDER_CHECK, false);
- final TaskReportGenerator parser = new TaskReportGenerator(MylarTasklistPlugin.getTaskListManager().getTaskList());
- parser.addCollector(new ReminderRequiredCollector());
- parser.checkTasks();
- if (!parser.getTasks().isEmpty()) {
- Workbench.getInstance().getDisplay().asyncExec(new Runnable() {
- public void run() {
- TasksReminderDialog dialog = new TasksReminderDialog(Workbench.getInstance().getDisplay().getActiveShell(), parser.getTasks());
- dialog.setBlockOnOpen(false);
- dialog.open();
- }
- });
- }
-// }
- }
public void shellClosed(ShellEvent arg0) {
- saveState();
+ getDefault().saveState();
}
+ /**
+ * bug 1002249: too slow to save state here
+ */
public void shellDeactivated(ShellEvent arg0) {
- // bug 1002249: too slow to save state here
+ //
}
+
public void shellActivated(ShellEvent arg0) {
- checkTaskListSave();
- checkReminders();
+ getDefault().checkTaskListSave();
+ getDefault().checkReminders();
}
public void shellDeiconified(ShellEvent arg0) { }
public void shellIconified(ShellEvent arg0) {
- saveState();
+ getDefault().saveState();
}
};
@@ -298,6 +258,7 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
super.stop(context);
plugin = null;
resourceBundle = null;
+ saveState();
createFileBackup();
// getPrefs().setValue(REMINDER_CHECK, true);
}
@@ -356,6 +317,48 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
return MylarPlugin.getDefault().getPreferenceStore();
}
+ private void saveState() {
+ taskListManager.saveTaskList();
+ for(ITask task : taskListManager.getTaskList().getActiveTasks()) {
+ MylarPlugin.getContextManager().saveContext(task.getHandle(), task.getPath());
+ }
+ lastSave = new Date();
+ plugin.getPreferenceStore().setValue(PREVIOUS_SAVE_DATE, lastSave.getTime());
+ }
+
+ private void checkTaskListSave() {
+ if (getPrefs().contains(PREVIOUS_SAVE_DATE)) {
+ lastSave = new Date(getPrefs().getLong(PREVIOUS_SAVE_DATE));
+ } else {
+ lastSave = new Date();
+ getPrefs().setValue(PREVIOUS_SAVE_DATE, lastSave.getTime());
+ }
+ Date currentTime = new Date();
+ if (currentTime.getTime() > lastSave.getTime() + TaskListSaveMode.fromStringToLong(getPrefs().getString(SAVE_TASKLIST_MODE))) {
+ taskListManager.saveTaskList();
+ lastSave = new Date();
+ plugin.getPreferenceStore().setValue(PREVIOUS_SAVE_DATE, lastSave.getTime());
+ }
+ }
+
+ private void checkReminders() {
+// if (getPrefs().getBoolean(REMINDER_CHECK)) {
+// getPrefs().setValue(REMINDER_CHECK, false);
+ final TaskReportGenerator parser = new TaskReportGenerator(MylarTasklistPlugin.getTaskListManager().getTaskList());
+ parser.addCollector(new ReminderRequiredCollector());
+ parser.checkTasks();
+ if (!parser.getTasks().isEmpty()) {
+ Workbench.getInstance().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ TasksReminderDialog dialog = new TasksReminderDialog(Workbench.getInstance().getDisplay().getActiveShell(), parser.getTasks());
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+ }
+ });
+ }
+// }
+ }
+
public static void setPriorityLevel(PriorityLevel pl) {
getPrefs().setValue(SELECTED_PRIORITY, pl.toString());
}

Back to the top