Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-12-10 03:37:47 +0000
committermkersten2005-12-10 03:37:47 +0000
commitd521af257a07fb9dabe2dcd3820e458458d5b5f9 (patch)
treefd9046921d6bd6bc52ba2a873c9b2d82f05c6e51
parent8544ffc58c3a40482ba93e2508353554b10b4f27 (diff)
downloadorg.eclipse.mylyn.tasks-d521af257a07fb9dabe2dcd3820e458458d5b5f9.tar.gz
org.eclipse.mylyn.tasks-d521af257a07fb9dabe2dcd3820e458458d5b5f9.tar.xz
org.eclipse.mylyn.tasks-d521af257a07fb9dabe2dcd3820e458458d5b5f9.zip
Progress on: fix schitzophrenia between task context paths and handle identifiers
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskDataExportTest.java14
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java164
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java28
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListSaveManager.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/planner/internal/InProgressTaskCollector.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java29
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DeleteAction.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/RemoveFromCategoryAction.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizard.java37
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizardPage.java176
13 files changed, 251 insertions, 235 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
index 03d789313..47510e222 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
@@ -79,7 +79,7 @@ public class BugzillaTaskHandler implements ITaskHandler {
// task.removeReport();
MylarTaskListPlugin.getTaskListManager().deleteTask(task);
- MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier(), task.getContextPath());
+ MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier());
IWorkbenchPage page = MylarTaskListPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
// if we couldn't get the page, get out of here
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskDataExportTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskDataExportTest.java
index 1e76877b2..78a2f03f5 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskDataExportTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskDataExportTest.java
@@ -47,15 +47,16 @@ public class TaskDataExportTest extends TestCase{
//Create a task and context with an interaction event to be saved
task1 = new Task(MylarTaskListPlugin.getTaskListManager().genUniqueTaskHandle(), "Export Test Task", true);
manager.moveToRoot(task1);
- MylarContext mockContext = MylarPlugin.getContextManager().loadContext(task1.getHandleIdentifier(), task1.getContextPath());
+ MylarContext mockContext = MylarPlugin.getContextManager().loadContext(task1.getHandleIdentifier());
InteractionEvent event = new InteractionEvent(InteractionEvent.Kind.EDIT,"structureKind","handle","originId");
mockContext.parseEvent(event);
MylarPlugin.getContextManager().contextActivated(mockContext);
//Save the context file and check that it exists
- MylarPlugin.getContextManager().saveContext(mockContext.getId(), task1.getContextPath());
- File taskFile = new File(MylarPlugin.getDefault().getDataDirectory() + File.separator + task1.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION);
- assertTrue(MylarPlugin.getContextManager().hasContext(task1.getContextPath()));
+ MylarPlugin.getContextManager().saveContext(mockContext.getId());
+ File taskFile = MylarPlugin.getContextManager().getFileForContext(task1.getHandleIdentifier());
+// new File(MylarPlugin.getDefault().getDataDirectory() + File.separator + task1.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION);
+ assertTrue(MylarPlugin.getContextManager().hasContext(task1.getHandleIdentifier()));
assertTrue(taskFile.exists());
}
@@ -68,7 +69,7 @@ public class TaskDataExportTest extends TestCase{
//Check that the task list file was exported
File destZipFile = new File(destinationDir + File.separator
- + TaskDataExportWizard.ZIP_FILE_NAME);
+ + TaskDataExportWizard.getZipFileName());
assertTrue(destZipFile.exists());
}
@@ -92,7 +93,8 @@ public class TaskDataExportTest extends TestCase{
assertTrue(destActivationHistoryFile.exists());
//Check that the task context file created in setUp() was exported
- File destTaskContextFile = new File(destinationDir + File.separator + task1.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION);
+ File destTaskContextFile = MylarPlugin.getContextManager().getFileForContext(task1.getHandleIdentifier());
+// File destTaskContextFile = new File(destinationDir + File.separator + task1.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION);
assertTrue(destTaskContextFile.exists());
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
index 5264e53b0..ccdbd92a6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
@@ -20,92 +20,85 @@ import org.eclipse.mylar.tasklist.ui.ITaskListElement;
/**
* @author Mik Kersten
-
+ *
*/
public interface ITask extends ITaskListElement {
-
- public abstract String getHandleIdentifier();
-
- public abstract ITask getParent();
-
- public abstract void setParent(ITask parent);
- public abstract boolean isActive();
-
- public abstract void setActive(boolean active);
+ public abstract String getHandleIdentifier();
+
+ public abstract ITask getParent();
+
+ public abstract void setParent(ITask parent);
+
+ public abstract boolean isActive();
+
+ public abstract void setActive(boolean active);
+
+ public abstract void addPlan(String plan);
+
+ public List<String> getPlans();
+
+ public abstract void setCompleted(boolean completed);
+
+ public abstract List<String> getRelatedLinks();
+
+ public abstract void setRelatedLinks(List<String> relatedLinks);
+
+ public abstract void addLink(String url);
+
+ public abstract void removeLink(String url);
- /**
- * TODO: consider changing to java.net.URL
- */
- public abstract String getContextPath();
-
- public abstract void setContextPath(String path);
-
- public abstract void addPlan(String plan);
-
- public List<String> getPlans();
-
- public abstract void setCompleted(boolean completed);
-
- public abstract List<String> getRelatedLinks();
-
- public abstract void setRelatedLinks(List<String> relatedLinks);
-
- public abstract void addLink(String url);
-
- public abstract void removeLink(String url);
-
public abstract void setIssueReportURL(String url);
-
+
public abstract String getIssueReportURL();
-
- public abstract String getNotes();
-
- public abstract void setNotes(String notes);
-
- /**
- * @param time in milliseconds
- */
- public abstract void setElapsedTime(long elapsed);
-
- /**
- * TODO: change to millis
- */
- public abstract int getEstimateTimeHours();
-
- public abstract void setEstimatedTimeHours(int estimated);
-
- public abstract List<ITask> getChildren();
-
- public abstract void addSubTask(ITask t);
-
- public abstract void removeSubTask(ITask t);
-
- public abstract String getDeleteConfirmationMessage();
-
- public abstract void setPriority(String priority);
-
- public abstract void setCategory(ITaskCategory cat);
-
- /**
- * @return null if root task
- */
- public abstract ITaskCategory getCategory();
-
- public abstract long getElapsedTime();
-
+
+ public abstract String getNotes();
+
+ public abstract void setNotes(String notes);
+
+ /**
+ * @param time in milliseconds
+ */
+ public abstract void setElapsedTime(long elapsed);
+
+ /**
+ * TODO: change to millis
+ */
+ public abstract int getEstimateTimeHours();
+
+ public abstract void setEstimatedTimeHours(int estimated);
+
+ public abstract List<ITask> getChildren();
+
+ public abstract void addSubTask(ITask t);
+
+ public abstract void removeSubTask(ITask t);
+
+ public abstract String getDeleteConfirmationMessage();
+
+ public abstract void setPriority(String priority);
+
+ public abstract void setCategory(ITaskCategory cat);
+
+ /**
+ * @return null if root task
+ */
+ public abstract ITaskCategory getCategory();
+
+ public abstract long getElapsedTime();
+
public abstract Date getCompletionDate();
-
+
public abstract void setCompletionDate(Date date);
-
+
public abstract Date getCreationDate();
-
+
public abstract void setCreationDate(Date date);
public abstract void setReminderDate(Date date);
-
+
public abstract Date getReminderDate();
-
+
/**
* TODO: move
*/
@@ -122,25 +115,6 @@ public interface ITask extends ITaskListElement {
public abstract boolean participatesInTaskHandles();
}
-//abstract void internalSetCategory(TaskCategory category);
-
-//public abstract void setEndDate(String date);
-//public abstract void setCreationDate(String date);
-//public abstract void setReminderDate(String date);
-
-//public abstract String getElapsedTimeForDisplay();
-
-///**
-// * @deprecated
-// */
-//public abstract String getEndDateForPersistance();
-
-///**
-// * @deprecated
-// */
-//public abstract String getReminderDateString(boolean forDisplay);
-
-///**
-// * @deprecated
-// */
-//public abstract String getCreationDateForPersistance();
+//public abstract String getRemoteContextPath();
+//
+// public abstract void setRemoteContextPath(String path);
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 a2692f2a8..aeb99df8d 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
@@ -207,17 +207,17 @@ public class MylarTaskListPlugin extends AbstractUIPlugin implements IStartup {
private static ITaskActivityListener CONTEXT_MANAGER_TASK_LISTENER = new ITaskActivityListener() {
public void taskActivated(ITask task) {
- MylarPlugin.getContextManager().contextActivated(task.getHandleIdentifier(), task.getContextPath());
+ MylarPlugin.getContextManager().contextActivated(task.getHandleIdentifier());//, task.getContextPath());
}
public void tasksActivated(List<ITask> tasks) {
for (ITask task : tasks) {
- MylarPlugin.getContextManager().contextActivated(task.getHandleIdentifier(), task.getContextPath());
+ MylarPlugin.getContextManager().contextActivated(task.getHandleIdentifier());//, task.getContextPath());
}
}
public void taskDeactivated(ITask task) {
- MylarPlugin.getContextManager().contextDeactivated(task.getHandleIdentifier(), task.getContextPath());
+ MylarPlugin.getContextManager().contextDeactivated(task.getHandleIdentifier());//, task.getContextPath());
}
public void tasklistRead() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java
index e409b2dee..a2c07b9cd 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java
@@ -141,7 +141,7 @@ public class DelegatingLocalTaskExternalizer implements ITaskListExternalizer {
public Element createTaskElement(ITask task, Document doc, Element parent) {
Element node = doc.createElement(getTaskTagName());
- node.setAttribute(PATH, task.getContextPath());
+// node.setAttribute(PATH, task.getRemoteContextPath());
node.setAttribute(LABEL, task.getDescription(false));
node.setAttribute(HANDLE, task.getHandleIdentifier());
node.setAttribute(PRIORITY, task.getPriority());
@@ -262,11 +262,11 @@ public class DelegatingLocalTaskExternalizer implements ITaskListExternalizer {
} else {
task.setPriority(DEFAULT_PRIORITY);
}
- if (element.hasAttribute(PATH)) {
- task.setContextPath(element.getAttribute(PATH));
- } else {
- task.setContextPath(task.getHandleIdentifier());
- }
+// if (element.hasAttribute(PATH)) {
+// task.setRemoteContextPath(element.getAttribute(PATH));
+// } else {
+// task.setRemoteContextPath(task.getHandleIdentifier());
+// }
if (element.getAttribute(ACTIVE).compareTo(TRUE) == 0) {
task.setActive(true);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java
index 138601756..beed1e6de 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java
@@ -46,7 +46,7 @@ public class Task implements ITask {
private boolean hasReminded = false;
- private String contextPath;
+// private String contextPath;
private String label;
@@ -88,22 +88,22 @@ public class Task implements ITask {
return label;
}
- public String getContextPath() {
- return contextPath;
- }
-
- public void setContextPath(String path) {
- if (path.startsWith(".mylar")) { // HACK: remove this
- this.contextPath = path.substring(path.lastIndexOf('/') + 1, path.length());
- } else if (!path.equals("")) {
- this.contextPath = path;
- }
- }
+// public String getRemoteContextPath() {
+// return contextPath;
+// }
+//
+// public void setRemoteContextPath(String path) {
+// if (path.startsWith(".mylar")) { // HACK: remove this
+// this.contextPath = path.substring(path.lastIndexOf('/') + 1, path.length());
+// } else if (!path.equals("")) {
+// this.contextPath = path;
+// }
+// }
public Task(String handle, String label, boolean newTask) {
this.handle = handle;
this.label = label;
- this.contextPath = handle;
+// this.contextPath = handle;
if (newTask) {
creationDate = new Date();
}
@@ -376,7 +376,7 @@ public class Task implements ITask {
if (isActive()) {
return TaskListImages.getImage(TaskListImages.TASK_ACTIVE);
} else {
- if (MylarPlugin.getContextManager().hasContext(getContextPath())) {
+ if (MylarPlugin.getContextManager().hasContext(handle)) {
return TaskListImages.getImage(TaskListImages.TASK_INACTIVE_CONTEXT);
} else {
return TaskListImages.getImage(TaskListImages.TASK_INACTIVE);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListSaveManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListSaveManager.java
index 712597c14..d32aad103 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListSaveManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListSaveManager.java
@@ -67,7 +67,15 @@ public class TaskListSaveManager implements ITaskActivityListener, DisposeListen
if (MylarTaskListPlugin.getDefault() != null) {
MylarTaskListPlugin.getTaskListManager().saveTaskList();
for (ITask task : MylarTaskListPlugin.getTaskListManager().getTaskList().getActiveTasks()) {
- MylarPlugin.getContextManager().saveContext(task.getHandleIdentifier(), task.getContextPath());
+// String path = task.getContextPath();
+// File file = MylarPlugin.getContextManager().getFileForContext(task.getContextPath());
+// System.err.println(">>> canWrite: " + file.canWrite());
+// if (!file.canWrite()) {
+// ErrorLogger.fail(new Exception(), "could not write context path, resetting: " + path, true);
+// task.setContextPath(task.getHandleIdentifier());
+// path = task.getHandleIdentifier();
+// }
+ MylarPlugin.getContextManager().saveContext(task.getHandleIdentifier());//, path);
}
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/planner/internal/InProgressTaskCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/planner/internal/InProgressTaskCollector.java
index 50faf0c91..c9e854a44 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/planner/internal/InProgressTaskCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/planner/internal/InProgressTaskCollector.java
@@ -38,7 +38,7 @@ public class InProgressTaskCollector implements ITasksCollector {
}
protected boolean hasActivitySince(ITask task, Date startDate){
- IMylarContext mylarContext = MylarPlugin.getContextManager().loadContext(task.getHandleIdentifier(),task.getContextPath());
+ IMylarContext mylarContext = MylarPlugin.getContextManager().loadContext(task.getHandleIdentifier());//,task.getContextPath());
if (mylarContext != null){
List<InteractionEvent> events = mylarContext.getInteractionHistory();
if (events.size() > 0){
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java
index ccf8610eb..09b7e1ef0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java
@@ -11,6 +11,7 @@
package org.eclipse.mylar.tasklist.ui;
+import java.io.File;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.List;
@@ -18,7 +19,6 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylar.core.MylarPlugin;
-import org.eclipse.mylar.core.internal.MylarContextManager;
import org.eclipse.mylar.core.util.DateUtil;
import org.eclipse.mylar.core.util.ErrorLogger;
import org.eclipse.mylar.tasklist.ITask;
@@ -196,12 +196,12 @@ public class TaskInfoEditor extends EditorPart {
// }
// }
// "<MylarDir>/" + res + ".xml"
- String path = pathText.getText();
- path = path.substring(path.indexOf('/') + 1, path.lastIndexOf('.'));
- task.setContextPath(path);
- if (datePicker != null && datePicker.getDate() != null) {
- task.setReminderDate(datePicker.getDate().getTime());
- }
+// String path = pathText.getText();
+// path = path.substring(path.indexOf('/') + 1, path.lastIndexOf('.'));
+// task.setContextPath(path);
+// if (datePicker != null && datePicker.getDate() != null) {
+// task.setReminderDate(datePicker.getDate().getTime());
+// }
refreshTaskListView(task);
MylarTaskListPlugin.getTaskListManager().notifyTaskChanged(task);
markDirty(false);
@@ -557,12 +557,15 @@ public class TaskInfoEditor extends EditorPart {
Label l2 = toolkit.createLabel(container, "Task context file:");
l2.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- String contextPath = MylarPlugin.getDefault().getDataDirectory()
- + '/' + task.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION;
- pathText = toolkit.createText(container, contextPath, SWT.BORDER);
- pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- pathText.setEditable(false);
- pathText.setEnabled(false);
+ File contextFile = MylarPlugin.getContextManager().getFileForContext(task.getHandleIdentifier());
+// String contextPath = MylarPlugin.getDefault().getDataDirectory()
+// + '/' + task.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION;
+ if (contextFile != null) {
+ pathText = toolkit.createText(container, contextFile.getAbsolutePath(), SWT.BORDER);
+ pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ pathText.setEditable(false);
+ pathText.setEnabled(false);
+ }
// browse = toolkit.createButton(container, "Change", SWT.PUSH | SWT.CENTER);
// if (task.isActive()) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DeleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DeleteAction.java
index 225d8f57f..9452bdaf7 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DeleteAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DeleteAction.java
@@ -65,7 +65,7 @@ public class DeleteAction extends Action {
}
MylarTaskListPlugin.getTaskListManager().deleteTask(task);
- MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier(), task.getContextPath());
+ MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier());//, task.getContextPath());
IWorkbenchPage page = MylarTaskListPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page == null) {
@@ -85,7 +85,7 @@ public class DeleteAction extends Action {
TaskCategory cat = (TaskCategory) selectedObject;
for (ITask task : cat.getChildren()) {
- MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier(), task.getContextPath());
+ MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier());//, task.getContextPath());
IWorkbenchPage page = MylarTaskListPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page != null) {
try {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/RemoveFromCategoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/RemoveFromCategoryAction.java
index 9cc8d650f..c4aa9b2f9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/RemoveFromCategoryAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/RemoveFromCategoryAction.java
@@ -75,7 +75,7 @@ public class RemoveFromCategoryAction extends Action {
return;
MylarTaskListPlugin.getTaskListManager().deleteTask(task);
- MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier(), task.getContextPath());
+ MylarPlugin.getContextManager().contextDeleted(task.getHandleIdentifier());//, task.getContextPath());
}
IWorkbenchPage page = MylarTaskListPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizard.java
index 1aa5c837c..8111f9939 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizard.java
@@ -7,9 +7,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -36,6 +39,7 @@ import org.eclipse.ui.progress.IProgressService;
* a single page: TaskDataExportWizardPage
*
* @author Wesley Coelho
+ * @author Mik Kersten
*/
public class TaskDataExportWizard extends Wizard implements IExportWizard {
@@ -45,12 +49,23 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
*/
private final static String SETTINGS_SECTION = "org.eclipse.mylar.tasklist.ui.exportWizard";
- public final static String ZIP_FILE_NAME = TaskDataExportWizardPage.ZIP_FILE_NAME;
+ private final static String ZIP_FILE_PREFIX = "mylardata";
+
+ private final static String ZIP_FILE_EXTENSION = ".zip";
+
+// public final static String ZIP_FILE_NAME = TaskDataExportWizardPage.ZIP_FILE_NAME;
private final static String WINDOW_TITLE = "Export";
private TaskDataExportWizardPage exportPage = null;
+ public static String getZipFileName() {
+ String fomratString = "yyyy-MM-dd";
+ SimpleDateFormat format = new SimpleDateFormat(fomratString, Locale.ENGLISH);
+ String date = format.format(new Date());
+ return ZIP_FILE_PREFIX + "-" + date + ZIP_FILE_EXTENSION;
+ }
+
public TaskDataExportWizard() {
IDialogSettings masterSettings = MylarTaskListPlugin.getDefault().getDialogSettings();
setDialogSettings(getSettingsSection(masterSettings));
@@ -107,7 +122,7 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
final File destTaskListFile = new File(destDir + File.separator + MylarTaskListPlugin.DEFAULT_TASK_LIST_FILE);
final File destActivationHistoryFile = new File(destDir + File.separator + MylarContextManager.CONTEXT_HISTORY_FILE_NAME
+ MylarContextManager.CONTEXT_FILE_EXTENSION);
- final File destZipFile = new File(destDir + File.separator + ZIP_FILE_NAME);
+ final File destZipFile = new File(destDir + File.separator + getZipFileName());
// Prompt the user to confirm if ANY of the save operations will cause
// an overwrite
@@ -137,7 +152,8 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
if (exportPage.exportTaskContexts()) {
for (ITask task : getAllTasks()) {
- File destTaskFile = new File(destDir + File.separator + task.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION);
+ File contextFile = MylarPlugin.getContextManager().getFileForContext(task.getHandleIdentifier());
+ File destTaskFile = new File(destDir + File.separator + contextFile.getName());
if (destTaskFile.exists()) {
if (!MessageDialog.openConfirm(getShell(), "Confirm File Replace", "Task context files already exist in " + destDir
+ ". Do you want to overwrite them?")) {
@@ -250,19 +266,22 @@ public class TaskDataExportWizard extends Wizard implements IExportWizard {
// messages
for (ITask task : tasks) {
- if (!MylarPlugin.getContextManager().hasContext(task.getContextPath())) {
+ if (!MylarPlugin.getContextManager().hasContext(task.getHandleIdentifier())) {
continue; // Tasks without a context have no file to
// copy
}
- File destTaskFile = new File(destinationDirectory + File.separator + task.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION);
- File sourceTaskFile = new File(MylarPlugin.getDefault().getDataDirectory() + File.separator + task.getContextPath()
- + MylarContextManager.CONTEXT_FILE_EXTENSION);
+ File contextFile = MylarPlugin.getContextManager().getFileForContext(task.getHandleIdentifier());
+
+ File destTaskFile = new File(destinationDirectory + File.separator + contextFile.getName());
+ File sourceTaskFile = contextFile;
+// new File(MylarPlugin.getDefault().getDataDirectory() + File.separator + task.getContextPath()
+// + MylarContextManager.CONTEXT_FILE_EXTENSION);
if (zip) {
- if (!filesToZipMap.containsKey(task.getContextPath())) {
+ if (!filesToZipMap.containsKey(task.getHandleIdentifier())) {
filesToZip.add(sourceTaskFile);
- filesToZipMap.put(task.getContextPath(), null);
+ filesToZipMap.put(task.getHandleIdentifier(), null);
}
} else {
if (!copy(sourceTaskFile, destTaskFile) && !errorDisplayed) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizardPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizardPage.java
index f70492d65..60038998b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizardPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/TaskDataExportWizardPage.java
@@ -22,41 +22,53 @@ import org.eclipse.swt.widgets.Text;
* Wizard Page for the Task Data Export Wizard
*
* @author Wesley Coelho
+ * @author Mik Kersten
*/
public class TaskDataExportWizardPage extends WizardPage {
protected final static String PAGE_TITLE = "Export Mylar Task Data";
+
public final static String PAGE_NAME = PAGE_TITLE;
- public final static String ZIP_FILE_NAME = "MylarTaskData.zip";
-
- //Control fields
+
private Button taskListCheckBox = null;
+
private Button taskActivationHistoryCheckBox = null;
+
private Button taskContextsCheckBox = null;
+
private Button zipCheckBox = null;
+
private Button browseButton = null;
- private Text destDirText = null;
+
+ private Text destDirText = null;
+
private Button overwriteCheckBox = null;
-
- //Key values for the dialog settings object
+
+ // Key values for the dialog settings object
private final static String SETTINGS_SAVED = "Settings saved";
+
private final static String TASKLIST_SETTING = "TaskList setting";
+
private final static String ACTIVATION_HISTORY_SETTING = "Activation history setting";
+
private final static String CONTEXTS_SETTING = "Contexts setting";
+
private final static String DEST_DIR_SETTING = "Destination directory setting";
+
private final static String OVERWRITE_SETTING = "Overwrite setting";
+
private final static String ZIP_SETTING = "Zip Setting";
- public TaskDataExportWizardPage(){
- super("org.eclipse.mylar.tasklist.exportPage", PAGE_TITLE,
- MylarTaskListPlugin.imageDescriptorFromPlugin(MylarTaskListPlugin.PLUGIN_ID, "icons/wizban/banner-export.gif"));
+ public TaskDataExportWizardPage() {
+ super("org.eclipse.mylar.tasklist.exportPage", PAGE_TITLE, MylarTaskListPlugin.imageDescriptorFromPlugin(
+ MylarTaskListPlugin.PLUGIN_ID, "icons/wizban/banner-export.gif"));
setPageComplete(false);
}
-
- public String getName(){
+
+ public String getName() {
return PAGE_NAME;
}
-
+
/**
* Create the widgets on the page
*/
@@ -65,58 +77,57 @@ public class TaskDataExportWizardPage extends WizardPage {
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
container.setLayout(layout);
-
+
createFileSelectionControl(container);
createExportDirectoryControl(container);
-
- zipCheckBox = createCheckBox(container, "Export to zip file: " + ZIP_FILE_NAME);
+
+ zipCheckBox = createCheckBox(container, "Export to zip file: " + TaskDataExportWizard.getZipFileName());
overwriteCheckBox = createCheckBox(container, "Overwrite existing files without warning");
-
+
initSettings();
-
+
setControl(container);
-
+
setPageComplete(validate());
} catch (RuntimeException e) {
ErrorLogger.fail(e, "Could not create export wizard page", true);
- }
+ }
}
/**
* Create widgets for selecting the data files to export
*/
- private void createFileSelectionControl(Composite parent){
- Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
+ private void createFileSelectionControl(Composite parent) {
+ Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
GridLayout gl = new GridLayout(1, false);
group.setLayout(gl);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gridData);
group.setText("Select data to export:");
-
+
taskListCheckBox = createCheckBox(group, "Task List");
taskActivationHistoryCheckBox = createCheckBox(group, "Task Activation History");
taskContextsCheckBox = createCheckBox(group, "Task Contexts");
}
-
+
/**
* Create widgets for specifying the destination directory
*/
private void createExportDirectoryControl(Composite parent) {
- Group destDirGroup= new Group(parent, SWT.SHADOW_ETCHED_IN);
+ Group destDirGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
destDirGroup.setText("Export destination folder");
destDirGroup.setLayout(new GridLayout(2, false));
destDirGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- destDirText = new Text(destDirGroup, SWT.BORDER);
+
+ destDirText = new Text(destDirGroup, SWT.BORDER);
destDirText.setEditable(false);
destDirText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- destDirText.addModifyListener(new ModifyListener(){
+ destDirText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
controlChanged();
}
});
-
-
+
browseButton = new Button(destDirGroup, SWT.PUSH);
browseButton.setText("Browse...");
browseButton.addSelectionListener(new SelectionAdapter() {
@@ -127,50 +138,49 @@ public class TaskDataExportWizardPage extends WizardPage {
String dir = destDirText.getText();
dialog.setFilterPath(dir);
dir = dialog.open();
- if(dir == null || dir.equals(""))
+ if (dir == null || dir.equals(""))
return;
destDirText.setText(dir);
}
- });
- }
-
-
+ });
+ }
+
/**
* Initializes controls with values from the Dialog Settings object
*/
- protected void initSettings(){
+ protected void initSettings() {
IDialogSettings settings = getDialogSettings();
-
- if (settings.get(SETTINGS_SAVED) == null){
- //Set default values
+
+ if (settings.get(SETTINGS_SAVED) == null) {
+ // Set default values
taskListCheckBox.setSelection(true);
taskActivationHistoryCheckBox.setSelection(true);
taskContextsCheckBox.setSelection(true);
destDirText.setText("");
overwriteCheckBox.setSelection(true);
zipCheckBox.setSelection(false);
- }
- else{
- //Retrieve previous values from the dialog settings
- taskListCheckBox.setSelection(settings.getBoolean(TASKLIST_SETTING));
+ } else {
+ // Retrieve previous values from the dialog settings
+ taskListCheckBox.setSelection(true); // force it
+ // taskListCheckBox.setSelection(settings.getBoolean(TASKLIST_SETTING));
taskActivationHistoryCheckBox.setSelection(settings.getBoolean(ACTIVATION_HISTORY_SETTING));
taskContextsCheckBox.setSelection(settings.getBoolean(CONTEXTS_SETTING));
String directory = settings.get(DEST_DIR_SETTING);
- if(directory != null){
+ if (directory != null) {
destDirText.setText(settings.get(DEST_DIR_SETTING));
- }
+ }
overwriteCheckBox.setSelection(settings.getBoolean(OVERWRITE_SETTING));
zipCheckBox.setSelection(settings.getBoolean(ZIP_SETTING));
}
}
-
+
/**
- * Saves the control values in the dialog settings to be used as
- * defaults the next time the page is opened
+ * Saves the control values in the dialog settings to be used as defaults
+ * the next time the page is opened
*/
- public void saveSettings(){
+ public void saveSettings() {
IDialogSettings settings = getDialogSettings();
-
+
settings.put(TASKLIST_SETTING, taskListCheckBox.getSelection());
settings.put(ACTIVATION_HISTORY_SETTING, taskActivationHistoryCheckBox.getSelection());
settings.put(CONTEXTS_SETTING, taskContextsCheckBox.getSelection());
@@ -180,81 +190,81 @@ 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);
+ protected Button createCheckBox(Composite parent, String text) {
+ Button newButton = new Button(parent, SWT.CHECK);
newButton.setText(text);
-
- newButton.addSelectionListener(new SelectionListener(){
+
+ newButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
controlChanged();
}
public void widgetDefaultSelected(SelectionEvent e) {
- //No action required
+ // No action required
}
});
-
+
return newButton;
}
-
+
/** Called to indicate that a control's value has changed */
- public void controlChanged(){
+ public void controlChanged() {
setPageComplete(validate());
}
/** Returns true if the information entered by the user is valid */
- protected boolean validate(){
-
- //Check that at least one type of data has been selected
- if (!taskListCheckBox.getSelection() &&
- !taskActivationHistoryCheckBox.getSelection() &&
- !taskContextsCheckBox.getSelection()){
+ protected boolean validate() {
+
+ // Check that at least one type of data has been selected
+ if (!taskListCheckBox.getSelection() && !taskActivationHistoryCheckBox.getSelection()
+ && !taskContextsCheckBox.getSelection()) {
return false;
}
-
- //Check that a destination dir has been specified
- if (destDirText.getText().equals("")){
+
+ // Check that a destination dir has been specified
+ if (destDirText.getText().equals("")) {
return false;
}
-
+
return true;
}
-
+
/** Returns the directory where data files are to be saved */
- public String getDestinationDirectory(){
+ public String getDestinationDirectory() {
return destDirText.getText();
}
-
+
/** True if the user wants to export the task list */
- public boolean exportTaskList(){
+ public boolean exportTaskList() {
return taskListCheckBox.getSelection();
}
-
+
/** True if the user wants to export task activation history */
- public boolean exportActivationHistory(){
+ public boolean exportActivationHistory() {
return taskActivationHistoryCheckBox.getSelection();
}
-
+
/** True if the user wants to export task context files */
- public boolean exportTaskContexts(){
+ public boolean exportTaskContexts() {
return taskContextsCheckBox.getSelection();
}
-
- /** True if the user wants to overwrite files by default*/
- public boolean overwrite(){
+
+ /** True if the user wants to overwrite files by default */
+ public boolean overwrite() {
return overwriteCheckBox.getSelection();
}
-
+
/** True if the user wants to write to a zip file */
- public boolean zip(){
+ public boolean zip() {
return zipCheckBox.getSelection();
}
-
+
/** For testing only. Sets controls to the specified values */
- public void setParameters(boolean overwrite, boolean exportTaskList, boolean exportActivationHistory, boolean exportTaskContexts, boolean zip, String destinationDir){
+ public void setParameters(boolean overwrite, boolean exportTaskList, boolean exportActivationHistory,
+ boolean exportTaskContexts, boolean zip, String destinationDir) {
overwriteCheckBox.setSelection(overwrite);
taskListCheckBox.setSelection(exportTaskList);
taskActivationHistoryCheckBox.setSelection(exportActivationHistory);

Back to the top