Package com.mucommander.commons.file.util

Examples of com.mucommander.commons.file.util.FileSet


    /** True if classes haven't been loaded yet */
    private boolean loadingClasses =  true;


    public SelfUpdateJob(ProgressDialog progressDialog, MainFrame mainFrame, AbstractFile remoteJarFile) {
        this(progressDialog, mainFrame, new FileSet(remoteJarFile.getParent(), remoteJarFile), getDestJarFile());
    }
View Full Code Here


        // 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 in 'change folder mode' or if the drop action is 'ACTION_LINK' in normal mode:
        // change the FolderPanel's current folder to the dropped file/folder :
        // - If the file is a directory, the current folder is changed to that directory
        // - For any other file kind (archive, regular file...), current folder is changed to the file's parent folder and the file is selected
        // 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);
            // For any other file kind (archive, regular file...), change directory to the file's parent folder
View Full Code Here

     * 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();
    }
View Full Code Here

     * @param progressDialog the ProgressDialog that monitors this job
     * @param mainFrame the MainFrame this job is attached to
     * @param fileToCopy the file to copy to a temporary location
     */
    public TempCopyJob(ProgressDialog progressDialog, MainFrame mainFrame, AbstractFile fileToCopy) {
        super(progressDialog, mainFrame, new FileSet(fileToCopy.getParent(), fileToCopy), FileFactory.getTemporaryFolder(), getTemporaryFileName(fileToCopy), COPY_MODE, FileCollisionDialog.OVERWRITE_ACTION);
    }
View Full Code Here

     * @param transferable a Transferable instance that contains the files to be retrieved
     * @return the files contained by the specified Transferable as a FileSet, or <code>null</code> if no file
     * was present or if an error occurred
     */
    public static FileSet getTransferFiles(Transferable transferable) {
        FileSet files;
        AbstractFile file;

        try {
            // FileSet DataFlavor
            if(transferable.isDataFlavorSupported(FILE_SET_DATA_FLAVOR)) {
                files = (FileSet)transferable.getTransferData(FILE_SET_DATA_FLAVOR);
            }
            // File list DataFlavor
            else if(transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                List<File> fileList = (List<File>)transferable.getTransferData(DataFlavor.javaFileListFlavor);

                int nbFiles = fileList.size();
                files = new FileSet();
                for(int i=0; i<nbFiles; i++) {
                    file = FileFactory.getFile(fileList.get(i).getAbsolutePath());

                    if(file!=null)
                        files.add(file);
                }
            }
            // Text plain DataFlavor: assume that lines designate file paths
            else if(transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                BufferedReader br;

                br = null;
                try {
                    br = new BufferedReader(DataFlavor.getTextPlainUnicodeFlavor().getReaderForText(transferable));

                    // Read input line by line and try to create AbstractFile instances
                    String path;
                    files = new FileSet();
                    while((path=br.readLine())!=null) {
                        // Try to create an AbstractFile instance, returned instance may be null
                        file = FileFactory.getFile(path);

                        // Safety precaution: if at least one line doesn't resolve as a file, stop reading
                        // and return null. This is to avoid any nasty effect that could arise if a random
                        // piece of text (let's say an email contents) was inadvertently pasted or dropped to muCommander.
                        if(file==null)
                            return null;

                        files.add(file);
                    }
                }
                // Documentation is not explicit on whether DataFlavor streams need to be closed, we might as well
                // do so just to be sure.
                finally {
View Full Code Here

    // MuAction implementation //
    /////////////////////////////

    @Override
    public final void performAction() {
        FileSet files = mainFrame.getActiveTable().getSelectedFiles();
        // Perform the action only if at least one file is selected/marked
        if(files.size()>0)
            performAction(files);
    }
View Full Code Here

     * file if no file is currently marked. The parent folder '..' is never included in the returned set.
     *
     * @return selected files in a FileSet
     */
    public FileSet getSelectedFiles() {
        FileSet selectedFiles = tableModel.getMarkedFiles();
        // if no row is marked, then add selected row if there is one, and if it is not parent folder
        if(selectedFiles.size()==0)  {
            AbstractFile selectedFile = getSelectedFile();
            if(selectedFile!=null)
                selectedFiles.add(selectedFile);
        }
        return selectedFiles;
    }
View Full Code Here

        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();
        }
View Full Code Here

                AbstractFile current;

                current = folderPanel.getCurrentFolder();
                // Starts moving files
                ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("move_dialog.moving"));
                FileSet files = new FileSet(current);
                files.add(fileToRename);
                MoveJob renameJob = new MoveJob(progressDialog, mainFrame, files, current, newName, FileCollisionDialog.ASK_ACTION, true);
                progressDialog.start(renameJob);
            }
        }
View Full Code Here

    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);
View Full Code Here

TOP

Related Classes of com.mucommander.commons.file.util.FileSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.