Changeset 6176


Ignore:
Timestamp:
2003-12-08T17:08:47+13:00 (20 years ago)
Author:
jmt12
Message:

When determining a node based on a file path, FileNode.size() and get() are used instead of getChildCount() and getChildAt(), which had previously lead to a problem with filtered children

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java

    r5785 r6176  
    4949    /** Retrieve the node denoted by the given tree path. Note that this isn't equivelent to saying path.lastPathComponent, as the references within the path may be stale. */
    5050    public FileNode getNode(TreePath path) {
    51     ///ystem.err.println("**** getNode(" + path + ") ****");
     51    ///atherer.println("**** getNode(" + path + ") ****");
    5252    FileNode current = (FileNode)root;
    5353    // Special case for the root node. Check the first path component is the root node.
    5454    FileNode first_node = (FileNode)path.getPathComponent(0);
    5555    if(current.equals(first_node)) {
    56                 ///ystem.err.println("First path component matches root node.");
    57                 // For each path with this tree path
     56        ///atherer.println("First path component matches root node.");
     57        // For each path with this tree path
    5858        for(int i = 1; current != null && i < path.getPathCount(); i++) {
    5959        // Retrieve the stale path
    6060        FileNode stale_node = (FileNode) path.getPathComponent(i);
    61         ///ystem.err.print("Searching for '" + stale_node + "': ");
     61        ///atherer.print("Searching for '" + stale_node + "': ");
    6262        // Locate the fresh node by searching current's children. Remember to ensure that current is mapped.
    6363        current.map();
    6464        boolean found = false;
     65
     66        // First we search through the mapped children
    6567        for(int j = 0; !found && j < current.getChildCount(); j++) {
    6668            FileNode child_node = (FileNode) current.getChildAt(j);
    67             ///ystem.err.print(child_node + " ");
     69            ///atherer.print(child_node + " ");
    6870            if(stale_node.equals(child_node)) {
    6971            found = true;
    7072            current = child_node;
    71             ///ystem.err.println("Found!");
     73            ///atherer.println("Found!");
     74            }
     75            child_node = null;
     76        }
     77        // Failing that we search through all the children, including filtered files
     78        for(int j = 0; !found && j < current.size(); j++) {
     79            FileNode child_node = (FileNode) current.get(j);
     80            ///atherer.print(child_node + " ");
     81            if(stale_node.equals(child_node)) {
     82            found = true;
     83            current = child_node;
     84            ///atherer.println("Found!");
    7285            }
    7386            child_node = null;
     
    7689        if(!found) {
    7790            current = null;
    78             ///ystem.err.println("Not Found!");
     91            ///atherer.println("Not Found!");
    7992        }
    8093        // Repeat as necessary
    8194        }
    8295    }
    83     ///ystem.err.println("Returning node: " + new TreePath(current.getPath()));
     96    ///atherer.println("Returning node: " + new TreePath(current.getPath()));
    8497    return current;
    8598    }
Note: See TracChangeset for help on using the changeset viewer.