Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1cbaf6e5bf51e59043fba5db48b3c1cd9ce8e4d6 (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
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2005 IBM Corporation 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
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ui.internal.cheatsheets.composite.explorer;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.cheatsheets.ICompositeCheatSheet;
import org.eclipse.ui.cheatsheets.ITaskGroup;

class TreeContentProvider implements ITreeContentProvider {
	public Object[] getChildren(Object parentElement) {
		if (parentElement instanceof ICompositeCheatSheet) {
			final Object[] rootTask = {((ICompositeCheatSheet) parentElement).getRootTask()};
			return rootTask;
		}
		if (parentElement instanceof ITaskGroup)
			return ((ITaskGroup) parentElement).getSubtasks();
		return new Object[0];
	}

	public Object getParent(Object element) {
		return null;
	}

	public boolean hasChildren(Object element) {
		if (element instanceof ICompositeCheatSheet)
			return true;
		if (element instanceof ITaskGroup)
			return ((ITaskGroup) element).getSubtasks().length > 0;
		return false;
	}

	public Object[] getElements(Object inputElement) {
		return getChildren(inputElement);
	}

	public void dispose() {
	}

	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
	}
}

Back to the top