diff options
author | Steffen Pingel | 2012-02-24 01:49:57 +0000 |
---|---|---|
committer | Steffen Pingel | 2012-02-24 01:49:57 +0000 |
commit | dd272410ed09dec302025f9fc5ffcf65ab092b77 (patch) | |
tree | d7d76c2fe2fbffb3a8af5857b412ebc57b2c7bef /org.eclipse.mylyn.tasks.core/src | |
parent | 1bed15b209c561664004a4f075d4a3e46d63fc85 (diff) | |
download | org.eclipse.mylyn.tasks-dd272410ed09dec302025f9fc5ffcf65ab092b77.tar.gz org.eclipse.mylyn.tasks-dd272410ed09dec302025f9fc5ffcf65ab092b77.tar.xz org.eclipse.mylyn.tasks-dd272410ed09dec302025f9fc5ffcf65ab092b77.zip |
NEW - bug 358554: [api] provide an extensible store for task-related
information
https://bugs.eclipse.org/bugs/show_bug.cgi?id=358554
Change-Id: Iebf65bc3560a3b3240ff86eb453f1c76391d972a
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src')
3 files changed, 59 insertions, 35 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java index c35f23c4d..ea879ae38 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/context/DefaultTaskContextStore.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.mylyn.commons.core.StatusHandler; import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.core.TaskRepository; import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore; /** @@ -32,6 +33,8 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore { public static final String CONTEXT_FILE_EXTENSION = ".xml.zip"; //$NON-NLS-1$ + private File directory; + private File contextDirectory; @Override @@ -40,15 +43,19 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore { } @Override - public void deleteContext(ITask task) { + public void clearContext(ITask task) { File file = getFileForContext(task); if (file.exists()) { file.delete(); } } - public File getContextDirectory() { - return contextDirectory; + @Override + public void deleteContext(ITask task) { + File file = getFileForContext(task); + if (file.exists()) { + file.delete(); + } } @Override @@ -84,11 +91,8 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore { return null; } - /** - * @since 3.7 - */ @Override - public void refactorRepositoryUrl(String oldRepositoryUrl, String newRepositoryUrl) { + public void refactorRepositoryUrl(TaskRepository repository, String oldRepositoryUrl, String newRepositoryUrl) { // ignore } @@ -98,8 +102,21 @@ public class DefaultTaskContextStore extends AbstractTaskContextStore { } @Override - public synchronized void setContextDirectory(File directory) { - this.contextDirectory = directory; + public synchronized void setDirectory(File directory) { + this.directory = directory; + + contextDirectory = new File(directory.getParent(), ITasksCoreConstants.CONTEXTS_DIRECTORY); + if (!contextDirectory.exists()) { + contextDirectory.mkdirs(); + } + } + + public File getDirectory() { + return directory; + } + + private File getContextDirectory() { + return contextDirectory; } } diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java index 72d46ea83..36a06f1c6 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java @@ -25,6 +25,7 @@ import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; +import org.eclipse.mylyn.commons.core.CoreUtil; import org.eclipse.mylyn.commons.core.DelegatingProgressMonitor; import org.eclipse.mylyn.commons.core.IDelegatingProgressMonitor; import org.eclipse.mylyn.commons.core.StatusHandler; @@ -353,26 +354,13 @@ public class TaskDataManager implements ITaskDataManager { // String pathName = task.getConnectorKind() + "-" // + URLEncoder.encode(task.getRepositoryUrl(), ENCODING_UTF_8); // String fileName = kind + "-" + URLEncoder.encode(task.getTaskId(), ENCODING_UTF_8) + EXTENSION; - String repositoryPath = task.getConnectorKind() + "-" + encode(repositoryUrl); //$NON-NLS-1$ - String fileName = encode(task.getTaskId()) + EXTENSION; + String repositoryPath = task.getConnectorKind() + "-" + CoreUtil.asFileName(repositoryUrl); //$NON-NLS-1$ + String fileName = CoreUtil.asFileName(task.getTaskId()) + EXTENSION; File path = new File(dataPath + File.separator + FOLDER_TASKS + File.separator + repositoryPath + File.separator + FOLDER_DATA); return new File(path, fileName); } - private static String encode(String text) { - StringBuffer sb = new StringBuffer(text.length()); - char[] chars = text.toCharArray(); - for (char c : chars) { - if (c >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '.') { - sb.append(c); - } else { - sb.append("%" + Integer.toHexString(c).toUpperCase()); //$NON-NLS-1$ - } - } - return sb.toString(); - } - private File getFile10(ITask task, String kind) { try { String pathName = URLEncoder.encode(task.getRepositoryUrl(), ENCODING_UTF_8); diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java index 60d7babde..613369ae1 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/context/AbstractTaskContextStore.java @@ -15,6 +15,7 @@ import java.io.File; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.core.TaskRepository; /** * A store for persisting task contexts. @@ -25,24 +26,24 @@ import org.eclipse.mylyn.tasks.core.ITask; public abstract class AbstractTaskContextStore { /** - * Copies the context from <code>sourceTask</code> to <code>destinationTask</code>. Creates a new context if a - * <code>sourceTask</code> does not have a context. + * Clears the context of <code>task</code>. * - * @return result of the copy operation * @since 3.7 */ - public abstract IAdaptable copyContext(ITask sourceTask, ITask destinationTask); + public abstract void clearContext(ITask task); /** - * Moves the context from <code>sourceTask</code> to <code>destinationTask</code>. Creates a new context if a + * Copies the context from <code>sourceTask</code> to <code>destinationTask</code>. Creates a new context if a * <code>sourceTask</code> does not have a context. * - * @return result of the move operation + * @return result of the copy operation * @since 3.7 */ - public abstract IAdaptable moveContext(ITask sourceTask, ITask destinationTask); + public abstract IAdaptable copyContext(ITask sourceTask, ITask destinationTask); /** + * Deletes the context of <code>task</code>. + * * @since 3.7 */ public abstract void deleteContext(ITask task); @@ -63,21 +64,39 @@ public abstract class AbstractTaskContextStore { /** * @since 3.7 */ - public abstract void refactorRepositoryUrl(String oldRepositoryUrl, String newRepositoryUrl); + public abstract void mergeContext(ITask sourceTask, ITask targetTask); + + /** + * Moves the context from <code>sourceTask</code> to <code>destinationTask</code>. Creates a new context if a + * <code>sourceTask</code> does not have a context. + * + * @return result of the move operation + * @since 3.7 + */ + public abstract IAdaptable moveContext(ITask sourceTask, ITask destinationTask); /** * @since 3.7 */ - public abstract void saveActiveContext(); + public abstract void refactorRepositoryUrl(TaskRepository repository, String oldRepositoryUrl, + String newRepositoryUrl); + + /** + * Returns an object for persisting task related information. The object needs to be released when it is no longer + * used. + */ + //public abstract ICommonStorable getStorable(ITask task); /** * @since 3.7 */ - public abstract void setContextDirectory(File contextStoreDir); + public abstract void saveActiveContext(); /** + * Sets the location of task file. + * * @since 3.7 */ - public abstract void mergeContext(ITask sourceTask, ITask targetTask); + public abstract void setDirectory(File directory); } |