Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-07-15 19:31:29 +0000
committermkersten2005-07-15 19:31:29 +0000
commit1aed5c236f690457fd68327e36e543728f2d9e40 (patch)
treeb320f94ce804ffbfbe68f5e5f31551afcb5724be /org.eclipse.mylyn.tasks.ui
parentff832fb11da934afb25235f85d1dcd662df3861e (diff)
downloadorg.eclipse.mylyn.tasks-1aed5c236f690457fd68327e36e543728f2d9e40.tar.gz
org.eclipse.mylyn.tasks-1aed5c236f690457fd68327e36e543728f2d9e40.tar.xz
org.eclipse.mylyn.tasks-1aed5c236f690457fd68327e36e543728f2d9e40.zip
Fix for Bugzilla Bug 103237
provide mechanism to back up all task
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
index 053cef9d4..20a838189 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
@@ -11,6 +11,11 @@
package org.eclipse.mylar.tasks;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
@@ -179,8 +184,7 @@ public class MylarTasksPlugin extends AbstractUIPlugin {
MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER);
}
- });
-
+ });
super.start(context);
}
@@ -189,6 +193,7 @@ public class MylarTasksPlugin extends AbstractUIPlugin {
super.stop(context);
plugin = null;
resourceBundle = null;
+ createFileBackup();
}
@Override
@@ -308,4 +313,30 @@ public class MylarTasksPlugin extends AbstractUIPlugin {
contributors.add(contributor);
if (TaskListView.getDefault() != null) TaskListView.getDefault().resetToolbarsAndPopups();
}
+
+ private void createFileBackup() {
+ String path = MylarPlugin.getDefault().getUserDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE;
+ File taskListFile = new File(path);
+ String backup = path.substring(0, path.lastIndexOf('.')) + "-backup.xml";
+ copy(taskListFile, new File(backup));
+ }
+
+ private boolean copy(File src, File dst) {
+ try {
+ InputStream in = new FileInputStream(src);
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ return true;
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
}

Back to the top