Created
February 17, 2009 15:54
-
-
Save torarnv/65799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* File tree iterator that automatically adapts to a container iterator when | |
* recursing into directories that are accessible from the given workspace | |
* root. | |
*/ | |
private class AdptableFileTreeIterator extends FileTreeIterator { | |
IWorkspaceRoot root; | |
public AdptableFileTreeIterator(final File path, | |
final IWorkspaceRoot workspaceRoot) { | |
super(path); | |
root = workspaceRoot; | |
} | |
protected AdptableFileTreeIterator( | |
final AdptableFileTreeIterator parent, File path, | |
final IWorkspaceRoot workspaceRoot) { | |
super(parent, path); | |
root = workspaceRoot; | |
} | |
@Override | |
public AbstractTreeIterator createSubtreeIterator(Repository repo) | |
throws IncorrectObjectTypeException, IOException { | |
File currentFile = ((FileEntry) current()).getFile(); | |
IContainer[] containers = root.findContainersForLocation(new Path( | |
currentFile.getAbsolutePath())); | |
if (containers.length > 0) | |
return new ContainerTreeIterator(this, containers[0]); | |
else | |
return new AdptableFileTreeIterator(this, currentFile, root); | |
} | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment