Search in sources :

Example 6 with FileSet

use of com.mucommander.commons.file.util.FileSet in project mucommander by mucommander.

the class BrowseLocationThread method showDownloadDialog.

/**
 * Displays a download dialog box where the user can choose where to download the given file or cancel
 * the operation.
 *
 * @param file the file to download
 */
private void showDownloadDialog(AbstractFile file) {
    FileSet fileSet = new FileSet(locationManager.getCurrentFolder());
    fileSet.add(file);
    // Show confirmation/path modification dialog
    new DownloadDialog(mainFrame, fileSet).showDialog();
}
Also used : FileSet(com.mucommander.commons.file.util.FileSet) DownloadDialog(com.mucommander.ui.dialog.file.DownloadDialog)

Example 7 with FileSet

use of com.mucommander.commons.file.util.FileSet in project mucommander by mucommander.

the class SearchBuilder method build.

public SearchJob build() {
    if (searchJob == null) {
        searchJob = new SearchJob(mainFrame, new FileSet(entrypoint, entrypoint));
        searchJob.setListener(listener);
        searchJob.setDepth(searchDepth);
        searchJob.setThreads(searchThreads);
        Predicate<AbstractFile> fileMatcher = createFilePredicate();
        searchJob.setFileMatcher(fileMatcher);
        Predicate<AbstractFile> lsFilter = createListFilter();
        searchJob.setListFilter(lsFilter);
        searchJob.setSearchText(searchText);
    }
    return searchJob;
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet) SearchJob(com.mucommander.job.impl.SearchJob)

Example 8 with FileSet

use of com.mucommander.commons.file.util.FileSet in project mucommander by mucommander.

the class XfceTrash method empty.

/**
 * Empty the trash
 * <p>
 * <b>Implementation notes:</b><br>
 * Simply free the <code>TRASH_PATH</code> directory
 * </p>
 *
 * @return True if everything went well
 */
@Override
public boolean empty() {
    // Abort if there is no usable trash folder
    if (TRASH_FOLDER == null)
        return false;
    FileSet filesToDelete = new FileSet(TRASH_FOLDER);
    try {
        // delete real files
        filesToDelete.addAll(TRASH_FILES_SUBFOLDER.ls());
        // delete spec files
        filesToDelete.addAll(TRASH_INFO_SUBFOLDER.ls());
    } catch (java.io.IOException ex) {
        LOGGER.debug("Failed to list files", ex);
        return false;
    }
    if (filesToDelete.size() > 0) {
        // Starts deleting files
        MainFrame mainFrame = WindowManager.getCurrentMainFrame();
        ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("delete_dialog.deleting"));
        DeleteJob deleteJob = new DeleteJob(progressDialog, mainFrame, filesToDelete, false);
        progressDialog.start(deleteJob);
    }
    return true;
}
Also used : DeleteJob(com.mucommander.job.impl.DeleteJob) FileSet(com.mucommander.commons.file.util.FileSet) IOException(java.io.IOException) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) MainFrame(com.mucommander.ui.main.MainFrame)

Example 9 with FileSet

use of com.mucommander.commons.file.util.FileSet in project mucommander by mucommander.

the class FileTable method setCurrentFolder.

/**
 * Changes the current folder to the specified one and refreshes the table to reflect the folder's contents.
 * The current file selection is also updated, with the following behavior:
 * <ul>
 *   <li>If <code>filetoSelect</code> is not <code>null</code>, the specified file becomes the currently selected
 * file, if it can be found in the new current folder. Previously marked files are cleared.</li>
 *   <li>If it is <code>null</code>:
 *     <ul>
 *       <li>if the current folder is the same as the previous one, the currently selected file and marked files
 * remain the same, provided they still exist.</li>
 *       <li>if the new current folder is the parent of the previous one, the previous current folder is selected.</li>
 *       <li>in any other case, the first row is selected, whether it be the parent directory ('..') or the first
 * file of the current folder if it has no parent.</li>
 *     </ul>
 *   </li>
 * </ul>
 *
 * <p>
 * This method returns only when the folder has actually been changed and the table refreshed.<br>
 * <b>Important:</b> This method should only be called by {@link FolderPanel} and in any case MUST be synchronized
 * externally to ensure this method is never called concurrently by different threads.
 * </p>
 *
 * @param folder the new current folder
 * @param children children of the specified folder
 * @param fileToSelect the file to select, <code>null</code> for the default selection.
 */
