1
/*****************************************************************************
2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is the CVS Client Library.
27
* The Initial Developer of the Original Software is Robert Greig.
28
* Portions created by Robert Greig are Copyright (C) 2000.
29
* All Rights Reserved.
31
* If you wish your version of this file to be governed by only the CDDL
32
* or only the GPL Version 2, indicate your decision by adding
33
* "[Contributor] elects to include this software in this distribution
34
* under the [CDDL or GPL Version 2] license." If you do not indicate a
35
* single choice of license, a recipient has the option to distribute
36
* your version of this file under either the CDDL, the GPL Version 2 or
37
* to extend the choice of license to its licensees as provided above.
38
* However, if you add GPL Version 2 code and therefore, elected the GPL
39
* Version 2 license, then the option applies only if the new code is
40
* made subject to such option by the copyright holder.
42
* Contributor(s): Robert Greig.
43
*****************************************************************************/
44
package org.netbeans.lib.cvsclient.command.status;
48
import org.netbeans.lib.cvsclient.*;
49
import org.netbeans.lib.cvsclient.command.*;
50
import org.netbeans.lib.cvsclient.connection.*;
51
import org.netbeans.lib.cvsclient.event.*;
52
import org.netbeans.lib.cvsclient.request.*;
55
* The status command looks up the status of files in the repository
56
* @author Robert Greig
58
public class StatusCommand extends BasicCommand {
60
* The event manager to use
62
private EventManager eventManager;
65
* Holds value of property includeTags.
67
private boolean includeTags;
70
* Construct a new status command
72
public StatusCommand() {
76
* Create a builder for this command.
77
* @param eventMan the event manager used to receive events.
79
public Builder createBuilder(EventManager eventManager) {
80
return new StatusBuilder(eventManager, this);
85
* @param client the client services object that provides any necessary
86
* services to this command, including the ability to actually process
89
public void execute(ClientServices client, EventManager em)
90
throws CommandException, AuthenticationException {
91
client.ensureConnection();
95
super.execute(client, em);
98
// parameters come now..
100
requests.add(1, new ArgumentRequest("-v")); //NOI18N
103
addRequestForWorkingDirectory(client);
104
addArgumentRequests();
105
addRequest(CommandRequest.STATUS);
107
client.processRequests(requests);
109
catch (CommandException ex) {
112
catch (Exception e) {
113
throw new CommandException(e, e.getLocalizedMessage());
121
* Getter for property includeTags.
122
* @return Value of property includeTags.
124
public boolean isIncludeTags() {
129
* Setter for property includeTags.
130
* @param includeTags New value of property includeTags.
132
public void setIncludeTags(boolean inclTags) {
133
includeTags = inclTags;
137
* called when server responses with "ok" or "error", (when the command finishes)
139
public void commandTerminated(TerminationEvent e) {
140
if (builder != null) {
141
builder.outputDone();
146
* This method returns how the command would looklike when typed on the command line.
147
* Each command is responsible for constructing this information.
148
* @returns <command's name> [<parameters>] files/dirs. Example: checkout -p CvsCommand.java
150
public String getCVSCommand() {
151
StringBuffer toReturn = new StringBuffer("status "); //NOI18N
152
toReturn.append(getCVSArguments());
153
File[] files = getFiles();
155
for (int index = 0; index < files.length; index++) {
156
toReturn.append(files[index].getName());
157
toReturn.append(' ');
160
return toReturn.toString();
164
* takes the arguments and sets the command. To be mainly
165
* used for automatic settings (like parsing the .cvsrc file)
166
* @return true if the option (switch) was recognized and set
168
public boolean setCVSCommand(char opt, String optArg) {
172
else if (opt == 'l') {
175
else if (opt == 'v') {
176
setIncludeTags(true);
185
* String returned by this method defines which options are available for this particular command
187
public String getOptString() {
188
return "Rlv"; //NOI18N
192
* resets all switches in the command. After calling this method,
193
* the command should have no switches defined and should behave defaultly.
195
public void resetCVSCommand() {
197
setIncludeTags(false);
201
* Returns the arguments of the command in the command-line style.
202
* Similar to getCVSCommand() however without the files and command's name
204
public String getCVSArguments() {
205
StringBuffer toReturn = new StringBuffer(""); //NOI18N
206
if (isIncludeTags()) {
207
toReturn.append("-v "); //NOI18N
209
if (!isRecursive()) {
210
toReturn.append("-l "); //NOI18N
212
return toReturn.toString();