|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.cvsclient.caching;
/**
*
* @author Milos Kleint
*/
import org.netbeans.modules.javacvs.commands.CacheUpdatingFsCommand;
import org.netbeans.modules.vcscore.cache.CacheHandler;
import org.netbeans.modules.javacvs.commands.ClientProvider;
import java.io.File;
import java.io.FileFilter;
import java.util.*;
import org.openide.util.NbBundle;
import org.netbeans.lib.cvsclient.command.status.StatusCommand;
public class OfflineRefreshCommand extends CacheUpdatingFsCommand {
/** Holds value of property recursive. */
private boolean recursive;
public OfflineRefreshCommand(File[] filesToCheck) {
super();
setRefreshing(false);
setFiles(filesToCheck);
}
/** Creates cvs status command.
*/
public OfflineRefreshCommand() {
super();
setRefreshing(false);
}
// for dirs to be recursively refreshed, perform check wheather they are CVS dirs. If not..
// search for all it's subdirs that are..
private File[] findRelevantDirs(File[] files) {
LinkedList localOnes = new LinkedList();
LinkedList okFiles = new LinkedList();
if (files == null) {
return null;
}
for (int index = 0; index < files.length; index++) {
File file = files[index];
if (file.isDirectory()) {
File[] cvsDir = file.listFiles(new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory() && f.getName().equalsIgnoreCase("CVS")) return true; // NOI18N
return false;
}
});
if (cvsDir.length == 0) {
localOnes.add(file);
// cacheObject.fireCacheHandlerEvent(FileSystemCache.EVENT_CHANGED, file);
}
else okFiles.add(file);
} else {
// okFiles.add(file);
// files are not included.. recursive refresh makes no sense for them
}
}
if (localOnes.size() == 0) {
// everything is ok.. return the initial file[] array.
return files;
}
Iterator it = localOnes.iterator();
while (it.hasNext()) {
File main = (File)it.next();
File[] toFind = main.listFiles();
if (toFind.length > 0) {
toFind = findRelevantDirs(toFind);
if (toFind.length > 0) {
for (int ind = 0; ind < toFind.length; ind++) {
okFiles.add(toFind[ind]);
}
}
}
}
File[] toReturn = new File[okFiles.size()];
toReturn = (File[])okFiles.toArray(toReturn);
return toReturn;
}
/** set the files/dirs that the command operates on. Not directly used here,
* but subclasses use it in 99% of cases. They should set it before starting a
* command, according to the nodes selected or otherwise.. and feed it to
* undelying library commands.
* @deprecated Use the setFileObjects() methods intead where possible. The setFiles() method might disappear soon.
* @param fls array of files that the comamnds is executed upon.
*/
public void setFiles(File[] fls) {
super.setFiles(findRelevantDirs(fls));
}
/** Needs to return a correct org.netbeans.lib.cvsclient.command.Command.java subclass.
*
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.