update copyright
[fedora-idea.git] / plugins / cvs / cvs-plugin / src / com / intellij / cvsSupport2 / cvsoperations / cvsTagOrBranch / RtagCommand.java
blob5c66f0a7a7c243df3d6bf5873560d090e57a08ab
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch;
18 import com.intellij.openapi.util.text.StringUtil;
19 import org.jetbrains.annotations.NonNls;
20 import org.netbeans.lib.cvsclient.IClientEnvironment;
21 import org.netbeans.lib.cvsclient.IRequestProcessor;
22 import org.netbeans.lib.cvsclient.command.AbstractCommand;
23 import org.netbeans.lib.cvsclient.command.CommandException;
24 import org.netbeans.lib.cvsclient.connection.AuthenticationException;
25 import org.netbeans.lib.cvsclient.event.ICvsListenerRegistry;
26 import org.netbeans.lib.cvsclient.event.IEventSender;
27 import org.netbeans.lib.cvsclient.file.FileObject;
28 import org.netbeans.lib.cvsclient.progress.IProgressViewer;
29 import org.netbeans.lib.cvsclient.progress.sending.DummyRequestsProgressHandler;
30 import org.netbeans.lib.cvsclient.request.CommandRequest;
31 import org.netbeans.lib.cvsclient.request.Requests;
33 import java.util.Iterator;
35 public class RtagCommand extends AbstractCommand{
36 private final String myTagName;
37 private boolean myOverrideExistings = false;
39 public RtagCommand(String tagName) {
40 myTagName = tagName;
43 public final boolean execute(IRequestProcessor requestProcessor,
44 IEventSender eventSender,
45 ICvsListenerRegistry listenerRegistry,
46 IClientEnvironment clientEnvironment,
47 IProgressViewer progressViewer) throws CommandException, AuthenticationException {
48 final Requests requests = new Requests(CommandRequest.RTAG, clientEnvironment);
49 requests.addArgumentRequest(myOverrideExistings, "-F");
50 requests.addArgumentRequest(true, myTagName);
51 for (Iterator iterator = getFileObjects().getFileObjects().iterator(); iterator.hasNext();) {
52 FileObject fileObject = (FileObject)iterator.next();
53 String path = fileObject.getPath();
54 if (StringUtil.startsWithChar(path, '/')) path = path.substring(1);
55 requests.addArgumentRequest(path);
57 return requestProcessor.processRequests(requests, new DummyRequestsProgressHandler());
61 public final String getCvsCommandLine() {
62 @NonNls final StringBuffer cvsCommandLine = new StringBuffer("rtag ");
63 cvsCommandLine.append(getCVSArguments());
64 appendFileArguments(cvsCommandLine);
65 return cvsCommandLine.toString();
68 private String getCVSArguments() {
69 @NonNls final StringBuffer cvsArguments = new StringBuffer();
70 cvsArguments.append("-F " + myTagName);
71 return cvsArguments.toString();
74 public void setOverrideExistings(boolean overrideExistings) {
75 myOverrideExistings = overrideExistings;