Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-06-14 23:24:42 +0000
committerspingel2009-06-14 23:24:42 +0000
commitca814281c55598e546a17efbcf9536e3c3c82583 (patch)
tree0da867907852327b751bb2f71537d56b9e99efdc /org.eclipse.mylyn.trac.core
parentdbeab4fcc537fb1671233266aba6f32089e714cb (diff)
downloadorg.eclipse.mylyn.tasks-ca814281c55598e546a17efbcf9536e3c3c82583.tar.gz
org.eclipse.mylyn.tasks-ca814281c55598e546a17efbcf9536e3c3c82583.tar.xz
org.eclipse.mylyn.tasks-ca814281c55598e546a17efbcf9536e3c3c82583.zip
NEW - bug 239154: attributes not updated when configuration is refreshed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=239154
Diffstat (limited to 'org.eclipse.mylyn.trac.core')
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttributeMapper.java54
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java9
2 files changed, 58 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttributeMapper.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttributeMapper.java
index 3237dd5c8..be41f72ce 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttributeMapper.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttributeMapper.java
@@ -13,7 +13,11 @@ package org.eclipse.mylyn.internal.trac.core;
import java.util.Date;
import java.util.EnumSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
import org.eclipse.mylyn.internal.trac.core.util.TracUtil;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
@@ -36,6 +40,8 @@ public class TracAttributeMapper extends TaskAttributeMapper {
public static final EnumSet<Flag> NO_FLAGS = EnumSet.noneOf(Flag.class);
+ private final ITracClient client;
+
public static boolean isInternalAttribute(TaskAttribute attribute) {
String type = attribute.getMetaData().getType();
if (TaskAttribute.TYPE_ATTACHMENT.equals(type) || TaskAttribute.TYPE_OPERATION.equals(type)
@@ -47,8 +53,10 @@ public class TracAttributeMapper extends TaskAttributeMapper {
|| NEW_CC.equals(id);
}
- public TracAttributeMapper(TaskRepository taskRepository) {
+ public TracAttributeMapper(TaskRepository taskRepository, ITracClient client) {
super(taskRepository);
+ Assert.isNotNull(client);
+ this.client = client;
}
@Override
@@ -71,4 +79,48 @@ public class TracAttributeMapper extends TaskAttributeMapper {
}
}
+ @Override
+ public Map<String, String> getOptions(TaskAttribute attribute) {
+ Map<String, String> options = getRepositoryOptions(attribute);
+ return (options != null) ? options : super.getOptions(attribute);
+ }
+
+ public Map<String, String> getRepositoryOptions(TaskAttribute attribute) {
+ if (client.hasAttributes()) {
+ String attributeId = attribute.getId();
+ if (TracAttribute.STATUS.getTracKey().equals(attributeId)) {
+ return getOptions(client.getTicketStatus(), false);
+ } else if (TracAttribute.RESOLUTION.getTracKey().equals(attributeId)) {
+ return getOptions(client.getTicketResolutions(), false);
+ } else if (TracAttribute.COMPONENT.getTracKey().equals(attributeId)) {
+ return getOptions(client.getComponents(), false);
+ } else if (TracAttribute.VERSION.getTracKey().equals(attributeId)) {
+ return getOptions(client.getVersions(), true);
+ } else if (TracAttribute.PRIORITY.getTracKey().equals(attributeId)) {
+ return getOptions(client.getPriorities(), false);
+ } else if (TracAttribute.SEVERITY.getTracKey().equals(attributeId)) {
+ return getOptions(client.getSeverities(), false);
+ } else if (TracAttribute.MILESTONE.getTracKey().equals(attributeId)) {
+ return getOptions(client.getMilestones(), true);
+ } else if (TracAttribute.TYPE.getTracKey().equals(attributeId)) {
+ return getOptions(client.getTicketTypes(), false);
+ }
+ }
+ return null;
+ }
+
+ private Map<String, String> getOptions(Object[] values, boolean allowEmpty) {
+ if (values != null && values.length > 0) {
+ Map<String, String> options = new LinkedHashMap<String, String>();
+ if (allowEmpty) {
+ options.put("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ for (Object value : values) {
+ options.put(value.toString(), value.toString());
+ }
+ return options;
+ }
+ return null;
+ }
+
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
index 9ed732ccf..be7e7042b 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
@@ -380,10 +380,10 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
}
private static TaskAttribute createAttribute(TaskData data, TracAttribute tracAttribute, Object[] values,
- boolean allowEmtpy) {
+ boolean allowEmpty) {
TaskAttribute attr = createAttribute(data, tracAttribute);
if (values != null && values.length > 0) {
- if (allowEmtpy) {
+ if (allowEmpty) {
attr.putOption("", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
for (Object value : values) {
@@ -502,8 +502,9 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
// }
@Override
- public TaskAttributeMapper getAttributeMapper(TaskRepository taskRepository) {
- return new TracAttributeMapper(taskRepository);
+ public TaskAttributeMapper getAttributeMapper(TaskRepository repository) {
+ ITracClient client = connector.getClientManager().getTracClient(repository);
+ return new TracAttributeMapper(repository, client);
}
public boolean supportsSubtasks(TaskData taskData) {

Back to the top