1 19 package org.netbeans.lib.cvsclient.command.watchers; 20 21 import java.io.*; 22 23 import org.netbeans.lib.cvsclient.*; 24 import org.netbeans.lib.cvsclient.command.*; 25 import org.netbeans.lib.cvsclient.connection.*; 26 import org.netbeans.lib.cvsclient.event.*; 27 import org.netbeans.lib.cvsclient.request.*; 28 29 36 public class WatchersCommand extends BasicCommand { 37 40 public WatchersCommand() { 41 resetCVSCommand(); 42 } 43 44 49 public Builder createBuilder(EventManager eventManager) { 50 return new WatchersBuilder(eventManager, getLocalDirectory()); 51 } 52 53 60 public void execute(ClientServices client, EventManager eventManager) 61 throws CommandException, AuthenticationException { 62 client.ensureConnection(); 63 64 super.execute(client, eventManager); 65 66 try { 67 addRequestForWorkingDirectory(client); 68 addArgumentRequests(); 69 addRequest(CommandRequest.WATCHERS); 70 71 client.processRequests(requests); 72 } 73 catch (CommandException ex) { 74 throw ex; 75 } 76 catch (Exception ex) { 77 throw new CommandException(ex, ex.getLocalizedMessage()); 78 } 79 finally { 80 requests.clear(); 81 } 82 } 83 84 87 public void commandTerminated(TerminationEvent e) { 88 if (builder != null) { 89 builder.outputDone(); 90 } 91 } 92 93 98 public String getCVSCommand() { 99 StringBuffer toReturn = new StringBuffer ("watchers "); toReturn.append(getCVSArguments()); 101 File[] files = getFiles(); 102 if (files != null) { 103 for (int index = 0; index < files.length; index++) { 104 toReturn.append(files[index].getName()); 105 toReturn.append(' '); 106 } 107 } 108 return toReturn.toString(); 109 } 110 111 116 public boolean setCVSCommand(char opt, String optArg) { 117 if (opt == 'R') { 118 setRecursive(true); 119 } 120 else if (opt == 'l') { 121 setRecursive(false); 122 } 123 else { 124 return false; 125 } 126 return true; 127 } 128 129 132 public String getOptString() { 133 return "Rl"; } 135 136 140 public void resetCVSCommand() { 141 setRecursive(true); 142 } 143 144 148 public String getCVSArguments() { 149 StringBuffer toReturn = new StringBuffer (); 150 if (!isRecursive()) { 151 toReturn.append("-l "); } 153 return toReturn.toString(); 154 } 155 } 156 | Popular Tags |