Community
Participate
Working Groups
As far as I know Mylyn has no official supported API. I think it would be beneficial for the user to have an API so that he: - Can create / delete / change a Task via API - Modify the context of a Taks via API I described a possible approach (without official API) a while ago here http://www.vogella.de/blog/2009/10/05/modifying-mylyn-context/ but it would be nice to have an official API to do these things.
Generic task manipulation is supported through the tasks API. Take a look at the org.eclipse.mylyn.examples.bugzilla plug-in for instance: http://wiki.eclipse.org/Mylyn_Integrator_Reference#Quick_Example . Manipulation of contexts is currently not directly supported though API. It would be great if you could add your specific requirements for the context API to bug 242428 so we can consider adding that for a future release. *** This bug has been marked as a duplicate of bug 242428 ***
Bug 204495 might actually be the better fit to track these requirements.
*** This bug has been marked as a duplicate of bug 204495 ***
(In reply to comment #3) > > *** This bug has been marked as a duplicate of bug 204495 *** Steffen, according to the original ticket description from Lars, the requested API was not just a public context API, but also public API for task creation/deletion etc. as well. In your initial comment you referred to the example but as far as I can see it does not cover the generic (connector independent) creation of a task and I'm still not sure about the official way to do it. Any hint or an updated example is highly appreciated.
It depends on the context. For standalone use this is a basic example for creating a task: // create task repository TaskRepository repository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND, URL); // create connector TracRepositoryConnector connector = new TracRepositoryConnector(); // initialize task data TaskAttributeMapper attributeMapper = connector.getTaskDataHandler().getAttributeMapper(repository); TaskData taskData = new TaskData(attributeMapper, repository.getConnectorKind(), repository.getRepositoryUrl(), ""); connector.getTaskDataHandler().initializeTaskData(repository, taskData, null, new NullProgressMonitor()); // set attributes TaskMapper mapping = connector.getTaskMapping(taskData); mapping.setSummary("new task"); mapping.setDescription("Task created."); // submit task RepositoryResponse response = connector.getTaskDataHandler().postTaskData(repository, taskData, null, new NullProgressMonitor()); String taskUrl = connector.getTaskUrl(repository.getRepositoryUrl(), response.getTaskId()); System.out.println(MessageFormat.format("Task ''{0}'' created at {1}", response.getTaskId(), taskUrl)); If you are looking for an example how to do this when running the Mylyn UI, I would recommend looking at NewTaskFromJunitResultViewAction for instance: TaskMapping taskMapping = new TaskMapping() { @Override public String getDescription() { return "New Task"; } }; TasksUiUtil.openNewTaskEditor(shell, taskMapping, null);
(In reply to comment #5) > It depends on the context. For standalone use this is a basic example for > creating a task: My context is definitely this one. Tasks are derived from other work in the eclipse environment and should be semi-automatically created, optionally immediately submitted and visible in the task list so thanks for the code. I used a lot of internal API so far (for example TasksUiInternal.createTaskData) that more or less does the things as you have pointed them out in the sample code. But I want to go "official" and therefore asked the question. Thanks Jan