1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.actions.tag; 21 22 import org.netbeans.modules.versioning.system.cvss.CvsVersioningSystem; 23 import org.netbeans.modules.versioning.system.cvss.ExecutorSupport; 24 import org.netbeans.modules.versioning.system.cvss.ClientRuntime; 25 import org.netbeans.modules.versioning.system.cvss.util.CommandDuplicator; 26 import org.netbeans.modules.versioning.system.cvss.util.Utils; 27 import org.netbeans.lib.cvsclient.command.GlobalOptions; 28 import org.netbeans.lib.cvsclient.command.tag.RtagCommand; 29 import org.netbeans.lib.cvsclient.admin.AdminHandler; 30 import org.openide.ErrorManager; 31 import org.openide.util.NbBundle; 32 33 import java.util.*; 34 import java.io.File ; 35 import java.io.IOException ; 36 import java.text.MessageFormat ; 37 38 43 public class RTagExecutor extends ExecutorSupport { 44 45 55 public static RTagExecutor [] splitCommand(RtagCommand cmd, File [] roots, GlobalOptions options) { 56 if (cmd.getDisplayName() == null) cmd.setDisplayName(NbBundle.getMessage(RTagExecutor.class, "MSG_RTagExecutor_CmdDisplayName")); 57 58 File [][] splitRoots; 59 try { 60 splitRoots = splitByCvsRoot(roots); 61 } catch (IOException e) { 62 ErrorManager.getDefault().notify(e); 63 return null; 64 } 65 if (options == null) options = CvsVersioningSystem.createGlobalOptions(); 66 67 CvsVersioningSystem cvs = CvsVersioningSystem.getInstance(); 68 AdminHandler ah = cvs.getAdminHandler(); 69 70 RTagExecutor [] executors = new RTagExecutor[splitRoots.length]; 71 CommandDuplicator cloner = CommandDuplicator.getDuplicator(cmd); 72 Set remoteRepositories = new HashSet(roots.length); 73 for (int i = 0; i < splitRoots.length; i++) { 74 File [] files = splitRoots[i]; 75 for (int j = 0; j < files.length; j++) { 76 File file = files[j]; 77 File directory = file.isDirectory() ? file : file.getParentFile(); 78 try { 79 String repository = ah.getRepositoryForDirectory(directory.getAbsolutePath(), "").substring(1); remoteRepositories.add(repository); 81 } catch (IOException e) { 82 ErrorManager.getDefault().notify(e); 83 return null; 84 } 85 } 86 GlobalOptions currentOptions = (GlobalOptions) options.clone(); 87 try { 88 currentOptions.setCVSRoot(Utils.getCVSRootFor(files[0])); 89 } catch (IOException e) { 90 ErrorManager.getDefault().notify(e); 91 return null; 92 } 93 94 RtagCommand command = (RtagCommand) cloner.duplicate(); 95 command.setModules((String []) remoteRepositories.toArray(new String [remoteRepositories.size()])); 96 String commandContext = NbBundle.getMessage(RTagExecutor.class, "MSG_RTagExecutor_CmdContext", Integer.toString(files.length)); 97 command.setDisplayName(MessageFormat.format(cmd.getDisplayName(), new Object [] { commandContext })); 98 executors[i] = new RTagExecutor(cvs, command, currentOptions); 99 } 100 return executors; 101 } 102 103 private RTagExecutor(CvsVersioningSystem cvs, RtagCommand cmd, GlobalOptions options) { 104 super(cvs, cmd, options); 105 } 106 107 protected void commandFinished(ClientRuntime.Result result) { 108 } 110 } 111 | Popular Tags |