@Override public boolean isRoot() { if(!isRootSet) { isRoot = file.isRoot(); isRootSet = true; } return isRoot; }
@Override public boolean isRoot() { return file.isRoot(); }
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { // get file name and create default component (JLabel) to display it AbstractFile file = (AbstractFile) value; String name = file.isRoot()?file.getAbsolutePath():file.getName(); super.getTreeCellRendererComponent(tree, name, sel, expanded, leaf, row, hasFocus); setIcon(model.getCurrentIcon(file)); return this; }
public Icon lookupCache(AbstractFile file, Dimension preferredResolution) { // Under Mac OS X, return the icon of /Network for the root of remote (non-local) locations. if(OsFamily.MAC_OS_X.isCurrent() && !FileProtocols.FILE.equals(file.getURL().getScheme()) && file.isRoot()) return getSwingIcon(new java.io.File("/Network")); // Look for an existing icon instance for the file's extension return (file.isDirectory()? directoryIconCache : fileIconCache).get(getCheckedExtension(file)); }
@Override protected PathFieldContent computeInitialPath(FileSet files) { String initialPath = mainFrame.getInactivePanel().getCurrentFolder().getAbsolutePath(true); AbstractFile file; String fileName; // Computes the archive's default name: // - if it only contains one file, uses that file's name. // - if it contains more than one file, uses the FileSet's parent folder's name. if(files.size() == 1) { file = files.elementAt(0); fileName = file.isDirectory() && !DesktopManager.isApplication(file) ?file.getName() :file.getNameWithoutExtension(); } else { file = files.getBaseFolder(); fileName = file.isRoot()?"":DesktopManager.isApplication(file)?file.getNameWithoutExtension():file.getName(); } return new PathFieldContent(initialPath + fileName + "." + Archiver.getFormatExtension(lastFormat), initialPath.length(), initialPath.length() + fileName.length()); }
public boolean accept(AbstractFile file) { switch(attribute) { case DIRECTORY: return file.isDirectory(); case FILE: return !file.isDirectory(); case BROWSABLE: return file.isBrowsable(); case ARCHIVE: return file.isArchive(); case SYMLINK: return file.isSymlink(); case HIDDEN: return file.isHidden(); case ROOT: return file.isRoot(); case SYSTEM: return file.isSystem(); default: return true; } } }
/** * Tests {@link AbstractFile#getParent()} and {@link AbstractFile#isParentOf(AbstractFile)} methods. * * @throws IOException should not happen */ @Test public void testParent() throws IOException { AbstractFile file = tempFile; AbstractFile parent; AbstractFile child; // Tests all parents until the root is reached while((parent=file.getParent())!=null) { assert parent.isParentOf(file); // a file that has a parent shouldn't be a root file assert !file.isRoot(); // Assert that the child file can be resolved into the same file using getDirectChild() child = parent.getDirectChild(file.getName()); assert child != null; assert child.equals(file); file = parent; } // Assert that the root file's parent URL is null: if that is not the case, the parent file should have been // resolved. assert file.getURL().getParent()==null; // A file that has no parent should be a root file assert file.isRoot(); }
else if(!FileProtocols.FILE.equals(file.getURL().getScheme()) && file.isRoot()) { icon = IconManager.getIcon(IconManager.FILE_ICON_SET, NETWORK_ICON_NAME);