Java Code Examples for org.eclipse.team.core.RepositoryProvider#map()

The following examples show how to use org.eclipse.team.core.RepositoryProvider#map() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckoutAsProjectOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void refreshProject(IProject project, IProgressMonitor monitor)
		throws SVNException {
    if (monitor != null)
    {
    	monitor.beginTask("", 100); //$NON-NLS-1$
    }
	try {
		// Register the project with Team
		RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
		RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
		project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
	} catch (Exception e) {
		throw new SVNException("Cannot map the project with svn provider",e);
	} finally {
		if (monitor != null)
		{
			monitor.done();
		}
	}
}
 
Example 2
Source File: CheckoutCommand.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void refreshProject(IProject project, IProgressMonitor monitor)
		throws SVNException {
    if (monitor != null)
    {
    	monitor.beginTask("", 100); //$NON-NLS-1$
    	monitor.subTask(Policy.bind("SVNProvider.Creating_project_1", project.getName()));
    }
	try {
		// Register the project with Team
		RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
		RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
	} catch (TeamException e) {
		throw new SVNException("Cannot map the project with svn provider",e);
	} finally {
		if (monitor != null)
		{
			monitor.subTask(" ");
			monitor.done();
		}
	}
}
 
Example 3
Source File: SVNProjectSetCapability.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Imports a existing SVN Project to the workbench
 * 
 * @param monitor
 *            project monitor
 * @return true if loaded, else false
 * @throws TeamException
 */

boolean importExistingProject(IProgressMonitor monitor)
        throws TeamException {
    if (directory == null) {
        return false;
    }
    try {
        monitor.beginTask("Importing", 3 * 1000);

        createExistingProject(new SubProgressMonitor(monitor, 1000));

        monitor.subTask("Refreshing " + project.getName());
        RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
        monitor.worked(1000);
        SVNWorkspaceRoot.setSharing(project, new SubProgressMonitor(
                monitor, 1000));

        return true;
    } catch (CoreException ce) {
        throw new SVNException("Failed to import External SVN Project"
                + ce, ce);
    } finally {
        monitor.done();
    }
}
 
Example 4
Source File: SVNWorkspaceRoot.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the sharing for a project to enable it to be used with the SVNTeamProvider.
    * This is used when a project has .svn directory but is not shared in Eclipse.
 * An exception is thrown if project does not have a remote directory counterpart
 */
public static void setSharing(IProject project, IProgressMonitor monitor) throws TeamException {

	// Ensure provided info matches that of the project
	LocalResourceStatus status = peekResourceStatusFor(project);

       // this folder needs to be managed but also to have a remote counter-part
       // because we need to know its url
       // we will change this exception !
       if (!status.hasRemote())
           throw new SVNException(new SVNStatus(IStatus.ERROR, Policy.bind("SVNProvider.infoMismatch", project.getName())));//$NON-NLS-1$

       String repositoryURL = null;
       ISVNClientAdapter client = SVNProviderPlugin.getPlugin().getSVNClient();
       try {
           SVNProviderPlugin.disableConsoleLogging();
		ISVNInfo info = client.getInfoFromWorkingCopy(project.getLocation().toFile());
		if (info.getRepository() != null)
			repositoryURL = info.getRepository().toString();
	} catch (SVNClientException e) {
	} finally {
        SVNProviderPlugin.enableConsoleLogging();
           SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
	}
	if (repositoryURL == null)
		repositoryURL = status.getUrlString();

	// Ensure that the provided location is managed
	SVNProviderPlugin.getPlugin().getRepositories().getRepository(repositoryURL, false);

	// Register the project with Team
	RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
}
 
Example 5
Source File: SVNTeamProviderType.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(null, IProgressMonitor.UNKNOWN);
SVNProviderPlugin plugin = SVNProviderPlugin.getPlugin();
SVNClientManager svnClientManager = plugin.getSVNClientManager();
ISVNClientAdapter client = null;
try{
	
	if (plugin == null || plugin.getSimpleDialogsHelper() == null){
		if (++reschedCount > MAX_RETRIES){
			String errorString = "Subclipse core and/or ui didn't come up in " + MAX_RETRIES + " retries, failing.";  //$NON-NLS-1$
			System.err.println(errorString); // Let it be visible to the user
			throw new SVNException(errorString);
		}
		schedule(1000);
		return Status.OK_STATUS;
	}
	
	if (!plugin.getSimpleDialogsHelper().promptYesNo(
			"Auto-add "+project.getName()+" to source control", //$NON-NLS-1$
			  "The new project \""+ project.getName() +"\" was created in a subversion " + //$NON-NLS-1$
			  "controlled directory.\n\n" + //$NON-NLS-1$
			  "Would you like to automatically add it to source control?", true)) { //$NON-NLS-1$

		return Status.OK_STATUS;
	}
			
	client = svnClientManager.getSVNClient();

	File file = project.getLocation().toFile();
	client.addDirectory(file, false);

	RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
	plugin.getStatusCacheManager().refreshStatus(project,
			true);
	
}catch(Exception e){
             SVNProviderPlugin.log(IStatus.ERROR, "Could not auto-add project " + project.getName(), e); //$NON-NLS-1$
	return Status.CANCEL_STATUS;
}finally{
	monitor.done();
	svnClientManager.returnSVNClient(client);
}
return Status.OK_STATUS;
     }