/** * Sets the path to the credentials file. * * @param file path to the credentials file * @throws FileNotFoundException if <code>path</code> is not available. */ public static void setCredentialsFile(AbstractFile file) throws FileNotFoundException { if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file); credentialsFile = file; }
/** * Sets the path to the toolbar description file to be loaded when calling {@link #loadDescriptionFile()}. * By default, this file is {@link #DEFAULT_TOOLBAR_FILE_NAME} within the preferences folder. * @param file path to the toolbar descriptor file */ public static void setDescriptionFile(AbstractFile file) throws FileNotFoundException { if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file); descriptionFile = file; }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * Sets the path to the bookmarks file. * @param file path to the bookmarks file * @exception FileNotFoundException if <code>path</code> is not accessible. * @see #getBookmarksFile() */ public static synchronized void setBookmarksFile(AbstractFile file) throws FileNotFoundException { if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); bookmarksFile = file; }
/** * Sets the path to the command bar description file to be loaded when calling {@link #loadCommandBar()}. * By default, this file is {@link #DEFAULT_COMMAND_BAR_FILE_NAME} within the preferences folder. * @param file path to the command bar descriptor file * @throws FileNotFoundException if the specified file is not accessible. */ public static void setDescriptionFile(AbstractFile file) throws FileNotFoundException { // Makes sure file can be used as a commandbar description file. if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); commandBarFile = file; }
/** * Sets the path to the user actions file to be loaded when calling {@link #loadActionKeymap()}. * By default, this file is {@link #DEFAULT_ACTIONS_FILE_NAME} within the preferences folder. * @param file path to the actions file * @throws FileNotFoundException if <code>file</code> is not accessible. */ private static void setActionsFile(AbstractFile file) throws FileNotFoundException { if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); actionsFile = file; }
/** * Sets the path to the configuration file. * @param file path to the file that should be used for configuration storage. * @throws FileNotFoundException if the specified file is not a valid file. */ private synchronized void setConfigurationFile(AbstractFile file) throws FileNotFoundException { // Makes sure file can be used as a configuration. if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); configurationFile = file; }
/** * Sets the path to the custom associations file. * @param file path to the custom associations file. * @throws FileNotFoundException if <code>file</code> is not accessible. * @see #getAssociationFile() * @see #loadAssociations() * @see #writeAssociations() */ public static void setAssociationFile(AbstractFile file) throws FileNotFoundException { if (file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); associationFile = file; }
/** * Sets the path of the shell history file. * @param file where to load the shell history from. * @exception FileNotFoundException if <code>path</code> is not accessible. * @see #getHistoryFile() * @see #setHistoryFile(File) * @see #setHistoryFile(String) */ public static void setHistoryFile(AbstractFile file) throws FileNotFoundException { // Makes sure file can be used as a shell history file. if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); historyFile = file; }
/** * Sets the path to the user theme file. * <p> * The specified file does not have to exist. If it does, however, it must be accessible. * </p> * @param file path to the user theme file. * @throws IllegalArgumentException if <code>file</code> exists but is not accessible. * @see #getUserThemeFile() */ public static void setUserThemeFile(AbstractFile file) throws FileNotFoundException { if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); userThemeFile = file; }
/** * Sets the path to the custom commands file. * @param file path to the custom commands file. * @throws FileNotFoundException if <code>file</code> is not accessible. * @see #getCommandFile() * @see #loadCommands() * @see #writeCommands() */ public static void setCommandFile(AbstractFile file) throws FileNotFoundException { // Makes sure file can be used as a command file. if(file.isBrowsable()) throw new FileNotFoundException("Not a valid file: " + file.getAbsolutePath()); commandsFile = file; }
/** * Adds the specified <code>file</code> to the class loader's classpath. * <p> * Note that the file will <b>not</b> be added if it's already in the classpath. * </p> * @param file file to add the class loader's classpath. * @throws IllegalArgumentException if <code>file</code> is not browsable. */ public void addFile(AbstractFile file) { // Makes sure the specified file is browsable. if(!file.isBrowsable()) throw new IllegalArgumentException(); // Only adds the file if it's not already there. if(!contains(file)) files.add(file); }
/** * Returns <code>true</code> if this file is a parent folder of the given file, or if the two files are equal. * * @param file the AbstractFile to test * @return true if this file is a parent folder of the given file, or if the two files are equal */ public final boolean isParentOf(AbstractFile file) { return isBrowsable() && file.getCanonicalPath(true).startsWith(getCanonicalPath(true)); }
/** * Changes the current folder in an associated folder panel, depending on * the current selection in tree. */ public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getNewLeadSelectionPath(); if (path != null) { AbstractFile f = (AbstractFile) path.getLastPathComponent(); if (f != null && f.isBrowsable() && f != folderPanel.getCurrentFolder()) { changeTimer.folder = f; changeTimer.restart(); } } }
/** * Opens the currently selected file in the inactive folder panel. */ @Override public void performAction() { AbstractFile file; // Retrieves the currently selected file, aborts if none (should not normally happen). if((file = mainFrame.getActiveTable().getSelectedFile(true, true)) == null || !file.isBrowsable()) return; // Opens the currently selected file in the inactive panel. mainFrame.getInactivePanel().tryChangeCurrentFolder(file); }
/** * Pre-fetch the attributes that are used by the table renderer and some actions from the given CachedFile. * By doing so, the attributes will be available when the associated getters are called and thus the methods won't * be I/O bound and will not lock. * * @param cachedFile a CachedFile instance from which to pre-fetch attributes */ private static void prefetchCachedFileAttributes(AbstractFile cachedFile) { cachedFile.isDirectory(); cachedFile.isBrowsable(); cachedFile.isHidden(); // Pre-fetch isSymlink attribute and if the file is a symlink, pre-fetch the canonical file and its attributes if(cachedFile.isSymlink()) { AbstractFile canonicalFile = cachedFile.getCanonicalFile(); if(canonicalFile!=cachedFile) // Cheap test to prevent infinite recursion on bogus file implementations prefetchCachedFileAttributes(canonicalFile); } }
/** * Tests <code>ResourceLoader#getRootPackageAsFile</code> methods. * * @throws IOException should not happen */ @Test public void testRootPackageAsFile() throws IOException { AbstractFile rootPackageFile = ResourceLoader.getRootPackageAsFile(getClass()); assert rootPackageFile != null; assert rootPackageFile.exists(); assert rootPackageFile.isBrowsable(); AbstractFile thisClassFile = rootPackageFile.getChild("com/mucommander/commons/file/util/ResourceLoaderTest.class"); assertReadable(thisClassFile); }
public void handleOpenFile(ApplicationEvent event) { // Wait until the application has been launched. This step is required to properly handle the case where the // application is launched with a file to open, for instance when drag-n-dropping a file to the Dock icon // when muCommander is not started yet. In this case, this method is called while Launcher is still busy // launching the application (no mainframe exists yet). muCommander.waitUntilLaunched(); AbstractFile file = FileFactory.getFile(event.getFilename()); FolderPanel activePanel = WindowManager.getCurrentMainFrame().getActivePanel(); if(file.isBrowsable()) activePanel.tryChangeCurrentFolder(file); else activePanel.tryChangeCurrentFolder(file.getParent(), file, false); }