Search in sources :

Example 11 with MainFrame

use of com.mucommander.ui.main.MainFrame in project mucommander by mucommander.

the class FileDropTargetListener method drop.

public void drop(DropTargetDropEvent event) {
    // Restore default cursor, no matter what
    folderPanel.setCursor(Cursor.getDefaultCursor());
    // so this test is really necessary
    if (!dragAccepted) {
        event.rejectDrop();
        return;
    }
    // Accept drop event
    event.acceptDrop(currentDropAction);
    // Retrieve the files contained by the transferable as a FileSet (takes care of handling the different
    // DataFlavors)
    FileSet droppedFiles = TransferableFileSet.getTransferFiles(event.getTransferable());
    // Stop and report failure if no file could not be retrieved
    if (droppedFiles == null || droppedFiles.size() == 0) {
        // Report drop failure
        event.dropComplete(false);
        return;
    }
    // If more than one file is dropped, only the first one is used
    if (changeFolderOnlyMode || currentDropAction == DnDConstants.ACTION_LINK) {
        AbstractFile file = droppedFiles.elementAt(0);
        // If file is a directory, change current folder to that directory
        if (file.isDirectory())
            folderPanel.tryChangeCurrentFolder(file);
        else
            // For any other file kind (archive, regular file...), change directory to the file's parent folder
            // and select the file
            folderPanel.tryChangeCurrentFolder(file.getParent(), file, false);
        // Request focus on the FolderPanel
        folderPanel.requestFocus();
    } else // Normal mode: copy or move dropped files to the FolderPanel's current folder
    {
        MainFrame mainFrame = folderPanel.getMainFrame();
        AbstractFile destFolder = folderPanel.getCurrentFolder();
        if (currentDropAction == DnDConstants.ACTION_MOVE) {
            // Start moving files
            ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("move_dialog.moving"));
            MoveJob moveJob = new MoveJob(progressDialog, mainFrame, droppedFiles, destFolder, null, FileCollisionDialog.FileCollisionAction.ASK, false);
            progressDialog.start(moveJob);
        } else {
            // Start copying files
            ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
            CopyJob job = new CopyJob(progressDialog, mainFrame, droppedFiles, destFolder, null, TransferMode.COPY, FileCollisionDialog.FileCollisionAction.ASK);
            progressDialog.start(job);
        }
    }
    // Report that the drop event has been successfully handled
    event.dropComplete(true);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet) CopyJob(com.mucommander.job.impl.CopyJob) MoveJob(com.mucommander.job.impl.MoveJob) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) MainFrame(com.mucommander.ui.main.MainFrame)

Example 12 with MainFrame

use of com.mucommander.ui.main.MainFrame in project mucommander by mucommander.

the class ClonedMainFrameBuilder method build.

@Override
public Collection<MainFrame> build() {
    MainFrame currentMainFrame = WindowManager.getCurrentMainFrame();
    MainFrame mainFrame = new MainFrame(currentMainFrame);
    // If this is a cloned window, use the same dimensions as the previous MainFrame, with
    // a slight horizontal and vertical offset to make sure we keep both of them visible.
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int x = currentMainFrame.getX() + X_OFFSET;
    int y = currentMainFrame.getY() + Y_OFFSET;
    int width = currentMainFrame.getWidth();
    int height = currentMainFrame.getHeight();
    // window managers, such as Gnome, return rather peculiar results.
    if (!isInsideUsableScreen(currentMainFrame, x + width, -1))
        x = 0;
    if (!isInsideUsableScreen(currentMainFrame, -1, y + height))
        y = 0;
    if (width + x > screenSize.width)
        width = screenSize.width - x;
    if (height + y > screenSize.height)
        height = screenSize.height - y;
    mainFrame.setBounds(new Rectangle(x, y, width, height));
    return Collections.singleton(mainFrame);
}
Also used : Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) MainFrame(com.mucommander.ui.main.MainFrame)

Example 13 with MainFrame

use of com.mucommander.ui.main.MainFrame in project mucommander by mucommander.

the class CommandLineMainFrameBuilder method build.

@Override
public Collection<MainFrame> build() {
    final List<MainFrame> mainFrames = new LinkedList<>();
    Iterator<String> iterator = folders.iterator();
    while (iterator.hasNext()) {
        int nbMainFrames = mainFrames.size();
        MainFrame newMainFrame = new MainFrame(new ConfFileTableTab(iterator.next()), getFileTableConfiguration(FolderPanelType.LEFT, nbMainFrames), new ConfFileTableTab(iterator.hasNext() ? iterator.next() : null), getFileTableConfiguration(FolderPanelType.RIGHT, nbMainFrames));
        newMainFrame.setBounds(getDefaultSize());
        mainFrames.add(newMainFrame);
    }
    return mainFrames;
}
Also used : MainFrame(com.mucommander.ui.main.MainFrame) LinkedList(java.util.LinkedList) ConfFileTableTab(com.mucommander.ui.main.tabs.ConfFileTableTab)

Aggregations

MainFrame (com.mucommander.ui.main.MainFrame)13 AbstractFile (com.mucommander.commons.file.AbstractFile)4 ProgressDialog (com.mucommander.ui.dialog.file.ProgressDialog)4 IOException (java.io.IOException)4 FileSet (com.mucommander.commons.file.util.FileSet)3 ConfFileTableTab (com.mucommander.ui.main.tabs.ConfFileTableTab)3 Rectangle (java.awt.Rectangle)3 DeleteJob (com.mucommander.job.impl.DeleteJob)2 FolderPanel (com.mucommander.ui.main.FolderPanel)2 FileTable (com.mucommander.ui.main.table.FileTable)2 Dimension (java.awt.Dimension)2 CopyJob (com.mucommander.job.impl.CopyJob)1 MoveJob (com.mucommander.job.impl.MoveJob)1 TempExecJob (com.mucommander.job.impl.TempExecJob)1 CoreService (com.mucommander.os.api.CoreService)1 ActionParameters (com.mucommander.ui.action.ActionParameters)1 MuAction (com.mucommander.ui.action.MuAction)1 OpenLocationAction (com.mucommander.ui.action.impl.OpenLocationAction)1 AboutDialog (com.mucommander.ui.dialog.about.AboutDialog)1 Column (com.mucommander.ui.main.table.Column)1