1 11 package org.eclipse.debug.internal.ui.sourcelookup; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.resources.IProject; 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.resources.IWorkspaceRoot; 18 import org.eclipse.jface.viewers.ITreeContentProvider; 19 import org.eclipse.jface.viewers.Viewer; 20 25 public class BasicContainerContentProvider implements ITreeContentProvider { 26 27 private boolean fShowClosedProjects = true; 28 31 public BasicContainerContentProvider() { 32 } 33 37 public void dispose() { 38 } 39 40 43 public Object [] getChildren(Object element) { 44 if (element instanceof IWorkspaceRoot) { 45 IProject[] allProjects = ((IWorkspaceRoot) element).getProjects(); 47 if (fShowClosedProjects) 48 return allProjects; 49 50 ArrayList accessibleProjects = new ArrayList (); 51 for (int i = 0; i < allProjects.length; i++) { 52 if (allProjects[i].isOpen()) { 53 accessibleProjects.add(allProjects[i]); 54 } 55 } 56 return accessibleProjects.toArray(); 57 } 58 return new Object [0]; 59 } 60 61 64 public Object [] getElements(Object element) { 65 return getChildren(element); 66 } 67 68 71 public Object getParent(Object element) { 72 if (element instanceof IResource) 73 return ((IResource) element).getParent(); 74 return null; 75 } 76 77 80 public boolean hasChildren(Object element) { 81 return getChildren(element).length > 0; 82 } 83 84 87 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 88 89 } 90 } 91 | Popular Tags |