@Deprecated public FileObject find(String aPackage, String name, String ext) { // create enumeration of name to look for Enumeration<String> st = NbCollections.checkedEnumerationByFilter(new StringTokenizer(aPackage, "."), String.class, true); // NOI18N if ((name == null) || (ext == null)) { // search for folder, return the object only if it is folder FileObject fo = getAbstractRoot().find(st); return ((fo != null) && fo.isFolder()) ? fo : null; } else { Enumeration<String> en = Enumerations.concat(st, Enumerations.singleton(name + '.' + ext)); // tries to find it (can return null) return getAbstractRoot().find(en); } }
/** Hooking method to allow MultiFileSystem to be informed when a new * file object is created. This is the only method that creates AbstractFileObjects. * * @param parent parent object * @param name of the object */ AbstractFileObject createFileObject(AbstractFileObject parent, String name) { return new AbstractFileObject(this, parent, name); }
/** * Actually implements contract of FileSystem.refresh(). */ public void refresh(boolean expected) { for (FileObject fo : NbCollections.iterable(getAbstractRoot().existingSubFiles(true))) { fo.refresh(expected); } }
void setAttribute(String attrName, Object value, boolean fire) throws IOException { Object oldValue = null; //FileSystem fs = getAbstractFileSystem (); //if (fs.isReadOnly()) XMLFileSystemTestHid.java:934 // throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FSisRO", fs.getDisplayName ()); // NOI18N if (fire) { oldValue = getAttribute(attrName); } getAbstractFileSystem().attr.writeAttribute(getPath(), attrName, value); if (fire && (oldValue != value) && hasAtLeastOneListeners()) { fileAttributeChanged0(new FileAttributeEvent(this, attrName, oldValue, value)); } }
getFileSystem().beginAtomicAction(); if (isFolder()) { super.refresh(added, removed, fire, expected, list); } else { boolean isInitialization = initLastModified(false); if (isInitialization) { return; } else { l = getAbstractFileSystem().info.lastModified(getPath()); if (Math.abs(getLastModified().getTime() - l.getTime()) != 0) { putLastModified(l); if (fire && hasAtLeastOneListeners()) { ev = new FileEvent(this, this, expected); fileDeleted0(ev); fileChanged0(ev); if (refreshParent && (parent.getFileObject(getName(), getExt()) != null)) { parent.refreshFolder(null, this.getNameExt(), fire, expected, null); getFileSystem().finishAtomicAction();
void handleDelete(FileLock lock) throws IOException { if (parent == null) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_CannotDeleteRoot", getAbstractFileSystem().getDisplayName())); getFileSystem().beginAtomicAction(); testLock(lock); fullName = getPath(); getAbstractFileSystem().change.delete(fullName); } catch (IOException ex) { StreamPool p = StreamPool.find(this); getAbstractFileSystem().attr.deleteAttributes(fullName); if (hasAtLeastOneListeners()) { fileDeleted0(new FileEvent(this)); getFileSystem().finishAtomicAction();
getFileSystem().beginAtomicAction(); String n = null; synchronized (this) { AbstractFileSystem fs = getAbstractFileSystem(); if (isReadOnly()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FisRO", name, fs.getDisplayName())); if (!isFolder()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FoNotFolder", n, getPath(), fs.getDisplayName())); fName = getPath() + PATH_SEP + n; getAbstractFileSystem().change.createData(fName); registerChild(n); AbstractFileObject fo = getAbstractChild(n); throw new FileStateInvalidException(NbBundle.getMessage(AbstractFileObject.class, "EXC_ApplicationCreateError", getPath(), n)); if (hasListeners()) { fileCreated0(new FileEvent(this, fo), true); getFileSystem().finishAtomicAction();
public void rename(FileLock lock, String name, String ext) throws IOException { if (parent == null) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_CannotRenameRoot", getAbstractFileSystem().getDisplayName())); ) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_CannotRenameFromTo", getPath(), getAbstractFileSystem().getDisplayName(), name + "." + ext)); getFileSystem().beginAtomicAction(); testLock(lock); if (isData()) { if (ext != null && ext.trim().length() > 0) { name = name + EXT_SEP + ext; oldFullName = getPath(); if (isReadOnly()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_CannotRenameFromTo", getPath(), getAbstractFileSystem().getDisplayName(), newFullName)); if (getFileSystem().isReadOnly()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FSisRO", getAbstractFileSystem().getDisplayName())); String on = getName(); String oe = getExt(); getAbstractFileSystem().change.rename(oldFullName, newFullName);
AbstractFileSystem fs = getAbstractFileSystem(); AbstractFileSystem.Transfer from = getAbstractFileSystem().transfer; AbstractFileSystem abstractFS = abstractTarget.getAbstractFileSystem(); AbstractFileSystem.Transfer to = abstractFS.transfer; getFileSystem().beginAtomicAction(); testLock(lock); String fullName = getPath(); abstractTarget.registerChild(n); AbstractFileObject fo = abstractTarget.getAbstractChild(n); NbBundle.getMessage(AbstractFileObject.class, "EXC_ApplicationCreateError", abstractTarget.getPath(), n)); if (hasAtLeastOneListeners()) { fileDeleted0(new FileEvent(this)); if (abstractTarget.hasListeners()) { abstractTarget.fileCreated0(new FileEvent(abstractTarget, fo), true); getFileSystem().finishAtomicAction();
boolean refreshParent = false; try { getFileSystem ().beginAtomicAction (); if (isFolder ()) { super.refresh (added, removed, fire, expected, list); } else { lastModified = l = getAbstractFileSystem().info.lastModified(getPath()); return; } else l = getAbstractFileSystem().info.lastModified(getPath()); if (fire && hasAtLeastOneListeners()) ev = new FileEvent(this, this, expected); if (validFlag) { validFlag = false; if (ev != null) fileDeleted0(ev); refreshParent = true; } else if (ev != null) fileChanged0(ev); if (refreshParent && parent.getFileObject(getName (),getExt ()) != null) parent.refreshFolder(null,this.getNameExt(),fire,expected,null); } finally { getFileSystem ().finishAtomicAction ();
AbstractFileSystem.Transfer from = getAbstractFileSystem().transfer; AbstractFileSystem abstractFS = abstractTarget.getAbstractFileSystem(); AbstractFileSystem.Transfer to = abstractFS.transfer; getFileSystem().beginAtomicAction(); if (from.copy(getPath(), to, target.getPath() + PATH_SEP + n)) { abstractTarget.registerChild(n); AbstractFileObject fo = abstractTarget.getAbstractChild(n); NbBundle.getMessage(AbstractFileObject.class, "EXC_ApplicationCreateError", abstractTarget.getPath(), n)); if (abstractTarget.hasListeners()) { abstractTarget.fileCreated0(new FileEvent(abstractTarget, fo), true); getFileSystem().finishAtomicAction();
/** This method allows to find Reference to resourceName * @param resourceName is name of resource * @return Reference to resourceName */ protected final Reference<? extends FileObject> findReference(String resourceName) { if (resourceName.length() == 0) { return null; } else { Enumeration<String> tok = NbCollections.checkedEnumerationByFilter(new StringTokenizer(resourceName, "/"), String.class, true); // NOI18N return getAbstractRoot().findRefIfExists(tok); } }
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); } }
private void refreshChildrenInAtomicAction(AbstractFolder fo, ResourceElem resElem) { try { beginAtomicAction(); Collection<AbstractFolder> oldChildren = new HashSet<AbstractFolder>(Collections.list(fo.existingSubFiles(true))); refreshChildren(fo, resElem); Collection<AbstractFolder> newChildren = Collections.list(fo.existingSubFiles(true)); oldChildren.removeAll(newChildren); for (Iterator<AbstractFolder> it = oldChildren.iterator(); it.hasNext();) { AbstractFileObject invalid = (AbstractFileObject)it.next(); if (invalid.validFlag) { invalid.validFlag = false; invalid.fileDeleted0(new FileEvent(invalid)); } } } finally { finishAtomicAction(); } }
getFileSystem().beginAtomicAction(); AbstractFileSystem fs = getAbstractFileSystem(); if (isReadOnly()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FisRO", name, fs.getDisplayName())); if (!isFolder()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FoNotFolder", name, getPath(), fs.getDisplayName())); getAbstractFileSystem().change.createFolder(getPath() + PATH_SEP + name); registerChild(name); fo = getAbstractChild(name); throw new FileStateInvalidException(NbBundle.getMessage(AbstractFileObject.class, "EXC_ApplicationCreateError", getPath(), name)); if (hasListeners()) { fileCreated0(new FileEvent(this, fo), false); getFileSystem().finishAtomicAction();
public void rename(FileLock lock, String name, String ext) throws IOException { if (parent == null) { FSException.io ("EXC_CannotRenameRoot", getAbstractFileSystem ().getDisplayName ()); // NOI18N FSException.io ("EXC_CannotRename", getPath (), getAbstractFileSystem ().getDisplayName (), name + "." + ext); // NOI18N getFileSystem ().beginAtomicAction (); String newFullName = null; String oldFullName = null; synchronized (parent) { testLock (lock); if (isData ()) { if (ext != null) name = name + EXT_SEP + ext; oldFullName = getPath (); if (isReadOnly ()) { FSException.io ("EXC_CannotRename", getPath (), getAbstractFileSystem ().getDisplayName (), newFullName); // NOI18N if (getFileSystem ().isReadOnly()) { FSException.io ("EXC_FSisRO", getAbstractFileSystem ().getDisplayName ()); // NOI18N String on = getName (); String oe = getExt (); getAbstractFileSystem ().change.rename (oldFullName, newFullName);
AbstractFileSystem fs = getAbstractFileSystem (); AbstractFileSystem.Transfer from = getAbstractFileSystem ().transfer; AbstractFileSystem abstractFS = abstractTarget.getAbstractFileSystem (); AbstractFileSystem.Transfer to = abstractFS.transfer; getFileSystem ().beginAtomicAction (); synchronized (parent) { testLock (lock); String fullName = getPath (); abstractTarget.registerChild (n); AbstractFileObject fo = abstractTarget.getAbstractChild (n); throw new FileStateInvalidException (FileSystem.getString ("EXC_ApplicationCreateError", abstractTarget.getPath (), n)); if (hasAtLeastOneListeners ()) { fileDeleted0(new FileEvent(this)); if (abstractTarget.hasListeners ()) { abstractTarget.fileCreated0(new FileEvent(abstractTarget, fo), true); getFileSystem ().finishAtomicAction ();
boolean refreshParent = false; try { getFileSystem ().beginAtomicAction (); if (isFolder ()) { super.refresh (added, removed, fire, expected, list); } else { lastModified = l = getAbstractFileSystem().info.lastModified(getPath()); return; } else l = getAbstractFileSystem().info.lastModified(getPath()); if (fire && hasAtLeastOneListeners()) ev = new FileEvent(this, this, expected); if (validFlag) { validFlag = false; if (ev != null) fileDeleted0(ev); refreshParent = true; } else if (ev != null) fileChanged0(ev); if (refreshParent && parent.getFileObject(getName (),getExt ()) != null) parent.refreshFolder(null,this.getNameExt(),fire,expected,null); } finally { getFileSystem ().finishAtomicAction ();
AbstractFileSystem.Transfer from = getAbstractFileSystem ().transfer; AbstractFileSystem abstractFS = abstractTarget.getAbstractFileSystem (); AbstractFileSystem.Transfer to = abstractFS.transfer; getFileSystem ().beginAtomicAction (); synchronized (abstractTarget) { if (from.copy (getPath (), to, target.getPath () + PATH_SEP + n)) { abstractTarget.registerChild (n); AbstractFileObject fo = abstractTarget.getAbstractChild (n); throw new FileStateInvalidException (FileSystem.getString ("EXC_ApplicationCreateError", abstractTarget.getPath (), n)); if (abstractTarget.hasListeners ()) { abstractTarget.fileCreated0(new FileEvent(abstractTarget, fo), true); getFileSystem ().finishAtomicAction ();
void handleDelete (FileLock lock) throws IOException { if (parent == null) { FSException.io ("EXC_CannotDeleteRoot", getAbstractFileSystem ().getDisplayName ()); // NOI18N getFileSystem ().beginAtomicAction (); synchronized (parent) { testLock (lock); fullName = getPath (); try { getAbstractFileSystem ().change.delete (fullName); } catch (IOException ex) { StreamPool p = StreamPool.find (this); getAbstractFileSystem ().attr.deleteAttributes (fullName); if (hasAtLeastOneListeners ()) { fileDeleted0(new FileEvent(this)); getFileSystem ().finishAtomicAction ();