protected boolean buildStructure( OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws ModelException { // check whether this folder can be opened if (!underlyingResource.isAccessible()) throw newNotPresentException(); int kind = getKind(); if (kind == IProjectFragment.K_SOURCE && Util.isExcluded(this)) throw newNotPresentException(); // add modules from resources HashSet vChildren = new HashSet(); try { ProjectFragment root = getProjectFragment(); char[][] inclusionPatterns = root.fullInclusionPatternChars(); char[][] exclusionPatterns = root.fullExclusionPatternChars(); IResource[] members = ((IContainer) underlyingResource).members(); for (int i = 0, max = members.length; i < max; i++) { IResource child = members[i]; if (child.getType() != IResource.FOLDER && !Util.isExcluded(child, inclusionPatterns, exclusionPatterns)) { IModelElement childElement; if (kind == IProjectFragment.K_SOURCE && Util.isValidSourceModule(this, child)) { childElement = getSourceModule(child.getName()); vChildren.add(childElement); } } } } catch (CoreException e) { throw new ModelException(e); } if (kind == IProjectFragment.K_SOURCE) { // add primary source modules ISourceModule[] primarySourceModules = getSourceModules(DefaultWorkingCopyOwner.PRIMARY); for (int i = 0, length = primarySourceModules.length; i < length; i++) { ISourceModule primary = primarySourceModules[i]; vChildren.add(primary); } } IModelElement[] children = new IModelElement[vChildren.size()]; vChildren.toArray(children); info.setChildren(children); return true; }
private Object[] computeForeignResources( IScriptProject scriptProject, IResource underlyingResource, ProjectFragment handle) { Object[] nonScriptResources = NO_NON_SCRIPT_RESOURCES; try { // the underlying resource may be a folder or a project (in the case // that the project folder // is actually the package fragment root) if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) { nonScriptResources = computeFolderForeignResources( (ScriptProject) scriptProject, (IContainer) underlyingResource, handle.fullInclusionPatternChars(), handle.fullExclusionPatternChars()); } } catch (ModelException e) { // ignore } return nonScriptResources; }