Search in sources :

Example 1 with CachedFile

use of com.mucommander.commons.file.CachedFile in project mucommander by mucommander.

the class FileTableModel method setCurrentFolder.

/**
 * Sets the current folder and its children.
 *
 * @param folder the current folder
 * @param children the current folder's children
 */
synchronized void setCurrentFolder(AbstractFile folder, AbstractFile[] children) {
    int nbFiles = children.length;
    this.currentFolder = (folder instanceof CachedFile) ? folder : new CachedFile(folder, true);
    // Note: the returned parent is a CachedFile instance
    this.parent = currentFolder.getParent();
    if (parent != null) {
        // Pre-fetch the attributes that are used by the table renderer and some actions.
        prefetchCachedFileAttributes(parent);
    }
    stopSizeCalculation();
    // Initialize file indexes and create CachedFile instances to speed up table display and navigation
    this.cachedFiles = children;
    this.fileArrayIndex = new int[nbFiles];
    AbstractFile file;
    for (int i = 0; i < nbFiles; i++) {
        file = new CachedFile(children[i], true);
        // Pre-fetch the attributes that are used by the table renderer and some actions.
        prefetchCachedFileAttributes(file);
        cachedFiles[i] = file;
        fileArrayIndex[i] = i;
    }
    // Reset marked files
    int nbRows = getRowCount();
    this.rowMarked = new boolean[nbRows];
    this.markedTotalSize = 0;
    this.nbRowsMarked = 0;
    // Init and fill cell cache to speed up table even more
    this.cellValuesCache = new Object[nbRows][Column.values().length - 1];
    fillCellCache();
}
Also used : CachedFile(com.mucommander.commons.file.CachedFile) AbstractFile(com.mucommander.commons.file.AbstractFile)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)1 CachedFile (com.mucommander.commons.file.CachedFile)1