Search in sources :

Example 1 with AbstractFile

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

the class CopyDialog method createTransferFileJob.

// ////////////////////////////////////////////
// TransferDestinationDialog implementation //
// ////////////////////////////////////////////
@Override
protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) {
    AbstractFile baseFolder = files.getBaseFolder();
    AbstractArchiveFile parentArchiveFile = baseFolder.getParentArchive();
    TransferFileJob job;
    String newName = resolvedDest.getDestinationType() == DestinationType.EXISTING_FOLDER ? null : resolvedDest.getDestinationFile().getName();
    // their natural order (more efficient)
    if (parentArchiveFile != null) {
        // Add all selected archive entries to a vector
        int nbFiles = files.size();
        List<ArchiveEntry> selectedEntries = new Vector<ArchiveEntry>();
        for (int i = 0; i < nbFiles; i++) {
            selectedEntries.add((ArchiveEntry) files.elementAt(i).getAncestor(AbstractArchiveEntryFile.class).getUnderlyingFileObject());
        }
        job = new UnpackJob(progressDialog, mainFrame, parentArchiveFile, PathUtils.getDepth(baseFolder.getAbsolutePath(), baseFolder.getSeparator()) - PathUtils.getDepth(parentArchiveFile.getAbsolutePath(), parentArchiveFile.getSeparator()), resolvedDest.getDestinationFolder(), newName, defaultFileExistsAction, selectedEntries);
    } else {
        job = new CopyJob(progressDialog, mainFrame, files, resolvedDest.getDestinationFolder(), newName, TransferMode.COPY, defaultFileExistsAction);
    }
    return job;
}
Also used : AbstractArchiveFile(com.mucommander.commons.file.archive.AbstractArchiveFile) AbstractArchiveEntryFile(com.mucommander.commons.file.archive.AbstractArchiveEntryFile) TransferFileJob(com.mucommander.job.impl.TransferFileJob) AbstractFile(com.mucommander.commons.file.AbstractFile) UnpackJob(com.mucommander.job.impl.UnpackJob) CopyJob(com.mucommander.job.impl.CopyJob) ArchiveEntry(com.mucommander.commons.file.archive.ArchiveEntry) Vector(java.util.Vector)

Example 2 with AbstractFile

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

the class CloneTabToOtherPanelAction method performAction.

@Override
public void performAction() {
    AbstractFile currentLocation = mainFrame.getActivePanel().getCurrentFolder();
    mainFrame.getInactivePanel().getTabs().add(currentLocation);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 3 with AbstractFile

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

the class CombineFilesAction method performAction.

@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();
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) CombineFilesDialog(com.mucommander.ui.dialog.file.CombineFilesDialog) AttributeFileFilter(com.mucommander.commons.file.filter.AttributeFileFilter) AttributeFileFilter(com.mucommander.commons.file.filter.AttributeFileFilter) FileFilter(com.mucommander.commons.file.filter.FileFilter)

Example 4 with AbstractFile

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

the class MkdirAction method toggleEnabledState.

@Override
protected void toggleEnabledState() {
    AbstractFile firstFile = mainFrame.getActiveTable().getFileTableModel().getFileAt(0);
    // If there is no file at all, do not rely on the action being supported by the current folder as this
    // would be incorrect for some filesystems which do not support operations consistently across the
    // filesystem (e.g. S3). In that case, err on the safe side and enable the action, even if the operation
    // end up not being supported.
    setEnabled(firstFile == null || firstFile.isFileOperationSupported(FileOperation.CREATE_DIRECTORY));
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 5 with AbstractFile

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

the class OpenAction method performAction.

/**
 * Opens the currently selected file in the active folder panel.
 */
@Override
public void performAction() {
    // Retrieves the currently selected file.
    // Note: a CachedFile instance is retrieved to avoid blocking the event thread.
    AbstractFile file = mainFrame.getActiveTable().getSelectedFile(true, true);
    // Aborts if none.
    if (file == null)
        return;
    // Opens the currently selected file.
    open(file, mainFrame.getActivePanel());
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)150 IOException (java.io.IOException)49 FileURL (com.mucommander.commons.file.FileURL)19 FileSet (com.mucommander.commons.file.util.FileSet)11 FileTable (com.mucommander.ui.main.table.FileTable)11 DialogAction (com.mucommander.ui.dialog.DialogAction)10 File (java.io.File)9 List (java.util.List)8 MainFrame (com.mucommander.ui.main.MainFrame)6 InputStream (java.io.InputStream)6 Vector (java.util.Vector)6 AbstractArchiveEntryFile (com.mucommander.commons.file.archive.AbstractArchiveEntryFile)5 ProtocolFile (com.mucommander.commons.file.protocol.ProtocolFile)5 LocalFile (com.mucommander.commons.file.protocol.local.LocalFile)5 ProgressDialog (com.mucommander.ui.dialog.file.ProgressDialog)5 FolderPanel (com.mucommander.ui.main.FolderPanel)5 FileTableModel (com.mucommander.ui.main.table.FileTableModel)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 UnsupportedFileOperationException (com.mucommander.commons.file.UnsupportedFileOperationException)4