KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > client > RemoteCommand


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.core.client;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.team.internal.ccvs.core.*;
18 import org.eclipse.team.internal.ccvs.core.CVSException;
19 import org.eclipse.team.internal.ccvs.core.ICVSResource;
20
21 /**
22  * This class acts as a super class for those CVS commands that do not send up the local file structure
23  */

24 public abstract class RemoteCommand extends Command {
25
26     protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions,
27         String JavaDoc[] arguments) throws CVSException {
28         return new ICVSResource[0];
29     }
30
31     protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions,
32         LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor)
33         throws CVSException {
34             
35         // do nothing
36
monitor.beginTask(null, 100);
37         monitor.done();
38         return resources;
39     }
40     
41     protected void sendLocalWorkingDirectory(Session session) throws CVSException {
42         // do nothing
43
}
44
45     /* (non-Javadoc)
46      * @see org.eclipse.team.internal.ccvs.core.client.Command#convertArgumentsForOpenSession(org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.team.internal.ccvs.core.client.Session)
47      */

48     protected String JavaDoc[] convertArgumentsForOpenSession(
49         ICVSResource[] arguments,
50         Session openSession)
51         throws CVSException {
52         
53             // Convert arguments
54
List JavaDoc stringArguments = new ArrayList JavaDoc(arguments.length);
55             for (int i = 0; i < arguments.length; i++) {
56                 ICVSResource resource = arguments[i];
57                 String JavaDoc remotePath;
58                 if (isDefinedModule(resource)) {
59                     remotePath = resource.getName();
60                 } else {
61                     remotePath = resource.getRepositoryRelativePath();
62                     
63                 }
64                 stringArguments.add(remotePath);
65             }
66             return (String JavaDoc[]) stringArguments.toArray(new String JavaDoc[stringArguments.size()]);
67     }
68
69     private boolean isDefinedModule(ICVSResource resource) {
70         return resource instanceof ICVSRemoteFolder && ((ICVSRemoteFolder)resource).isDefinedModule();
71     }
72
73 }
74
Popular Tags