? patch.diff ? test/unit/src/META-INF/services/org.netbeans.modules.masterfs.providers.AnnotationProvider ? test/unit/src/org/netbeans/modules/masterfs/providers/InterceptionListenerTest.java Index: nbproject/project.xml =================================================================== RCS file: /cvs/openide/masterfs/nbproject/project.xml,v retrieving revision 1.15 diff -u -c -r1.15 project.xml *** nbproject/project.xml 4 Jun 2005 05:16:48 -0000 1.15 --- nbproject/project.xml 6 Jun 2006 12:06:27 -0000 *************** *** 53,58 **** --- 53,59 ---- org.netbeans.modules.vcscore org.netbeans.modules.versioning.system.cvss + org.netbeans.modules.subversion org.netbeans.modules.masterfs.providers Index: src/org/netbeans/modules/masterfs/Delegate.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/Delegate.java,v retrieving revision 1.19.6.1 diff -u -c -r1.19.6.1 Delegate.java *** src/org/netbeans/modules/masterfs/Delegate.java 18 Jan 2006 19:37:29 -0000 1.19.6.1 --- src/org/netbeans/modules/masterfs/Delegate.java 6 Jun 2006 12:06:27 -0000 *************** *** 39,45 **** private FileObject delegate; private FileObject secondDelegate; private FileChangeListener weakListener; ! final private FileChangeListener fListener; private Reference lock = null; private int attribs = 0; --- 39,45 ---- private FileObject delegate; private FileObject secondDelegate; private FileChangeListener weakListener; ! final FileChangeListener fListener; private Reference lock = null; private int attribs = 0; Index: src/org/netbeans/modules/masterfs/MasterFileObject.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/MasterFileObject.java,v retrieving revision 1.45.2.1 diff -u -c -r1.45.2.1 MasterFileObject.java *** src/org/netbeans/modules/masterfs/MasterFileObject.java 18 Jan 2006 19:37:31 -0000 1.45.2.1 --- src/org/netbeans/modules/masterfs/MasterFileObject.java 6 Jun 2006 12:06:27 -0000 *************** *** 22,34 **** import org.openide.filesystems.*; import org.openide.util.Utilities; import org.netbeans.modules.masterfs.filebasedfs.fileobjects.ReplaceForSerialization; - import org.netbeans.modules.masterfs.providers.InterceptionListener; import javax.swing.event.EventListenerList; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.*; /** * Implements FileObject, hosts delegate and mostly uses it whenever possible. --- 22,35 ---- import org.openide.filesystems.*; import org.openide.util.Utilities; import org.netbeans.modules.masterfs.filebasedfs.fileobjects.ReplaceForSerialization; import javax.swing.event.EventListenerList; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.*; + import org.netbeans.modules.masterfs.filebasedfs.utils.FileInfo; + import org.netbeans.modules.masterfs.providers.ProvidedExtensions; /** * Implements FileObject, hosts delegate and mostly uses it whenever possible. *************** *** 365,374 **** } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! InterceptionListener iListener = status.getInterceptionListener(); ! if (iListener != null) { ! iListener.beforeCreate(this, name, true); ! } IOException toThrow = null; FileObject newFolder = null; try { --- 366,373 ---- } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! ProvidedExtensions extensions = status.getExtensions(); ! extensions.beforeCreate(this, name, true); IOException toThrow = null; FileObject newFolder = null; try { *************** *** 378,389 **** toThrow = iex; throw iex; } finally { ! if (iListener != null) { ! if (toThrow == null) { ! iListener.createSuccess(newFolder); ! } else { ! iListener.createFailure(this, name, true); ! } } } } --- 377,386 ---- toThrow = iex; throw iex; } finally { ! if (toThrow == null) { ! extensions.createSuccess(newFolder); ! } else { ! extensions.createFailure(this, name, true); } } } *************** *** 397,406 **** } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! InterceptionListener iListener = status.getInterceptionListener(); ! if (iListener != null) { ! iListener.beforeCreate(this, name, false); ! } IOException toThrow = null; FileObject newFile = null; try { --- 394,401 ---- } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! ProvidedExtensions extensions = status.getExtensions(); ! extensions.beforeCreate(this, name, false); IOException toThrow = null; FileObject newFile = null; try { *************** *** 410,420 **** toThrow = iex; throw iex; } finally { ! if (iListener != null) { if (toThrow == null) { ! iListener.createSuccess(newFile); } else { ! iListener.createFailure(this, name, false); } } } --- 405,415 ---- toThrow = iex; throw iex; } finally { ! if (extensions != null) { if (toThrow == null) { ! extensions.createSuccess(newFile); } else { ! extensions.createFailure(this, name, false); } } } *************** *** 429,438 **** } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! InterceptionListener iListener = status.getInterceptionListener(); ! if (iListener != null) { ! iListener.beforeCreate(this, name, false); ! } IOException toThrow = null; FileObject newFile = null; try { --- 424,431 ---- } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! ProvidedExtensions extensions = status.getExtensions(); ! extensions.beforeCreate(this, FileInfo.composeName(name, ext), false); IOException toThrow = null; FileObject newFile = null; try { *************** *** 442,452 **** toThrow = iex; throw iex; } finally { ! if (iListener != null) { if (toThrow == null) { ! iListener.createSuccess(newFile); } else { ! iListener.createFailure(this, name, false); } } } --- 435,445 ---- toThrow = iex; throw iex; } finally { ! if (extensions != null) { if (toThrow == null) { ! extensions.createSuccess(newFile); } else { ! extensions.createFailure(this, FileInfo.composeName(name, ext), false); } } } *************** *** 471,480 **** MountTable.getDefault().unmount(getDelegateFileSystem()); } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! InterceptionListener iListener = status.getInterceptionListener(); ! if (iListener != null) { ! iListener.beforeDelete(this); ! } IOException toThrow = null; try { new AtomicAction(this).delete(lock); --- 464,471 ---- MountTable.getDefault().unmount(getDelegateFileSystem()); } MasterFileSystem.StatusImpl status = (MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus(); ! ProvidedExtensions extensions = status.getExtensions(); ! extensions.beforeDelete(this); IOException toThrow = null; try { new AtomicAction(this).delete(lock); *************** *** 482,493 **** toThrow = iex; throw iex; } finally { ! if (iListener != null) { ! if (toThrow == null) { ! iListener.deleteSuccess(this); ! } else { ! iListener.deleteFailure(this); ! } } } } --- 473,482 ---- toThrow = iex; throw iex; } finally { ! if (toThrow == null) { ! extensions.deleteSuccess(this); ! } else { ! extensions.deleteFailure(this); } } } *************** *** 499,504 **** --- 488,497 ---- // overwritten only because of included in sync. section enterExclusiveCriticalSection(); try { + if (getParent().equals(target)) { + rename(lock,name, ext); + return this; + } return new AtomicAction(this).move(lock, target, name, ext); } finally { finishExclusiveCriticalSection(); *************** *** 548,556 **** */ public void rename(FileLock lock, String name, String ext) throws IOException { //TODO: rename is wrong implemeted enterCriticalSection(); try { ! FileObject deleg = getValidOrInvalid(getDelegate().get()); if (isReadOnly()) { Utils.throwIOException("EXC_CannotRename", new Object[]{getPath(), getHFs().getDisplayName()}); --- 541,551 ---- */ public void rename(FileLock lock, String name, String ext) throws IOException { //TODO: rename is wrong implemeted + FileObject deleg = null; + ProvidedExtensions.IOHandler renameHandler = getRenameHandler(name, ext); enterCriticalSection(); try { ! deleg = getValidOrInvalid(getDelegate().get()); if (isReadOnly()) { Utils.throwIOException("EXC_CannotRename", new Object[]{getPath(), getHFs().getDisplayName()}); *************** *** 565,571 **** try { //TODO: here is fired exception sometimes FileLock lck = Delegate.getLockForDelegate(lock, deleg); ! deleg.rename(lck, name, ext); MountTable.getDefault().renameCachedFileObjects(oldResName.getNormalizedPath(), getResource().getNormalizedPath()); return; } catch (IOException iex) { --- 560,570 ---- try { //TODO: here is fired exception sometimes FileLock lck = Delegate.getLockForDelegate(lock, deleg); ! if (renameHandler == null) { ! deleg.rename(lck, name, ext); ! } else { ! ((BaseFileObj)deleg).rename(lck, name, ext, renameHandler); ! } MountTable.getDefault().renameCachedFileObjects(oldResName.getNormalizedPath(), getResource().getNormalizedPath()); return; } catch (IOException iex) { *************** *** 585,590 **** --- 584,597 ---- } } + private ProvidedExtensions.IOHandler getRenameHandler(final String name, final String ext) { + ProvidedExtensions pe; + pe = ((MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus()).getExtensions(); + + File fileToRename = getResource().getFile(); + return pe.getRenameHandler(fileToRename, FileInfo.composeName(name, ext)); + } + public final Object writeReplace() { return new Replace(getPath()); } *************** *** 1114,1120 **** } private void move() throws IOException { ! retVal = hfoI.superMove(fLockI, targetI, nameI, extI); } private void iRefreshExpected() { --- 1121,1162 ---- } private void move() throws IOException { ! ProvidedExtensions.IOHandler moveHandler = getMoveHandler(); ! if (moveHandler != null) { ! if (targetI instanceof MasterFileObject) { ! BaseFileObj deleg = (BaseFileObj)getValidOrInvalid(hfoI.getDelegate().get(), hfoI); ! FileLock lck = Delegate.getLockForDelegate(fLockI, deleg); ! MasterFileObject targetMfo = (MasterFileObject)targetI; ! BaseFileObj targetDeleg = (BaseFileObj)getValidOrInvalid(targetMfo.getDelegate().get(), targetMfo); ! deleg.move(lck,targetDeleg,nameI, extI, moveHandler); ! retVal = getCache().getOrCreate(targetMfo.getResource().getChild(nameI, extI)); ! FileUtil.copyAttributes(hfoI, retVal); ! } else { ! //!!! NOT NICE: #73042 - Subversion support ! moveHandler.handle(); ! hfoI.refresh(true); ! //perfromance bottleneck to call refresh on folder ! //(especially for many files to be moved) ! targetI.refresh(true); ! retVal = targetI.getFileObject(nameI, extI); ! assert (retVal != null); ! //!!! hfoI is already deleted when copyAttributes is invoked ! FileUtil.copyAttributes(hfoI, retVal); ! return; ! } ! } else { ! retVal = hfoI.superMove(fLockI, targetI, nameI, extI); ! } ! } ! ! private ProvidedExtensions.IOHandler getMoveHandler() { ! ProvidedExtensions pe; ! pe = ((MasterFileSystem.StatusImpl)MasterFileSystem.getDefault().getStatus()).getExtensions(); ! ! String fName = FileInfo.composeName(nameI, extI); ! File from = hfoI.getResource().getFile(); ! File to = ((MasterFileObject)targetI).getResource().getChild(fName).getFile(); ! return pe.getMoveHandler(from,to); } private void iRefreshExpected() { Index: src/org/netbeans/modules/masterfs/MasterFileSystem.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/MasterFileSystem.java,v retrieving revision 1.19.10.1 diff -u -c -r1.19.10.1 MasterFileSystem.java *** src/org/netbeans/modules/masterfs/MasterFileSystem.java 18 Jan 2006 19:37:31 -0000 1.19.10.1 --- src/org/netbeans/modules/masterfs/MasterFileSystem.java 6 Jun 2006 12:06:27 -0000 *************** *** 14,19 **** --- 14,21 ---- package org.netbeans.modules.masterfs; + import java.io.*; + import org.netbeans.modules.masterfs.providers.*; import org.netbeans.modules.masterfs.providers.AnnotationProvider; import org.netbeans.modules.masterfs.providers.InterceptionListener; import org.openide.filesystems.*; *************** *** 21,27 **** import org.openide.util.actions.SystemAction; import org.openide.util.Utilities; - import javax.swing.*; import java.awt.*; import java.beans.PropertyVetoException; import java.io.File; --- 23,28 ---- *************** *** 327,340 **** resultChanged (null); } ! public InterceptionListener getInterceptionListener() { ! InterceptionListener retVal = null; ! java.util.Iterator it = annotationProviders.allInstances ().iterator (); ! while (retVal == null && it.hasNext ()) { ! AnnotationProvider ap = (AnnotationProvider)it.next (); ! retVal = ap.getInterceptionListener (); ! } ! return retVal; } public void resultChanged (org.openide.util.LookupEvent ev) { --- 328,337 ---- resultChanged (null); } ! public ProvidedExtensions getExtensions() { ! Collection c = (previousProviders != null) ? ! Collections.unmodifiableCollection(previousProviders) : Collections.EMPTY_LIST; ! return new ProvidedExtensionsProxy(c); } public void resultChanged (org.openide.util.LookupEvent ev) { Index: src/org/netbeans/modules/masterfs/filebasedfs/children/ChildrenSupport.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/children/ChildrenSupport.java,v retrieving revision 1.10 diff -u -c -r1.10 ChildrenSupport.java *** src/org/netbeans/modules/masterfs/filebasedfs/children/ChildrenSupport.java 5 Apr 2005 12:43:06 -0000 1.10 --- src/org/netbeans/modules/masterfs/filebasedfs/children/ChildrenSupport.java 6 Jun 2006 12:06:27 -0000 *************** *** 20,25 **** --- 20,26 ---- import java.io.File; import java.util.*; + import org.netbeans.modules.masterfs.providers.ProvidedExtensions; /** * @author Radek Matous *************** *** 112,117 **** --- 113,122 ---- return id; } public boolean rename(String name) { + // not implemented, as it will not be called + throw new IllegalStateException(); + } + public boolean rename(String name, ProvidedExtensions.IOHandler h) { // not implemented, as it will not be called throw new IllegalStateException(); } Index: src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/BaseFileObj.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/BaseFileObj.java,v retrieving revision 1.16.16.2 diff -u -c -r1.16.16.2 BaseFileObj.java *** src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/BaseFileObj.java 18 Jan 2006 19:37:34 -0000 1.16.16.2 --- src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/BaseFileObj.java 6 Jun 2006 12:06:27 -0000 *************** *** 29,34 **** --- 29,35 ---- import java.io.*; import java.util.Date; import java.util.Enumeration; + import org.netbeans.modules.masterfs.providers.ProvidedExtensions; /** * Implements FileObject methods as simple as possible. *************** *** 150,156 **** return false; } ! public final void rename(final FileLock lock, final String name, final String ext) throws IOException { final File file = getFileName().getFile(); final File parent = file.getParentFile(); --- 151,167 ---- return false; } ! public void move(FileLock lock, BaseFileObj target, String name, String ext, ProvidedExtensions.IOHandler moveHandler) throws IOException { ! moveHandler.handle(); ! BaseFileObj result = (BaseFileObj)FileBasedFileSystem.getFileObject( ! new File(target.getFileName().getFile(),FileInfo.composeName(name,ext))); ! assert result != null; ! result.fireFileDataCreatedEvent(false); ! fireFileDeletedEvent(false); ! } ! ! ! public void rename(final FileLock lock, final String name, final String ext, ProvidedExtensions.IOHandler handler) throws IOException { final File file = getFileName().getFile(); final File parent = file.getParentFile(); *************** *** 171,177 **** final String originalExt = getExt(); //TODO: no lock used ! if (!NamingFactory.rename(getFileName(),file2Rename.getName())) { FileObject parentFo = getExistingParent(); String parentPath = (parentFo != null) ? parentFo.getPath() : file.getParentFile().getAbsolutePath(); FSException.io("EXC_CannotRename", file.getName(), parentPath, file2Rename.getName());// NOI18N --- 182,188 ---- final String originalExt = getExt(); //TODO: no lock used ! if (!NamingFactory.rename(getFileName(),file2Rename.getName(),handler)) { FileObject parentFo = getExistingParent(); String parentPath = (parentFo != null) ? parentFo.getPath() : file.getParentFile().getAbsolutePath(); FSException.io("EXC_CannotRename", file.getName(), parentPath, file2Rename.getName());// NOI18N *************** *** 184,189 **** --- 195,205 ---- } + public final void rename(final FileLock lock, final String name, final String ext) throws IOException { + rename(lock, name, ext, null); + } + + public Object getAttribute(final String attrName) { return BaseFileObj.attribs.readAttribute(getFileName().getFile().getAbsolutePath().replace('\\', '/'), attrName);//NOI18N } *************** *** 399,404 **** --- 415,423 ---- } abstract protected void setValid(boolean valid); + + abstract public void refresh(final boolean expected, boolean fire); + //TODO: attributes written by VCS must be readable by FileBaseFS and vice versa /** * FileBaseFS Index: src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FileObj.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FileObj.java,v retrieving revision 1.12.8.1 diff -u -c -r1.12.8.1 FileObj.java *** src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FileObj.java 18 Jan 2006 19:37:35 -0000 1.12.8.1 --- src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FileObj.java 6 Jun 2006 12:06:27 -0000 *************** *** 26,33 **** --- 26,35 ---- import org.netbeans.modules.masterfs.filebasedfs.naming.FileNaming; import org.netbeans.modules.masterfs.filebasedfs.utils.FSException; import org.netbeans.modules.masterfs.filebasedfs.utils.FileInfo; + import org.netbeans.modules.masterfs.providers.ProvidedExtensions; import org.openide.filesystems.FileLock; import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileUtil; import org.openide.util.Enumerations; /** *************** *** 167,180 **** return false; } ! public final void refresh(final boolean expected) { Statistics.StopWatch stopWatch = Statistics.getStopWatch(Statistics.REFRESH_FILE); stopWatch.start(); if (isValid()) { final long oldLastModified = lastModified; setLastModified(getFileName().getFile().lastModified()); ! if (oldLastModified != -1 && lastModified != -1 && lastModified != 0 && oldLastModified < lastModified) { fireFileChangedEvent(expected); } --- 169,182 ---- return false; } ! public void refresh(final boolean expected, boolean fire) { Statistics.StopWatch stopWatch = Statistics.getStopWatch(Statistics.REFRESH_FILE); stopWatch.start(); if (isValid()) { final long oldLastModified = lastModified; setLastModified(getFileName().getFile().lastModified()); ! if (fire && oldLastModified != -1 && lastModified != -1 && lastModified != 0 && oldLastModified < lastModified) { fireFileChangedEvent(expected); } *************** *** 182,194 **** --- 184,203 ---- if (!validityFlag) { //fileobject is invalidated setValid(false); + if (fire) { fireFileDeletedEvent(expected); } } + } stopWatch.stop(); } + public final void refresh(final boolean expected) { + refresh(expected, true); + } + + public final Enumeration getChildren(final boolean rec) { *************** *** 234,238 **** --- 243,252 ---- final boolean checkLock(final FileLock lock) throws IOException { final File f = getFileName().getFile(); return ((lock instanceof WriteLock) && (((WriteLock) lock).isValid(f))); + } + + public void rename(final FileLock lock, final String name, final String ext, ProvidedExtensions.IOHandler handler) throws IOException { + super.rename(lock, name, ext, handler); + setLastModified(getFileName().getFile().lastModified()); } } Index: src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FolderObj.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FolderObj.java,v retrieving revision 1.12.2.1 diff -u -c -r1.12.2.1 FolderObj.java *** src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FolderObj.java 18 Jan 2006 19:37:36 -0000 1.12.2.1 --- src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FolderObj.java 6 Jun 2006 12:06:27 -0000 *************** *** 238,250 **** } } ! ! public final void refresh(final boolean expected) { Statistics.StopWatch stopWatch = Statistics.getStopWatch(Statistics.REFRESH_FOLDER); stopWatch.start(); if (isValid()) { - boolean isFileCreatedFired = false; final ChildrenCache cache = getChildrenCache(); final Mutex.Privileged mutexPrivileged = cache.getMutexPrivileged(); --- 238,248 ---- } } ! public void refresh(final boolean expected, boolean fire) { Statistics.StopWatch stopWatch = Statistics.getStopWatch(Statistics.REFRESH_FOLDER); stopWatch.start(); if (isValid()) { final ChildrenCache cache = getChildrenCache(); final Mutex.Privileged mutexPrivileged = cache.getMutexPrivileged(); *************** *** 282,300 **** if (operationId == ChildrenCache.ADDED_CHILD && newChild != null) { if (newChild.isFolder()) { ! isFileCreatedFired = true; newChild.fireFileFolderCreatedEvent(expected); } else { ! isFileCreatedFired = true; newChild.fireFileDataCreatedEvent(expected); } } else if (operationId == ChildrenCache.REMOVED_CHILD) { if (newChild != null) { if (newChild.isValid()) { newChild.setValid(false); newChild.fireFileDeletedEvent(expected); } } else { //TODO: should be rechecked //assert false; --- 280,302 ---- if (operationId == ChildrenCache.ADDED_CHILD && newChild != null) { if (newChild.isFolder()) { ! if (fire) { newChild.fireFileFolderCreatedEvent(expected); + } } else { ! if (fire) { newChild.fireFileDataCreatedEvent(expected); } + } } else if (operationId == ChildrenCache.REMOVED_CHILD) { if (newChild != null) { if (newChild.isValid()) { newChild.setValid(false); + if (fire) { newChild.fireFileDeletedEvent(expected); } + } } else { //TODO: should be rechecked //assert false; *************** *** 308,316 **** --- 310,320 ---- } fakeInvalid.setValid(false); + if (fire) { fakeInvalid.fireFileDeletedEvent(expected); } } + } } else { assert !(new FileInfo(child.getFile()).isConvertibleToFileObject()); *************** *** 321,330 **** --- 325,340 ---- if (!validityFlag) { //fileobject is invalidated setValid(false); + if (fire) { fireFileDeletedEvent(expected); } } + } stopWatch.stop(); + } + + public final void refresh(final boolean expected) { + refresh(expected, true); } //TODO: rewrite partly and check FileLocks for existing FileObjects Index: src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/ReplaceForSerialization.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/ReplaceForSerialization.java,v retrieving revision 1.4 diff -u -c -r1.4 ReplaceForSerialization.java *** src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/ReplaceForSerialization.java 2 Apr 2005 10:38:11 -0000 1.4 --- src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/ReplaceForSerialization.java 6 Jun 2006 12:06:27 -0000 *************** *** 101,105 **** --- 101,108 ---- public FileObject createData(String name, String ext) throws IOException { throw new IOException (getPath()); } + + public void refresh(final boolean expected, boolean fire) { } + } } Index: src/org/netbeans/modules/masterfs/filebasedfs/naming/FileName.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/naming/FileName.java,v retrieving revision 1.6 diff -u -c -r1.6 FileName.java *** src/org/netbeans/modules/masterfs/filebasedfs/naming/FileName.java 22 Mar 2005 12:17:36 -0000 1.6 --- src/org/netbeans/modules/masterfs/filebasedfs/naming/FileName.java 6 Jun 2006 12:06:27 -0000 *************** *** 15,20 **** --- 15,23 ---- import java.io.File; + import java.io.IOException; + import org.netbeans.modules.masterfs.providers.ProvidedExtensions; + import org.openide.ErrorManager; /** * @author Radek Matous *************** *** 34,46 **** return (file.getParentFile() == null) ? file.getPath() : file.getName(); } ! public final boolean rename(final String name) { boolean retVal = false; final File f = getFile(); if (f.exists()) { File newFile = new File(f.getParentFile(), name); ! retVal = f.renameTo(newFile); if (retVal) { this.name = name; id = NamingFactory.createID(newFile); --- 37,58 ---- return (file.getParentFile() == null) ? file.getPath() : file.getName(); } ! public boolean rename(String name, ProvidedExtensions.IOHandler handler) { boolean retVal = false; final File f = getFile(); if (f.exists()) { File newFile = new File(f.getParentFile(), name); ! if (handler != null) { ! try { ! handler.handle(); ! retVal = true; ! } catch (IOException ex) { ! ErrorManager.getDefault().notify(ex); ! } ! } else { ! retVal = f.renameTo(newFile); ! } if (retVal) { this.name = name; id = NamingFactory.createID(newFile); *************** *** 48,54 **** --- 60,69 ---- } FolderName.freeCaches(); return retVal; + } + public final boolean rename(final String name) { + return rename(name, null); } public final boolean isRoot() { Index: src/org/netbeans/modules/masterfs/filebasedfs/naming/FileNaming.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/naming/FileNaming.java,v retrieving revision 1.4 diff -u -c -r1.4 FileNaming.java *** src/org/netbeans/modules/masterfs/filebasedfs/naming/FileNaming.java 15 Mar 2005 12:10:45 -0000 1.4 --- src/org/netbeans/modules/masterfs/filebasedfs/naming/FileNaming.java 6 Jun 2006 12:06:27 -0000 *************** *** 15,38 **** import java.io.File; /** * @author Radek Matous */ public interface FileNaming { String getName(); ! FileNaming getParent(); ! boolean isRoot(); ! File getFile(); ! ! boolean isFile (); ! Integer getId(); ! Integer getId(boolean recompute); ! boolean rename(String name); } --- 15,41 ---- import java.io.File; + import org.netbeans.modules.masterfs.providers.ProvidedExtensions; /** * @author Radek Matous */ public interface FileNaming { String getName(); ! FileNaming getParent(); ! boolean isRoot(); ! File getFile(); ! ! boolean isFile(); ! Integer getId(); ! Integer getId(boolean recompute); ! boolean rename(String name); + boolean rename(String name, ProvidedExtensions.IOHandler handler); + } Index: src/org/netbeans/modules/masterfs/filebasedfs/naming/NamingFactory.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/naming/NamingFactory.java,v retrieving revision 1.5.28.1 diff -u -c -r1.5.28.1 NamingFactory.java *** src/org/netbeans/modules/masterfs/filebasedfs/naming/NamingFactory.java 18 Jan 2006 19:37:38 -0000 1.5.28.1 --- src/org/netbeans/modules/masterfs/filebasedfs/naming/NamingFactory.java 6 Jun 2006 12:06:27 -0000 *************** *** 19,24 **** --- 19,25 ---- import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.util.*; + import org.netbeans.modules.masterfs.providers.ProvidedExtensions; /** * @author Radek Matous *************** *** 58,68 **** } } } ! public static synchronized boolean rename (FileNaming fNaming, String newName) { boolean retVal = false; remove(fNaming, null); ! retVal = fNaming.rename(newName); NamingFactory.registerInstanceOfFileNaming(fNaming.getParent(), fNaming.getFile(), fNaming); renameChildren(); return retVal; --- 59,73 ---- } } } ! public static synchronized boolean rename (FileNaming fNaming, String newName) { + return rename(fNaming, newName, null); + } + + public static synchronized boolean rename (FileNaming fNaming, String newName, ProvidedExtensions.IOHandler handler) { boolean retVal = false; remove(fNaming, null); ! retVal = fNaming.rename(newName, handler); NamingFactory.registerInstanceOfFileNaming(fNaming.getParent(), fNaming.getFile(), fNaming); renameChildren(); return retVal; Index: src/org/netbeans/modules/masterfs/filebasedfs/utils/FileInfo.java =================================================================== RCS file: /cvs/openide/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/utils/FileInfo.java,v retrieving revision 1.8.6.1 diff -u -c -r1.8.6.1 FileInfo.java *** src/org/netbeans/modules/masterfs/filebasedfs/utils/FileInfo.java 18 Jan 2006 19:37:39 -0000 1.8.6.1 --- src/org/netbeans/modules/masterfs/filebasedfs/utils/FileInfo.java 6 Jun 2006 12:06:27 -0000 *************** *** 239,243 **** --- 239,260 ---- public String toString() { return getFile().toString(); } + + public static final String composeName(String name, String ext) { + return (ext != null && ext.length() > 0) ? (name + "." + ext) : name;//NOI18N + } + + public static final String getName(String name) { + int i = name.lastIndexOf('.'); + + /** period at first position is not considered as extension-separator */ + return (i <= 0) ? name : name.substring(0, i); + } + public static final String getExt(String name) { + int i = name.lastIndexOf('.') + 1; + + /** period at first position is not considered as extension-separator */ + return ((i <= 1) || (i == name.length())) ? "" : name.substring(i); // NOI18N + } } Index: test/unit/src/org/netbeans/modules/masterfs/MasterFileSystemTest.java =================================================================== RCS file: /cvs/openide/masterfs/test/unit/src/org/netbeans/modules/masterfs/MasterFileSystemTest.java,v retrieving revision 1.7 diff -u -c -r1.7 MasterFileSystemTest.java *** test/unit/src/org/netbeans/modules/masterfs/MasterFileSystemTest.java 25 Jan 2005 21:33:57 -0000 1.7 --- test/unit/src/org/netbeans/modules/masterfs/MasterFileSystemTest.java 6 Jun 2006 12:06:27 -0000 *************** *** 20,25 **** --- 20,26 ---- import org.netbeans.junit.NbTestSuite; import org.netbeans.modules.masterfs.providers.AutoMountProvider; import org.netbeans.modules.masterfs.providers.FileSystemProvider; + import org.netbeans.modules.masterfs.providers.ProvidedExtensionsTest; import org.netbeans.modules.masterfs.providers.MountSupport; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileObjectTestHid; *************** *** 49,54 **** --- 50,58 ---- /** Creates new MasterFileSystemTest */ public MasterFileSystemTest(Test test) { super(test); + ProvidedExtensionsTest.ProvidedExtensionsImpl.setImplsMoveRetVal(false); + ProvidedExtensionsTest.ProvidedExtensionsImpl.setImplsRenameRetVal(false); + }