Search in sources :

Example 1 with FileSet

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

the class InternalEditAction method performInternalAction.

// - AbstractViewerAction implementation ---------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
/**
 * Opens the internal editor on the specified file.
 * @param file file to edit.
 */
@Override
protected void performInternalAction(AbstractFile file) {
    if (file.isDirectory()) {
        FileSet fileSet = new FileSet();
        fileSet.add(file);
        new ChangePermissionsDialog(mainFrame, fileSet).showDialog();
    } else {
        EditorRegistrar.createEditorFrame(mainFrame, file, getIcon().getImage());
    }
}
Also used : ChangePermissionsDialog(com.mucommander.ui.dialog.file.ChangePermissionsDialog) FileSet(com.mucommander.commons.file.util.FileSet)

Example 2 with FileSet

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

the class CommandAction method performAction.

// - Action code -----------------------------------------------------------
// -------------------------------------------------------------------------
@Override
public void performAction() {
    FileSet selectedFiles;
    // Retrieves the current selection.
    selectedFiles = mainFrame.getActiveTable().getSelectedFiles();
    // If no files are either selected or marked, aborts.
    if (command.hasSelectedFileKeyword() && selectedFiles.size() == 0)
        return;
    // If we're working with local files, go ahead and runs the command.
    if (selectedFiles.getBaseFolder().getURL().getScheme().equals(LocalFile.SCHEMA) && (selectedFiles.getBaseFolder().hasAncestor(LocalFile.class))) {
        try {
            InformationDialog.showErrorDialogIfNeeded(getMainFrame(), ProcessRunner.executeAsync(command.getTokens(selectedFiles), selectedFiles.getBaseFolder()));
        } catch (Exception e) {
            InformationDialog.showErrorDialog(mainFrame);
            LOGGER.debug("Failed to execute command: " + command.getCommand(), e);
        }
    } else // Otherwise, copies the files locally before running the command.
    {
        ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
        progressDialog.start(new TempOpenWithJob(new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying")), mainFrame, selectedFiles, command));
    }
}
Also used : FileSet(com.mucommander.commons.file.util.FileSet) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) TempOpenWithJob(com.mucommander.job.impl.TempOpenWithJob)

Example 3 with FileSet

use of com.mucommander.commons.file.util.FileSet 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 4 with FileSet

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

the class FileDragSourceListener method dragGestureRecognized.

// /**
// * Creates a custom DragGestureEvent instance re-using the information contained in the given DragGestureEvent, but
// * overridding the actions with the specified actions bitwise mask.
// * When used with <code>DragSource.startDrag</code>, this allows to start a drag operation with a different source
// * action set from the one specified in the <code>DragGestureRecognizer</code>, based on the current state and
// * contents of the FolderPanel.
// */
// private DragGestureEvent createCustomDragGestureEvent(DragGestureEvent originalDGE, int actions) {
// Vector eventList = new Vector();
// Iterator eventIterator = originalDGE.iterator();
// 
// while(eventIterator.hasNext())
// eventList.add(eventIterator.next());
// 
// DragGestureRecognizer dragGestureRecognizer = originalDGE.getSourceAsDragGestureRecognizer();
// dragGestureRecognizer.setSourceActions(actions);
// 
// return new DragGestureEvent(dragGestureRecognizer,
// actions,
// originalDGE.getDragOrigin(),
// eventList);
// }
// ///////////////////////////////
// DragGestureListener methods //
// ///////////////////////////////
public void dragGestureRecognized(DragGestureEvent event) {
    if (folderPanel.getMainFrame().getNoEventsMode())
        return;
    FileTable fileTable = folderPanel.getFileTable();
    FileTableModel tableModel = fileTable.getFileTableModel();
    // Return (do not initiate drag) if mouse button2 or button3 was used
    if ((event.getTriggerEvent().getModifiers() & (InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK)) != 0)
        return;
    // Do not use that to retrieve the current selected file as it is inaccurate: the selection could have changed since the
    // the mouse was clicked.
    // AbstractFile selectedFile = fileTable.getSelectedFile(false);
    // // Return if selected file is null (could happen if '..' is selected)
    // if(selectedFile==null)
    // return;
    // Find out which row was clicked
    int clickedRow = fileTable.rowAtPoint(event.getDragOrigin());
    // Return (do not initiate drag) if the selected file is the parent folder '..'
    if (clickedRow == -1 || fileTable.isParentFolder(clickedRow))
        return;
    // Retrieve the file corresponding to the clicked row
    AbstractFile selectedFile = tableModel.getFileAtRow(clickedRow);
    // Find out which files are to be dragged, based on the selected file and currenlty marked files.
    // If there are some files marked, drag marked files only if the selected file is one of the marked files.
    // In any other case, only drag the selected file.
    FileSet markedFiles;
    FileSet draggedFiles;
    if (tableModel.getNbMarkedFiles() > 0 && (markedFiles = fileTable.getSelectedFiles()).contains(selectedFile)) {
        draggedFiles = markedFiles;
    } else {
        draggedFiles = new FileSet(folderPanel.getCurrentFolder(), selectedFile);
    }
    // Set initial DnDContext information
    DnDContext.setDragInitiatedByMucommander(true);
    DnDContext.setDragInitiator(folderPanel);
    DnDContext.setDragGestureModifiersEx(event.getTriggerEvent().getModifiersEx());
    // Start dragging
    DragSource.getDefaultDragSource().startDrag(event, null, new TransferableFileSet(draggedFiles), this);
// DragSource.getDefaultDragSource().startDrag(createCustomDragGestureEvent(event, DnDConstants.ACTION_MOVE), null, new TransferableFileSet(draggedFiles), this);
}
Also used : FileTableModel(com.mucommander.ui.main.table.FileTableModel) AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet) FileTable(com.mucommander.ui.main.table.FileTable)

Example 5 with FileSet

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

the class EmailFilesDialog method actionPerformed.

// //////////////////////////
// ActionListener methods //
// //////////////////////////
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();
    // OK Button
    if (source == okButton) {
        String to = toField.getText().trim();
        String subject = subjectField.getText();
        String body = bodyArea.getText();
        if (!to.equals("")) {
            lastTo = to;
            lastSubject = subject;
            lastBody = body;
            // Starts by disposing the dialog
            dispose();
            // Creates new FileSet with files that have been selected
            FileSet filesToSend = new FileSet(flattenedFiles.getBaseFolder());
            int nbFiles = fileCheckboxes.length;
            for (int i = 0; i < nbFiles; i++) if (fileCheckboxes[i].isSelected())
                filesToSend.add(flattenedFiles.elementAt(i));
            // Starts sending files
            ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("email_dialog.sending"));
            SendMailJob mailJob = new SendMailJob(progressDialog, mainFrame, filesToSend, to, subject, body);
            progressDialog.start(mailJob);
        }
    } else // Cancel button
    if (source == cancelButton) {
        dispose();
    }
}
Also used : SendMailJob(com.mucommander.job.impl.SendMailJob) 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