1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.team.internal.ccvs.core.*; 17 import org.eclipse.team.internal.ccvs.core.CVSException; 18 import org.eclipse.team.internal.ccvs.core.CVSStatus; 19 import org.eclipse.team.internal.ccvs.core.CVSTag; 20 import org.eclipse.team.internal.ccvs.core.ICVSResource; 21 import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener; 22 import org.eclipse.team.internal.ccvs.core.client.listeners.TagListener; 23 24 public class Tag extends Command { 25 26 public static final LocalOption CREATE_BRANCH = new LocalOption("-b", null); public static final LocalOption FORCE_REASSIGNMENT = new LocalOption("-F", null); 29 30 private static final ICommandOutputListener DEFAULT_OUTPUT_LISTENER = new TagListener(); 31 32 private boolean customBehaviorEnabled; 34 35 protected Tag(boolean customBehaviorEnabled) { 36 this.customBehaviorEnabled = customBehaviorEnabled; 37 } 38 39 protected Tag() { 40 this(false); 41 } 42 43 protected String getRequestId() { 44 return "tag"; } 46 47 protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, 48 String [] arguments) throws CVSException { 49 50 if (arguments.length < 1) throw new IllegalArgumentException (); 51 String [] allButFirst = new String [arguments.length - 1]; 52 System.arraycopy(arguments, 1, allButFirst, 0, arguments.length - 1); 53 return super.computeWorkResources(session, localOptions, allButFirst); 54 } 55 56 public IStatus execute(Session session, GlobalOption[] globalOptions, 57 LocalOption[] localOptions, CVSTag tag, String [] arguments, ICommandOutputListener listener, 58 IProgressMonitor monitor) throws CVSException { 59 60 if(tag.getType() != CVSTag.VERSION && tag.getType() != CVSTag.BRANCH) { 61 throw new CVSException(new CVSStatus(IStatus.ERROR, CVSMessages.Tag_notVersionOrBranchError)); 62 } 63 64 if (tag.getType() == CVSTag.BRANCH) { 66 if ( ! CREATE_BRANCH.isElementOf(localOptions)) { 67 LocalOption[] newLocalOptions = new LocalOption[localOptions.length + 1]; 68 System.arraycopy(localOptions, 0, newLocalOptions, 0, localOptions.length); 69 newLocalOptions[newLocalOptions.length - 1] = CREATE_BRANCH; 70 localOptions = newLocalOptions; 71 } 72 } 73 74 String [] newArguments = new String [arguments.length + 1]; 76 newArguments[0] = tag.getName(); 77 System.arraycopy(arguments, 0, newArguments, 1, arguments.length); 78 79 return execute(session, globalOptions, localOptions, newArguments, listener, monitor); 80 } 81 82 public IStatus execute(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions, 83 CVSTag tag, ICVSResource[] arguments, ICommandOutputListener listener, IProgressMonitor monitor) 84 throws CVSException { 85 86 String [] stringArguments = convertArgumentsForOpenSession(arguments, session); 87 88 return execute(session, globalOptions, localOptions, tag, stringArguments, listener, monitor); 89 } 90 91 protected ICommandOutputListener getDefaultCommandOutputListener() { 92 return DEFAULT_OUTPUT_LISTENER; 93 } 94 95 protected ICVSResource[] sendLocalResourceState(Session session, GlobalOption[] globalOptions, 96 LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) 97 throws CVSException { 98 99 if (customBehaviorEnabled) { 101 new TagFileSender(session, localOptions).visit(session, resources, monitor); 102 } else { 103 new FileStructureVisitor(session, localOptions, false, false).visit(session, resources, monitor); 104 } 105 return resources; 106 } 107 } 108 | Popular Tags |