switch (type) { case IJavaElement.JAVA_PROJECT: { IJavaProject project= (IJavaProject)iJavaElement; IProject proj= project.getProject();  List children= new ArrayList();  IPackageFragmentRoot defaultroot= project.getPackageFragmentRoot(proj); if(defaultroot.exists()) { IJavaElement[] els= defaultroot.getChildren(); children= getTopLevelChildrenByElementName(els); } return filter(children.toArray());
switch (type) { case IJavaElement.JAVA_PROJECT: { IJavaProject project= (IJavaProject) iJavaElement;  IPackageFragmentRoot root= project.findPackageFragmentRoot(project.getPath()); if (root != null) { List children= getTopLevelChildren(root); return filter(children).toArray(); } break; } case IJavaElement.PACKAGE_FRAGMENT_ROOT: { IPackageFragmentRoot root= (IPackageFragmentRoot) parentElement; if (root.exists()) { return filter(getTopLevelChildren(root)).toArray();
	public Object[] getChildren(Object parentElement) {		try {			if (parentElement instanceof IJavaElement) {				IJavaElement iJavaElement= (IJavaElement) parentElement;				int type= iJavaElement.getElementType();				switch (type) {					case IJavaElement.JAVA_PROJECT: {						IJavaProject project= (IJavaProject)iJavaElement;						IProject proj= project.getProject();																							List children= new ArrayList();												IPackageFragmentRoot defaultroot= project.getPackageFragmentRoot(proj);						if(defaultroot.exists()) {							IJavaElement[] els= defaultroot.getChildren();							children= getTopLevelChildrenByElementName(els);						}						return filter(children.toArray());					}									case IJavaElement.PACKAGE_FRAGMENT_ROOT: {							IPackageFragmentRoot root= (IPackageFragmentRoot) parentElement;							if (root.exists()) {								IResource resource= root.getUnderlyingResource();								if (root.isArchive()) {									IJavaElement[] els= root.getChildren();									return filter(getTopLevelChildrenByElementName(els).toArray());								} else if (resource instanceof IFolder) {									IFolder folder= (IFolder) resource;									IResource[] reses= folder.members();									List children= getFolders(reses);									IPackageFragment defaultPackage= root.getPackageFragment(""); //$NON-NLS-1$									if(defaultPackage.exists())										children.add(defaultPackage);									return filter(children.toArray());								}							}							break;						}					case IJavaElement.PACKAGE_FRAGMENT: {							IPackageFragment packageFragment = (IPackageFragment) parentElement;							if (!packageFragment.isDefaultPackage()) {								IResource resource = packageFragment.getUnderlyingResource();								if (resource != null && resource instanceof IFolder) {									IFolder folder = (IFolder) resource;									IResource[] reses = folder.members();									Object[] children = getFolders(reses).toArray();									return filter(children);									//if the resource is null, maybe member of an archive								} else {									IJavaElement parent = packageFragment.getParent();									if (parent instanceof IPackageFragmentRoot) {										IPackageFragmentRoot root = (IPackageFragmentRoot) parent;										Object[] children = findNextLevelChildrenByElementName(root, packageFragment);										return filter(children);									}								}							}							break;						}					default :						// do nothing				}			} else if (parentElement instanceof IFolder) {				IFolder folder= (IFolder)parentElement;				IResource[] resources= folder.members();				Object[] children = getFolders(resources).toArray();				return filter(children);			}		} catch (JavaModelException e) {			JavaPlugin.log(e);		} catch (CoreException e) {			JavaPlugin.log(e);		}		return new Object[0];	}