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.List;
 
Abstract operation for caching the contents for any files in a particular remote tree that differ from the local contents.*
 
 public abstract class CacheTreeContentsOperation extends SingleCommandOperation {
 
 	private final IResourceDiffTree tree;
 
 		super(partmappings.);
 		this. = tree;
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], boolean, org.eclipse.core.runtime.IProgressMonitor)
 	 */
 	protected void execute(CVSTeamProvider providerIResource[] resourcesboolean recurseIProgressMonitor monitorthrows CVSExceptionInterruptedException {
 		IResource[] files = getFilesWithUncachedContents(resourcesrecurse);
 		if (files.length > 0)
 			super.execute(providerfilesrecursemonitor);
 	}
 	
 	private IResource[] getFilesWithUncachedContents(IResource[] resourcesboolean recurse) {
 		ArrayList result = new ArrayList();
 		for (int i = 0; i < resources.lengthi++) {
 			IResource resource = resources[i];
 			IDiff[] nodes = .getDiffs(resourcerecurse ? ..);
 			for (int j = 0; j < nodes.lengthj++) {
 				IDiff node = nodes[j];
 				if (needsContents(node)) {
 					result.add(.getResource(node));
 				}
 			}
 		}
 		return (IResource[]) result.toArray(new IResource[result.size()]);
 	}
 
 	protected boolean needsContents(IDiff node) {
 		if (node instanceof IThreeWayDiff) {
 			IThreeWayDiff twd = (IThreeWayDiffnode;	
 			IResource local = getTree().getResource(node);
 			IFileRevision remote = getRemoteFileState(twd);
 			if (remote != null) {
 				IResourceVariant variant = (IResourceVariant)Utils.getAdapter(remoteIResourceVariant.class);
 				if (local.getType() == . 
 						&& variant instanceof RemoteFile) {
 					RemoteFile rf = (RemoteFilevariant;
 					if (!rf.isContentsCached()) {
 						return true;
 					}
 				}
 			}
 		}
 		return false;
 	}

Get the remote file state that is of interest.

Parameters:
twd a three way diff
Returns:
the remote file state that is of interest
 
	protected abstract IFileRevision getRemoteFileState(IThreeWayDiff twd);

Return whether the direction is of interest.

Parameters:
direction the direction of a diff
Returns:
whether the direction is of interest
	protected abstract boolean isEnabledForDirection(int direction);
	/* (non-Javadoc)
	 * 
	 * Use a local root that is really the base tree so we can cache
	 * the base contents without affecting the local contents.
	 * 
	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getLocalRoot(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
	 */
			throws CVSException {
		try {
			ICVSRemoteResource tree = buildTree(provider);
			return (ICVSFolder)tree;
catch (TeamException e) {
			throw CVSException.wrapException(e);
		}
	}
	protected abstract ICVSRemoteResource buildTree(CVSTeamProvider providerthrows TeamException;
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getCVSArguments(org.eclipse.core.resources.IResource[])
	 */
	protected ICVSResource[] getCVSArguments(Session sessionIResource[] resources) {
        List result = new ArrayList();
        for (int i = 0; i < resources.lengthi++) {
            IResource resource = resources[i];
            try {
				result.add(file);
catch (CVSException e) {
				// Log and continue
				CVSUIPlugin.log(e);
			}
        }
        return (ICVSResource[]) result.toArray(new ICVSResource[result.size()]);
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.team.internal.ccvs.core.ICVSResource[], boolean, org.eclipse.core.runtime.IProgressMonitor)
	 */
	protected IStatus executeCommand(Session sessionCVSTeamProvider providerICVSResource[] resourcesboolean recurseIProgressMonitor monitorthrows CVSExceptionInterruptedException {
                session,
                .,
                getLocalOptions(true),
                resources,
                new UpdateListener(new IUpdateMessageListener() {
					public void fileInformation(int typeICVSFolder parentString filename) {
						// Do nothing
					}
					public void fileDoesNotExist(ICVSFolder parentString filename) {
						// Do nothing
					}
					public void directoryInformation(ICVSFolder commandRootString path,
							boolean newDirectory) {
						// Do nothing
					}
					public void directoryDoesNotExist(ICVSFolder commandRootString path) {
						// Do nothing
					}
				}),
                monitor);
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#getLocalOptions(boolean)
	 */
	protected LocalOption[] getLocalOptions(boolean recurse) {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
	 */
	protected String getTaskName(CVSTeamProvider provider) {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
	 */
	protected String getTaskName() {
	}

Return the diff tree whose contents are being cached

Returns:
	protected IResourceDiffTree getTree() {
		return ;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#consultModelsForMappings()
	 */
	public boolean consultModelsForMappings() {
		return false;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#isReportableError(org.eclipse.core.runtime.IStatus)
	 */
	protected boolean isReportableError(IStatus status) {
		return super.isReportableError(status) && status.getSeverity() == .;
	}
New to GrepCode? Check out our FAQ X