1 19 package org.netbeans.lib.cvsclient.command.editors; 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 32 public class EditorsCommand extends BasicCommand { 33 34 37 public EditorsCommand() { 38 resetCVSCommand(); 39 } 40 41 45 public Builder createBuilder(EventManager eventManager) { 46 return new EditorsBuilder(eventManager); 47 } 48 49 56 public void execute(ClientServices clientServices, EventManager eventManager) 57 throws CommandException, AuthenticationException { 58 59 clientServices.ensureConnection(); 60 61 super.execute(clientServices, eventManager); 62 63 try { 64 addRequestForWorkingDirectory(clientServices); 65 addArgumentRequests(); 66 addRequest(CommandRequest.EDITORS); 67 68 clientServices.processRequests(requests); 69 } 70 catch (CommandException ex) { 71 throw ex; 72 } 73 catch (EOFException ex) { 74 throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); } 76 catch (Exception ex) { 77 throw new CommandException(ex, ex.getLocalizedMessage()); 78 } 79 finally { 80 requests.clear(); 81 } 82 } 83 84 88 public void commandTerminated(TerminationEvent e) { 89 if (builder != null) { 90 builder.outputDone(); 91 } 92 } 93 94 98 public String getCVSCommand() { 99 StringBuffer toReturn = new StringBuffer ("editors "); 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 133 public String getOptString() { 134 return "Rl"; } 136 137 142 public void resetCVSCommand() { 143 setRecursive(true); 144 } 145 146 150 public String getCVSArguments() { 151 StringBuffer toReturn = new StringBuffer (); 152 if (!isRecursive()) { 153 toReturn.append("-l "); } 155 return toReturn.toString(); 156 } 157 158 } 159 | Popular Tags |