Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Dong2016-06-01 17:48:45 -0400
committerGerrit Code Review @ Eclipse.org2016-06-07 16:48:29 -0400
commit06987bc26647b3a2f7d0af591325daeb75acf4b9 (patch)
treeb36a040c26620f2ee52abaefc20c1fd44a6f5ca4 /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal
parent79868313c19332a9f90a1ffc6c83623a33d8c96a (diff)
downloadorg.eclipse.mylyn.tasks-06987bc26647b3a2f7d0af591325daeb75acf4b9.tar.gz
org.eclipse.mylyn.tasks-06987bc26647b3a2f7d0af591325daeb75acf4b9.tar.xz
org.eclipse.mylyn.tasks-06987bc26647b3a2f7d0af591325daeb75acf4b9.zip
494568: add support for refactoring task attribute values
Change-Id: Ia943f2ddd5201c8fa2c196a91f1116b2434336b2 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=495066 Signed-off-by: Brandon Dong <brandon.dong@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java22
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java25
2 files changed, 44 insertions, 3 deletions
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 c12679ef2..39a46aca0 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
@@ -42,8 +42,11 @@ import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.ITaskDataManager;
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
+import com.google.common.collect.ListMultimap;
+
/**
* Encapsulates synchronization policy.
*
@@ -596,4 +599,23 @@ public class TaskDataManager implements ITaskDataManager {
}
});
}
+
+ public void refactorAttributeValue(final ITask itask, final ListMultimap<TaskAttribute, String> newValues)
+ throws CoreException {
+ Assert.isTrue(itask instanceof AbstractTask);
+ final AbstractTask task = (AbstractTask) itask;
+ final String kind = task.getConnectorKind();
+ taskList.run(new ITaskListRunnable() {
+ public void execute(IProgressMonitor monitor) throws CoreException {
+ File file = getMigratedFile(task, kind);
+ if (file.exists()) {
+ TaskDataState state = taskDataStore.getTaskDataState(file);
+ if (state != null) {
+ state.changeAttributeValues(newValues);
+ taskDataStore.putTaskData(file, state);
+ }
+ }
+ }
+ });
+ }
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
index 4ba4b8000..576776405 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
@@ -21,6 +21,8 @@ import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
+import com.google.common.collect.ListMultimap;
+
/**
* @author Rob Elves
* @author Steffen Pingel
@@ -136,9 +138,8 @@ public class TaskDataState implements ITaskDataWorkingCopy {
if (editsTaskData != null) {
deepCopyChildren(editsTaskData.getRoot(), localTaskData.getRoot());
} else {
- editsTaskData = new TaskData(repositoryTaskData.getAttributeMapper(),
- repositoryTaskData.getConnectorKind(), repositoryTaskData.getRepositoryUrl(),
- repositoryTaskData.getTaskId());
+ editsTaskData = new TaskData(repositoryTaskData.getAttributeMapper(), repositoryTaskData.getConnectorKind(),
+ repositoryTaskData.getRepositoryUrl(), repositoryTaskData.getTaskId());
editsTaskData.setVersion(repositoryTaskData.getVersion());
}
}
@@ -201,6 +202,24 @@ public class TaskDataState implements ITaskDataWorkingCopy {
setRepositoryData(createCopy(oldState.getRepositoryData()));
}
+ public void changeAttributeValues(ListMultimap<TaskAttribute, String> newValues) {
+ changeAttributeValues(localTaskData, newValues);
+ changeAttributeValues(repositoryTaskData, newValues);
+ changeAttributeValues(editsTaskData, newValues);
+ changeAttributeValues(lastReadTaskData, newValues);
+ }
+
+ private void changeAttributeValues(TaskData taskData, ListMultimap<TaskAttribute, String> newValues) {
+ if (taskData != null) {
+ for (TaskAttribute key : newValues.keySet()) {
+ TaskAttribute attribute = taskData.getRoot().getMappedAttribute(key.getPath());
+ if (attribute != null) {
+ attribute.setValues(newValues.get(key));
+ }
+ }
+ }
+ }
+
public static TaskData createCopy(TaskData oldData) {
if (oldData == null) {
return null;

Back to the top