Changeset 6174


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

Now all child nodes, not just the filtered ones, are available for size() and get() methods

File:
1 edited

Legend:

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

    r6148 r6174  
    2525
    2626    private ArrayList children;
     27    private ArrayList raw_children;
    2728    private boolean children_readonly = true;
    2829    private boolean current_collection = false;
     
    3536
    3637    public FileNode(File file) {
    37     ///ystem.err.println("New FileNode(" + file.getAbsolutePath() + ")");
     38    ///atherer.println("New FileNode(" + file.getAbsolutePath() + ")");
    3839    this.file = file;
    3940    }
     
    9899    }
    99100    return result;
     101    }
     102
     103    /** Retrieve the filenode at the given index, regardless of filters set.
     104     * @param index int
     105     */
     106    public FileNode get(int index) {
     107    if(0 <= index && index < size() && file != null) {
     108        return (FileNode) raw_children.get(index);
     109    }
     110    return null;
    100111    }
    101112
     
    293304        if(files != null && files.length > 0) {
    294305            ArrayTools tools = new ArrayTools();
     306            // Sort the remaining files.
     307            tools.sort(files, true);
     308            // Now add them to children.
     309            raw_children = new ArrayList();
     310            for(int i = 0; i < files.length; i++) {
     311            FileNode child = new FileNode(files[i], model, children_readonly);
     312            child.setParent(this);
     313            raw_children.add(child);
     314            }
    295315            // Apply the filters set in the model.
    296316            //if(model != null) {
     
    314334                }
    315335                catch (IOException exception) {
    316                 Gatherer.printStackTrace(exception);
     336                ///atherer.printStackTrace(exception);
    317337                }
    318338            }
    319339            }
    320340            */
    321             // Sort the remaining files.
    322             tools.sort(files, true);
    323341            // Now add them to children.
    324342            for(int i = 0; i < files.length; i++) {
    325343            FileNode child = new FileNode(files[i], model, children_readonly);
    326             child.setParent(this);
    327             children.add(child);
     344            int index = -1;
     345            if((index = raw_children.indexOf(child)) != -1) {
     346                children.add(raw_children.get(index));
     347            }
     348            else {
     349                child.setParent(this);
     350                children.add(child);
     351            }
    328352            }
    329353        }
     
    387411        error.printStackTrace();
    388412    }
     413    }
     414
     415    /** Retrieve the total number of child files for the file this node represents, irrespective of filters set
     416     * @return int
     417     */
     418    public int size() {
     419    if(raw_children != null) {
     420        return raw_children.size();
     421    }
     422    return 0;
    389423    }
    390424
     
    407441        ///atherer.println("Unmap: " + this);
    408442        children = null;
     443        raw_children = null;
    409444    }
    410445    else {
Note: See TracChangeset for help on using the changeset viewer.