Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.team.internal.ccvs.ui.operations;
 
 import java.util.Set;
 
 
 public class TagOperation extends RepositoryProviderOperation implements ITagOperation {
 
 	private Set localOptions = new HashSet();
 	private CVSTag tag;
 
 	public TagOperation(IWorkbenchPart partResourceMapping[] mappers) {
 		super(partmappers);
 	}
 
 	public CVSTag getTag() {
 		return ;
 	}
 
 	public void setTag(CVSTag tag) {
 		this. = tag;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
 	 */
 	protected void execute(CVSTeamProvider providerIResource[] resourcesboolean recurseIProgressMonitor monitorthrows CVSExceptionInterruptedException {
 		IStatus status = tag(providerresourcesrecursemonitor);
 		collectStatus(status);
 	}

Override to dislay the number of tag operations that succeeded
 
 	protected String getErrorMessage(IStatus[] problemsint operationCount) {
 		// We accumulated 1 status per resource above.
 		if(operationCount == 1) {
 		} else {
 			return NLS.bind(.new String[] { Integer.toString(operationCount - problems.length), Integer.toString(problems.length) });
 		}
 	}

Tag the resources in the CVS repository with the given tag. The returned IStatus will be a status containing any errors or warnings. If the returned IStatus is a multi-status, the code indicates the severity. Possible codes are: CVSStatus.OK - Nothing to report CVSStatus.SERVER_ERROR - The server reported an error any other code - warning messages received from the server

Parameters:
recurse
 
 	public IStatus tag(CVSTeamProvider providerIResource[] resourcesboolean recurseIProgressMonitor progressthrows CVSException {
 						
         if (recurse) {
             commandOptions = ..removeFrom(commandOptions);
         } else {
             commandOptions = ..removeFrom(commandOptions);
             commandOptions = ..addTo(commandOptions);
         }
 				
 		// Build the arguments list
 		String[] arguments = getStringArguments(resources);
 
 		// Execute the command
 		CVSWorkspaceRoot root = provider.getCVSWorkspaceRoot();
 		Session s = new Session(root.getRemoteLocation(), root.getLocalRoot());
 		progress.beginTask(null, 100);
 		try {
			// Opening the session takes 20% of the time
			s.open(Policy.subMonitorFor(progress, 20), true /* open for modification */);
			return ..execute(s,
				commandOptions,
				arguments,
				null,
				Policy.subMonitorFor(progress, 80));
finally {
			s.close();
			progress.done();
		}
	}
	public void addLocalOption(LocalOption option)  {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#moveTag()
	 */
	public void moveTag() {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#recurse()
	 */
	public void doNotRecurse() {
	}
	protected  String getTaskName() {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
	 */
	protected String getTaskName(CVSTeamProvider provider) {
		return NLS.bind(.new String[] { provider.getProject().getName() }); 
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
	 */
	public void execute(IProgressMonitor monitorthrows CVSExceptionInterruptedException {
		super.execute(monitor);
		if (!errorsOccurred()) {
			try {
catch (InvocationTargetException e) {
				throw CVSException.wrapException(e);
			}
		}
	}
    private ICVSResource[] getCVSResources() {
        IResource[] resources = getTraversalRoots();
        ICVSResource[] cvsResources = new ICVSResource[resources.length];
        for (int i = 0; i < resources.lengthi++) {
            cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]);
        }
        return cvsResources;
    }
    /* (non-Javadoc)
     * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#getTagSource()
     */
    public TagSource getTagSource() {
       return TagSource.create(getProjects());
    }
    private IProject[] getProjects() {
		Set projects = new HashSet();
		for (int i = 0; i < mappings.lengthi++) {
			ResourceMapping mapping = mappings[i];
			projects.addAll(Arrays.asList(mapping.getProjects()));
		}
		return (IProject[]) projects.toArray(new IProject[projects.size()]);
	}
	protected boolean isReportableError(IStatus status) {
        return super.isReportableError(status)
        	|| status.getCode() == .;
    }
    /* (non-Javadoc)
     * @see org.eclipse.team.internal.ccvs.ui.operations.ITagOperation#isEmpty()
     */
    public boolean isEmpty() {
        return getSelectedMappings().length == 0;
    }
New to GrepCode? Check out our FAQ X