Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2bd45444807ff6a1068d7bd834371a3f06a01902 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*******************************************************************************
 * Copyright (c) 2004 - 2006 Mylar committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.mylyn.internal.tasks.ui.workingset;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.tasks.core.ITaskListElement;
import org.eclipse.mylyn.tasks.core.TaskList;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;

/**
 * Element factory used to restore task containers for working sets
 * 
 * @author Eugene Kuleshov
 */
public class TaskElementFactory implements IElementFactory {

	public static final String HANDLE_ID = "handle";

	public IAdaptable createElement(IMemento memento) {
		TaskList taskList = TasksUiPlugin.getTaskListManager().getTaskList();

		String handle = memento.getString(HANDLE_ID);
		for (ITaskListElement element : taskList.getRootElements()) {
			if (element instanceof AbstractTaskContainer && element.getHandleIdentifier().equals(handle)) {
				return (IAdaptable) element;
			}
		}
		return null;
	}

}

Back to the top