Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2012-11-16 06:53:13 -0500
committerSteffen Pingel2013-07-04 17:09:42 -0400
commit4de53483f9cbdc8556101045d7dfa4d3402caf54 (patch)
tree0fc91a8cb9d991ef94293eba56619ec278cba32e /org.eclipse.mylyn.tasks.ui
parentf82af84a906206b9f3cdbf92132bf0db1f4832f9 (diff)
downloadorg.eclipse.mylyn.tasks-4de53483f9cbdc8556101045d7dfa4d3402caf54.tar.gz
org.eclipse.mylyn.tasks-4de53483f9cbdc8556101045d7dfa4d3402caf54.tar.xz
org.eclipse.mylyn.tasks-4de53483f9cbdc8556101045d7dfa4d3402caf54.zip
386764: [api] TaskMapping should be able to handle custom attributes
Added new API called TaskInitializationData to provide common mutators for ITaskMapping to be used for task data initialization. Also-By: Steffen Pingel <steffen.pingel@tasktop.com> Change-Id: I13c88b5e33a8ab097953833627383ae85cfa692f Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=386764 Signed-off-by: Benjamin Muskalla <benjamin.muskalla@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CloneTaskAction.java48
1 files changed, 27 insertions, 21 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CloneTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CloneTaskAction.java
index b8b7ad6fd..1ed74451c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CloneTaskAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CloneTaskAction.java
@@ -17,11 +17,11 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.core.DefaultTaskMapping;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
+import org.eclipse.mylyn.tasks.core.TaskInitializationData;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUi;
@@ -68,8 +68,8 @@ public class CloneTaskAction extends BaseSelectionListenerAction implements IVie
}
}
- ITaskMapping taskSelection = new DefaultTaskMapping();
- ((DefaultTaskMapping) taskSelection).setDescription(description);
+ TaskInitializationData initializationData = new TaskInitializationData();
+ initializationData.setDescription(description);
TaskData taskData;
try {
@@ -79,24 +79,7 @@ public class CloneTaskAction extends BaseSelectionListenerAction implements IVie
continue;
}
- if (taskData != null) {
- AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(taskData.getConnectorKind());
- ITaskMapping mapping = connector.getTaskMapping(taskData);
- if (mapping.getDescription() != null) {
- ((DefaultTaskMapping) taskSelection).setDescription(description + "\n\n" //$NON-NLS-1$
- + mapping.getDescription());
-
- TaskAttribute attrDescription = mapping.getTaskData()
- .getRoot()
- .getMappedAttribute(TaskAttribute.DESCRIPTION);
- if (attrDescription != null) {
- attrDescription.getMetaData().setReadOnly(false);
- }
-
- }
- mapping.merge(taskSelection);
- taskSelection = mapping;
- }
+ ITaskMapping taskSelection = getTaskMapping(initializationData, taskData);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
if (!TasksUiUtil.openNewTaskEditor(shell, taskSelection, null)) {
@@ -107,6 +90,29 @@ public class CloneTaskAction extends BaseSelectionListenerAction implements IVie
}
}
+ public ITaskMapping getTaskMapping(TaskInitializationData initializationData, TaskData taskData) {
+ if (taskData != null) {
+ AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(taskData.getConnectorKind());
+ ITaskMapping mapping = connector.getTaskMapping(taskData);
+ if (mapping.getDescription() != null) {
+ initializationData.setDescription(initializationData.getDescription() + "\n\n" //$NON-NLS-1$
+ + mapping.getDescription());
+
+ TaskAttribute attrDescription = mapping.getTaskData()
+ .getRoot()
+ .getMappedAttribute(TaskAttribute.DESCRIPTION);
+ if (attrDescription != null) {
+ attrDescription.getMetaData().setReadOnly(false);
+ }
+
+ }
+ mapping.merge(initializationData);
+ return mapping;
+ } else {
+ return initializationData;
+ }
+ }
+
public void run(IAction action) {
run();
}

Back to the top