public FileObject getRoot() { return getAbstractRoot(); }
public SystemAction[] getActions() { if (!isEnabledRefreshFolder()) { return NO_SYSTEM_ACTIONS; } else { if (SYSTEM_ACTIONS == null) { try { ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class); if (l == null) { l = getClass().getClassLoader(); } Class<?> c = Class.forName("org.openide.actions.FileSystemRefreshAction", true, l); // NOI18N SystemAction ra = SharedClassObject.findObject(c.asSubclass(SystemAction.class), true); // initialize the SYSTEM_ACTIONS SYSTEM_ACTIONS = new SystemAction[] { ra }; } catch (Exception ex) { // ok, we are probably running in standalone mode and // classes needed to initialize the RefreshAction are // not available SYSTEM_ACTIONS = NO_SYSTEM_ACTIONS; } } return SYSTEM_ACTIONS; } }
public boolean canRead() { AbstractFileSystem fs = getAbstractFileSystem(); return fs.canRead(getPath()); }
/** Existing folders for abstract file objects. */ private static Enumeration<? extends FileObject> existingFolders(AbstractFileSystem fs) { return fs.existingFileObjects(fs.getAbstractRoot()); }
/** Tests if this file can be written to. * @param name resource name * @return true if this file can be written, false if not. * @since 3.31 */ protected boolean canWrite(String name) { AbstractFileObject afo = (AbstractFileObject) this.findResource(name); return (afo != null) ? afo.superCanWrite() : false; }
/** Instruct the filesystem * that the root should change. * A fresh root is created. Subclasses that support root changes should use this. * * @return the new root */ final synchronized AbstractFileObject refreshRootImpl() { if (root != null) { root.validFlag = false; } root = createFileObject(null, ""); // NOI18N return root; }
/** * Tests if file really exists or is missing. Some operation on it may be restricted. * @return true indicates that the file is missing. * @since 1.9 */ public boolean isVirtual() { return getAbstractFileSystem().checkVirtual(getPath()); }
/** Creates Reference. In FileSystem, which subclasses AbstractFileSystem, you can overload method * createReference(FileObject fo) to achieve another type of Reference (weak, strong etc.) * @param fo FileObject * @return Reference to FileObject */ protected final Reference<AbstractFolder> createReference(AbstractFolder fo) { return (getAbstractFileSystem().createReference(fo)); }
public boolean canWrite() { AbstractFileSystem fs = getAbstractFileSystem(); return fs.canWrite(getPath()); }
/** Allows subclasses to fire that a change occured in a * file or folder. The change can be "expected" when it is * a result of an user action and the user knows that such * change should occur. * * @param name resource name of the file where the change occured * @param expected true if the user initiated change and expects it */ protected final void refreshResource(String name, boolean expected) { AbstractFileObject fo = (AbstractFileObject) findResourceIfExists(name); if (fo != null) { // refresh and behave like the changes is expected fo.refresh(null, null, true, expected); } }
final Enumeration<? extends FileObject> existingFileObjects(AbstractFolder fo) { class OnlyValidAndDeep implements org.openide.util.Enumerations.Processor<Reference<AbstractFolder>,FileObject> { public FileObject process(Reference<AbstractFolder> obj, Collection<Reference<AbstractFolder>> toAdd) { AbstractFolder file = obj.get(); if (file != null) { AbstractFolder[] arr = file.subfiles(); // make the array weak for (int i = 0; i < arr.length; i++) { toAdd.add(new WeakReference<AbstractFolder>(arr[i])); } return file.isValid() ? file : null; } return null; } } Reference<AbstractFolder> ref = new WeakReference<AbstractFolder>(fo); Enumeration<Reference<AbstractFolder>> singleEn = org.openide.util.Enumerations.<Reference<AbstractFolder>>singleton(ref); return org.openide.util.Enumerations.removeNulls( org.openide.util.Enumerations.queue(singleEn, new OnlyValidAndDeep()) ); }
/** Existing folders for abstract file objects. */ private static Enumeration existingFolders (AbstractFileSystem fs) { return fs.existingFileObjects (fs.getAbstractRoot()); }
/** Tests if this file can be read. * @param name resource name * @return true if this file can be read, false if not. * @since 3.31 */ protected boolean canRead(String name) { AbstractFileObject afo = (AbstractFileObject) this.findResource(name); return (afo != null) ? afo.superCanRead() : false; }
/** Method to create a file object for given subfile. * @param name of the subfile * @return the file object */ protected final AbstractFolder createFile(String name) { return getAbstractFileSystem().createFileObject(this, name); }
/** * Tests if file really exists or is missing. Some operation on it may be restricted. * @return true indicates that the file is missing. * @since 1.9 */ public boolean isVirtual() { return getAbstractFileSystem ().checkVirtual (getPath ()); }
/** Creates Reference. In FileSystem, which subclasses AbstractFileSystem, you can overload method * createReference(FileObject fo) to achieve another type of Reference (weak, strong etc.) * @param fo FileObject * @return Reference to FileObject */ protected final Reference createReference(FileObject fo){ return(getAbstractFileSystem ().createReference(fo)); }
public boolean canWrite() { AbstractFileSystem fs = getAbstractFileSystem (); return fs.canWrite (getPath ()); }
/** Allows subclasses to fire that a change occured in a * file or folder. The change can be "expected" when it is * a result of an user action and the user knows that such * change should occur. * * @param name resource name of the file where the change occured * @param expected true if the user initiated change and expects it */ protected final void refreshResource (String name, boolean expected) { AbstractFileObject fo = (AbstractFileObject)findResourceIfExists (name); if (fo != null) { // refresh and behave like the changes is expected fo.refresh (null, null, true, expected); } } /**
private FileObject findResourceIfExists(String name) { if (name.length() == 0) { return getAbstractRoot(); } else { Enumeration<String> tok = NbCollections.checkedEnumerationByFilter(new StringTokenizer(name, "/"), String.class, true); // NOI18N return getAbstractRoot().findIfExists(tok); } }
/** Existing folders for abstract file objects. */ private static Enumeration existingFolders (AbstractFileSystem fs) { return fs.existingFileObjects (fs.getAbstractRoot()); }