1 19 20 package org.netbeans.modules.versioning.system.cvss.executor; 21 22 import org.netbeans.modules.versioning.system.cvss.*; 23 import org.netbeans.lib.cvsclient.command.GlobalOptions; 24 import org.netbeans.lib.cvsclient.command.DefaultFileInfoContainer; 25 import org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand; 26 import org.netbeans.lib.cvsclient.command.commit.CommitInformation; 27 import org.netbeans.lib.cvsclient.event.ModuleExpansionEvent; 28 import org.netbeans.api.progress.aggregate.ProgressContributor; 29 import org.openide.filesystems.FileObject; 30 import org.openide.filesystems.FileUtil; 31 32 import java.util.*; 33 import java.io.File ; 34 35 40 public class CheckoutExecutor extends ExecutorSupport { 41 42 private Set refreshedFiles; 43 private Set expandedModules = new HashSet(); 44 45 public CheckoutExecutor(CvsVersioningSystem cvs, CheckoutCommand cmd) { 46 this(cvs, cmd, null); 47 } 48 49 public CheckoutExecutor(CvsVersioningSystem cvs, CheckoutCommand cmd, GlobalOptions options) { 50 super(cvs, cmd, options); 51 } 52 53 57 public Set getExpandedModules() { 58 return expandedModules; 59 } 60 61 public final void moduleExpanded(ModuleExpansionEvent e) { 62 String module = e.getModule(); 63 expandedModules.add(module); 64 } 65 66 69 protected void commandFinished(ClientRuntime.Result result) { 70 71 CheckoutCommand xcmd = (CheckoutCommand) cmd; 72 73 refreshedFiles = new HashSet(toRefresh.size()); 75 76 for (Iterator i = toRefresh.iterator(); i.hasNext();) { 77 DefaultFileInfoContainer info = (DefaultFileInfoContainer) i.next(); 79 int repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UNKNOWN; 80 if (CommitInformation.CHANGED.equals(info.getType()) || CommitInformation.ADDED.equals(info.getType())) { 81 repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UPTODATE; 82 } else if (CommitInformation.REMOVED.equals(info.getType()) || CommitInformation.TO_ADD.equals(info.getType())) { 83 repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UNKNOWN; 84 } 85 File file = FileUtil.normalizeFile(info.getFile()); 86 cache.refreshCached(file, repositoryStatus); 87 refreshedFiles.add(file); 88 } 89 90 File [] files = xcmd.getFiles(); 92 for (int i = 0; i < files.length; i++) { 93 File file = FileUtil.normalizeFile(files[i]); 94 refreshRecursively(file); 95 if (file.isFile()) { 96 cache.refreshCached(file.getParentFile(), FileStatusCache.REPOSITORY_STATUS_UNKNOWN); 97 } 98 FileObject fo = FileUtil.toFileObject(file); 99 if (fo != null) { 100 fo.refresh(true); 101 } 102 } 103 } 104 105 private void refreshRecursively(File file) { 106 if (cvs.isIgnoredFilename(file)) return; 107 if (refreshedFiles.contains(file)) return; 108 if (file.isDirectory()) { 109 File [] files = file.listFiles(); 110 for (int i = 0; i < files.length; i++) { 111 refreshRecursively(files[i]); 112 } 113 cache.refreshCached(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN); 114 } else { 115 if (cache.getStatus(file.getParentFile()).getStatus() == FileInformation.STATUS_VERSIONED_UPTODATE) { 116 } else { 118 cache.refreshCached(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN); 119 } 120 } 121 } 122 123 } 124 | Popular Tags |