Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2010 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  org.eclipse.swt.widgets.Shell;
Create a folder and any missing parents in the repository
 
 public class ShareProjectOperation extends CVSOperation {
 
 	private IProject project;
 	private String moduleName;
 	private Shell shell;
 
 	public ShareProjectOperation(Shell shellICVSRepositoryLocation locationIProject projectString moduleName) {
 		super(null);
 		this. = shell;
 		this. = moduleName;
 		this. = project;
 		this. = location;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
 	 */
 	protected void execute(IProgressMonitor monitorthrows CVSExceptionInterruptedException {
 		try {
 			monitor.beginTask(getTaskName(), 100);
 			// Create the remote module
 			final ICVSRemoteFolder remote = createRemoteFolder(Policy.subMonitorFor(monitor, 50));
 			// Map the project to the module in a workspace runnable
 			final TeamException[] exception = new TeamException[] {null};
 			ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
 				public void run(IProgressMonitor monitorthrows CoreException {
 					try {
 						mapProjectToRemoteFolder(remotemonitor);
 					} catch (TeamException e) {
 						exception[0] = e;
 					}
 				}
 			}, ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(), 0, Policy.subMonitorFor(monitor, 100));
 			if (exception[0] != null)
 				throw exception[0];
 		} catch (CoreException e) {
 			throw CVSException.wrapException(e);
 		} finally {
 			monitor.done();
 		}
 	}

Create the remote folder to which the project is being mapped (as well as any ancestors) and return it. If the remote folder does not exist remotely, this method will create it.

Parameters:
monitor a progress monitor
Returns:
the existing remote folder to which the project is being mapped
Throws:
CVSException
 
 		String projectName = .getName();
 		if ( == null)
 			 = projectName;
 
 		RemoteFolderTree root = new RemoteFolderTree(null..toString(), null);
 		Path path = new Path(null);
 		
 		try {
 			monitor.beginTask(getTaskName(), 100 * path.segmentCount());
 			return ensureTreeExists(rootpathmonitor);
 		} catch (TeamException e) {
 			throw CVSException.wrapException(e);
 		} finally {
 			monitor.done();
 		}
 	}

Map the project to the remote folder by associating the CVS Repository Provider with the project and, at the very least, assigning the folder sync info for the remote folder as the folder sync info for the project.

Parameters:
remote the remote folder to which the project is being mapped
monitor a progress monitor
Throws:
CVSException
	protected void mapProjectToRemoteFolder(final ICVSRemoteFolder remoteIProgressMonitor monitorthrows TeamException {
		// Link the project to the newly created module
        monitor.subTask(NLS.bind(.new String[] { .getName(), remote.getRepositoryRelativePath() }));
		ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor();
		//Register it with Team.  If it already is, no harm done.
		RepositoryProvider.map(, CVSProviderPlugin.getTypeId());
		monitor.done();
	}
	/*
	 * Create handles for all the children in the moduleName path
	 */
		RemoteFolderTree child = new RemoteFolderTree(parentnamenew Path(nullparent.getRepositoryRelativePath()).append(name).toString(), null);
		parent.setChildren(new ICVSRemoteResource[] { child });
		if (child.exists(Policy.subMonitorFor(monitor, 50))) {
			// The child exists so get the handle that was received from the server
			return (RemoteFolderTree)parent.getFolder(name);
else {
			// Create the folder remotely
			createFolder(child, Policy.subMonitorFor(monitor, 50));
			return child;
		}
	}
	/*
	 * Ensure that all the folders in the tree exist
	 */
		if (path.isEmpty()) return folder;
		String name = path.segment(0);
		RemoteFolderTree child = createChild(foldernamemonitor);
		return ensureTreeExists(childpath.removeFirstSegments(1), monitor);
	}
	private void createFolder(RemoteFolderTree folderIProgressMonitor monitorthrows TeamException {
		Session s = new Session(folder.getParent());
		s.open(monitortrue /* open for modification */);
		try {
			IStatus status = ..execute(s,
					new String[] { folder.getName() },
					null,
					monitor);
			// If we get a warning, the operation most likely failed so check that the status is OK
			if (status.getCode() == .  || ! status.isOK()) {
				throw new CVSServerException(status);
			}
finally {
			s.close();
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
	 */
	protected String getTaskName() {
	}

Returns:
Returns the project.
	public IProject getProject() {
		return ;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getShell()
	 */
	public Shell getShell() {
		return ;
	}

Purge any CVS folders.

Parameters:
monitor a progress monitor
	private void purgeAnyCVSFolders(final IProgressMonitor monitor) {
		try {
            monitor.beginTask(null.);
			ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor();
			folder.accept(new ICVSResourceVisitor() {
				public void visitFile(ICVSFile filethrows CVSException {
					// nothing to do for files
				}
				public void visitFolder(ICVSFolder folderthrows CVSException {
                    monitor.subTask(NLS.bind(.new String[] { folder.getIResource().getFullPath().toString() } ));
					if (folder.isCVSFolder()) {
						// for now, just unmanage
						folder.unmanage(null);
					}
				}
			}, true /* recurse */);
catch (CVSException e) {
			// log the exception and return null
			CVSUIPlugin.log(e);
finally {
		    monitor.done();
        }
	}
New to GrepCode? Check out our FAQ X