Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-03-02 19:35:11 +0000
committerDavid Green2012-03-02 19:35:11 +0000
commit2befecfd0c9ea65a84504ad94eea486e317407cf (patch)
treed8ae786d9caa90e9abcf7ea5a6978637e207d8ff /org.eclipse.mylyn.tasks.index.ui/src
parent20cefdff005db68155f001f06733accae2382a1c (diff)
downloadorg.eclipse.mylyn.tasks-2befecfd0c9ea65a84504ad94eea486e317407cf.tar.gz
org.eclipse.mylyn.tasks-2befecfd0c9ea65a84504ad94eea486e317407cf.tar.xz
org.eclipse.mylyn.tasks-2befecfd0c9ea65a84504ad94eea486e317407cf.zip
bug 372725: handle changes to task data directory
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372725 Change-Id: I24cc1a042b41a0fc83c28638b78c25fb74a818f1
Diffstat (limited to 'org.eclipse.mylyn.tasks.index.ui/src')
-rw-r--r--org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexReference.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexReference.java b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexReference.java
index 742986d60..5181cbf43 100644
--- a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexReference.java
+++ b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexReference.java
@@ -14,12 +14,14 @@ package org.eclipse.mylyn.internal.tasks.index.ui;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
+import org.eclipse.mylyn.internal.tasks.core.IRepositoryModelListener;
import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
/**
* @author David Green
+ * @author Steffen Pingel
*/
public class IndexReference {
@@ -27,6 +29,20 @@ public class IndexReference {
private static AtomicInteger referenceCount = new AtomicInteger();
+ private static IRepositoryModelListener listener = new IRepositoryModelListener() {
+ public void loaded() {
+ synchronized (IndexReference.class) {
+ if (theIndex != null) {
+ theIndex.setLocation(getDefaultIndexLocation());
+ }
+ }
+ }
+ };
+
+ static File getDefaultIndexLocation() {
+ return new File(TasksUiPlugin.getDefault().getDataDirectory(), ".taskListIndex"); //$NON-NLS-1$
+ }
+
/**
* When not null serves as flag indicating that theIndex is referenced, thus preventing bad behaviour if dispose is
* called multiple times.
@@ -38,11 +54,9 @@ public class IndexReference {
if (index == null) {
if (theIndex == null) {
final IRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
- final File indexLocation = new File(TasksUiPlugin.getDefault().getDataDirectory(), ".taskListIndex"); //$NON-NLS-1$
-
theIndex = new TaskListIndex(TasksUiPlugin.getTaskList(), TasksUiPlugin.getTaskDataManager(),
- repositoryManager, indexLocation);
-
+ repositoryManager, getDefaultIndexLocation());
+ TasksUiPlugin.getDefault().addModelListener(listener);
}
index = theIndex;
referenceCount.incrementAndGet();
@@ -57,10 +71,12 @@ public class IndexReference {
index = null;
if (referenceCount.decrementAndGet() == 0) {
+ TasksUiPlugin.getDefault().removeModelListener(listener);
theIndex.close();
theIndex = null;
}
}
}
}
+
}

Back to the top