1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 14 import org.eclipse.core.runtime.*; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.team.internal.ccvs.core.*; 17 import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; 18 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; 19 import org.eclipse.team.internal.ccvs.core.syncinfo.MutableFolderSyncInfo; 20 21 public class Add extends Command { 22 23 24 protected Add() { } 25 protected String getRequestId() { 26 return "add"; } 28 29 protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, 30 LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) 31 throws CVSException { 32 33 for (int i = 0; i < resources.length; i++) { 37 Assert.isNotNull(resources[i].getRemoteLocation(session.getLocalRoot())); 38 } 39 40 AddStructureVisitor visitor = new AddStructureVisitor(session, localOptions); 43 visitor.visit(session, resources, monitor); 44 return resources; 45 } 46 47 51 protected IStatus commandFinished(Session session, GlobalOption[] globalOptions, 52 LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor, 53 IStatus status) throws CVSException { 54 55 if (status.getCode() == CVSStatus.SERVER_ERROR) { 56 return status; 57 } 58 59 for (int i = 0; i < resources.length; i++) { 60 if (resources[i].isFolder()) { 61 ICVSFolder mFolder = (ICVSFolder) resources[i]; 62 FolderSyncInfo info = mFolder.getParent().getFolderSyncInfo(); 63 if (info == null) { 64 status = mergeStatus(status, new CVSStatus(IStatus.ERROR, NLS.bind(CVSMessages.Add_invalidParent, new String [] { mFolder.getRelativePath(session.getLocalRoot()) }))); 65 } else { 66 String repository = info.getRepository() + "/" + mFolder.getName(); MutableFolderSyncInfo newInfo = info.cloneMutable(); 68 newInfo.setRepository(repository); 69 mFolder.setFolderSyncInfo(newInfo); 70 } 71 } 72 } 73 return status; 74 } 75 76 79 protected ICommandOutputListener getDefaultCommandOutputListener() { 80 return new CommandOutputListener() { 81 public IStatus errorLine(String line, 82 ICVSRepositoryLocation location, ICVSFolder commandRoot, 83 IProgressMonitor monitor) { 84 85 String serverMessage = getServerMessage(line, location); 86 if (serverMessage != null) { 87 if (serverMessage.indexOf("cvs commit") != -1 && serverMessage.indexOf("add") != -1 && serverMessage.indexOf("permanently") != -1) return OK; 89 if (serverMessage.startsWith("scheduling file") && serverMessage.indexOf("for addition") != -1) return OK; 91 } 92 return super.errorLine(line, location, commandRoot, monitor); 93 } 94 }; 95 } 96 97 } 98 | Popular Tags |