Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mylyn » Adding Elements to the active context of the task
Adding Elements to the active context of the task [message #920572] Sun, 23 September 2012 07:12 Go to next message
saurav sarkar is currently offline saurav sarkar
Messages: 424
Registered: July 2009
Senior Member
Hi All,

I am very new to Mylyn Internals.

My requirement is as follows:

Everything has to be done progmatically.

(a) Create a local task and activate.
(b) Add few java files to the task's context.

For the step b is it possible to do progmmatically ?
I debugged how the existing adding functionality to the context works.

An IInteractionElement is created from the selection and added to the context. Is it possible to do the same through a programme given the set of files.

cheers,
Saurav


Re: Adding Elements to the active context of the task [message #921902 is a reply to message #920572] Mon, 24 September 2012 14:38 Go to previous message
saurav sarkar is currently offline saurav sarkar
Messages: 424
Registered: July 2009
Senior Member
ok...i was able to proceed till creation of task and adding it to the task context

LocalTask createNewLocalTask = new LocalTask("JUnit", "JUnit");
		
		TasksUiUtil.openTask(createNewLocalTask);
		//TaskCategory category = new TaskCategory(TasksUiPlugin.getTaskList().getUniqueHandleIdentifier(), "JUNit");
		
		TasksUi.getTaskActivityManager().activateTask(createNewLocalTask);
		//TasksUiPlugin.getTaskList().addTask(createNewLocalTask, category);
		
		//add task category
		
//		TaskCategory category = new TaskCategory(TasksUiPlugin.getTaskList().getUniqueHandleIdentifier(), "JUNits");
//		TasksUiPlugin.getTaskList().addCategory(category);
		ICompilationUnit firstElement = (ICompilationUnit)((IStructuredSelection)selection).getFirstElement();
		//IProject project = ResourceUtil.getFile(firstElement).getProject();
		
		//add files to the task context
		
		IInteractionContext activeContext = ContextCore.getContextManager().getActiveContext();
		
		
//		List<InteractionContextElement> nodes = new ArrayList<InteractionContextElement>();
//		InteractionContextElement node = new InteractionContextElement(
//		InteractionEvent.Kind.MANIPULATION, firstElement.getHandleIdentifier(), (InteractionContext) activeContext); //$NON-NLS-1$ //$NON-NLS-2$
//		nodes.add(node);
//		IInteractionElement newElement = new CompositeContextElement(
//				InteractionEvent.Kind.MANIPULATION, nodes, activeContext.getScaling()); //$NON-NLS-1$
//		activeContext.getAllElements().add(newElement);
		
		InteractionEvent event = new InteractionEvent(InteractionEvent.Kind.MANIPULATION,
				"java", firstElement.getHandleIdentifier(), "source");
		InteractionContextManager contextManager = ContextCorePlugin.getContextManager();
		IInteractionElement element = contextManager.processInteractionEvent(event, true);
		contextManager.manipulateInterestForElements(Collections.singletonList(element), true, false, false, "test",
				contextManager.getActiveContext(), true);


But couple of things need to be working here.

(1) The element is added as an invisible element not as a visible element.
(2) The focus has not set to the particular file.

cheers,
Saurav


Previous Topic:Mylyn 3.8.0 and Atlassian JIRA v5.1.4 not working
Next Topic:Access changesets (ChangeSetManager) via Mylyn
Goto Forum:
  


Current Time: Sun Oct 26 03:05:17 GMT 2014

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

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