|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.lib.cvsclient.command.annotate;
import java.io.*;
import java.util.*;
import org.netbeans.lib.cvsclient.*;
import org.netbeans.lib.cvsclient.command.*;
import org.netbeans.lib.cvsclient.connection.*;
import org.netbeans.lib.cvsclient.event.*;
import org.netbeans.lib.cvsclient.request.*;
/**
* The annotate command shows all lines of the file and annotates each line with cvs-related info.
* @author Milos Kleint
*/
public class AnnotateCommand extends BasicCommand {
/**
* The event manager to use
*/
protected EventManager eventManager;
/**
* Use head revision if a revision meeting criteria set by switches -r/-D
* (tag/date) is not found.
*/
private boolean useHeadIfNotFound;
/**
* equals the -D switch of command line cvs.
*/
private String annotateByDate;
/**
* Equals the -r switch of command-line cvs.
*/
private String annotateByRevision;
/**
* Construct a new diff command
*/
public AnnotateCommand() {
}
/**
* Create a builder for this command.
* @param eventMan the event manager used to receive events.
*/
public Builder createBuilder(EventManager eventMan) {
return new AnnotateBuilder(eventMan, this);
}
/**
* Execute a command
* @param client the client services object that provides any necessary
* services to this command, including the ability to actually process
* all the requests.
*/
public void execute(ClientServices client, EventManager em)
throws CommandException, AuthenticationException {
eventManager = em;
client.ensureConnection();
super.execute(client, em);
excludeBinaryFiles(requests);
try {
if (useHeadIfNotFound) {
requests.add(1, new ArgumentRequest("-f")); //NOI18N
}
if (annotateByDate != null && annotateByDate.length() > 0) {
requests.add(1, new ArgumentRequest("-D")); //NOI18N
requests.add(2, new ArgumentRequest(getAnnotateByDate()));
}
if (annotateByRevision != null && annotateByRevision.length() > 0) {
requests.add(1, new ArgumentRequest("-r")); //NOI18N
requests.add(2, new ArgumentRequest(getAnnotateByRevision()));
}
addRequestForWorkingDirectory(client);
addArgumentRequests();
addRequest(CommandRequest.ANNOTATE);
client.processRequests(requests);
}
catch (CommandException ex) {
throw ex;
}
catch (Exception ex) {
throw new CommandException(ex, ex.getLocalizedMessage());
}
finally {
requests.clear();
}
}
private void excludeBinaryFiles(java.util.List requests) {
Iterator it = requests.iterator();
while (it.hasNext()) {
Object obj = it.next();
if (obj instanceof EntryRequest) {
EntryRequest req = (EntryRequest)obj;
if (req.getEntry().isBinary()) {
it.remove();
if (it.hasNext()) {
// removes also the follwoing modified/unchanged request
it.next();
it.remove();
}
}
}
}
}
/** called when server responses with "ok" or "error", (when the command finishes)
*/
public void commandTerminated(TerminationEvent e) {
if (builder != null) {
builder.outputDone();
}
}
/**
* Getter for property useHeadIfNotFound.
* @return Value of property useHeadIfNotFound.
*/
public boolean isUseHeadIfNotFound() {
return useHeadIfNotFound;
}
/**
* Setter for property useHeadIfNotFound.
* @param useHeadIfNotFound New value of property useHeadIfNotFound.
*/
public void setUseHeadIfNotFound(boolean useHeadIfNotFound) {
this.useHeadIfNotFound = useHeadIfNotFound;
}
/**
* Getter for property annotateByDate.
* @return Value of property annotateByDate.
*/
public String getAnnotateByDate() {
return annotateByDate;
}
/**
* Setter for property annotateByDate.
* @param annotateByDate New value of property annotateByDate.
*/
public void setAnnotateByDate(String annotateByDate) {
this.annotateByDate = annotateByDate;
}
/**
* Getter for property annotateByRevision.
* @return Value of property annotateByRevision.
*/
public String getAnnotateByRevision() {
return annotateByRevision;
}
/**
* Setter for property annotateByRevision.
* @param annotateByRevision New value of property annotateByRevision.
*/
public void setAnnotateByRevision(String annotateByRevision) {
this.annotateByRevision = annotateByRevision;
}
/**
* This method returns how the command would looklike when typed on the command line.
* Each command is responsible for constructing this information.
* @returns
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.