Search in sources :

Example 6 with AbstractFile

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

the class OpenCommandPromptAction method toggleEnabledState.

@Override
protected void toggleEnabledState() {
    AbstractFile currentFolder = mainFrame.getActivePanel().getCurrentFolder();
    setEnabled(currentFolder.getURL().getScheme().equals(FileProtocols.FILE) && !currentFolder.isArchive() && !currentFolder.hasAncestor(AbstractArchiveEntryFile.class));
}
Also used : AbstractArchiveEntryFile(com.mucommander.commons.file.archive.AbstractArchiveEntryFile) AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 7 with AbstractFile

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

the class OpenInBothPanelsAction method performAction.

// - Action code ---------------------------------------------------------------------
// -----------------------------------------------------------------------------------
/**
 * Opens the current selection and its inactive equivalent.
 */
@Override
public void performAction() {
    Thread openThread;
    AbstractFile selectedFile;
    AbstractFile otherFile = null;
    // Retrieves the current selection, aborts if none (should not normally happen).
    if ((selectedFile = mainFrame.getActiveTable().getSelectedFile(true, true)) == null || !selectedFile.isBrowsable())
        return;
    try {
        FileTableModel otherTableModel = mainFrame.getInactiveTable().getFileTableModel();
        if (mainFrame.getActiveTable().isParentFolderSelected()) {
            otherFile = otherTableModel.getParentFolder();
        } else {
            // Look for a file in the other table with the same name as the selected one (case insensitive)
            int fileCount = otherTableModel.getFileCount();
            String targetFilename = selectedFile.getName();
            for (int i = otherTableModel.getFirstMarkableRow(); i < fileCount; i++) {
                otherFile = otherTableModel.getCachedFileAtRow(i);
                if (otherFile.getName().equalsIgnoreCase(targetFilename))
                    break;
                if (i == fileCount - 1)
                    otherFile = null;
            }
        }
    } catch (Exception e) {
        otherFile = null;
    }
    // Opens 'file' in the active panel.
    openThread = mainFrame.getActivePanel().tryChangeCurrentFolder(selectedFile);
    // Opens 'otherFile' (if any) in the inactive panel.
    if (otherFile != null) {
        // Waits for the previous folder change to be finished.
        if (openThread != null) {
            while (openThread.isAlive()) {
                try {
                    openThread.join();
                } catch (InterruptedException e) {
                }
            }
        }
        mainFrame.getInactivePanel().tryChangeCurrentFolder(otherFile);
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileTableModel(com.mucommander.ui.main.table.FileTableModel)

Example 8 with AbstractFile

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

the class OpenNativelyAction method performAction.

@Override
public void performAction() {
    AbstractFile selectedFile = mainFrame.getActiveTable().getSelectedFile(true, true);
    if (selectedFile == null)
        return;
    // file is not on a local filesystem or file is an archive entry
    if (!LocalFile.SCHEMA.equals(selectedFile.getURL().getScheme()) || selectedFile.hasAncestor(AbstractArchiveEntryFile.class)) {
        ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
        TempExecJob job = new TempExecJob(progressDialog, mainFrame, selectedFile);
        progressDialog.start(job);
    } else {
        // Tries to execute file with native file associations
        try {
            OpenAction.openFile(getMainFrame(), selectedFile);
            RecentExecutedFilesQL.addFile(selectedFile);
        } catch (IOException | UnsupportedOperationException e) {
            InformationDialog.showErrorDialog(mainFrame);
        }
    }
}
Also used : AbstractArchiveEntryFile(com.mucommander.commons.file.archive.AbstractArchiveEntryFile) AbstractFile(com.mucommander.commons.file.AbstractFile) TempExecJob(com.mucommander.job.impl.TempExecJob) IOException(java.io.IOException) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog)

Example 9 with AbstractFile

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

the class PasteClipboardFilesAction method performAction.

@Override
public void performAction() {
    // Retrieve clipboard files
    FileSet clipboardFiles = ClipboardSupport.getClipboardFiles();
    if (clipboardFiles == null || clipboardFiles.isEmpty())
        return;
    // Start copying files
    ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
    AbstractFile destFolder = mainFrame.getActivePanel().getCurrentFolder();
    CopyJob job = new CopyJob(progressDialog, mainFrame, clipboardFiles, destFolder, null, TransferMode.COPY, FileCollisionDialog.FileCollisionAction.ASK);
    progressDialog.start(job);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet) CopyJob(com.mucommander.job.impl.CopyJob) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog)

Example 10 with AbstractFile

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

the class QuickFindAction method performAction.

@Override
public void performAction() {
    AbstractFile currentFile = mainFrame.getActivePanel().getCurrentFolder();
    FileURL searchURL = SearchUtils.toSearchURL(currentFile);
    LocationTextField locationTextField = mainFrame.getActivePanel().getLocationTextField();
    locationTextField.setText(searchURL.toString());
    locationTextField.requestFocus();
}
Also used : FileURL(com.mucommander.commons.file.FileURL) LocationTextField(com.mucommander.ui.main.LocationTextField) 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