Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Dong2016-06-06 18:11:43 +0000
committerGerrit Code Review @ Eclipse.org2016-06-08 18:10:36 +0000
commitc7b61a4748ba0ca0687fef5563165c01cfde0dc3 (patch)
tree29c1290d2e2fd17499a143637f8a94c781a0673c /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks
parent06987bc26647b3a2f7d0af591325daeb75acf4b9 (diff)
downloadorg.eclipse.mylyn.tasks-c7b61a4748ba0ca0687fef5563165c01cfde0dc3.tar.gz
org.eclipse.mylyn.tasks-c7b61a4748ba0ca0687fef5563165c01cfde0dc3.tar.xz
org.eclipse.mylyn.tasks-c7b61a4748ba0ca0687fef5563165c01cfde0dc3.zip
436128: [api] connectors can provide the PriorityLevel for icons that
should be shown in PriorityEditor and tooltip uses priority value label from taskdata Change-Id: I7ab493f912fab6ec72ca3819b782467de122943a Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=436128 Signed-off-by: Brandon Dong <brandon.dong@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java32
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java16
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java26
3 files changed, 59 insertions, 15 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java
index 4c00e944a..759448d62 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java
@@ -75,7 +75,7 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
/**
* Defines an interface for priorities that have an associated integer value.
- *
+ *
* @author Steffen Pingel
* @since 3.7
* @see PriorityLevel#fromValue(IPriorityValue[], IPriorityValue)
@@ -205,11 +205,23 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
}
/**
+ * @since 3.20
+ */
+ public static boolean isValidPriority(String string) {
+ try {
+ PriorityLevel.valueOf(string);
+ return true;
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ }
+
+ /**
* Maps a priority value to a {@link PriorityLevel}. The value needs to be present in <code>priorities</code>,
* otherwise {@link PriorityLevel#getDefault()} is returned.
* <p>
* NOTE: <code>priorities</code> needs to be sorted in ascending order.
- *
+ *
* @param priorities
* a sorted array of priority levels
* @param value
@@ -242,28 +254,28 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
/**
* Returns the date that the task was completed.
- *
+ *
* @since 3.0
*/
public abstract Date getCompletionDate();
/**
* Returns the identifier that uniquely distinguishes the repository connector associated with this task.
- *
+ *
* @since 3.0
*/
public abstract String getConnectorKind();
/**
* Returns the date that this task was created.
- *
+ *
* @since 3.0
*/
public abstract Date getCreationDate();
/**
* Returns the date after which this task will become overdue.
- *
+ *
* @since 3.0
*/
public abstract Date getDueDate();
@@ -275,7 +287,7 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
/**
* Returns the date that the repository contents of this task were last modified.
- *
+ *
* @since 3.0
*/
public abstract Date getModificationDate();
@@ -284,7 +296,7 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
* Returns the label of the owner, that is, the <i>option label</i> corresponding to the value of the
* {@link TaskAttribute#USER_ASSIGNED} attribute in the TaskData. If the connector does not provide option labels
* for this attribute, the {@link #getOwnerId() ID} is returned instead.
- *
+ *
* @since 3.0
*/
public abstract String getOwner();
@@ -292,7 +304,7 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
/**
* Returns the ID of the owner, that is, the <i>value</i> of the {@link TaskAttribute#USER_ASSIGNED} attribute in
* the TaskData.
- *
+ *
* @since 3.15
*/
public abstract String getOwnerId();
@@ -325,7 +337,7 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
/**
* User identifiable key for the task to be used in UI facilities such as label displays and hyperlinked references.
* Can return the same as the ID (e.g. in the case of Bugzilla). Can return null if no such label exists.
- *
+ *
* @since 3.0
*/
public abstract String getTaskKey();
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
index f3daee40f..97ea66e67 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
+import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.ITaskComment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -40,8 +41,8 @@ public class TaskAttributeMapper {
@NonNull
public TaskAttribute createTaskAttachment(@NonNull TaskData taskData) {
- TaskAttribute taskAttribute = taskData.getRoot().createAttribute(
- mapToRepositoryKey(taskData.getRoot(), TaskAttribute.NEW_ATTACHMENT));
+ TaskAttribute taskAttribute = taskData.getRoot()
+ .createAttribute(mapToRepositoryKey(taskData.getRoot(), TaskAttribute.NEW_ATTACHMENT));
// TaskAttachmentMapper mapper = TaskAttachmentMapper.createFrom(taskAttribute);
// mapper.setContentType("");
// mapper.setFileName("");
@@ -360,4 +361,15 @@ public class TaskAttributeMapper {
TaskCommentMapper.createFrom(taskAttribute).applyTo(taskComment);
}
+ /**
+ * Connectors may override this method to specify the mapping from the repository's priority options to
+ * {@link PriorityLevel}
+ *
+ * @return the {@link PriorityLevel} corresponding to the given option for the given priority attribute
+ * @since 3.20
+ */
+ public PriorityLevel getPriorityLevel(TaskAttribute priorityAttribute, String priorityOption) {
+ return PriorityLevel.fromString(priorityOption);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java
index 63c0511a3..660601f39 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
@@ -72,6 +73,12 @@ public class TaskMapper implements ITaskMapping {
task.setPriority(getPriorityLevelString());
changed = true;
}
+ String priorityLabel = getPriority();
+ if (hasChanges(task.getAttribute(ITasksCoreConstants.ATTRIBUTE_PRIORITY_LABEL), priorityLabel,
+ TaskAttribute.PRIORITY)) {
+ task.setAttribute(ITasksCoreConstants.ATTRIBUTE_PRIORITY_LABEL, priorityLabel);
+ changed = true;
+ }
if (hasChanges(task.getSummary(), getSummary(), TaskAttribute.SUMMARY)) {
task.setSummary(getSummary());
changed = true;
@@ -139,7 +146,7 @@ public class TaskMapper implements ITaskMapping {
* <li>description
* </ul>
* Other attribute values are only set if they exist on <code>sourceTaskData</code> and <code>targetTaskData</code>.
- *
+ *
* @param sourceTaskData
* the source task data values are copied from, the connector kind of repository of
* <code>sourceTaskData</code> can be different from <code>targetTaskData</code>
@@ -282,10 +289,21 @@ public class TaskMapper implements ITaskMapping {
return getValue(TaskAttribute.PRIORITY);
}
+ /**
+ * Connectors should override {@link TaskAttributeMapper#getPriorityLevel(TaskAttribute, String)} to customize how
+ * priority options are mapped to {@link PriorityLevel}
+ */
@Nullable
public PriorityLevel getPriorityLevel() {
- String value = getPriority();
- return (value != null) ? PriorityLevel.fromString(value) : null;
+ String valueLabel = getPriority();
+ if (valueLabel != null && PriorityLevel.isValidPriority(valueLabel)) {
+ return PriorityLevel.fromString(valueLabel);
+ }
+ TaskAttribute attribute = taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY);
+ if (attribute != null) {
+ return getTaskData().getAttributeMapper().getPriorityLevel(attribute, attribute.getValue());
+ }
+ return null;
}
@Nullable
@@ -400,6 +418,8 @@ public class TaskMapper implements ITaskMapping {
changed |= hasChanges(task.getTaskKey(), getTaskKey(), TaskAttribute.TASK_KEY);
changed |= hasChanges(task.getTaskKind(), getTaskKind(), TaskAttribute.TASK_KIND);
changed |= hasChanges(task.getUrl(), getTaskUrl(), TaskAttribute.TASK_URL);
+ changed |= hasChanges(task.getAttribute(ITasksCoreConstants.ATTRIBUTE_PRIORITY_LABEL), getPriority(),
+ TaskAttribute.PRIORITY);
return changed;
}

Back to the top