1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.actions.commit; 21 22 import org.netbeans.modules.versioning.system.cvss.*; 23 import org.netbeans.lib.cvsclient.command.GlobalOptions; 24 import org.netbeans.lib.cvsclient.command.Command; 25 import org.netbeans.lib.cvsclient.command.commit.CommitInformation; 26 import org.netbeans.lib.cvsclient.command.commit.CommitCommand; 27 import org.openide.filesystems.FileObject; 28 import org.openide.filesystems.FileUtil; 29 import org.openide.ErrorManager; 30 import org.openide.util.NbBundle; 31 32 import java.util.*; 33 import java.io.File ; 34 import java.io.IOException ; 35 36 41 public class CommitExecutor extends ExecutorSupport { 42 43 54 public static CommitExecutor [] splitCommand(CommitCommand cmd, CvsVersioningSystem cvs, GlobalOptions options) { 55 Command [] cmds = new org.netbeans.lib.cvsclient.command.Command[0]; 56 ResourceBundle loc = NbBundle.getBundle(CommitExecutor.class); 57 if (cmd.getDisplayName() == null) cmd.setDisplayName(loc.getString("MSG_CommitExecutor_CmdDisplayName")); 58 try { 59 cmds = prepareBasicCommand(cmd); 60 } catch (IOException e) { 61 ErrorManager.getDefault().notify(e); 62 return null; 63 } 64 CommitExecutor [] executors = new CommitExecutor[cmds.length]; 65 for (int i = 0; i < cmds.length; i++) { 66 Command command = cmds[i]; 67 executors[i] = new CommitExecutor(cvs, (CommitCommand) command, options); 68 } 69 return executors; 70 } 71 72 private CommitExecutor(CvsVersioningSystem cvs, CommitCommand cmd, GlobalOptions options) { 73 super(cvs, cmd, options); 74 } 75 76 79 protected void commandFinished(ClientRuntime.Result result) { 80 81 CommitCommand xcmd = (CommitCommand) cmd; 82 83 for (Iterator i = toRefresh.iterator(); i.hasNext();) { 84 CommitInformation info = (CommitInformation) i.next(); 85 if (info.getFile() == null) continue; 86 int repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UNKNOWN; 87 String type = info.getType(); 88 if (CommitInformation.CHANGED.equals(type) || CommitInformation.ADDED.equals(type)) { 89 repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UPTODATE; 90 } else if (CommitInformation.REMOVED.equals(type) || CommitInformation.TO_ADD.equals(type)) { 91 repositoryStatus = FileStatusCache.REPOSITORY_STATUS_UNKNOWN; 92 } 93 cache.refreshCached(info.getFile(), repositoryStatus); 94 } 95 96 if (cmd.hasFailed()) return; 97 98 File [] files = xcmd.getFiles(); 100 for (int i = 0; i < files.length; i++) { 101 FileObject fo = FileUtil.toFileObject(files[i]); 102 if (fo != null) { 103 fo.refresh(true); 104 } 105 } 106 } 107 108 } 109 | Popular Tags |