# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /data/work/src/netbeans-cdev
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: masterfs/apichanges.xml
--- masterfs/apichanges.xml Base (BASE)
+++ masterfs/apichanges.xml Locally Modified (Based On LOCAL)
@@ -49,6 +49,31 @@
+
+
+ createSuccess
and deleteSuccess
are called imediatelly
+ after a file is created or deleted.
+ createdExternally
, deletedExternally
,
+ fileChanged
, beforeMove
,
+ moveSuccess
, moveFailure
+
ProvidedExtensions.priorityIO
to suspend background refreshMasterFileSystem
after FileObject
+ * was created externally
+ * @param fo created file
+ * @since 2.27
+ */
+ public void createdExternally(FileObject fo) {}
+
+ /**
+ * Called by MasterFileSystem
after FileObject
+ * was deleted externally
+ * @param fo deleted file
+ * @since 2.27
+ */
+ public void deletedExternally(FileObject fo) {}
+
+ /**
+ * Called by MasterFileSystem
after FileObject
+ * was changed
+ * @param fo changed file
+ * @since 2.27
+ */
+ public void fileChanged(FileObject fo) {}
+
+ /**
+ * Called by MasterFileSystem
before FileObject
+ * is moved
+ * @param from FileObject to be moved
+ * @param to File target to move this file to
+ * @since 2.27
+ */
+ @Override
+ public void beforeMove(FileObject from, File to) {}
+
+ /**
+ * Called by MasterFileSystem
after FileObject
+ * was successfully
+ * @param from FileObject to be moved
+ * @param to File target to move this file to
+ * @since 2.27
+ */
+ @Override
+ public void moveSuccess(FileObject from, File to) {}
+
+ /**
+ * Called by MasterFileSystem
after a FileObject
+ * move failed
+ * @param from FileObject to be moved
+ * @param to File target to move this file to
+ * @since 2.27
+ */
+ @Override
+ public void moveFailure(FileObject from, File to) {}
+
+ /**
* Called by MasterFileSystem
when FileObject
is queried for writability with the
* canWrite() method.
*
Index: masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/InterceptionListenerTest.java
--- masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/InterceptionListenerTest.java Base (BASE)
+++ masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/InterceptionListenerTest.java Locally Modified (Based On LOCAL)
@@ -44,6 +44,7 @@
package org.netbeans.modules.masterfs.providers;
+import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
@@ -51,6 +52,7 @@
import javax.swing.Action;
import org.netbeans.junit.MockServices;
import org.netbeans.junit.NbTestCase;
+import org.openide.filesystems.FileLock;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Lookup;
@@ -145,6 +147,43 @@
}
}
+ public void testMove_BeforeSuccessFailure() throws IOException {
+ FileObject fromFolder = FileUtil.toFileObject(getWorkDir()).createFolder("moveFrom");
+ FileObject toFolder = FileUtil.toFileObject(getWorkDir()).createFolder("moveTo");
+ assertNotNull(fromFolder);
+ assertNotNull(toFolder);
+ FileObject toMove = fromFolder.createData("aa");
+ assertNotNull(toMove);
+ iListener.clear();
+
+ assertNotNull(iListener);
+ assertEquals(0,iListener.beforeMoveCalls);
+ assertEquals(0,iListener.moveSuccessCalls);
+ assertEquals(0,iListener.moveFailureCalls);
+
+ // move
+ FileLock lock = toMove.lock();
+ toMove.move(lock, toFolder, toMove.getName(), toMove.getExt());
+ assertFalse(toMove.isValid());
+ assertEquals(1,iListener.beforeMoveCalls);
+ assertEquals(1,iListener.moveSuccessCalls);
+
+ iListener.clear();
+ try {
+ // success
+ assertEquals(0,iListener.moveSuccessCalls);
+ assertEquals(0,iListener.moveFailureCalls);
+
+ // move to itself => failure
+ toMove.move(lock, toFolder, toMove.getName(), toMove.getExt());
+ fail();
+ } catch (IOException ex) {
+ // failure
+ assertEquals(0,iListener.moveSuccessCalls);
+ assertEquals(1,iListener.moveFailureCalls);
+ }
+ }
+
public static class AnnotationProviderImpl extends AnnotationProvider {
private static int cnt;
@@ -200,6 +239,9 @@
private int beforeDeleteCalls = 0;
private int deleteSuccessCalls = 0;
private int deleteFailureCalls = 0;
+ private int beforeMoveCalls = 0;
+ private int moveSuccessCalls = 0;
+ private int moveFailureCalls = 0;
private final AnnotationProviderImpl provider;
public InterceptionListenerImpl(AnnotationProviderImpl provider) {
@@ -213,6 +255,9 @@
beforeDeleteCalls = 0;
deleteSuccessCalls = 0;
deleteFailureCalls = 0;
+ beforeMoveCalls = 0;
+ moveSuccessCalls = 0;
+ moveFailureCalls = 0;
}
public void beforeCreate(org.openide.filesystems.FileObject parent, java.lang.String name, boolean isFolder) {
@@ -239,5 +284,17 @@
public void deleteFailure(org.openide.filesystems.FileObject fo) {
deleteFailureCalls++;
}
+
+ public void beforeMove(FileObject fo, File to) {
+ beforeMoveCalls++;
}
+
+ public void moveSuccess(FileObject fo, File to) {
+ moveSuccessCalls++;
}
+
+ public void moveFailure(FileObject fo, File to) {
+ moveFailureCalls++;
+ }
+ }
+}
Index: masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/ProvidedExtensionsTest.java
--- masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/ProvidedExtensionsTest.java Base (BASE)
+++ masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/ProvidedExtensionsTest.java Locally Modified (Based On LOCAL)
@@ -240,17 +240,65 @@
}
}
- public void testAfterAtomicAction() throws IOException {
+ public void testDuringAtomicAction() throws IOException {
FileObject fo = FileUtil.toFileObject(getWorkDir());
+ iListener.clear();
fo.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
public void run() throws IOException {
- FileUtil.createData(new File(getWorkDir(),"a/b/c/d/e/f/g.txt"));
- assertEquals(0, iListener.implsCreateSuccessCalls);
+ FileObject f = FileUtil.createData(new File(getWorkDir(), "a/b/c/d/e/f/g.txt"));
+ assertEquals(7, iListener.implsCreateSuccessCalls);
+ f.delete();
+ assertEquals(1, iListener.implsDeleteSuccessCalls);
}
});
- assertEquals(7, iListener.implsCreateSuccessCalls);
}
+ public void testCreatedExternally() throws IOException {
+ FileObject fo = FileUtil.toFileObject(getWorkDir());
+ FileObject[] children = fo.getChildren(); // scan folder
+
+ FileObject folder = fo.createFolder("folder");
+ iListener.clear();
+ assertEquals(0, iListener.implsCreatedExternallyCalls);
+ File f = new File(FileUtil.toFile(fo), "file");
+ f.createNewFile();
+ assertEquals(0, iListener.implsCreatedExternallyCalls);
+ fo.refresh();
+ assertEquals(1, iListener.implsCreatedExternallyCalls);
+ }
+
+ public void testDeletedExternally() throws IOException {
+ FileObject fo = FileUtil.toFileObject(getWorkDir());
+ FileObject file = fo.createData("file");
+
+ iListener.clear();
+ FileUtil.toFile(file).delete();
+ assertEquals(0, iListener.implsDeletedExternallyCalls);
+ fo.refresh();
+ assertEquals(1, iListener.implsDeletedExternallyCalls);
+ }
+
+ public void testFileChangedExternally() throws IOException {
+ FileObject fo = FileUtil.toFileObject(getWorkDir());
+ FileObject file = fo.createData("file");
+ FileUtil.toFile(file).setLastModified(System.currentTimeMillis() - 10000);
+ fo.refresh();
+
+ iListener.clear();
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(FileUtil.toFile(file));
+ fos.write("data".getBytes());
+ fos.flush();
+ } finally {
+ if(fos != null) fos.close();
+ }
+ assertEquals(0, iListener.implsFileChangedCalls);
+ fo.refresh();
+ file.refresh();
+ assertEquals(1, iListener.implsFileChangedCalls);
+ }
+
public void testImplsRename2() throws IOException {
final List events = new ArrayList();
FileObject fo = FileUtil.toFileObject(getWorkDir());
@@ -464,6 +512,10 @@
private int renameImplCalls;
private int implsBeforeChangeCalls;
private int implsCreateSuccessCalls;
+ private int implsDeleteSuccessCalls;
+ private int implsCreatedExternallyCalls;
+ private int implsDeletedExternallyCalls;
+ private int implsFileChangedCalls;
private int implsFileLockCalls;
private int implsFileUnlockCalls;
private int implsCanWriteCalls;
@@ -501,6 +553,10 @@
renameImplCalls = 0;
implsBeforeChangeCalls = 0;
implsCreateSuccessCalls = 0;
+ implsDeleteSuccessCalls = 0;
+ implsCreatedExternallyCalls = 0;
+ implsDeletedExternallyCalls = 0;
+ implsFileChangedCalls = 0;
implsFileLockCalls = 0;
implsCanWriteCalls = 0;
}
@@ -527,11 +583,27 @@
implsCreateSuccessCalls++;
}
+ public void deleteSuccess(FileObject fo) {
+ implsDeleteSuccessCalls++;
+ }
+
public void beforeChange(FileObject f) {
assertNotNull(FileUtil.toFile(f));
implsBeforeChangeCalls++;
}
+ public void createdExternally(FileObject fo) {
+ implsCreatedExternallyCalls++;
+ }
+
+ public void deletedExternally(FileObject fo) {
+ implsDeletedExternallyCalls++;
+ }
+
+ public void fileChanged(FileObject fo) {
+ implsFileChangedCalls++;
+ }
+
public static void nextRefreshCall(File forDir, long retValue, File... toAdd) {
refreshCallForDir = forDir;
refreshCallRetValue = retValue;