Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mylyn » How to retrieve context-artifacts and change them
icon4.gif  How to retrieve context-artifacts and change them [message #557688] Wed, 08 September 2010 14:13
Marc Schlegel is currently offline Marc SchlegelFriend
Messages: 69
Registered: July 2009
Member
Hi
In my project we are about to finally start using Mylyn (with BugZilla) but we do have a small problem.

Everytime we branch our main java-project (its one of those single-monolithic-projects) we will lose our context. Well we dont lose it completely but the information wont map to the new branch any more.

Mylyn stores its relevant artifacts in XML including the project. When a context from branch A will be opened in branch B no files will be found because project B != A.

So I started to write a little plugin that hooks into the TaskList and adds a little popup-menu there. When the action is triggered I want to retrieve the task, iterate over all artifacts and change the root
/ProjectA/somefile -> /ProjectB/somefile

Basically pretty simple, but I cannot find the right API to do this (trying to avoid "internal" packages)

Here is what I did.
public void run(IAction action) {
		
	if (selectedElement instanceof ITask) {
		ITask task = (ITask) selectedElement;
//		System.out.println(task);
//		System.out.println(task.getTaskId());
		ContextCore.getContextManager().activateContext(task.getTaskId());
		IInteractionContext c = ContextCore.getContextManager().getActiveContext();
		for (Iterator it = c.getAllElements().iterator(); it.hasNext();) {
			IInteractionElement e = (IInteractionElement) it.next();
			String h = e.getHandleIdentifier();
			h = h.replaceAll("/A/", "/B/");
			e.setHandleIdentifier(h);
		}
		try {
			System.out.println(TasksUi.getTaskDataManager().getTaskData(task));
			System.out.println(TasksUi.getTaskDataManager().hasTaskData(task));
			System.out.println(ContextCore.getStructureBridge(task));
		} catch (CoreException e) {
			e.printStackTrace();
		}
		
	}
}

The task that I am getting from the selection is correct. It has the right repository and id. As you can see I tried several ways: one was via the ContextManager but here the task needed to be active and the changes (replaceAll) havent been saved (probably this is completely wrong). The second ways was to retrieve the TaskData for that task, but this statement returns only NULL.

Can someone help me out here please.
Thanks

P.S. While working on the menuContribution I found out that Mylyn still uses Actions rather than Commands. Is there a plan to migrate this in the future (especially since E4 is about to shine)?

[Updated on: Wed, 08 September 2010 15:25]

Report message to a moderator

Previous Topic:WikiText Confluce to HTML
Next Topic:mediawiki templates and wikitext
Goto Forum:
  


Current Time: Fri Mar 29 15:25:20 GMT 2024

Powered by FUDForum. Page generated in 0.05552 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top