Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-07-28 19:14:25 +0000
committersminto2005-07-28 19:14:25 +0000
commitb0c5396f93f5359d70e474a057be56e2ec9cba39 (patch)
tree45c0098438ebed07ddc112becdee55cb27528228 /org.eclipse.mylyn.tasks.ui
parentdd9fd4bdd5f8f8eab2befa838e37daeaf07c90b6 (diff)
downloadorg.eclipse.mylyn.tasks-b0c5396f93f5359d70e474a057be56e2ec9cba39.tar.gz
org.eclipse.mylyn.tasks-b0c5396f93f5359d70e474a057be56e2ec9cba39.tar.xz
org.eclipse.mylyn.tasks-b0c5396f93f5359d70e474a057be56e2ec9cba39.zip
Applied kens patch for Bug 104898 periodically save the task list
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java79
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTaskPreferencePage.java20
2 files changed, 94 insertions, 5 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 307b197ab..ff4a64c3b 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
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@@ -68,9 +69,47 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
public static final String SELECTED_PRIORITY = "org.eclipse.mylar.tasklist.filter.priority";
public static final String FILTER_COMPLETE_MODE = "org.eclipse.mylar.tasklist.filter.complete";
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";
private ResourceBundle resourceBundle;
+ private static Date lastSave = null;
// private ITaskListActionContributor primaryContributor;
+ public enum TaskListSaveMode {
+ ONE_HOUR,
+ THREE_HOURS,
+ DAY;
+ @Override
+ public String toString() {
+ switch(this) {
+ case ONE_HOUR: return "1 hour";
+ case THREE_HOURS: return "3 hours";
+ case DAY: return "1 day";
+ default: return "3 hours";
+ }
+ }
+ public static TaskListSaveMode fromString(String string) {
+ if (string == null) return null;
+ if (string.equals("1 hour")) return ONE_HOUR;
+ if (string.equals("3 hours")) return THREE_HOURS;
+ if (string.equals("1 day")) return DAY;
+ return null;
+ }
+ public static long fromStringToLong(String string) {
+ long hour = 3600*1000;
+ switch(fromString(string)) {
+ case ONE_HOUR:
+ return hour;
+ case THREE_HOURS:
+ return hour * 3;
+ case DAY:
+ return hour * 24;
+ default:
+ return hour * 3;
+ }
+ }
+ }
+
public enum Report_Open_Mode {
EDITOR,
INTERNAL_BROWSER,
@@ -133,6 +172,28 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
for(ITask task : taskListManager.getTaskList().getActiveTasks()) {
MylarPlugin.getContextManager().saveTaskscape(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());
+ }
}
public void shellClosed(ShellEvent arg0) {
@@ -142,7 +203,9 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
public void shellDeactivated(ShellEvent arg0) {
// bug 1002249: too slow to save state here
}
- public void shellActivated(ShellEvent arg0) { }
+ public void shellActivated(ShellEvent arg0) {
+ checkTaskListSave();
+ }
public void shellDeiconified(ShellEvent arg0) { }
@@ -207,15 +270,14 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
@Override
protected void initializeDefaultPreferences(IPreferenceStore store) {
- store.setDefault(MylarPlugin.CLOSE_EDITORS, true);
-
+ store.setDefault(MylarPlugin.CLOSE_EDITORS, true);
store.setDefault(SELECTED_PRIORITY, "P5");
store.setDefault(REPORT_OPEN_EDITOR, true);
store.setDefault(REPORT_OPEN_INTERNAL, false);
store.setDefault(REPORT_OPEN_EXTERNAL, false);
store.setDefault(MULTIPLE_ACTIVE_TASKS, false);
- }
-
+ store.setDefault(SAVE_TASKLIST_MODE, TaskListSaveMode.THREE_HOURS.toString());
+ }
public static TaskListManager getTaskListManager() {
return taskListManager;
@@ -371,4 +433,11 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
public boolean isMultipleMode() {
return getPrefs().getBoolean(MULTIPLE_ACTIVE_TASKS);
}
+
+ public String[] getSaveOptions() {
+ String[] options = {TaskListSaveMode.ONE_HOUR.toString(),
+ TaskListSaveMode.THREE_HOURS.toString(),
+ TaskListSaveMode.DAY.toString()};
+ return options;
+ }
}
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 c07f1cdbc..78117d465 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
@@ -18,9 +18,11 @@ 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;
@@ -35,6 +37,7 @@ public class MylarTaskPreferencePage extends PreferencePage implements
private Button reportInternal = null;
private Button reportExternal = null;
private Button multipleActive = null;
+ private Combo saveCombo = null;
public MylarTaskPreferencePage() {
super();
@@ -48,6 +51,7 @@ public class MylarTaskPreferencePage extends PreferencePage implements
createUserbooleanControl(container);
createBugzillaReportOption(container);
+ createSaveTaskListSection(container);
return container;
}
@@ -86,6 +90,19 @@ public class MylarTaskPreferencePage extends PreferencePage implements
reportExternal.setEnabled(false);
}
+ private void createSaveTaskListSection(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ container.setLayoutData(gridData);
+ 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));
+ }
@Override
public boolean performOk() {
getPreferenceStore().setValue(MylarPlugin.CLOSE_EDITORS, closeEditors.getSelection());
@@ -93,6 +110,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());
return true;
}
@Override
@@ -102,6 +120,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));
return true;
}
@@ -112,5 +131,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));
}
}

Back to the top