Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2009-02-09 18:17:42 -0500
committerrelves2009-02-09 18:17:42 -0500
commit01aec0cb9adc992f8d5c8970296b641d1aacea1b (patch)
tree864b5c6d89d46587514ed453bb34026324b2164b
parent1e928bfa6436ac95f62e882a199fad7d2f87e131 (diff)
downloadorg.eclipse.mylyn.tasks-01aec0cb9adc992f8d5c8970296b641d1aacea1b.tar.gz
org.eclipse.mylyn.tasks-01aec0cb9adc992f8d5c8970296b641d1aacea1b.tar.xz
org.eclipse.mylyn.tasks-01aec0cb9adc992f8d5c8970296b641d1aacea1b.zip
NEW - bug 248364: improve import/export functionality
https://bugs.eclipse.org/bugs/show_bug.cgi?id=248364
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java57
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java276
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataSnapshotOperation.java34
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizard.java17
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizardPage.java64
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizard.java139
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizardPage.java54
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties2
11 files changed, 246 insertions, 414 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java
index 4a35f0c78..53562b071 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataExportTest.java
@@ -17,10 +17,12 @@ import java.util.ArrayList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.commons.tests.support.CommonsTestUtil;
import org.eclipse.mylyn.context.tests.AbstractContextTest;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.wizards.Messages;
+import org.eclipse.mylyn.internal.tasks.ui.util.TaskDataExportOperation;
+import org.eclipse.mylyn.internal.tasks.ui.util.TaskDataSnapshotOperation;
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskDataExportWizard;
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskDataExportWizardPage;
import org.eclipse.swt.widgets.Shell;
@@ -47,7 +49,7 @@ public class TaskDataExportTest extends AbstractContextTest {
wizard = new TaskDataExportWizard();
wizard.addPages();
wizard.createPageControls(new Shell());
- wizardPage = (TaskDataExportWizardPage) wizard.getPage(Messages.TaskDataExportWizardPage_Export_Mylyn_Task_Data);
+ wizardPage = (TaskDataExportWizardPage) wizard.getPage("org.eclipse.mylyn.tasklist.exportPage");
assertNotNull(wizardPage);
// Create test export destination directory
@@ -57,13 +59,17 @@ public class TaskDataExportTest extends AbstractContextTest {
destinationDir.mkdir();
// Create folder/file structure
- File tasklist = new File(mylynFolder, "tasklist.xml.zip");
+ File tasklist = new File(mylynFolder, "tasks.xml.zip");
assertTrue(tasklist.createNewFile());
File hidden = new File(mylynFolder, ".hidden");
hidden.createNewFile();
assertTrue(hidden.exists());
File tasks = new File(mylynFolder, "tasksandstuff");
assertTrue(tasks.mkdir());
+ File backup = new File(mylynFolder, "backup");
+ if (!backup.exists()) {
+ assertTrue(backup.mkdir());
+ }
File tasksFile = new File(tasks, "file1.xml.zip");
assertTrue(tasksFile.createNewFile());
File tasksSubDir = new File(tasks, "sub");
@@ -74,7 +80,21 @@ public class TaskDataExportTest extends AbstractContextTest {
@Override
protected void tearDown() throws Exception {
+ wizard.dispose();
+ wizardPage.dispose();
CommonsTestUtil.deleteFolder(destinationDir);
+ File mylynFolder = new File(TasksUiPlugin.getDefault().getDataDirectory());
+ // Create folder/file structure
+ File tasklist = new File(mylynFolder, "tasks.xml.zip");
+ tasklist.delete();
+ File hidden = new File(mylynFolder, ".hidden");
+ hidden.delete();
+ File tasks = new File(mylynFolder, "tasksandstuff");
+ File tasksSubDir = new File(tasks, "sub");
+ File backup = new File(mylynFolder, "backup");
+ CommonsTestUtil.deleteFolder(backup);
+ CommonsTestUtil.deleteFolder(tasksSubDir);
+ CommonsTestUtil.deleteFolder(tasks);
super.tearDown();
}
@@ -97,10 +117,37 @@ public class TaskDataExportTest extends AbstractContextTest {
entries.add(entry.getName());
entry = zipInputStream.getNextEntry();
}
- assertTrue(entries.contains(".hidden"));
- assertTrue(entries.contains("tasklist.xml.zip"));
+ assertFalse(entries.contains(".hidden"));
+ assertTrue(entries.contains("tasks.xml.zip"));
assertTrue(entries.contains("tasksandstuff/file1.xml.zip"));
assertTrue(entries.contains("tasksandstuff/sub/file2.xml.zip"));
+ assertFalse(entries.contains("backup"));
+ } finally {
+ zipInputStream.close();
+ }
+ }
+
+ public void testSnapshot() throws Exception {
+ final TaskDataExportOperation backupJob = new TaskDataSnapshotOperation(destinationDir.getPath(),
+ "testBackup.zip");
+ backupJob.run(new NullProgressMonitor());
+ // check that the task list file was exported
+ File[] files = destinationDir.listFiles();
+ assertEquals(1, files.length);
+ ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(files[0]));
+ try {
+ ArrayList<String> entries = new ArrayList<String>();
+ ZipEntry entry = zipInputStream.getNextEntry();
+ while (entry != null) {
+ entries.add(entry.getName());
+ entry = zipInputStream.getNextEntry();
+ }
+ assertFalse(entries.contains(".hidden"));
+ assertTrue(entries.contains("tasks.xml.zip"));
+ assertTrue(entries.contains("repositories.xml.zip"));
+ assertTrue(entries.contains("contexts/activity.xml.zip"));
+ assertFalse(entries.contains("tasks"));
+ assertEquals(3, entries.size());
} finally {
zipInputStream.close();
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java
index b19f37c10..90ed04c0d 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataImportTest.java
@@ -61,6 +61,8 @@ public class TaskDataImportTest extends AbstractContextTest {
@Override
protected void tearDown() throws Exception {
+ wizard.dispose();
+ wizardPage.dispose();
ContextCorePlugin.getContextManager().resetActivityMetaContext();
TasksUiPlugin.getRepositoryManager().clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
TaskTestUtil.resetTaskList();
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 abd6f3c59..ba067612e 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
@@ -17,7 +17,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
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,10 +35,10 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.mylyn.internal.tasks.ui.util.TaskDataExportOperation;
+import org.eclipse.mylyn.internal.tasks.ui.util.TaskDataSnapshotOperation;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
@@ -112,8 +111,8 @@ public class TaskListBackupManager implements IPropertyChangeListener {
} else {
- final TaskDataExportOperation backupJob = new TaskDataExportOperation(backupFolderPath, true, true, false,
- true, getBackupFileName(), new HashSet<AbstractTask>());
+ final TaskDataExportOperation backupJob = new TaskDataSnapshotOperation(backupFolderPath,
+ getBackupFileName());
IProgressService service = PlatformUI.getWorkbench().getProgressService();
try {
@@ -252,8 +251,8 @@ public class TaskListBackupManager implements IPropertyChangeListener {
public ExportJob(String destination, String filename) {
super(Messages.TaskListBackupManager_Scheduled_task_data_backup);
- backupJob = new TaskDataExportOperation(destination, true, true, false, true, filename,
- new HashSet<AbstractTask>());
+ backupJob = new TaskDataSnapshotOperation(destination, filename);
+
}
@Override
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 44d40b083..68e607069 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
@@ -12,40 +12,26 @@
package org.eclipse.mylyn.internal.tasks.ui.util;
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.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.context.core.ContextCore;
+import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.internal.commons.core.ZipFileUtil;
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
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.tasks.core.ITask;
/**
- * Job that performs exporting (copying or zipping) of the Task List data Assumes that check with user for overwrite
- * already done. Overwrites destination if exists!
+ * Zips task data up to specified directly and filename.
*
* @author Wesley Coelho
* @author Mik Kersten
@@ -58,244 +44,74 @@ public class TaskDataExportOperation implements IRunnableWithProgress {
private static final String EXPORT_JOB_LABEL = Messages.TaskDataExportOperation_exporting_task_data;
- private final boolean zip;
+ private static final Pattern excludeHidden = Pattern.compile("^\\."); //$NON-NLS-1$
- private final boolean exportTaskList;
-
- private final boolean exportActivationHistory;
-
- private final boolean exportTaskContexts;
+ private static final Pattern excludeBackup = Pattern.compile("backup\\z"); //$NON-NLS-1$
private final String destinationDirectory;
- private final String zipFileName;
-
- private File destZipFile = null;
-
- private final Collection<AbstractTask> tasks;
-
- private boolean exportAll = false;
-
- // List of files to add to the zip archive
- private final List<File> filesToZip = new ArrayList<File>();
-
- // Map of file paths used to avoid duplicates
- private final Map<String, String> filesToZipMap = new HashMap<String, String>();
+ private final String destinationFilename;
- /** export all data */
- public TaskDataExportOperation(String destinationDirectory, boolean zipIt, String zipFileName) {
- this.zipFileName = zipFileName;
- this.zip = zipIt;
+ public TaskDataExportOperation(String destinationDirectory, String destinationFilename) {
+ this.destinationFilename = destinationFilename;
this.destinationDirectory = destinationDirectory;
- this.tasks = Collections.emptySet();
- this.exportActivationHistory = true;
- this.exportTaskContexts = true;
- this.exportTaskList = true;
- this.exportAll = true;
- }
-
- /** export specified data */
- 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;
- this.exportActivationHistory = exportActivationHistory;
- this.exportTaskContexts = exportTaskContexts;
- this.destinationDirectory = destinationDirectory;
- this.tasks = taskContextsToExport;
}
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
+ monitor = Policy.monitorFor(monitor);
+ Set<File> filesToExport = new HashSet<File>();
- int totalWork = filesToZip.size();
- if (totalWork == 0) {
- totalWork = IProgressMonitor.UNKNOWN;
- }
- monitor.beginTask(EXPORT_JOB_LABEL, totalWork + 1);
+ selectFiles(filesToExport);
- Job.getJobManager().beginRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE, new SubProgressMonitor(monitor, 1));
- if (exportAll) {
- exportAll();
- } else {
- exportChosen();
- }
+ if (filesToExport.size() > 0) {
+ try {
+ monitor.beginTask(EXPORT_JOB_LABEL, filesToExport.size() + 1);
+
+ Job.getJobManager().beginRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE,
+ new SubProgressMonitor(monitor, 1));
+ File destZipFile = new File(destinationDirectory + File.separator + destinationFilename);
- 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", //$NON-NLS-1$
- e));
+ //TODO: append a (2) to the file?
+ if (destZipFile.exists()) {
+ destZipFile.delete();
}
+
+ ZipFileUtil.createZipFile(destZipFile, new ArrayList<File>(filesToExport), TasksUiPlugin.getDefault()
+ .getDataDirectory(), monitor);
+ } catch (Exception e) {
+ StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not perform export", //$NON-NLS-1$
+ e));
+ } finally {
+
+ Job.getJobManager().endRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE);
+ monitor.done();
}
- } finally {
- Job.getJobManager().endRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE);
- monitor.done();
}
}
- private void exportAll() {
+ protected void selectFiles(Set<File> filesToExport) {
+ Set<Pattern> exclusionPatterns = new HashSet<Pattern>();
+ exclusionPatterns.add(excludeHidden);
+ exclusionPatterns.add(excludeBackup);
String dataRoot = TasksUiPlugin.getDefault().getDataDirectory();
File dataFolder = new File(dataRoot);
- // add all files in dataRoot
for (File file : dataFolder.listFiles()) {
- filesToZip.add(file);
- }
- }
-
- private void exportChosen() {
- int jobSize = 1; // 1 for repositories.xml
- if (exportTaskList) {
- jobSize++;
- }
- if (exportActivationHistory) {
- jobSize++;
- }
- if (exportTaskContexts) {
- jobSize += tasks.size();
- }
-
- String sourceContextsPath = TasksUiPlugin.getDefault().getDataDirectory() + File.separator
- + ITasksCoreConstants.CONTEXTS_DIRECTORY;
- File contextsDirectory = new File(sourceContextsPath);
-
- // Task Repositories data file
- 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())); //$NON-NLS-1$
+ boolean exclude = false;
+ for (Pattern pattern : exclusionPatterns) {
+ if (pattern.matcher(file.getName()).find()) {
+ exclude = true;
+ break;
}
}
- }
-
- if (exportTaskList) {
- 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())); //$NON-NLS-1$
- }
- }
- }
-
- }
-
- if (exportActivationHistory) {
- try {
- File sourceActivationHistoryFile = new File(contextsDirectory,
- InteractionContextManager.CONTEXT_HISTORY_FILE_NAME
- + InteractionContextManager.CONTEXT_FILE_EXTENSION);
-
- if (sourceActivationHistoryFile.exists()) {
-
- File destActivationHistoryFile = new File(destinationDirectory + File.separator
- + InteractionContextManager.CONTEXT_HISTORY_FILE_NAME
- + InteractionContextManager.CONTEXT_FILE_EXTENSION);
-
- if (zip) {
- filesToZip.add(sourceActivationHistoryFile);
- } else if (!destActivationHistoryFile.equals(sourceActivationHistoryFile)) {
- if (destActivationHistoryFile.exists()) {
- destActivationHistoryFile.delete();
- }
- copy(sourceActivationHistoryFile, destActivationHistoryFile);
- }
- }
- } 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)); //$NON-NLS-1$
+ if (!exclude) {
+ filesToExport.add(file);
}
}
- if (exportTaskContexts) {
- // Prevent many repeated error messages
- boolean errorDisplayed = false;
- for (ITask task : tasks) {
-
- if (!ContextCore.getContextManager().hasContext(task.getHandleIdentifier())) {
- continue; // Tasks without a context have no file to
- // copy
- }
-
- File sourceTaskContextFile = ContextCorePlugin.getContextStore().getFileForContext(
- task.getHandleIdentifier());
-
- 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() + " -> " //$NON-NLS-1$ //$NON-NLS-2$
- + destTaskFile.getPath());
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- "Could not export one or more task context files", e)); //$NON-NLS-1$
- errorDisplayed = true;
- }
- }
- }
- }
}
- 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;
- }
+ protected File getSourceFolder() {
+ return new File(TasksUiPlugin.getDefault().getDataDirectory());
}
-
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataSnapshotOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataSnapshotOperation.java
new file mode 100644
index 000000000..227fc6072
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataSnapshotOperation.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.util;
+
+import java.io.File;
+import java.util.Set;
+
+/**
+ * @author Robert Elves
+ */
+public class TaskDataSnapshotOperation extends TaskDataExportOperation {
+
+ public TaskDataSnapshotOperation(String destinationDirectory, String destinationFilename) {
+ super(destinationDirectory, destinationFilename);
+ }
+
+ @Override
+ protected void selectFiles(Set<File> filesToExport) {
+
+ filesToExport.add(new File(getSourceFolder(), "tasks.xml.zip")); //$NON-NLS-1$
+ filesToExport.add(new File(getSourceFolder(), "repositories.xml.zip")); //$NON-NLS-1$
+ filesToExport.add(new File(getSourceFolder(), "contexts/activity.xml.zip")); //$NON-NLS-1$
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java
index af0998d15..6399d23d5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java
@@ -99,6 +99,8 @@ public class Messages extends NLS {
public static String TaskDataExportWizard_Export;
+ public static String TaskDataExportWizard_export_failed;
+
public static String TaskDataExportWizard_Task_context_files_already_exist_in_X;
public static String TaskDataExportWizard_The_task_activation_history_file_X_already_exists;
@@ -153,6 +155,8 @@ public class Messages extends NLS {
public static String TaskDataImportWizard_Overwrite_existing_file_;
+ public static String TaskDataImportWizard_task_data_import_failed;
+
public static String TaskDataImportWizardPage_Restore_tasks_from_history;
public static String TaskDataImportWizardPage_Browse_;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizard.java
index c8eafc3c9..a0284d17a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizard.java
@@ -19,10 +19,10 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.ui.TaskListBackupManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TaskDataExportOperation;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
@@ -53,7 +53,7 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
/**
* Finds or creates a dialog settings section that is used to make the dialog control settings persistent
*/
- public IDialogSettings getSettingsSection(IDialogSettings master) {
+ private IDialogSettings getSettingsSection(IDialogSettings master) {
IDialogSettings settings = master.getSection(SETTINGS_SECTION);
if (settings == null) {
settings = master.addNewSection(SETTINGS_SECTION);
@@ -64,7 +64,6 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
@Override
public void addPages() {
exportPage = new TaskDataExportWizardPage();
- exportPage.setWizard(this);
addPage(exportPage);
}
@@ -72,11 +71,6 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
// no initialization needed
}
- @Override
- public boolean canFinish() {
- return exportPage.isPageComplete();
- }
-
/**
* Called when the user clicks finish. Saves the task data. Waits until all overwrite decisions have been made
* before starting to save files. If any overwrite is canceled, no files are saved and the user must adjust the
@@ -88,7 +82,7 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
final File destZipFile = new File(destDir + File.separator + TaskListBackupManager.getBackupFileName());
- TaskDataExportOperation job = new TaskDataExportOperation(exportPage.getDestinationDirectory(), true,
+ TaskDataExportOperation job = new TaskDataExportOperation(exportPage.getDestinationDirectory(),
destZipFile.getName());
try {
@@ -99,9 +93,10 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
service.run(true, true, job);
}
} catch (InvocationTargetException e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not export files", e)); //$NON-NLS-1$
+ Status status = new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, e.getMessage(), e);
+ TasksUiInternal.logAndDisplayStatus(Messages.TaskDataExportWizard_export_failed, status);
} catch (InterruptedException e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not export files", e)); //$NON-NLS-1$
+ // user canceled
}
exportPage.saveSettings();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizardPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizardPage.java
index e747fe38c..04cf7e4f8 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizardPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataExportWizardPage.java
@@ -12,11 +12,9 @@
package org.eclipse.mylyn.internal.tasks.ui.wizards;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.ui.TaskListBackupManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.swt.SWT;
@@ -24,7 +22,6 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -39,9 +36,12 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
*
* @author Wesley Coelho
* @author Mik Kersten
+ * @author Rob Elves
*/
public class TaskDataExportWizardPage extends WizardPage {
+ private static final String PAGE_ID = "org.eclipse.mylyn.tasklist.exportPage"; //$NON-NLS-1$
+
private Button browseButton = null;
private Text destDirText = null;
@@ -52,36 +52,27 @@ public class TaskDataExportWizardPage extends WizardPage {
private final static String DEST_DIR_SETTING = "Destination directory setting"; //$NON-NLS-1$
public TaskDataExportWizardPage() {
- super(
- "org.eclipse.mylyn.tasklist.exportPage", Messages.TaskDataExportWizardPage_Export_Mylyn_Task_Data, AbstractUIPlugin.imageDescriptorFromPlugin( //$NON-NLS-1$
- TasksUiPlugin.ID_PLUGIN, "icons/wizban/banner-export.gif")); //$NON-NLS-1$
+ super(PAGE_ID);
setPageComplete(false);
- }
-
- @Override
- public String getName() {
- return Messages.TaskDataExportWizardPage_Export_Mylyn_Task_Data;
+ setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(TasksUiPlugin.ID_PLUGIN,
+ "icons/wizban/banner-export.gif")); //$NON-NLS-1$
+ setTitle(Messages.TaskDataExportWizardPage_Export_Mylyn_Task_Data);
}
/**
* Create the widgets on the page
*/
public void createControl(Composite parent) {
- try {
- Composite container = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, false);
- container.setLayout(layout);
- createExportDirectoryControl(container);
-
- initSettings();
-
- Dialog.applyDialogFont(container);
- setControl(container);
- setPageComplete(validate());
- } catch (RuntimeException e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- "Could not create export wizard page", e)); //$NON-NLS-1$
- }
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, false);
+ container.setLayout(layout);
+ createExportDirectoryControl(container);
+
+ initSettings();
+
+ Dialog.applyDialogFont(container);
+ setControl(container);
+ setPageComplete(validate());
}
/**
@@ -118,11 +109,11 @@ public class TaskDataExportWizardPage extends WizardPage {
String dir = destDirText.getText();
dialog.setFilterPath(dir);
dir = dialog.open();
- controlChanged();
if (dir == null || dir.equals("")) { //$NON-NLS-1$
return;
}
destDirText.setText(dir);
+ controlChanged();
}
});
}
@@ -152,25 +143,6 @@ public class TaskDataExportWizardPage extends WizardPage {
settings.put(SETTINGS_SAVED, SETTINGS_SAVED);
}
- /** Convenience method for creating a new checkbox */
- protected Button createCheckBox(Composite parent, String text) {
- Button newButton = new Button(parent, SWT.CHECK);
- newButton.setText(text);
-
- newButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- controlChanged();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- // No action required
- }
- });
-
- return newButton;
- }
-
/** Called to indicate that a control's value has changed */
public void controlChanged() {
setPageComplete(validate());
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizard.java
index 7ea9c95df..a0273939d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizard.java
@@ -13,7 +13,6 @@ package org.eclipse.mylyn.internal.tasks.ui.wizards;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
@@ -29,21 +28,21 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.mylyn.commons.core.CoreUtil;
-import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.commons.core.ZipFileUtil;
+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonsUiUtil;
+import org.eclipse.mylyn.internal.provisional.commons.ui.ICoreRunnable;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.internal.tasks.core.externalization.AbstractExternalizationParticipant;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
/**
* @author Rob Elves
@@ -63,7 +62,7 @@ public class TaskDataImportWizard extends Wizard implements IImportWizard {
/**
* Finds or creates a dialog settings section that is used to make the dialog control settings persistent
*/
- public IDialogSettings getSettingsSection(IDialogSettings master) {
+ private IDialogSettings getSettingsSection(IDialogSettings master) {
IDialogSettings settings = master.getSection("org.eclipse.mylyn.tasklist.ui.importWizard"); //$NON-NLS-1$
if (settings == null) {
settings = master.addNewSection("org.eclipse.mylyn.tasklist.ui.importWizard"); //$NON-NLS-1$
@@ -93,7 +92,7 @@ public class TaskDataImportWizard extends Wizard implements IImportWizard {
TasksUi.getTaskActivityManager().deactivateTask(TasksUi.getTaskActivityManager().getActiveTask());
String sourceZip = importPage.getSourceZipFile();
- File sourceZipFile = new File(sourceZip);
+ final File sourceZipFile = new File(sourceZip);
if (!sourceZipFile.exists()) {
MessageDialog.openError(getShell(), Messages.TaskDataImportWizard_File_not_found, sourceZipFile.toString()
@@ -105,51 +104,31 @@ public class TaskDataImportWizard extends Wizard implements IImportWizard {
return false;
}
- Enumeration<? extends ZipEntry> entries;
- ZipFile zipFile;
- boolean restoreM2Tasklist = false;
- int numEntries = 0;
-
- try {
- zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
- entries = zipFile.entries();
- while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
- if (entry.getName().startsWith(ITasksCoreConstants.OLD_TASK_LIST_FILE)) {
- restoreM2Tasklist = true;
- }
- numEntries++;
- }
- } catch (IOException e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not import files", e)); //$NON-NLS-1$
- return false;
- }
-
- FileCopyJob job = new FileCopyJob(sourceZipFile, numEntries);
- job.setRestoreM2Tasklist(restoreM2Tasklist);
try {
if (getContainer() != null) {
- getContainer().run(true, true, job);
+ CommonsUiUtil.run(getContainer(), new FileCopyJob(sourceZipFile));
} else {
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- service.run(true, true, job);
+ CommonsUiUtil.busyCursorWhile(new FileCopyJob(sourceZipFile));
}
- } catch (InvocationTargetException e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not import files", e)); //$NON-NLS-1$
- } catch (InterruptedException e) {
- // User canceled
+
+ importPage.saveSettings();
+ } catch (CoreException e) {
+ Status status = new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind(
+ "Problems encountered importing task data: {0}", e.getMessage()), e); //$NON-NLS-1$
+ TasksUiInternal.logAndDisplayStatus(Messages.TaskDataImportWizard_task_data_import_failed, status);
+ } catch (OperationCanceledException e) {
+ // canceled
}
- importPage.saveSettings();
return true;
}
/** Job that performs the file copying and zipping */
- class FileCopyJob implements IRunnableWithProgress {
+ class FileCopyJob implements ICoreRunnable {
private static final String PREFIX_BACKUP = ".backup-"; //$NON-NLS-1$
- private/*static*/final String JOB_LABEL = Messages.TaskDataImportWizard_Importing_Data;
+ private final String JOB_LABEL = Messages.TaskDataImportWizard_Importing_Data;
private File sourceZipFile = null;
@@ -157,63 +136,75 @@ public class TaskDataImportWizard extends Wizard implements IImportWizard {
private boolean restoreM2Tasklist = false;
- public FileCopyJob(File sourceZipFile, int numEntries) {
+ public FileCopyJob(File sourceZipFile) {
this.sourceZipFile = sourceZipFile;
- this.numEntries = numEntries;
}
- public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ public void run(final IProgressMonitor monitor) throws CoreException {
- // always a zip source since post 1.0.1
try {
- monitor.beginTask(JOB_LABEL, numEntries);
- Job.getJobManager().beginRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE, monitor);
- if (!sourceZipFile.exists()) {
- throw new InvocationTargetException(new IOException("Source file does not exist.")); //$NON-NLS-1$
- }
+ checkZipFile();
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
+ if (numEntries > 0) {
+
+ monitor.beginTask(JOB_LABEL, numEntries);
+ Job.getJobManager().beginRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE, monitor);
- ZipFileUtil.unzipFiles(sourceZipFile, TasksUiPlugin.getDefault().getDataDirectory(), monitor);
+ if (monitor.isCanceled()) {
+ return;
+ }
- if (restoreM2Tasklist) {
+ ZipFileUtil.unzipFiles(sourceZipFile, TasksUiPlugin.getDefault().getDataDirectory(), monitor);
- SimpleDateFormat format = new SimpleDateFormat(ITasksCoreConstants.FILENAME_TIMESTAMP_FORMAT,
- Locale.ENGLISH);
- String date = format.format(new Date());
+ if (restoreM2Tasklist) {
- File taskListFile = new File(TasksUiPlugin.getDefault().getDataDirectory(),
- ITasksCoreConstants.DEFAULT_TASK_LIST_FILE);
- if (taskListFile.exists()) {
- taskListFile.renameTo(new File(taskListFile.getParentFile(), taskListFile.getName()
- + PREFIX_BACKUP + date));
- }
+ SimpleDateFormat format = new SimpleDateFormat(ITasksCoreConstants.FILENAME_TIMESTAMP_FORMAT,
+ Locale.ENGLISH);
+ String date = format.format(new Date());
- File taskListFileSnapshot = new File(TasksUiPlugin.getDefault().getDataDirectory(),
- AbstractExternalizationParticipant.SNAPSHOT_PREFIX
- + ITasksCoreConstants.DEFAULT_TASK_LIST_FILE);
- if (taskListFileSnapshot.exists()) {
- taskListFileSnapshot.renameTo(new File(taskListFile.getParentFile(),
- taskListFileSnapshot.getName() + PREFIX_BACKUP + date));
- }
+ File taskListFile = new File(TasksUiPlugin.getDefault().getDataDirectory(),
+ ITasksCoreConstants.DEFAULT_TASK_LIST_FILE);
+ if (taskListFile.exists()) {
+ taskListFile.renameTo(new File(taskListFile.getParentFile(), taskListFile.getName()
+ + PREFIX_BACKUP + date));
+ }
+ File taskListFileSnapshot = new File(TasksUiPlugin.getDefault().getDataDirectory(),
+ AbstractExternalizationParticipant.SNAPSHOT_PREFIX
+ + ITasksCoreConstants.DEFAULT_TASK_LIST_FILE);
+ if (taskListFileSnapshot.exists()) {
+ taskListFileSnapshot.renameTo(new File(taskListFile.getParentFile(),
+ taskListFileSnapshot.getName() + PREFIX_BACKUP + date));
+ }
+
+ }
+ readTaskListData();
}
- readTaskListData();
} catch (IOException e) {
- throw new InvocationTargetException(e);
+ Status status = new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, e.getMessage(), e);
+ throw new CoreException(status);
} finally {
Job.getJobManager().endRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE);
monitor.done();
}
- return;
-
}
- public void setRestoreM2Tasklist(boolean restoreM2Tasklist) {
- this.restoreM2Tasklist = restoreM2Tasklist;
+ private void checkZipFile() throws IOException {
+ Enumeration<? extends ZipEntry> entries;
+ ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
+ try {
+ entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ ZipEntry entry = entries.nextElement();
+ if (entry.getName().startsWith(ITasksCoreConstants.OLD_TASK_LIST_FILE)) {
+ restoreM2Tasklist = true;
+ }
+ numEntries++;
+ }
+ } finally {
+ zipFile.close();
+ }
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizardPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizardPage.java
index 9ffd2c56f..721408dd2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizardPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskDataImportWizardPage.java
@@ -15,14 +15,11 @@ import java.io.File;
import java.text.DateFormat;
import java.util.SortedMap;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.swt.SWT;
@@ -39,7 +36,6 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* Wizard Page for the Task Data Import Wizard
@@ -70,9 +66,7 @@ public class TaskDataImportWizardPage extends WizardPage {
private final static String IMPORT_BACKUPMETHOD_SETTING = Messages.TaskDataImportWizardPage_Import_method_backup;
public TaskDataImportWizardPage() {
- super(
- "org.eclipse.mylyn.tasklist.importPage", Messages.TaskDataImportWizardPage_Import_Task_Data, AbstractUIPlugin.imageDescriptorFromPlugin( //$NON-NLS-1$
- TasksUiPlugin.ID_PLUGIN, "icons/wizban/banner-import.gif")); //$NON-NLS-1$
+ super("org.eclipse.mylyn.tasklist.importPage"); //$NON-NLS-1$
setPageComplete(false);
setMessage(Messages.TaskDataImportWizardPage_Importing_overwrites_current_tasks_and_repositories,
IMessageProvider.WARNING);
@@ -81,22 +75,17 @@ public class TaskDataImportWizardPage extends WizardPage {
}
public void createControl(Composite parent) {
- try {
- Composite container = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(3, false);
- layout.verticalSpacing = 15;
- container.setLayout(layout);
- createImportFromZipControl(container);
- createImportFromBackupControl(container);
- addRadioListeners();
- initSettings();
- Dialog.applyDialogFont(container);
- setControl(container);
- setPageComplete(validate());
- } catch (RuntimeException e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
- Messages.TaskDataImportWizardPage_Could_not_create_import_wizard_page, e));
- }
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(3, false);
+ layout.verticalSpacing = 15;
+ container.setLayout(layout);
+ createImportFromZipControl(container);
+ createImportFromBackupControl(container);
+ addRadioListeners();
+ initSettings();
+ Dialog.applyDialogFont(container);
+ setControl(container);
+ setPageComplete(validate());
}
private void addRadioListeners() {
@@ -224,25 +213,6 @@ public class TaskDataImportWizardPage extends WizardPage {
settings.put(SETTINGS_SAVED, SETTINGS_SAVED);
}
- /** Convenience method for creating a new checkbox */
- protected Button createCheckBox(Composite parent, String text) {
- Button newButton = new Button(parent, SWT.CHECK);
- newButton.setText(text);
-
- newButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- controlChanged();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- // No action required
- }
- });
-
- return newButton;
- }
-
/** Called to indicate that a control's value has changed */
public void controlChanged() {
setPageComplete(validate());
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties
index bd1b2d415..5c4a9584e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties
@@ -47,6 +47,7 @@ TaskAttachmentWizard_Screenshot=Screenshot
TaskDataExportWizard_Confirm_File_Replace=Confirm File Replace
TaskDataExportWizard_Export=Export
+TaskDataExportWizard_export_failed=Export Failed
TaskDataExportWizard_Task_context_files_already_exist_in_X=Task context files already exist in {0}. Do you want to overwrite them?
TaskDataExportWizard_The_task_activation_history_file_X_already_exists=The task activation history file {0} already exists. Do you want to overwrite it?
TaskDataExportWizard_The_task_list_file_X_already_exists=The task list file {0} already exists. Do you want to overwrite it?
@@ -75,6 +76,7 @@ TaskDataImportWizard_Import=Import
TaskDataImportWizard_Import_Error=Import Error: Please retry importing or use alternate source
TaskDataImportWizard_Importing_Data=Importing Data
TaskDataImportWizard_Overwrite_existing_file_=Overwrite existing file?\n
+TaskDataImportWizard_task_data_import_failed=Task Data import failed
TaskDataImportWizardPage_Browse_=Browse...
TaskDataImportWizardPage_From_snapshot=From snapshot

Back to the top