@Override protected AbstractFile[] getFiles(AbstractFile directory) throws IOException { return fileFilter.filter(directory.ls()); } }
/** * Returns <code>true</code> if the specified file matches the association. * @param file file to match against the association. * @return <code>true</code> if the specified file matches the association, <code>false</code> otherwise. */ public boolean accept(AbstractFile file) {return fileFilter.match(file);}
/** * Calls {@link #match(com.mucommander.commons.file.AbstractFile)} on each of the registered filters, and returns * <code>true</code> if all of them matched the given file, <code>false</code> if one of them didn't. * * <p>If this {@link ChainedFileFilter} contains no filter, this method will always return <code>true</code>.</p> * * @param file the file to test against the registered filters * @return if the file was matched by all filters, false if one of them didn't */ public boolean accept(AbstractFile file) { int nbFilters = filters.size(); for(int i=0; i<nbFilters; i++) if(!filters.elementAt(i).match(file)) return false; return true; } }
/** * Returns the children files that this file contains, filtering out files that do not match the specified FileFilter. * For this operation to be successful, this file must be 'browsable', i.e. {@link #isBrowsable()} must return * <code>true</code>. * * @param filter the FileFilter to be used to filter files out from the list, may be <code>null</code> * @return the children files that this file contains * @throws IOException if this operation is not possible (file is not browsable) or if an error occurred. * @throws UnsupportedFileOperationException if this method relies on a file operation that is not supported * or not implemented by the underlying filesystem. */ public AbstractFile[] ls(FileFilter filter) throws IOException, UnsupportedFileOperationException { return filter==null?ls():filter.filter(ls()); }
/** * Calls {@link #match(com.mucommander.commons.file.AbstractFile)} on each of the registered filters, and returns * <code>true</code> if one of them matched the given file, <code>false</code> if none of them did. * * <p>If this {@link ChainedFileFilter} contains no filter, this method will always return <code>true</code>.</p> * * @param file the file to test against the registered filters * @return if the file was matched by one filter, false if none of them did */ public boolean accept(AbstractFile file) { int nbFilters = filters.size(); if(nbFilters==0) return true; for(int i=0; i<nbFilters; i++) if((filters.elementAt(i)).match(file)) return true; return false; } }
/** * Returns the contents (direct children) of the specified tree node. * * @throws UnsupportedFileOperationException if {@link FileOperation#READ_FILE} operations are not supported by the * underlying file protocol. */ private AbstractFile[] ls(DefaultMutableTreeNode treeNode, AbstractFile parentFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException, UnsupportedFileOperationException { AbstractFile files[]; int nbChildren = treeNode.getChildCount(); // No FilenameFilter, create entry files and store them directly into an array if(filenameFilter==null) { files = new AbstractFile[nbChildren]; for(int c=0; c<nbChildren; c++) { files[c] = getArchiveEntryFile((ArchiveEntry)(((DefaultMutableTreeNode)treeNode.getChildAt(c)).getUserObject()), parentFile); } } // Use provided FilenameFilter and temporarily store created entry files that match the filter in a Vector else { Vector<AbstractFile> filesV = new Vector<AbstractFile>(); for(int c=0; c<nbChildren; c++) { ArchiveEntry entry = (ArchiveEntry)(((DefaultMutableTreeNode)treeNode.getChildAt(c)).getUserObject()); if(!filenameFilter.accept(entry.getName())) continue; filesV.add(getArchiveEntryFile(entry, parentFile)); } files = new AbstractFile[filesV.size()]; filesV.toArray(files); } return fileFilter==null?files:fileFilter.filter(files); }
@Override protected boolean getFileTableCondition(FileTable fileTable) { AbstractFile selectedFile = fileTable.getSelectedFile(false, true); boolean enable = selectedFile!=null; if(enable && filter!=null) enable = filter.match(selectedFile); return enable; } }
@Override public void performAction(FileSet files) { // Filter out files that are not regular files FileFilter filter = new AttributeFileFilter(FileAttribute.FILE); filter.filter(files); if (files.size()==0) return; AbstractFile destFolder = mainFrame.getInactivePanel().getCurrentFolder(); new CombineFilesDialog(mainFrame, files, destFolder).showDialog(); }
/** * Marks/unmarks the files that match the given {@link FileFilter}. * * @param filter the FileFilter to match the files against * @param marked if true, matching files will be marked, if false, they will be unmarked */ public synchronized void setFilesMarked(FileFilter filter, boolean marked) { int nbFiles = getRowCount(); for(int i=parent==null?0:1; i<nbFiles; i++) { if(filter.match(getCachedFileAtRow(i))) setRowMarked(i, marked); } }