Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315016 - Mylyn should have API (for tasks)
Summary: Mylyn should have API (for tasks)
Status: RESOLVED DUPLICATE of bug 204495
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Mylyn Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-30 16:22 EDT by Lars Vogel CLA
Modified: 2011-10-20 09:05 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2010-05-30 16:22:17 EDT
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.
Comment 1 Steffen Pingel CLA 2010-07-09 22:01:15 EDT
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 ***
Comment 2 Steffen Pingel CLA 2010-07-09 22:02:37 EDT
Bug 204495 might actually be the better fit to track these requirements.
Comment 3 Steffen Pingel CLA 2010-07-09 22:02:51 EDT

*** This bug has been marked as a duplicate of bug 204495 ***
Comment 4 Jan Mauersberger CLA 2011-10-20 03:06:24 EDT
(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.
Comment 5 Steffen Pingel CLA 2011-10-20 06:19:43 EDT
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);
Comment 6 Jan Mauersberger CLA 2011-10-20 09:05:11 EDT
(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