1 22 package org.netbeans.lib.cvsclient.command.status; 23 24 import java.io.*; 25 26 import org.netbeans.lib.cvsclient.*; 27 import org.netbeans.lib.cvsclient.command.*; 28 import org.netbeans.lib.cvsclient.connection.*; 29 import org.netbeans.lib.cvsclient.event.*; 30 import org.netbeans.lib.cvsclient.request.*; 31 32 36 public class StatusCommand extends BasicCommand { 37 40 private EventManager eventManager; 41 42 45 private boolean includeTags; 46 47 50 public StatusCommand() { 51 } 52 53 57 public Builder createBuilder(EventManager eventManager) { 58 return new StatusBuilder(eventManager, this); 59 } 60 61 67 public void execute(ClientServices client, EventManager em) 68 throws CommandException, AuthenticationException { 69 client.ensureConnection(); 70 71 eventManager = em; 72 73 super.execute(client, em); 74 75 try { 76 if (includeTags) { 78 requests.add(1, new ArgumentRequest("-v")); } 80 81 addRequestForWorkingDirectory(client); 82 addArgumentRequests(); 83 addRequest(CommandRequest.STATUS); 84 85 client.processRequests(requests); 86 } 87 catch (CommandException ex) { 88 throw ex; 89 } 90 catch (Exception e) { 91 throw new CommandException(e, e.getLocalizedMessage()); 92 } 93 finally { 94 requests.clear(); 95 } 96 } 97 98 102 public boolean isIncludeTags() { 103 return includeTags; 104 } 105 106 110 public void setIncludeTags(boolean inclTags) { 111 includeTags = inclTags; 112 } 113 114 117 public void commandTerminated(TerminationEvent e) { 118 if (builder != null) { 119 builder.outputDone(); 120 } 121 } 122 123 128 public String getCVSCommand() { 129 StringBuffer toReturn = new StringBuffer ("status "); toReturn.append(getCVSArguments()); 131 File[] files = getFiles(); 132 if (files != null) { 133 for (int index = 0; index < files.length; index++) { 134 toReturn.append(files[index].getName()); 135 toReturn.append(' '); 136 } 137 } 138 return toReturn.toString(); 139 } 140 141 146 public boolean setCVSCommand(char opt, String optArg) { 147 if (opt == 'R') { 148 setRecursive(true); 149 } 150 else if (opt == 'l') { 151 setRecursive(false); 152 } 153 else if (opt == 'v') { 154 setIncludeTags(true); 155 } 156 else { 157 return false; 158 } 159 return true; 160 } 161 162 165 public String getOptString() { 166 return "Rlv"; } 168 169 173 public void resetCVSCommand() { 174 setRecursive(true); 175 setIncludeTags(false); 176 } 177 178 182 public String getCVSArguments() { 183 StringBuffer toReturn = new StringBuffer (""); if (isIncludeTags()) { 185 toReturn.append("-v "); } 187 if (!isRecursive()) { 188 toReturn.append("-l "); } 190 return toReturn.toString(); 191 } 192 193 } 194 | Popular Tags |