Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-10-18 00:34:37 -0400
committermkersten2006-10-18 00:34:37 -0400
commit7a301552003933c084fe9252581525c23b62dd6f (patch)
tree3752824c0704bc0e9d6248443f73ad8db30640d2 /org.eclipse.mylyn.trac.core/src
parentce4e637ad52dd3cdec1d3ca334721a9e781323cf (diff)
downloadorg.eclipse.mylyn.tasks-7a301552003933c084fe9252581525c23b62dd6f.tar.gz
org.eclipse.mylyn.tasks-7a301552003933c084fe9252581525c23b62dd6f.tar.xz
org.eclipse.mylyn.tasks-7a301552003933c084fe9252581525c23b62dd6f.zip
NEW - bug 156685: Rich editor for creating new tasks
Diffstat (limited to 'org.eclipse.mylyn.trac.core/src')
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/ITracClient.java5
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java2
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java6
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java29
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java58
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java11
6 files changed, 87 insertions, 24 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/ITracClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/ITracClient.java
index 3e2188b14..c33e99ffd 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/ITracClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/ITracClient.java
@@ -151,7 +151,10 @@ public interface ITracClient {
void putAttachmentData(int id, String name, String description, byte[] data) throws TracException;
- void createTicket(TracTicket ticket) throws TracException;
+ /**
+ * @return the id of the created ticket
+ */
+ int createTicket(TracTicket ticket) throws TracException;
void updateTicket(TracTicket ticket, String comment) throws TracException;
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java
index 9e114f26a..bb4e2997d 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/Trac09Client.java
@@ -463,7 +463,7 @@ public class Trac09Client extends AbstractTracClient {
throw new TracException("Unsupported operation");
}
- public void createTicket(TracTicket ticket) throws TracException {
+ public int createTicket(TracTicket ticket) throws TracException {
throw new TracException("Unsupported operation");
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java
index 3584a92ac..968264d32 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java
@@ -66,7 +66,7 @@ public class TracAttachmentHandler implements IAttachmentHandler {
}
public void uploadAttachment(TaskRepository repository, AbstractRepositoryTask task, String comment, String description, File file, String contentType, boolean isPatch, Proxy proxySettings) throws CoreException {
- if (!connector.hasAttachmentSupport(repository, task)) {
+ if (!TracRepositoryConnector.hasAttachmentSupport(repository, task)) {
throw new CoreException(new Status(IStatus.INFO, TracCorePlugin.PLUGIN_ID, IStatus.OK, "Attachments are not supported by this repository access type.", null));
}
@@ -100,11 +100,11 @@ public class TracAttachmentHandler implements IAttachmentHandler {
}
public boolean canDownloadAttachment(TaskRepository repository, AbstractRepositoryTask task) {
- return connector.hasAttachmentSupport(repository, task);
+ return TracRepositoryConnector.hasAttachmentSupport(repository, task);
}
public boolean canUploadAttachment(TaskRepository repository, AbstractRepositoryTask task) {
- return connector.hasAttachmentSupport(repository, task);
+ return TracRepositoryConnector.hasAttachmentSupport(repository, task);
}
public boolean canDeprecate(TaskRepository repository, RepositoryAttachment attachment) {
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java
index 2eb66749c..7ec00d6b6 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java
@@ -60,7 +60,7 @@ public class TracOfflineTaskHandler implements IOfflineTaskHandler {
}
public RepositoryTaskData downloadTaskData(TaskRepository repository, int id) throws CoreException {
- if (!connector.hasRichEditor(repository)) {
+ if (!TracRepositoryConnector.hasRichEditor(repository)) {
// offline mode is only supported for XML-RPC
return null;
}
@@ -71,7 +71,7 @@ public class TracOfflineTaskHandler implements IOfflineTaskHandler {
ITracClient client = connector.getClientManager().getRepository(repository);
client.updateAttributes(new NullProgressMonitor(), false);
TracTicket ticket = client.getTicket(id);
- createDefaultAttributes(attributeFactory, data, client);
+ createDefaultAttributes(attributeFactory, data, client, true);
updateTaskData(repository, attributeFactory, data, ticket);
return data;
} catch (Exception e) {
@@ -192,22 +192,33 @@ public class TracOfflineTaskHandler implements IOfflineTaskHandler {
}
public static void createDefaultAttributes(AbstractAttributeFactory factory, RepositoryTaskData data,
- ITracClient client) {
- createAttribute(factory, data, Attribute.STATUS, client.getTicketStatus());
- createAttribute(factory, data, Attribute.RESOLUTION, client.getTicketResolutions());
-
+ ITracClient client, boolean existingTask) {
+ if (existingTask) {
+ createAttribute(factory, data, Attribute.STATUS, client.getTicketStatus());
+ createAttribute(factory, data, Attribute.RESOLUTION, client.getTicketResolutions());
+ }
+
createAttribute(factory, data, Attribute.COMPONENT, client.getComponents());
createAttribute(factory, data, Attribute.VERSION, client.getVersions(), true);
createAttribute(factory, data, Attribute.PRIORITY, client.getPriorities());
createAttribute(factory, data, Attribute.SEVERITY, client.getSeverities());
createAttribute(factory, data, Attribute.TYPE, client.getTicketTypes());
- createAttribute(factory, data, Attribute.OWNER);
+ if (existingTask) {
+ createAttribute(factory, data, Attribute.OWNER);
+ }
createAttribute(factory, data, Attribute.MILESTONE, client.getMilestones(), true);
- createAttribute(factory, data, Attribute.REPORTER);
+ if (existingTask) {
+ createAttribute(factory, data, Attribute.REPORTER);
+ }
createAttribute(factory, data, Attribute.CC);
createAttribute(factory, data, Attribute.KEYWORDS);
+
+ if (!existingTask) {
+ createAttribute(factory, data, Attribute.SUMMARY);
+ createAttribute(factory, data, Attribute.DESCRIPTION);
+ }
}
private static RepositoryTaskAttribute createAttribute(AbstractAttributeFactory factory, RepositoryTaskData data,
@@ -246,7 +257,7 @@ public class TracOfflineTaskHandler implements IOfflineTaskHandler {
return tasks;
}
- if (!connector.hasChangedSince(repository)) {
+ if (!TracRepositoryConnector.hasChangedSince(repository)) {
// return an empty list to avoid causing all tasks to synchronized
return Collections.emptySet();
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
index 9da4c72c1..bda71efce 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
@@ -32,6 +32,8 @@ import org.eclipse.mylar.tasks.core.IAttachmentHandler;
import org.eclipse.mylar.tasks.core.IOfflineTaskHandler;
import org.eclipse.mylar.tasks.core.ITask;
import org.eclipse.mylar.tasks.core.QueryHitCollector;
+import org.eclipse.mylar.tasks.core.RepositoryOperation;
+import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskRepository;
@@ -156,7 +158,7 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
} else {
RepositoryTaskData taskData = offlineTaskHandler.downloadTaskData(repository, bugId);
if (taskData != null) {
- task = new TracTask(handle, taskData.getId() + ":" + taskData.getDescription(), true);
+ task = new TracTask(handle, getTicketDescription(taskData), true);
task.setTaskData(taskData);
taskList.addTask(task);
} else {
@@ -221,19 +223,27 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
}
}
- private static String getTicketDescription(TracTicket ticket) {
+ public static String getTicketDescription(TracTicket ticket) {
return ticket.getId() + ": " + ticket.getValue(Key.SUMMARY);
}
- public boolean hasChangedSince(TaskRepository repository) {
+ public static String getTicketDescription(RepositoryTaskData taskData) {
+ return taskData.getId() + ":" + taskData.getSummary();
+ }
+
+ public static boolean hasChangedSince(TaskRepository repository) {
return Version.XML_RPC.name().equals(repository.getVersion());
}
- public boolean hasRichEditor(TaskRepository repository) {
+ public static boolean hasRichEditor(TaskRepository repository) {
return Version.XML_RPC.name().equals(repository.getVersion());
}
- public boolean hasAttachmentSupport(TaskRepository repository, AbstractRepositoryTask task) {
+ public static boolean hasRichEditor(TaskRepository repository, AbstractRepositoryTask task) {
+ return hasRichEditor(repository);
+ }
+
+ public static boolean hasAttachmentSupport(TaskRepository repository, AbstractRepositoryTask task) {
return Version.XML_RPC.name().equals(repository.getVersion());
}
@@ -264,5 +274,43 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
public String getTaskIdPrefix() {
return "#";
}
+
+ public static TracTicket getTracTicket(TaskRepository repository, RepositoryTaskData data) throws InvalidTicketException {
+ TracTicket ticket = new TracTicket(Integer.parseInt(data.getId()));
+
+ List<RepositoryTaskAttribute> attributes = data.getAttributes();
+ for (RepositoryTaskAttribute attribute : attributes) {
+ if (!attribute.isReadOnly()) {
+ ticket.putValue(attribute.getID(), attribute.getValue());
+ }
+ }
+ // TODO "1" should not be hard coded here
+ if ("1".equals(data.getAttributeValue(RepositoryTaskAttribute.ADD_SELF_CC))) {
+ String cc = data.getAttributeValue(RepositoryTaskAttribute.USER_CC);
+ ticket.putBuiltinValue(Key.CC, cc + "," + repository.getUserName());
+ }
+
+ RepositoryOperation operation = data.getSelectedOperation();
+ if (operation != null) {
+ String action = operation.getKnobName();
+ if (!"leave".equals(action)) {
+ if ("accept".equals(action)) {
+ ticket.putValue("status", "assigned");
+ ticket.putValue("owner", getDisplayUsername(repository));
+ } else if ("resolve".equals(action)) {
+ ticket.putValue("status", "closed");
+ ticket.putValue("resolution", operation.getOptionSelection());
+ } else if ("reopen".equals(action)) {
+ ticket.putValue("status", "reopened");
+ ticket.putValue("resolution", "");
+ } else if ("reassign".equals(operation.getKnobName())) {
+ ticket.putValue("status", "new");
+ ticket.putValue("owner", operation.getInputValue());
+ }
+ }
+ }
+
+ return ticket;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java
index 8e7a694fa..e2423fe07 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracXmlRpcClient.java
@@ -160,7 +160,8 @@ public class TracXmlRpcClient extends AbstractTracClient {
}
}
- throw new TracException("Required API calls are missing, please update your Trac XML-RPC Plugin to revision " + REQUIRED_REVISION + " or later");
+ throw new TracException("Required API calls are missing, please update your Trac XML-RPC Plugin to revision "
+ + REQUIRED_REVISION + " or later");
}
public TracTicket getTicket(int id) throws TracException {
@@ -179,9 +180,9 @@ public class TracXmlRpcClient extends AbstractTracClient {
String[] actions = getActions(id);
ticket.setActions(actions);
-
+
ticket.setResolutions(getDefaultTicketResolutions());
-
+
return ticket;
}
@@ -412,14 +413,14 @@ public class TracXmlRpcClient extends AbstractTracClient {
}
- public void createTicket(TracTicket ticket) throws TracException {
+ public int createTicket(TracTicket ticket) throws TracException {
Map<String, String> attributes = ticket.getValues();
String summary = attributes.remove(Key.SUMMARY.getKey());
String description = attributes.remove(Key.DESCRIPTION.getKey());
if (summary == null || description == null) {
throw new InvalidTicketException();
}
- call("ticket.create", summary, description, attributes);
+ return (Integer) call("ticket.create", summary, description, attributes);
}
public void updateTicket(TracTicket ticket, String comment) throws TracException {

Back to the top