It writes user's data files. Folders, temporary * files and metadata files are written directly by * the cvsclient library. * - *
It supresses FilesystemHandler event propagating + *
It surpresses FilesystemHandler event propagating * to cache to avoid * * @author Petr Kuzel */ class CvsLiteFileHandler extends DefaultFileHandler implements FileReadOnlyHandler { + @Override protected boolean createNewFile(File file) throws IOException { boolean exists = file.isFile(); if (exists) { @@ -90,6 +91,7 @@ } } + @Override protected OutputStream createOutputStream(File file) throws IOException { file = FileUtil.normalizeFile(file); FileObject fo = FileUtil.toFileObject(file); @@ -108,6 +110,7 @@ return new LockedOutputStream(lock, stream); } + @Override public void removeLocalFile(String pathname) throws IOException { File fileToDelete = new File(pathname); fileToDelete = FileUtil.normalizeFile(fileToDelete); @@ -125,8 +128,9 @@ } } + @Override public void setFileReadOnly(File file, boolean readOnly) throws IOException { - file.setWritable(readOnly); + file.setWritable(!readOnly); } private static class LockedOutputStream extends OutputStream { @@ -139,6 +143,7 @@ this.peer = peer; } + @Override public void close() throws IOException { lock.releaseLock(); try { @@ -149,18 +154,22 @@ } } + @Override public void flush() throws IOException { peer.flush(); } + @Override public void write(byte b[]) throws IOException { peer.write(b); } + @Override public void write(byte b[], int off, int len) throws IOException { peer.write(b, off, len); } + @Override public void write(int b) throws IOException { peer.write(b); } diff -r f59e600a848d versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/ExecutorSupport.java --- a/versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/ExecutorSupport.java Fri Apr 09 22:32:02 2010 +0200 +++ b/versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/ExecutorSupport.java Mon Apr 12 21:17:05 2010 +0100 @@ -151,6 +151,13 @@ this.nonInteractive = nonInteractive; } + private void ensureGroupExists() { + if (group == null) { + group = new ExecutorGroup(getDisplayName()); + group.setNonInteractive(nonInteractive); + } + } + /** * Async execution. @@ -160,10 +167,7 @@ public void execute() { assert executed == false; executed = true; - if (group == null) { - group = new ExecutorGroup(getDisplayName()); - group.setNonInteractive(nonInteractive); - } + ensureGroupExists(); setup(); executeImpl(); @@ -359,13 +363,14 @@ } /** - * Associates this executor with actualy enqueued runnable + * Associates this executor with actually enqueued runnable * (ClientRunnable created by ClientRuntime) performing the command. * - *
Adds the runnable into group cancelable chain. + *
Adds the runnable into group cancellable chain.
*/
public void commandEnqueued(CommandRunnable commandRunnable) {
this.commandRunnable = commandRunnable;
+ ensureGroupExists();
group.enqueued(cvs.getClientRuntime(cmd, options), this);
group.addCancellable(commandRunnable);
}
diff -r f59e600a848d versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/FilesystemHandler.java
--- a/versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/FilesystemHandler.java Fri Apr 09 22:32:02 2010 +0200
+++ b/versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/FilesystemHandler.java Mon Apr 12 21:17:05 2010 +0100
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common
@@ -41,6 +41,8 @@
package org.netbeans.modules.versioning.system.cvss;
+import org.netbeans.lib.cvsclient.command.CommandException;
+import org.netbeans.lib.cvsclient.connection.AuthenticationException;
import org.netbeans.modules.versioning.spi.VCSInterceptor;
import org.netbeans.modules.versioning.util.Utils;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
@@ -51,19 +53,21 @@
import java.io.File;
import java.io.IOException;
import java.util.*;
-import javax.swing.SwingUtilities;
import org.netbeans.lib.cvsclient.command.GlobalOptions;
+import org.netbeans.lib.cvsclient.command.Watch;
+import org.netbeans.lib.cvsclient.command.edit.EditCommand;
import org.netbeans.lib.cvsclient.command.update.UpdateCommand;
+import org.netbeans.modules.versioning.system.cvss.ui.actions.edit.EditExecutor;
import org.netbeans.modules.versioning.system.cvss.ui.actions.update.UpdateExecutor;
-import org.openide.util.RequestProcessor;
+import org.openide.util.Exceptions;
/**
* Handles events fired from the filesystem such as file/folder create/delete/move.
- *
+ *
* @author Maros Sandor
*/
class FilesystemHandler extends VCSInterceptor {
-
+
private final FileStatusCache cache;
private static Thread ignoredThread;
@@ -73,19 +77,21 @@
/**
* We save all CVS metadata to be able to commit files that were in that directory.
- *
+ *
* @param file File, we are only interested in files inside CVS directory
- */
+ */
+ @Override
public boolean beforeDelete(File file) {
return !ignoringEvents();
}
+ @Override
public void doDelete(File file) throws IOException {
if (file.isDirectory() && hasMetadata(file)) {
CvsVisibilityQuery.hideFolder(file);
cache.refresh(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN, true);
} else if (org.netbeans.modules.versioning.system.cvss.util.Utils.isPartOfCVSMetadata(file)) {
- // medatada are never deleted
+ // metadata are never deleted
} else {
if (!file.delete()) {
throw new IOException("Failed to delete file: " + file.getAbsolutePath());
@@ -94,10 +100,11 @@
}
}
+ @Override
public void afterDelete(File file) {
refreshDeleted(file, false);
}
-
+
private void refreshDeleted(File file, boolean refreshNow) {
if (refreshNow) {
cache.refreshNow(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN, false);
@@ -110,17 +117,19 @@
/**
* We handle directory renames that are managed by CVS.
*/
+ @Override
public boolean beforeMove(File from, File to) {
File destDir = to.getParentFile();
return from != null && destDir != null && org.netbeans.modules.versioning.system.cvss.util.Utils.containsMetadata(from);
}
-
+
/**
* We only handle directories, file renames are examined ex post. Both directories share the same parent.
- *
+ *
* @param from source directory to be renamed
- * @param to new directory to be created
+ * @param to new directory to be created
*/
+ @Override
public void doMove(File from, File to) throws IOException {
List
@@ -364,7 +407,7 @@
/**
* @return true if filesystem events are ignored in current thread, false otherwise
- */
+ */
private static boolean ignoringEvents() {
return ignoredThread == Thread.currentThread();
}
diff -r f59e600a848d versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/util/Utils.java
--- a/versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/util/Utils.java Fri Apr 09 22:32:02 2010 +0200
+++ b/versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/util/Utils.java Mon Apr 12 21:17:05 2010 +0100
@@ -106,7 +106,7 @@
/**
* Validates annotation format text
- * @param format format to be validatet
+ * @param format format to be validated
* @return
true
if the format is correct, false
otherwise.
*/
public static boolean isAnnotationFormatValid(final String format) {
@@ -124,7 +124,7 @@
/**
* Semantics is similar to {@link org.openide.windows.TopComponent#getActivatedNodes()} except that this
- * method returns File objects instead od Nodes. Every node is examined for Files it represents. File and Folder
+ * method returns File objects instead of Nodes. Every node is examined for Files it represents. File and Folder
* nodes represent their underlying files or folders. Project nodes are represented by their source groups. Other
* logical nodes must provide FileObjects in their Lookup.
*
@@ -142,7 +142,7 @@
/**
* Semantics is similar to {@link org.openide.windows.TopComponent#getActivatedNodes()} except that this
- * method returns File objects instead od Nodes. Every node is examined for Files it represents. File and Folder
+ * method returns File objects instead of Nodes. Every node is examined for Files it represents. File and Folder
* nodes represent their underlying files or folders. Project nodes are represented by their source groups. Other
* logical nodes must provide FileObjects in their Lookup.
*
@@ -165,7 +165,7 @@
}
}
// if there are no exclusions, we may safely return this context because filtered files == root files
- if (context.getExclusions().size() == 0) return context;
+ if (context.getExclusions().isEmpty()) return context;
// in this code we remove files from filteredFiles to NOT include any files that do not have required status
// consider a freeform project that has 'build' in filteredFiles, the Branch action would try to branch it
@@ -294,7 +294,7 @@
}
/**
- * Returns the widest possible versioned context for the given file, the outter boundary is the file's Project.
+ * Returns the widest possible versioned context for the given file, the outer boundary is the file's Project.
*
* @param file a file
* @return Context a context
@@ -380,7 +380,7 @@
* Computes path of this file to repository root.
*
* @param file a file
- * @return String path of this file in repsitory. If this path does not describe a
+ * @return String path of this file in repository. If this path does not describe a
* versioned file, this method returns an empty string
*/
public static String getRelativePath(File file) {
@@ -453,7 +453,7 @@
} else {
int rev = Integer.parseInt(nums[lastIndex]);
if (!cutoff) rev--;
- StringBuffer sb = new StringBuffer(nums[0]);
+ StringBuilder sb = new StringBuilder(nums[0]);
for (int i = 1; i