1 11 package org.eclipse.jdt.internal.ui.workingsets; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.runtime.CoreException; 15 16 import org.eclipse.jdt.core.IJavaModel; 17 import org.eclipse.jdt.core.IPackageFragment; 18 import org.eclipse.jdt.core.IPackageFragmentRoot; 19 import org.eclipse.jdt.core.JavaModelException; 20 21 import org.eclipse.jdt.ui.StandardJavaElementContentProvider; 22 23 class JavaWorkingSetPageContentProvider extends StandardJavaElementContentProvider { 24 25 public boolean hasChildren(Object element) { 26 27 if (element instanceof IProject && !((IProject)element).isAccessible()) 28 return false; 29 30 if (element instanceof IPackageFragment) { 31 IPackageFragment pkg= (IPackageFragment)element; 32 try { 33 if (pkg.getKind() == IPackageFragmentRoot.K_BINARY) 34 return pkg.getChildren().length > 0; 35 } catch (JavaModelException ex) { 36 } 38 } 39 return super.hasChildren(element); 40 } 41 42 public Object [] getChildren(Object parentElement) { 43 try { 44 if (parentElement instanceof IJavaModel) 45 return concatenate(super.getChildren(parentElement), getNonJavaProjects((IJavaModel)parentElement)); 46 47 if (parentElement instanceof IProject) 48 return ((IProject)parentElement).members(); 49 50 return super.getChildren(parentElement); 51 } catch (CoreException e) { 52 return NO_CHILDREN; 53 } 54 } 55 56 private Object [] getNonJavaProjects(IJavaModel model) throws JavaModelException { 57 return model.getNonJavaResources(); 58 } 59 } 60 | Popular Tags |