1 11 12 package org.eclipse.ui.internal.cheatsheets.composite.explorer; 13 14 import org.eclipse.jface.viewers.ITreeContentProvider; 15 import org.eclipse.jface.viewers.Viewer; 16 import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; 17 import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheet; 18 import org.eclipse.ui.internal.provisional.cheatsheets.ITaskGroup; 19 20 class TreeContentProvider implements ITreeContentProvider { 21 public Object [] getChildren(Object parentElement) { 22 if (parentElement instanceof ICompositeCheatSheet) { 23 final Object [] rootTask = {((ICompositeCheatSheet) parentElement).getRootTask()}; 24 return rootTask; 25 } 26 if (parentElement instanceof ITaskGroup) 27 return ((ITaskGroup) parentElement).getSubtasks(); 28 return new Object [0]; 29 } 30 31 public Object getParent(Object element) { 32 if (element instanceof AbstractTask) { 33 return ((AbstractTask)element).getParent(); 34 } 35 return null; 36 } 37 38 public boolean hasChildren(Object element) { 39 if (element instanceof ICompositeCheatSheet) 40 return true; 41 if (element instanceof ITaskGroup) 42 return ((ITaskGroup) element).getSubtasks().length > 0; 43 return false; 44 } 45 46 public Object [] getElements(Object inputElement) { 47 return getChildren(inputElement); 48 } 49 50 public void dispose() { 51 } 52 53 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 54 } 55 } 56 | Popular Tags |