Package com.mucommander.commons.file

Examples of com.mucommander.commons.file.AbstractFile


    }

    @Override
    public void performAction() {
        FileTable activeTable = mainFrame.getActiveTable();
        AbstractFile selectedFile = activeTable.getSelectedFile(false);

        // Trigger in-table editing only if a file other than parent folder '..' is selected
        if(selectedFile!=null) {
            // Trigger in-table renaming
            activeTable.editCurrentFilename();
View Full Code Here


     * </p>
     * @param  path                  path to the actions file
     * @throws FileNotFoundException if <code>file</code> is not accessible.
     */
    public static void setActionsFile(String path) throws FileNotFoundException {
        AbstractFile file;

        if((file = FileFactory.getFile(path)) == null)
            setActionsFile(new File(path));
        else
            setActionsFile(file);
View Full Code Here

     *
     * <p>This method must be called before requesting and registering any action.
     */
    public static void loadActionKeymap() throws Exception {
      // Load user's file if exist
      AbstractFile actionKeymapFile = getActionsFile();
      if (actionKeymapFile != null && actionKeymapFile.exists()) {
        ActionKeymapReader reader = new ActionKeymapReader(actionKeymapFile);
        ActionKeymap.registerActions(reader.getPrimaryActionsKeymap(), reader.getAlternateActionsKeymap());
      }
      else {
        createEmptyFile();
View Full Code Here

            return;

        FileTable currentFileTable = mainFrame.getActiveTable();

        // Currently select file, can be null
        AbstractFile selectedFile = currentFileTable.getSelectedFile(false, true);
        FileTableModel tableModel = currentFileTable.getFileTableModel();
        // Number of marked files, can be 0
        int nbMarkedFiles = tableModel.getNbMarkedFiles();
        // Combined size of marked files, 0 if no file has been marked
        long markedTotalSize = tableModel.getTotalMarkedSize();
        // number of files in folder
        int fileCount = tableModel.getFileCount();

        // Update files info based on marked files if there are some, or currently selected file otherwise
        int nbSelectedFiles;
        if(nbMarkedFiles==0 && selectedFile!=null)
            nbSelectedFiles = 1;
        else
            nbSelectedFiles = nbMarkedFiles;

        String filesInfo;
   
        if(fileCount==0) {
            // Set status bar to a space character, not an empty string
            // otherwise it will disappear
            filesInfo = " ";
        }
        else {
            filesInfo = Translator.get("status_bar.selected_files", ""+nbSelectedFiles, ""+fileCount);
     
            if(nbMarkedFiles>0)
                filesInfo += " - "+ SizeFormat.format(markedTotalSize, selectedFileSizeFormat);
 
            if(selectedFile!=null)
                filesInfo += " - "+selectedFile.getName();
        }   

        // Update label
        setStatusInfo(filesInfo);
    }
View Full Code Here

    private synchronized void updateVolumeInfo() {
        // No need to waste precious cycles if status bar is not visible
        if(!isVisible())
            return;

        final AbstractFile currentFolder = mainFrame.getActivePanel().getCurrentFolder();
        // Resolve the current folder's volume and use its path as a key for the volume info cache
        final String volumePath = currentFolder.exists() ?
            currentFolder.getVolume().getAbsolutePath(true) : "";

        Long cachedVolumeInfo[] = volumeInfoCache.get(volumePath);
        if(cachedVolumeInfo!=null) {
            LOGGER.debug("Cache hit!");
            volumeSpaceLabel.setVolumeSpace(cachedVolumeInfo[0], cachedVolumeInfo[1]);
        }
        else {
            // Retrieves free and total volume space.
            // Perform volume info retrieval in a separate thread as this method may be called
            // by the event thread and it can take a while, we want to return as soon as possible
            new Thread("StatusBar.updateVolumeInfo") {
                @Override
                public void run() {
                    // Free space on current volume, -1 if this information is not available
                    long volumeFree;
                    // Total space on current volume, -1 if this information is not available
                    long volumeTotal;

                    // Folder is a local file and Java version is 1.5: call getVolumeInfo() instead of
                    // separate calls to getFreeSpace() and getTotalSpace() as it is twice as fast.
                    if(currentFolder instanceof LocalFile && JavaVersion.JAVA_1_5.isCurrentOrLower()) {
                        try {
                            long volumeInfo[] = ((LocalFile)currentFolder).getVolumeInfo();
                            volumeTotal = volumeInfo[0];
                            volumeFree = volumeInfo[1];
                        }
                        catch(IOException e) {
                            volumeTotal = -1;
                            volumeFree = -1;
                        }
                    }
                    // Java 1.6 and up or any other file type
                    else {
                        try { volumeFree = currentFolder.getFreeSpace(); }
                        catch(IOException e) { volumeFree = -1; }

                        try { volumeTotal = currentFolder.getTotalSpace(); }
                        catch(IOException e) { volumeTotal = -1; }
                    }

// For testing the free space indicator
//volumeFree = (long)(volumeTotal * Math.random());
 
View Full Code Here

    /**
     * This method is overridden to enable this action when the parent folder is selected.
     */
    @Override
    protected boolean getFileTableCondition(FileTable fileTable) {
        AbstractFile selectedFile = fileTable.getSelectedFile(true, true);

        return selectedFile!=null && selectedFile.isBrowsable();
    }
View Full Code Here

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

     * @param  sourcePanel panel whose parent should be used.
     * @param  destPanel   panel in which to change the location.
     * @return             <code>true</code> if <code>sourcePanel</code> has a parent, <code>false</code> otherwise.
     */
    private boolean goToParent(FolderPanel sourcePanel, FolderPanel destPanel) {
        AbstractFile parent;

        if((parent = sourcePanel.getCurrentFolder().getParent()) != null) {
            destPanel.tryChangeCurrentFolder(parent, null, true);
            return true;
        }
View Full Code Here

    }


    @Override
    protected boolean getFileTableCondition(FileTable fileTable) {
        AbstractFile selectedFile = fileTable.getSelectedFile(false, true);
        boolean enable = selectedFile!=null;

        if(enable && filter!=null)
            enable = filter.match(selectedFile);
View Full Code Here

     * </p>
     * @param file        file to open.
     * @param destination if <code>file</code> is browsable, folder panel in which to open the file.
     */
    protected void open(final AbstractFile file, FolderPanel destination) {
      AbstractFile resolvedFile;
      if (file.isSymlink()) {
        resolvedFile = resolveSymlink(file);

        if (resolvedFile == null) {
          InformationDialog.showErrorDialog(mainFrame, Translator.get("cannot_open_cyclic_symlink"));
          return;
        }
      }
      else
        resolvedFile = file;

        // Opens browsable files in the destination FolderPanel.
        if(resolvedFile.isBrowsable()) {
          resolvedFile = MuConfigurations.getPreferences().getVariable(MuPreference.CD_FOLLOWS_SYMLINKS, MuPreferences.DEFAULT_CD_FOLLOWS_SYMLINKS) ? resolvedFile : file;

          FileTableTabs tabs = destination.getTabs();
          if (tabs.getCurrentTab().isLocked())
            tabs.add(resolvedFile);
          else
            destination.tryChangeCurrentFolder(resolvedFile);
        }

        // Opens local files using their native associations.
        else if(resolvedFile.getURL().getScheme().equals(FileProtocols.FILE) && (resolvedFile.hasAncestor(LocalFile.class))) {
            try {
              DesktopManager.open(resolvedFile);
              RecentExecutedFilesQL.addFile(resolvedFile);
        }
            catch(IOException e) {
View Full Code Here

TOP

Related Classes of com.mucommander.commons.file.AbstractFile

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.