private void buildDirTree(BuildConfigNode node, String rootPath, List importedFiles, String configFileName) {
File[] dirs = new File(node.getResourcePath()).listFiles(DIR_FILTER);
if (dirs == null) return;
for (int i = 0; i < dirs.length; i++) {
BuildConfigNode dir = new BuildConfigNode(dirs[i].getName(), BuildConfigNode.Kind.DIRECTORY, dirs[i].getPath());
File[] files = dirs[i].listFiles(SOURCE_FILE_FILTER);
for (int j = 0; j < files.length; j++) {
if (files[j] != null) {// && !files[j].getName().endsWith(".lst")) {
String filePath = fileUpdater.relativizePath(files[j].getPath(), rootPath);
BuildConfigNode.Kind kind = BuildConfigNode.Kind.FILE_JAVA;
if (!files[j].getName().endsWith(".lst")) {
//kind = BuildConfigNode.Kind.FILE_LST;
BuildConfigNode file = new BuildConfigNode(files[j].getName(), kind, filePath);
file.setActive(false);
dir.addChild(file);
}
}
}
node.addChild(dir);
// boolean foundMatch = false;
for (Iterator it = importedFiles.iterator(); it.hasNext(); ) {
File importedFile = (File)it.next();
if (importedFile.getParentFile().getAbsolutePath().equals(dirs[i].getAbsolutePath())) {
// foundMatch = true;
BuildConfigNode importedFileNode = new BuildConfigNode(
importedFile.getName(),
BuildConfigNode.Kind.FILE_LST,
fileUpdater.relativizePath(importedFile.getPath(), rootPath));
importedFileNode.setActive(true);
//dir.getChildren().clear();
boolean found = false;
for (Iterator it2 = dir.getChildren().iterator(); it2.hasNext(); ) {
if (((BuildConfigNode)it2.next()).getName().equals(importedFile.getName())) {
found = true;
}
}
if (!found) dir.addChild(importedFileNode);
}
}
//if (!foundMatch)
buildDirTree(dir, rootPath, importedFiles, configFileName);
}
if (node.getName().endsWith(".lst")) {
File[] files = new File(rootPath).listFiles(SOURCE_FILE_FILTER);
if (files == null) return;
for (int i = 0; i < files.length; i++) {
if (files[i] != null && !files[i].getName().equals(configFileName)) {// && !files[i].getName().endsWith(".lst")) {
BuildConfigNode.Kind kind = BuildConfigNode.Kind.FILE_JAVA;
if (files[i].getName().endsWith(".lst")) {
kind = BuildConfigNode.Kind.FILE_LST;
}
BuildConfigNode file = new BuildConfigNode(files[i].getName(), kind, files[i].getName());
file.setActive(false);
node.addChild(file);
}
}
}
}