Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-11-02 14:28:38 -0500
committermkersten2005-11-02 14:28:38 -0500
commit27a3810e91e8781d656968f52e4e657d12562495 (patch)
tree72937aa3f8b4fa8cbd77a5c216a1fa952f569ed1 /org.eclipse.mylyn.tasks.ui
parent797b9453b0b8a8c069f8a2cc66db2563ae43e73a (diff)
downloadorg.eclipse.mylyn.tasks-27a3810e91e8781d656968f52e4e657d12562495.tar.gz
org.eclipse.mylyn.tasks-27a3810e91e8781d656968f52e4e657d12562495.tar.xz
org.eclipse.mylyn.tasks-27a3810e91e8781d656968f52e4e657d12562495.zip
Patch for Bugzilla Bug 114172 Switch task data directory option on 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.java48
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java42
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DropDownTaskNavigateAction.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskDropDownAction.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskDropDownAction.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTasklistPreferencePage.java39
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java9
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java40
9 files changed, 106 insertions, 86 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 b0823ccf7..dd69a3c9c 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
@@ -61,6 +61,7 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
public static final String REPORT_OPEN_INTERNAL = "org.eclipse.mylar.tasklist.report.open.internal";
public static final String REPORT_OPEN_EXTERNAL = "org.eclipse.mylar.tasklist.report.open.external";
public static final String MULTIPLE_ACTIVE_TASKS = "org.eclipse.mylar.tasklist.active.multipe";
+ public static final String COPY_TASK_DATA = "org.eclipse.mylar.tasklist.preferences.copyTaskData";
public static final String PLUGIN_ID = "org.eclipse.mylar.tasklist";
public static final String FILE_EXTENSION = ".xml";
@@ -205,25 +206,17 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
private static IPropertyChangeListener PREFERENCE_LISTENER = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
- // TODO Auto-generated method stub
- if (event.getProperty().equals(MylarPlugin.MYLAR_DIR)) {
- if (event.getOldValue() instanceof String) {
- String prevDir = (String) event.getOldValue();
- MylarPlugin.getContextManager().updateMylarDirContents(prevDir);
- getTaskListManager().updateTaskscapeReference(prevDir);
-
- String path = MylarPlugin.getDefault().getMylarDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE;
- getTaskListManager().setTaskListFile(new File(path));
- }
- } else if (event.getProperty().equals(MULTIPLE_ACTIVE_TASKS)) {
+
+ if (event.getProperty().equals(MULTIPLE_ACTIVE_TASKS)) {
TaskListView.getDefault().togglePreviousAction(!getPrefs().getBoolean(MULTIPLE_ACTIVE_TASKS));
TaskListView.getDefault().toggleNextAction(!getPrefs().getBoolean(MULTIPLE_ACTIVE_TASKS));
TaskListView.getDefault().clearTaskHistory();
- } else {
- }
+ }
}
};
+
+
public MylarTasklistPlugin() {
super();
plugin = this;
@@ -317,6 +310,20 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
return MylarPlugin.getDefault().getPreferenceStore();
}
+
+ /**
+ * Sets the directory containing the task list file to use.
+ * Switches immediately to use the data at that location.
+ */
+ public void setDataDirectory(String newDirPath){
+ String taskListFilePath = newDirPath + File.separator + DEFAULT_TASK_LIST_FILE;
+ getTaskListManager().setTaskListFile(new File(taskListFilePath));
+ getTaskListManager().createNewTaskList();
+ getTaskListManager().readTaskList();
+
+ TaskListView.getDefault().clearTaskHistory();
+ }
+
/**
* TODO: make private
*/
@@ -472,6 +479,21 @@ public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
copy(new File(backup), taskListFile);
}
+ /**
+ * Copies all files in the current data directory to
+ * the specified folder. Will overwrite.
+ */
+ public void copyDataDirContentsTo(String targetFolderPath){
+ File mainDataDir = new File(MylarPlugin.getDefault().getMylarDataDirectory());
+
+ for ( File currFile : mainDataDir.listFiles()) {
+ if (currFile.isFile()){
+ File destFile = new File(targetFolderPath + File.separator + currFile.getName());
+ copy(currFile, destFile);
+ }
+ }
+ }
+
private boolean copy(File src, File dst) {
try {
InputStream in = new FileInputStream(src);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java
index 2cda5683f..6d15c9ca0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/TaskListManager.java
@@ -20,8 +20,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.mylar.core.MylarPlugin;
-import org.eclipse.mylar.tasklist.internal.RelativePathUtil;
-import org.eclipse.mylar.tasklist.internal.TaskCategory;
import org.eclipse.mylar.tasklist.internal.TaskList;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
@@ -158,47 +156,7 @@ public class TaskListManager {
for (ITaskActivityListener listener : listeners) listener.taskPropertyChanged(task, property);
}
- public void updateTaskscapeReference(String prevDir) {
- List<ITask> rootTasks = this.getTaskList().getRootTasks();
- for (TaskCategory cat : taskList.getTaskCategories()) {
- updateTaskscapeReferenceHelper(cat.getChildren(), prevDir);
- }
- updateTaskscapeReferenceHelper(rootTasks, prevDir);
-
- }
-
- public void updateTaskscapeReferenceHelper(List<ITask> list, String prevDir) {
- for (ITask task : list) {
- if (!task.getPath().startsWith("task-")) {
- if (task.getPath().startsWith("..")) {
- String path = task.getPath();
- File d = new File(prevDir);
- while (path.startsWith("..")) {
- d = d.getParentFile();
- path = path.substring(3, path.length());
- }
-
- String absPath = d.getPath() + "/" + path + MylarTasklistPlugin.FILE_EXTENSION;
- absPath = absPath.replaceAll("\\\\", "/");
- String rel = RelativePathUtil.findRelativePath(MylarPlugin.getDefault().getMylarDataDirectory() + "/", absPath);
- task.setPath(rel);
- taskPropertyChanged(task, "Path");
- } else {
- String absPath = prevDir + "/" + task.getPath() + MylarTasklistPlugin.FILE_EXTENSION;
- absPath = absPath.replaceAll("\\\\", "/");
- String rel = RelativePathUtil.findRelativePath(MylarPlugin.getDefault().getMylarDataDirectory(), absPath);
- task.setPath(rel);
- taskPropertyChanged(task, "Path");
- }
- }
-// updateTaskscapeReferenceHelper(task.getChildren(), prevDir);
- }
- }
-
public void setTaskListFile(File f) {
- if (this.taskListFile.exists()) {
- this.taskListFile.delete();
- }
this.taskListFile = f;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java
index ce0ef1407..7c4df46f9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskSummaryEditor.java
@@ -26,7 +26,6 @@ import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskActivityListener;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
import org.eclipse.mylar.tasklist.contribution.DatePicker;
-import org.eclipse.mylar.tasklist.internal.RelativePathUtil;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
@@ -527,15 +526,12 @@ public class TaskSummaryEditor extends EditorPart {
String mylarDir = MylarPlugin.getDefault().getMylarDataDirectory()
+ "/";
mylarDir = mylarDir.replaceAll("\\\\", "/");
- // mylarDir = formatPath(mylarDir);
dialog.setFilterPath(mylarDir);
String res = dialog.open();
if (res != null) {
res = res.replaceAll("\\\\", "/");
- res = RelativePathUtil.findRelativePath(mylarDir, res);
pathText.setText("<MylarDir>/" + res + ".xml");
-// task.setPath(res);
markDirty(true);
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DropDownTaskNavigateAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DropDownTaskNavigateAction.java
index 479a7045a..68c59ba68 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DropDownTaskNavigateAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/DropDownTaskNavigateAction.java
@@ -34,7 +34,7 @@ public abstract class DropDownTaskNavigateAction extends Action implements IMenu
protected TaskListLabelProvider labelProvider = new TaskListLabelProvider();
/** Maximum number of items to appear in the drop-down menu */
- protected final static int MAX_ITEMS = 5;
+ protected final static int MAX_ITEMS_TO_DISPLAY = 10;
public DropDownTaskNavigateAction(TaskListView view, TaskActivationHistory history){
super();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskDropDownAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskDropDownAction.java
index d04ac4ccc..320209acb 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskDropDownAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskDropDownAction.java
@@ -37,8 +37,8 @@ public class NextTaskDropDownAction extends DropDownTaskNavigateAction {
protected void addActionsToMenu(){
List<ITask> tasks = taskHistory.getNextTasks();
- if(tasks.size() > MAX_ITEMS){
- tasks = tasks.subList(0, MAX_ITEMS);
+ if(tasks.size() > MAX_ITEMS_TO_DISPLAY){
+ tasks = tasks.subList(0, MAX_ITEMS_TO_DISPLAY);
}
for(int i = 0; i < tasks.size(); i++){
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskDropDownAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskDropDownAction.java
index 3e04120a9..fd05b3948 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskDropDownAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskDropDownAction.java
@@ -37,8 +37,8 @@ public class PreviousTaskDropDownAction extends DropDownTaskNavigateAction {
protected void addActionsToMenu(){
List<ITask> tasks = taskHistory.getPreviousTasks();
- if(tasks.size() > MAX_ITEMS){
- tasks = tasks.subList(tasks.size() - MAX_ITEMS, tasks.size());
+ if(tasks.size() > MAX_ITEMS_TO_DISPLAY){
+ tasks = tasks.subList(tasks.size() - MAX_ITEMS_TO_DISPLAY, tasks.size());
}
for(int i = tasks.size() - 1; i >= 0; i--){
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTasklistPreferencePage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTasklistPreferencePage.java
index cfd20c4f8..d5be7ec01 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTasklistPreferencePage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/preferences/MylarTasklistPreferencePage.java
@@ -38,9 +38,10 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
public class MylarTasklistPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
- private Text taskDirectoryText;
- private Text taskURLPrefixText;
- private Button browse;
+ private Text taskDirectoryText = null;
+ private Text taskURLPrefixText = null;
+ private Button browse = null;
+ private Button copyExistingDataCheckbox = null;
private Button reportEditor = null;
private Button reportInternal = null;
// private Button reportExternal = null;
@@ -104,9 +105,18 @@ public class MylarTasklistPreferencePage extends PreferencePage implements
@Override
public boolean performOk() {
String taskDirectory = taskDirectoryText.getText();
- taskDirectory = taskDirectory.replaceAll("\\\\", "/");
- getPreferenceStore().setValue(MylarPlugin.MYLAR_DIR, taskDirectory);
+ taskDirectory = taskDirectory.replaceAll("\\\\", "/");
+ if (!taskDirectory.equals(MylarPlugin.getDefault().getMylarDataDirectory())){
+ //Order matters:
+ MylarTasklistPlugin.getDefault().saveTaskListAndContexts();
+ if (copyExistingDataCheckbox.getSelection()){
+ MylarTasklistPlugin.getDefault().copyDataDirContentsTo(taskDirectory);
+ }
+ getPreferenceStore().setValue(MylarPlugin.MYLAR_DIR, taskDirectory);
+ MylarTasklistPlugin.getDefault().setDataDirectory(MylarPlugin.getDefault().getMylarDataDirectory());
+ }
+ getPreferenceStore().setValue(MylarTasklistPlugin.COPY_TASK_DATA, copyExistingDataCheckbox.getSelection());
getPreferenceStore().setValue(MylarTasklistPlugin.REPORT_OPEN_EDITOR, reportEditor.getSelection());
getPreferenceStore().setValue(MylarTasklistPlugin.REPORT_OPEN_INTERNAL, reportInternal.getSelection());
// getPreferenceStore().setValue(MylarTasklistPlugin.REPORT_OPEN_EXTERNAL, reportExternal.getSelection());
@@ -130,9 +140,10 @@ public class MylarTasklistPreferencePage extends PreferencePage implements
super.performDefaults();
IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- String taskDirectory = rootPath.toString() + "/" +MylarPlugin.MYLAR_DIR_NAME;
+ String taskDirectory = rootPath.toString() + "/" + MylarPlugin.MYLAR_DIR_NAME;
taskDirectoryText.setText(taskDirectory);
-
+
+ copyExistingDataCheckbox.setSelection(getPreferenceStore().getDefaultBoolean(MylarTasklistPlugin.COPY_TASK_DATA));
reportEditor.setSelection(getPreferenceStore().getDefaultBoolean(MylarTasklistPlugin.REPORT_OPEN_EDITOR));
reportInternal.setSelection(getPreferenceStore().getDefaultBoolean(MylarTasklistPlugin.REPORT_OPEN_INTERNAL));
// reportExternal.setSelection(getPreferenceStore().getDefaultBoolean(MylarTasklistPlugin.REPORT_OPEN_EXTERNAL));
@@ -162,14 +173,7 @@ public class MylarTasklistPreferencePage extends PreferencePage implements
taskDirectoryText.setEditable(false);
taskDirectoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
browse = createButton(taskDirComposite, "Browse...");
- if (!MylarPlugin.getContextManager().hasActiveContext()) {
- browse.setEnabled(true);
- } else {
- browse.setEnabled(false);
- createLabel(taskDirComposite, "NOTE: if you have a task active, deactivate it before changing directories");
- }
browse.addSelectionListener(new SelectionAdapter() {
@Override
@@ -186,7 +190,12 @@ public class MylarTasklistPreferencePage extends PreferencePage implements
return;
taskDirectoryText.setText(dir);
}
- });
+ });
+
+ copyExistingDataCheckbox = new Button(taskDirComposite, SWT.CHECK);
+ copyExistingDataCheckbox.setText("Copy existing data to new location");
+ copyExistingDataCheckbox.setSelection(getPreferenceStore().getBoolean(MylarTasklistPlugin.COPY_TASK_DATA));
+
}
private void createCreationGroup(Composite parent) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java
index 2bc7de6ab..72efb0cb2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java
@@ -28,8 +28,11 @@ public class TaskActivationHistory {
private int currentIndex = -1;
- /** The number of tasks from the previous session to load into the history*/
- private static final int PERSISTENT_HISTORY_SIZE = 16;
+ /**
+ * The number of tasks from the previous Eclipse session to load into the history
+ * at startup. (This is not the maximum size of the history, which is currently unbounded)
+ */
+ private static final int NUM_SAVED_HISTORY_ITEMS_TO_LOAD = 10;
private boolean persistentHistoryLoaded = false;
@@ -49,7 +52,7 @@ public class TaskActivationHistory {
history.add(0, prevTask);
currentIndex++;
tasksAdded++;
- if (tasksAdded == PERSISTENT_HISTORY_SIZE){
+ if (tasksAdded == NUM_SAVED_HISTORY_ITEMS_TO_LOAD){
break;
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
index 7706325cc..f6c76a4a2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
@@ -185,6 +185,11 @@ public class TaskListView extends ViewPart {
// private boolean canEnableGoInto = false;
+ /**
+ * True if the view should indicate that interaction monitoring is paused
+ */
+ protected boolean isPaused = false;
+
private final class PriorityDropDownAction extends Action implements IMenuCreator {
private Menu dropDownMenu = null;
@@ -1289,12 +1294,39 @@ public class TaskListView extends ViewPart {
}
return null;
}
-
+
+ //TODO: Need a better way to indicate paused and/or the shared folder
public void indicatePaused(boolean paused) {
- if (paused) {
- setPartName("(paused) " + PART_NAME);
+ isPaused = paused;
+ if (isPaused) {
+ setPartName("(paused) " + getPartName());
} else {
- setPartName(PART_NAME);
+ setPartName(getPartName().replaceAll("\\(paused\\) ", ""));
}
}
+
+ /**
+ * Show the shared data folder currently in use.
+ * Call with "" to turn off the indication.
+ * TODO: Need a better way to indicate paused and/or the shared folder
+ */
+ public void indicateSharedFolder(String folderName){
+ if (folderName.equals("")){
+ if (isPaused){
+ setPartName("(paused) " + PART_NAME);
+ }
+ else{
+ setPartName(PART_NAME);
+ }
+ }
+ else{
+ if (isPaused){
+ setPartName("(paused) " + folderName + " " + PART_NAME);
+ }
+ else{
+ setPartName(folderName + " " + PART_NAME);
+ }
+ }
+
+ }
} \ No newline at end of file

Back to the top