Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-08-22 13:36:11 -0400
committermkersten2005-08-22 13:36:11 -0400
commit7268a2ca8896e36586d98d9cd38526d8e68bac27 (patch)
treecce6bd833be569a425e9814b185f1f2d83fe741e
parentf2a01a5585237bda0646868dbb087550fb1829b7 (diff)
downloadorg.eclipse.mylyn.tasks-7268a2ca8896e36586d98d9cd38526d8e68bac27.tar.gz
org.eclipse.mylyn.tasks-7268a2ca8896e36586d98d9cd38526d8e68bac27.tar.xz
org.eclipse.mylyn.tasks-7268a2ca8896e36586d98d9cd38526d8e68bac27.zip
Task list save on dispose fix
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java53
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java8
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTaskPreferencePage.java20
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java6
6 files changed, 53 insertions, 44 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 2b5cf806c..4b82e6127 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
@@ -31,6 +31,8 @@ import org.eclipse.mylar.tasklist.report.internal.ReminderRequiredCollector;
import org.eclipse.mylar.tasklist.report.internal.TaskReportGenerator;
import org.eclipse.mylar.tasklist.ui.TasksReminderDialog;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.ui.IStartup;
@@ -78,7 +80,6 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
public static final String FILTER_INCOMPLETE_MODE = "org.eclipse.mylar.tasklist.filter.incomplete";
public static final String SAVE_TASKLIST_MODE = "org.eclipse.mylar.tasklist.save.mode";
public static final String PREVIOUS_SAVE_DATE = "org.eclipse.mylar.tasklist.save.last";
-// public static final String REMINDER_CHECK = "org.eclipse.mylar.tasklist.reminder.check";
private ResourceBundle resourceBundle;
private static Date lastSave = null;
@@ -175,28 +176,33 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
};
+ /**
+ * TODO: move into reminder mechanims
+ */
private static ShellListener SHELL_LISTENER = new ShellListener() {
public void shellClosed(ShellEvent arg0) {
-// getDefault().saveState();
+ // ignore
}
/**
* bug 1002249: too slow to save state here
*/
public void shellDeactivated(ShellEvent arg0) {
- //
+ // ignore
}
public void shellActivated(ShellEvent arg0) {
- getDefault().checkTaskListSave();
+// getDefault().checkTaskListSave();
getDefault().checkReminders();
}
- public void shellDeiconified(ShellEvent arg0) { }
+ public void shellDeiconified(ShellEvent arg0) {
+ // ingore
+ }
public void shellIconified(ShellEvent arg0) {
-// getDefault().saveState();
+ // ignore
}
};
@@ -240,6 +246,11 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
workbench.getDisplay().syncExec(new Runnable() {
public void run() {
Workbench.getInstance().getActiveWorkbenchWindow().getShell().addShellListener(SHELL_LISTENER);
+ Workbench.getInstance().getActiveWorkbenchWindow().getShell().addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ getDefault().saveTaskListAndContexts();
+ }
+ });
MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER);
taskListManager.readTaskList();
@@ -317,7 +328,7 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
/**
* TODO: make private
*/
- public void saveState() {
+ public void saveTaskListAndContexts() {
taskListManager.saveTaskList();
for(ITask task : taskListManager.getTaskList().getActiveTasks()) {
MylarPlugin.getContextManager().saveContext(task.getHandle(), task.getPath());
@@ -326,20 +337,20 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
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 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)) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java
index 70fb43aa8..220027d34 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/Task.java
@@ -317,21 +317,21 @@ public class Task implements ITask {
public void addSubTask(ITask t) {
children.add(t);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
public void removeSubTask(ITask t) {
children.remove(t);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
public void setCategory(TaskCategory cat) {
this.parentCategory = cat;
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java
index a22d5d6ab..3299b5ab3 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskCategory.java
@@ -60,7 +60,7 @@ public class TaskCategory extends AbstractCategory implements Serializable {
public void addTask(ITask task) {
tasks.add(task);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
@@ -71,7 +71,7 @@ public class TaskCategory extends AbstractCategory implements Serializable {
public void removeTask(ITask task) {
tasks.remove(task);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java
index 54d3364b9..3314a43c1 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskList.java
@@ -37,7 +37,7 @@ public class TaskList implements Serializable {
public void addRootTask(ITask task) {
rootTasks.add(task);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
@@ -48,7 +48,7 @@ public class TaskList implements Serializable {
public void addCategory(AbstractCategory cat) {
categories.add(cat);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
@@ -79,7 +79,7 @@ public class TaskList implements Serializable {
}
}
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
@@ -99,7 +99,7 @@ public class TaskList implements Serializable {
public void deleteCategory(AbstractCategory category) {
categories.remove(category);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTaskPreferencePage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTaskPreferencePage.java
index 32667ae76..ddb7c0061 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTaskPreferencePage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTaskPreferencePage.java
@@ -17,11 +17,9 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -36,7 +34,7 @@ public class MylarTaskPreferencePage extends PreferencePage implements
private Button reportInternal = null;
private Button reportExternal = null;
private Button multipleActive = null;
- private Combo saveCombo = null;
+// private Combo saveCombo = null;
public MylarTaskPreferencePage() {
super();
@@ -96,11 +94,11 @@ public class MylarTaskPreferencePage extends PreferencePage implements
GridLayout gl = new GridLayout(2, false);
container.setLayout(gl);
- Label l = new Label(container, SWT.NONE);
- l.setText("Automatically save task list every:");
- saveCombo = new Combo(container, SWT.DROP_DOWN);
- saveCombo.setItems(MylarTasklistPlugin.getDefault().getSaveOptions());
- saveCombo.setText(getPreferenceStore().getString(MylarTasklistPlugin.SAVE_TASKLIST_MODE));
+// Label l = new Label(container, SWT.NONE);
+// l.setText("Automatically save task list every:");
+// saveCombo = new Combo(container, SWT.DROP_DOWN);
+// saveCombo.setItems(MylarTasklistPlugin.getDefault().getSaveOptions());
+// saveCombo.setText(getPreferenceStore().getString(MylarTasklistPlugin.SAVE_TASKLIST_MODE));
}
@Override
public boolean performOk() {
@@ -109,7 +107,7 @@ public class MylarTaskPreferencePage extends PreferencePage implements
getPreferenceStore().setValue(MylarTasklistPlugin.REPORT_OPEN_INTERNAL, reportInternal.getSelection());
getPreferenceStore().setValue(MylarTasklistPlugin.REPORT_OPEN_EXTERNAL, reportExternal.getSelection());
getPreferenceStore().setValue(MylarTasklistPlugin.MULTIPLE_ACTIVE_TASKS, multipleActive.getSelection());
- getPreferenceStore().setValue(MylarTasklistPlugin.SAVE_TASKLIST_MODE, saveCombo.getText());
+// getPreferenceStore().setValue(MylarTasklistPlugin.SAVE_TASKLIST_MODE, saveCombo.getText());
return true;
}
@Override
@@ -119,7 +117,7 @@ public class MylarTaskPreferencePage extends PreferencePage implements
reportInternal.setSelection(getPreferenceStore().getBoolean(MylarTasklistPlugin.REPORT_OPEN_INTERNAL));
reportExternal.setSelection(getPreferenceStore().getBoolean(MylarTasklistPlugin.REPORT_OPEN_EXTERNAL));
multipleActive.setSelection(getPreferenceStore().getBoolean(MylarTasklistPlugin.MULTIPLE_ACTIVE_TASKS));
- saveCombo.setText(getPreferenceStore().getString(MylarTasklistPlugin.SAVE_TASKLIST_MODE));
+// saveCombo.setText(getPreferenceStore().getString(MylarTasklistPlugin.SAVE_TASKLIST_MODE));
return true;
}
@@ -130,6 +128,6 @@ public class MylarTaskPreferencePage extends PreferencePage implements
reportInternal.setSelection(getPreferenceStore().getDefaultBoolean(MylarTasklistPlugin.REPORT_OPEN_INTERNAL));
reportExternal.setSelection(getPreferenceStore().getDefaultBoolean(MylarTasklistPlugin.REPORT_OPEN_EXTERNAL));
multipleActive.setSelection(getPreferenceStore().getDefaultBoolean(MylarTasklistPlugin.MULTIPLE_ACTIVE_TASKS));
- saveCombo.setText(getPreferenceStore().getDefaultString(MylarTasklistPlugin.SAVE_TASKLIST_MODE));
+// saveCombo.setText(getPreferenceStore().getDefaultString(MylarTasklistPlugin.SAVE_TASKLIST_MODE));
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
index 241d6213b..00b4a6048 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
@@ -643,7 +643,7 @@ public class TaskListView extends ViewPart {
m.putInteger("sortIndex", sortIndex);
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
}
@@ -822,7 +822,7 @@ public class TaskListView extends ViewPart {
getViewer().setSelection(null);
getViewer().refresh();
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
return true;
} else if(selectedObject instanceof ITaskListElement &&
@@ -833,7 +833,7 @@ public class TaskListView extends ViewPart {
getViewer().setSelection(null);
getViewer().refresh();
if (MylarTasklistPlugin.getDefault() != null) {
- MylarTasklistPlugin.getDefault().saveState();
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
}
return true;
}

Back to the top