protected Object internalGetParent(final Object element) { if (!fIsFlatLayout && element instanceof IScriptFolder) { return getHierarchicalPackageParent((IScriptFolder) element); } else if (element instanceof IProjectFragment) { // since we insert logical package containers we have to fix // up the parent for package fragment roots so that they refer // to the container and containers refer to the project IProjectFragment root = (IProjectFragment) element; try { IBuildpathEntry entry = root.getRawBuildpathEntry(); if (entry != null) { int entryKind = entry.getEntryKind(); if (entryKind == IBuildpathEntry.BPE_CONTAINER) { return new BuildPathContainer(root.getScriptProject(), entry); } else if (fShowLibrariesNode && (entryKind == IBuildpathEntry.BPE_LIBRARY /* * || * entryKind * == * IBuildpathEntry * . * BPE_VARIABLE */)) { return new LibraryContainer(root.getScriptProject()); } } } catch (ModelException e) { // fall through } } else if (element instanceof ProjectFragmentContainer) { return ((ProjectFragmentContainer) element).getScriptProject(); } return super.internalGetParent(element); }
/* * (non-Javadoc) * * @see * org.eclipse.jdt.ui.StandardJavaElementContentProvider#getPackageFragmentRoots * (org.eclipse.jdt.core.IJavaProject) */ protected Object[] getProjectFragments(final IScriptProject project) throws ModelException { if (!project.getProject().isOpen()) { return StandardModelElementContentProvider.NO_CHILDREN; } List<Object> result = new ArrayList<Object>(); boolean addZIPContainer = false; IProjectFragment[] roots = project.getProjectFragments(); for (int i = 0; i < roots.length; i++) { IProjectFragment root = roots[i]; IBuildpathEntry classpathEntry = root.getRawBuildpathEntry(); if (classpathEntry == null) { continue; } int entryKind = classpathEntry.getEntryKind(); if (entryKind == IBuildpathEntry.BPE_CONTAINER) { // all ClassPathContainers are added later } else if (fShowLibrariesNode && (entryKind == IBuildpathEntry.BPE_LIBRARY /* * || entryKind * == * IBuildpathEntry * .BPE_VARIABLE */)) { addZIPContainer = true; } else { if (isProjectProjectFragment(root)) { // filter out package fragments that correspond to projects // and // replace them with the package fragments directly Object[] fragments = getProjectFragmentContent(root); for (int j = 0; j < fragments.length; j++) { result.add(fragments[j]); } } else { result.add(root); } } } if (addZIPContainer) { result.add(new LibraryContainer(project)); } // separate loop to make sure all containers are on the classpath IBuildpathEntry[] rawBuidspath = project.getRawBuildpath(); for (int i = 0; i < rawBuidspath.length; i++) { IBuildpathEntry classpathEntry = rawBuidspath[i]; if (classpathEntry.getEntryKind() == IBuildpathEntry.BPE_CONTAINER) { result.add(new BuildPathContainer(project, classpathEntry)); } } Object[] resources = project.getForeignResources(); for (int i = 0; i < resources.length; i++) { result.add(resources[i]); } return result.toArray(); }