Search in sources :

Example 1 with MapRecognizer

use of org.pepsoft.worldpainter.mapexplorer.MapRecognizer in project WorldPainter by Captain-Chaos.

the class DirectoryNode method loadChildren.

@Override
protected Node[] loadChildren() {
    File[] contents = file.listFiles(showFiles ? null : File::isDirectory);
    if (contents != null) {
        Node[] children = new Node[contents.length];
        for (int i = 0; i < contents.length; i++) {
            if (contents[i].isDirectory()) {
                for (MapRecognizer mapRecognizer : MAP_RECOGNIZERS) {
                    if (mapRecognizer.isMap(contents[i])) {
                        children[i] = mapRecognizer.getMapNode(contents[i]);
                        break;
                    }
                }
                if (children[i] == null) {
                    children[i] = new DirectoryNode(contents[i], showFiles);
                }
            } else {
                children[i] = new FileSystemNode(contents[i]);
            }
        }
        Arrays.sort(children, (node1, node2) -> COLLATOR.compare(node1.getName(), node2.getName()));
        return children;
    } else {
        return new Node[0];
    }
}
Also used : Node(org.pepsoft.worldpainter.mapexplorer.Node) MapRecognizer(org.pepsoft.worldpainter.mapexplorer.MapRecognizer) File(java.io.File)

Aggregations

File (java.io.File)1 MapRecognizer (org.pepsoft.worldpainter.mapexplorer.MapRecognizer)1 Node (org.pepsoft.worldpainter.mapexplorer.Node)1