1 19 20 package org.netbeans.modules.versioning.system.cvss.executor; 21 22 import org.openide.util.NbBundle; 23 import org.openide.ErrorManager; 24 import org.openide.filesystems.FileObject; 25 import org.openide.filesystems.FileUtil; 26 import org.netbeans.modules.versioning.system.cvss.*; 27 import org.netbeans.lib.cvsclient.command.GlobalOptions; 28 import org.netbeans.lib.cvsclient.command.Command; 29 import org.netbeans.lib.cvsclient.command.remove.RemoveCommand; 30 import org.netbeans.lib.cvsclient.command.remove.RemoveInformation; 31 32 import java.util.Set ; 33 import java.util.HashSet ; 34 import java.util.Iterator ; 35 import java.io.IOException ; 36 import java.io.File ; 37 38 43 public class RemoveExecutor extends ExecutorSupport { 44 45 private Set refreshedFiles; 46 47 58 public static RemoveExecutor [] splitCommand(RemoveCommand cmd, CvsVersioningSystem cvs, GlobalOptions options) { 59 Command [] cmds = new org.netbeans.lib.cvsclient.command.Command[0]; 60 if (cmd.getDisplayName() == null) cmd.setDisplayName(NbBundle.getMessage(RemoveExecutor.class, "MSG_RemoveExecutor_CmdDisplayName")); 61 try { 62 cmds = prepareBasicCommand(cmd); 63 } catch (IOException e) { 64 ErrorManager.getDefault().notify(e); 65 return null; 66 } 67 RemoveExecutor [] executors = new RemoveExecutor[cmds.length]; 68 for (int i = 0; i < cmds.length; i++) { 69 Command command = cmds[i]; 70 executors[i] = new RemoveExecutor(cvs, (RemoveCommand) command, options); 71 } 72 return executors; 73 } 74 75 private RemoveExecutor(CvsVersioningSystem cvs, RemoveCommand cmd, GlobalOptions options) { 76 super(cvs, cmd, options); 77 } 78 79 82 protected void commandFinished(ClientRuntime.Result result) { 83 84 RemoveCommand xcmd = (RemoveCommand) cmd; 85 86 refreshedFiles = new HashSet (toRefresh.size()); 88 89 for (Iterator i = toRefresh.iterator(); i.hasNext();) { 90 RemoveInformation info = (RemoveInformation) i.next(); 91 if (info.getFile() == null) continue; 92 int repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UNKNOWN; 93 if (info.isRemoved()) { 94 repositoryStatus = FileStatusCache.REPOSITORY_STATUS_REMOVED; 95 } else { 96 repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UNKNOWN; 97 } 98 cache.refreshCached(info.getFile(), repositoryStatus); 99 refreshedFiles.add(info.getFile()); 100 } 101 102 if (cmd.hasFailed()) return; 103 104 File [] files = xcmd.getFiles(); 106 for (int i = 0; i < files.length; i++) { 107 refreshRecursively(files[i]); 108 FileObject fo = FileUtil.toFileObject(files[i]); 109 if (fo != null) { 110 fo.refresh(true); 111 } 112 } 113 } 114 115 private void refreshRecursively(File file) { 116 if (cvs.isIgnoredFilename(file)) return; 117 if (refreshedFiles.contains(file)) return; 118 if (file.isDirectory()) { 119 File [] files = file.listFiles(); 120 for (int i = 0; i < files.length; i++) { 121 refreshRecursively(files[i]); 122 } 123 cache.refreshCached(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN); 124 } else { 125 cache.refreshCached(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN); 126 } 127 } 128 } 129 | Popular Tags |