public void setCurrentFolder(AbstractFile folder, AbstractFile[] children, AbstractFile fileToSelect) {
    overlayTable.setOverlayVisible(!folder.exists());
    // Stop quick search in case it was being used before folder change
    quickSearch.stop();
    AbstractFile currentFolder = folderPanel.getCurrentFolder();
    // If we're refreshing the current folder, save the current selection and marked files
    // in order to restore them properly.
    FileSet markedFiles = null;
    if (currentFolder != null && folder.equalsCanonical(currentFolder)) {
        markedFiles = tableModel.getMarkedFiles();
        if (fileToSelect == null)
            fileToSelect = getSelectedFile();
    } else // If we're navigating to the current folder's parent, we select the current folder.
    if (fileToSelect == null) {
        if (tableModel.hasParentFolder() && folder.equals(tableModel.getParentFolder()))
            fileToSelect = currentFolder;
    }
    // Changes the current folder in the swing thread to make sure that repaints cannot
    // happen in the middle of the operation - this is used to prevent flickering, badly
    // refreshed frames and such unpleasant graphical artifacts.
    Runnable folderChangeThread = new FolderChangeThread(folder, children, markedFiles, fileToSelect);
    // due to AWT thread synchronization issues.
    synchronized (folderChangeThread) {
        SwingUtilities.invokeLater(folderChangeThread);
        while (true) {
            try {
                // FolderChangeThread will call notify when done
                folderChangeThread.wait();
                break;
            } catch (InterruptedException e) {
            // will keep looping
            }
        }
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet)

Example 10 with FileSet

use of com.mucommander.commons.file.util.FileSet in project mucommander by mucommander.

the class FileTableModel method getMarkedFiles.

/**
 * Returns a {@link com.mucommander.commons.file.util.FileSet FileSet} with all currently marked files.
 * <p>
 * The returned <code>FileSet</code> is a freshly created instance, so it can be safely modified.
 *     & However, it won't be kept current : the returned FileSet is just a snapshot
 * which might not reflect the current marked files state after this method has returned and additional
 * files have been marked/unmarked.
 * </p>
 *
 * @return a FileSet containing all the files that are currently marked
 */
public synchronized FileSet getMarkedFiles() {
    FileSet markedFiles = new FileSet(currentFolder, nbRowsMarked);
    int nbRows = getRowCount();
    if (parent == null) {
        for (int i = 0; i < nbRows; i++) {
            if (rowMarked[fileArrayIndex[i]])
                markedFiles.add(getFileAtRow(i));
        }
    } else {
        for (int i = 1, iMinusOne = 0; i < nbRows; i++) {
            if (rowMarked[fileArrayIndex[iMinusOne]])
                markedFiles.add(getFileAtRow(i));
            iMinusOne = i;
        }
    }
    return markedFiles;
}
Also used : FileSet(com.mucommander.commons.file.util.FileSet)

Aggregations

FileSet (com.mucommander.commons.file.util.FileSet)16 AbstractFile (com.mucommander.commons.file.AbstractFile)8 ProgressDialog (com.mucommander.ui.dialog.file.ProgressDialog)5 MainFrame (com.mucommander.ui.main.MainFrame)3 IOException (java.io.IOException)3 CopyJob (com.mucommander.job.impl.CopyJob)2 DeleteJob (com.mucommander.job.impl.DeleteJob)2 LocalFile (com.mucommander.commons.file.protocol.local.LocalFile)1 DestinationType (com.mucommander.commons.file.util.DestinationType)1 PathUtils (com.mucommander.commons.file.util.PathUtils)1 MkdirJob (com.mucommander.job.impl.MkdirJob)1 MoveJob (com.mucommander.job.impl.MoveJob)1 SearchJob (com.mucommander.job.impl.SearchJob)1 SendMailJob (com.mucommander.job.impl.SendMailJob)1 TempOpenWithJob (com.mucommander.job.impl.TempOpenWithJob)1 ChangePermissionsDialog (com.mucommander.ui.dialog.file.ChangePermissionsDialog)1 DownloadDialog (com.mucommander.ui.dialog.file.DownloadDialog)1 LocalCopyDialog (com.mucommander.ui.dialog.file.LocalCopyDialog)1 FolderPanel (com.mucommander.ui.main.FolderPanel)1 FileTable (com.mucommander.ui.main.table.FileTable)1