org.eclipse.team.core.RepositoryProvider Java Examples

The following examples show how to use org.eclipse.team.core.RepositoryProvider. 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: CommitOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private Map<ProjectAndRepository, List<IResource>> getCommitProviderMapping(IResource[] resources) {
	ProjectAndRepository mapKey = null;
	Map<ProjectAndRepository, List<IResource>> result = new HashMap<ProjectAndRepository, List<IResource>>();
	for (IResource resource : resources) {
		if (mapKey == null || !svnClient.canCommitAcrossWC()) {
			SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
			mapKey = new ProjectAndRepository(provider, getRootURL(SVNWorkspaceRoot.getSVNResourceFor(resource)));
		}
		List<IResource> list = result.get(mapKey);
		if (list == null) {
			list = new ArrayList<IResource>();
			result.put(mapKey, list);
		}
		list.add(resource);
	}
	return result;
}
 
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: 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 #5
Source File: FilesInSyncFilter.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean accept(Object element) {
  boolean passes = true;

  if (element instanceof IFile) {

    IFile file = (IFile) element;
    IProject project = file.getProject();

    if (RepositoryProvider.isShared(project)) {

      RepositoryProvider provider = RepositoryProvider.getProvider(project);

      if (provider != null) {

        Subscriber subscriber = provider.getSubscriber();

        if (subscriber != null) {
          passes = hasChanges(file, subscriber);
        }
      }
    }
  }
  return passes;
}
 
Example #6
Source File: SVNWorkspaceSubscriber.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public boolean isSupervised(IResource resource) throws TeamException {
try {
	if (resource.isTeamPrivateMember() || SVNWorkspaceRoot.isLinkedResource(resource)) return false;
	RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
	if (provider == null) return false;
	// TODO: what happens for resources that don't exist?
	// TODO: is it proper to use ignored here?
	ISVNLocalResource svnThing = SVNWorkspaceRoot.getSVNResourceFor(resource);
	if (svnThing.isIgnored()) {
		// An ignored resource could have an incoming addition (conflict)
		return (remoteSyncStateStore.getBytes(resource) != null) || 
				((remoteSyncStateStore.members(resource) != null) && (remoteSyncStateStore.members(resource).length > 0));
	}
	return true;
} catch (TeamException e) {
	// If there is no resource in coe this measn there is no local and no remote
	// so the resource is not supervised.
	if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) {
		return false;
	}
	throw e;
}
  }
 
Example #7
Source File: SVNSynchronizeOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	// First, ask the user if they want to include conflicts
	SyncInfoSet syncSet = getSyncInfoSet();
	if (!promptForConflictHandling(getShell(), syncSet)) return;
	// Divide the sync info by project
	final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
	monitor.beginTask(null, projectSyncInfos.size() * 100);
	for (Iterator iter = projectSyncInfos.keySet().iterator(); iter.hasNext(); ) {
		final IProject project = (IProject) iter.next();

		// Pass the scheduling rule to the synchronizer so that sync change events
		// and cache commits to disk are batched
		SVNTeamProvider provider = (SVNTeamProvider)RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
		if (provider != null) {
			run(provider, (SyncInfoSet)projectSyncInfos.get(project), Policy.subMonitorFor(monitor,100));
		}
	}
	monitor.done();
}
 
Example #8
Source File: IgnoreSynchronizeOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	// First, ask the user if they want to include conflicts
	SyncInfoSet syncSet = getSyncInfoSet();
	if (!promptForConflictHandling(getShell(), syncSet)) return;
	// Divide the sync info by project
	final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
	monitor.beginTask(null, projectSyncInfos.size() * 100);
	for (Iterator iter = projectSyncInfos.keySet().iterator(); iter.hasNext(); ) {
		final IProject project = (IProject) iter.next();

		// Pass the scheduling rule to the synchronizer so that sync change events
		// and cache commits to disk are batched
		SVNTeamProvider provider = (SVNTeamProvider)RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
		if (provider != null) {
			run(provider, (SyncInfoSet)projectSyncInfos.get(project), Policy.subMonitorFor(monitor,100));
			break;
		}
	}
	monitor.done();
}
 
Example #9
Source File: SVNHistoryPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public boolean isValidInput(Object object) {
  if(object instanceof IResource) {
    RepositoryProvider provider = RepositoryProvider.getProvider(((IResource) object).getProject());
    return provider instanceof SVNTeamProvider;
  } else if(object instanceof ISVNRemoteResource) {
    return true;
  }

  // TODO
  // } else if(object instanceof CVSFileRevision) {
  // return true;
  // } else if(object instanceof CVSLocalFileRevision) {
  // return true;

  return false;
}
 
Example #10
Source File: SVNWorkspaceRoot.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
   * Gets the repository which the local filesystem <code>location</code> belongs to.
   */
  public static ISVNRepositoryLocation getRepositoryFor(IPath location) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = root.getProjects();
for (IProject project : projects) {
	if (project.getLocation().isPrefixOf(location) && SVNWorkspaceRoot.isManagedBySubclipse(project)) {
		try {
			SVNTeamProvider teamProvider = (SVNTeamProvider)RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
			return teamProvider.getSVNWorkspaceRoot().getRepository();
		} catch (SVNException e) {
			// an exception is thrown when resource	is not managed
			SVNProviderPlugin.log(e);
			return null;
		}
	}
}
return null;
  }
 
Example #11
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 #12
Source File: RelocateWizard.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setSharedProjects() {
	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	ArrayList shared = new ArrayList();
	for (int i = 0; i < projects.length; i++) {
		RepositoryProvider teamProvider = RepositoryProvider.getProvider(projects[i], SVNProviderPlugin.getTypeId());
		if (teamProvider!=null) {
		    try {
				SVNTeamProvider svnProvider = (SVNTeamProvider)teamProvider;
				if (svnProvider.getSVNWorkspaceRoot().getRepository().equals(repository)) shared.add(projects[i]);
		    } catch(Exception e) {}				
		}
	}
	sharedProjects = new IProject[shared.size()];
	shared.toArray(sharedProjects);
}
 
Example #13
Source File: SVNProjectSetCapability.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Answer a string representing the specified project
 * 
 * @param project
 *            the project (not <code>null</code>)
 * @return the project reference (not <code>null</code>)
 */
private String asReference(IProject project) {
    StringBuffer buffer = new StringBuffer();
    buffer.append("0.9.3,"); //$NON-NLS-1$

    SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider
            .getProvider(project);
    SVNWorkspaceRoot root = provider.getSVNWorkspaceRoot();

    buffer.append(root.getLocalRoot().getUrl().toString());
    buffer.append(",");
    buffer.append(project.getName());
    return buffer.toString();
}
 
Example #14
Source File: SVNProviderPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return true if the container is managed by SVN
 */
public boolean isManagedBySubversion(IContainer container)
{
	if (container instanceof IProject)
	{
		if (RepositoryProvider.getProvider((IProject)container, getTypeId()) != null)
			return true; // svn handled project
		// Don't return at this point, since the project may not be registered
		// yet with Team.
	}

	return isManagedBySubversion(container.getLocation());
}
 
Example #15
Source File: SVNWorkspaceSubscriber.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public IResource[] roots() {
List<IProject> result = new ArrayList<IProject>();
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
	if(project.isAccessible()) {
		RepositoryProvider provider = RepositoryProvider.getProvider(project, SVNProviderPlugin.PROVIDER_ID);
		if(provider != null) {
			result.add(project);
		}
	}
}
return (IProject[]) result.toArray(new IProject[result.size()]);
  }
 
Example #16
Source File: SVNWorkspaceSubscriber.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
monitor = Policy.monitorFor(monitor);
List<IStatus> errors = new ArrayList<IStatus>();
try {
	monitor.beginTask("", 1000 * resources.length);
	for (IResource resource : resources) {
		// Make certain that resource is still connected with SVN.  When
		// Synch is on a schedule it is possible for the project to become disconnected
		SVNTeamProvider teamProvider = (SVNTeamProvider)RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
		if (teamProvider != null) {
			monitor.subTask(resource.getName());
			IStatus status = refresh(resource, depth, monitor);
			if (!status.isOK()) {
				errors.add(status);
			}
		}
	}
} finally {
	monitor.done();
} 
if (!errors.isEmpty()) {
	int numSuccess = resources.length - errors.size();
	throw new TeamException(new MultiStatus(SVNProviderPlugin.ID, 0, 
			(IStatus[]) errors.toArray(new IStatus[errors.size()]), 
			Policy.bind("SVNWorkspaceSubscriber.errorWhileSynchronizing.1", new Object[] {getName(), Integer.toString(numSuccess), Integer.toString(resources.length)}), null)); //$NON-NLS-1$
}
  }
 
Example #17
Source File: SVNTeamProviderType.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public boolean shouldRun() {
    synchronized (projectsToShare) {
        for (Iterator<IProject> iter = projectsToShare.iterator(); iter.hasNext();) {
            IProject project = iter.next();
            if (RepositoryProvider.isShared(project)) {
                iter.remove();
            }
        }
        return !projectsToShare.isEmpty();
    }
}
 
Example #18
Source File: SVNTeamProviderType.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void share(IProject project) {
    if (!RepositoryProvider.isShared(project)) {
        synchronized (projectsToShare) {
            if (!projectsToShare.contains(project)) {
                SVNWorkspaceRoot.setManagedBySubclipse(project);
                projectsToShare.add(project);
            }
        }
        if(getState() == Job.NONE && !isQueueEmpty())
            schedule();
    }
}
 
Example #19
Source File: SVNWorkspaceRoot.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isManagedBySubclipse(IProject project) {
	if (project == null)
		return false;

	synchronized (sharedProjects) {
		if (sharedProjects.contains(project))
			return true;
	}

	return null != RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
}
 
Example #20
Source File: RelocateWizard.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public boolean performFinish() {
	ISVNClientAdapter client = null;
	try {
		SVNRepositoryLocation newRepository = SVNRepositoryLocation.fromString(urlPage.getNewUrl());
		newRepository.setUsername(repository.getUsername());
		newRepository.setLabel(repository.getLabel());
		newRepository.validateConnection(new NullProgressMonitor());
		client = repository.getSVNClient();
		for (int i = 0; i < sharedProjects.length; i++) {
			client.relocate(repository.getUrl().toString(), newRepository.getUrl().toString(), sharedProjects[i].getLocation().toString(), true);
		}
           SVNRepositories repositories = SVNProviderPlugin.getPlugin().getRepositories();
           repositories.addOrUpdateRepository(newRepository);
		for (int i = 0; i < sharedProjects.length; i++) {
			SVNProviderPlugin.getPlugin().getStatusCacheManager().refreshStatus(sharedProjects[i], true);
			sharedProjects[i].refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
			RepositoryProvider provider = RepositoryProvider.getProvider(sharedProjects[i], SVNProviderPlugin.getTypeId());
			provider.setProject(sharedProjects[i]);
		}
		repositories.disposeRepository(repository);
	} catch (Exception e) {
		MessageDialog.openError(getShell(), Policy.bind("RelocateWizard.heading"), e.getMessage()); //$NON-NLS-1$
		return false;
	}
	finally {
		repository.returnSVNClient(client);
	}
	return true;
}
 
Example #21
Source File: CommitSynchronizeOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	// First, ask the user if they want to include conflicts
	SyncInfoSet syncSet = getSyncInfoSet();
	if (!promptForConflictHandling(getShell(), syncSet)) return;
	// Divide the sync info by project
	final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
	Iterator iter = projectSyncInfos.keySet().iterator();
	final IProject project = (IProject) iter.next();
	SVNTeamProvider provider = (SVNTeamProvider)RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
	monitor.beginTask(null, projectSyncInfos.size() * 100);
	run(provider, syncSet, Policy.subMonitorFor(monitor,100));
	monitor.done();
}
 
Example #22
Source File: GenerateDiffFileSynchronizeOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	SyncInfoSet syncSet = getSyncInfoSet();
	final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
	Iterator iter = projectSyncInfos.keySet().iterator();
	final IProject project = (IProject) iter.next();
	SVNTeamProvider provider = (SVNTeamProvider)RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
	monitor.beginTask(null, projectSyncInfos.size() * 100);
	run(provider, syncSet, Policy.subMonitorFor(monitor,100));
	monitor.done();
}
 
Example #23
Source File: CommitAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected boolean isEnabled() throws TeamException {
	
	// invoke the inherited method so that overlaps are maintained
	IResource[] resources = super.getSelectedResources();
	
	// disable if no resources are selected
	if(resources.length==0) return false;
	
	// validate enabled for each resource in the selection
	for (int i = 0; i < resources.length; i++) {
		IResource resource = resources[i];
		
		// no SVN actions are enabled if the selection contains a linked resource
		if (SVNWorkspaceRoot.isLinkedResource(resource)) return false;
		
		// only enable for resources in a project shared with SVN
		if(RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId()) == null) {
			return false;
		}
		
		// ensure that resource management state matches what the action requires
		ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
		if (!isEnabledForSVNResource(svnResource)) {
			return false;
		}
	}
	return true;
}
 
Example #24
Source File: CommitOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private Map<SVNTeamProvider, List<IResource>> getProviderMapping(IResource[] resources) {
	SVNTeamProvider provider = null;
	Map<SVNTeamProvider, List<IResource>> result = new HashMap<SVNTeamProvider, List<IResource>>();
	for (int i = 0; i < resources.length; i++) {
		if (provider == null || !svnClient.canCommitAcrossWC())
			provider = (SVNTeamProvider) RepositoryProvider.getProvider(resources[i].getProject(), SVNProviderPlugin.getTypeId());
		List<IResource> list = result.get(provider);
		if (list == null) {
			list = new ArrayList<IResource>();
			result.put(provider, list);
		}
		list.add(resources[i]);
	}
	return result;
}
 
Example #25
Source File: AppraisePluginUtils.java    From git-appraise-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the git repository object (if any) associated with the given task repository.
 */
public static Repository getGitRepoForRepository(TaskRepository repo) {
  IProject project = getProjectForRepository(repo);
  GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project, GitProvider.ID);
  if (provider != null) {
    return provider.getData().getRepositoryMapping(project).getRepository();
  }
  return null;
}
 
Example #26
Source File: CustomPopupMenuExtender.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private boolean isLocalProject(IProject project) {
    return !RepositoryProvider.isShared(project);
}
 
Example #27
Source File: NonSharedProjectFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static boolean isSharedProject(IProject project) {
	return !project.isAccessible() || RepositoryProvider.isShared(project) && !isBinaryPDEProject(project);
}
 
Example #28
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;
     }
 
Example #29
Source File: SVNFileModificationValidator.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IStatus validateEdit(IFile[] files, Object context) {
     String comment = "";
     boolean stealLock = false;
     // reduce the array to just read only files
     ReadOnlyFiles readOnlyFiles = processFileArray(files);
     if (readOnlyFiles.size() == 0) return Status.OK_STATUS;
     // of the read-only files, get array of ones which are versioned
  IFile[] managedFiles = readOnlyFiles.getManaged();
  if (managedFiles.length > 0) {
  	// Prompt user to lock files
  	if (context != null) {
  		ISVNFileModificationValidatorPrompt svnFileModificationValidatorPrompt = 
  			SVNProviderPlugin.getPlugin().getSvnFileModificationValidatorPrompt();
  		if (svnFileModificationValidatorPrompt != null) {
  			if (!svnFileModificationValidatorPrompt.prompt(managedFiles, context))
  				return Status.CANCEL_STATUS;
  			comment = svnFileModificationValidatorPrompt.getComment();
  			stealLock = svnFileModificationValidatorPrompt.isStealLock();
  		}
  	}
  	// Run the svn lock command
  	RepositoryProvider provider = RepositoryProvider.getProvider(managedFiles[0].getProject());
  	if ((provider != null) && (provider instanceof SVNTeamProvider)) {
  		SVNTeamProvider svnTeamProvider = (SVNTeamProvider) provider;
  		LockResourcesCommand command = new LockResourcesCommand(svnTeamProvider.getSVNWorkspaceRoot(), managedFiles, stealLock, comment, false);
  		try {
  			command.run(new NullProgressMonitor());
  		} catch (SVNException e) {
  			SVNProviderPlugin.log(IStatus.ERROR, e.getMessage(), e);
  			return Status.CANCEL_STATUS;
  		}
  	}
     }
  // Process any unmanaged but read-only files.  For
  // those we need to prompt the user to flip the read only bit
  IFile[] unManagedFiles = readOnlyFiles.getUnManaged();
  if (unManagedFiles.length > 0) {
   synchronized (this) {
       if (uiValidator == null) 
           uiValidator = loadUIValidator();
   }
   if (uiValidator != null) {
       return uiValidator.validateEdit(unManagedFiles, context);
   }
   // There was no plugged in validator so fail gracefully
return getStatus(unManagedFiles); 
  }
  return Status.OK_STATUS;
 }
 
Example #30
Source File: LocalResource.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SVNWorkspaceRoot getWorkspaceRoot() {
	SVNTeamProvider teamProvider = (SVNTeamProvider)RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
	if (teamProvider == null) return null;
	return teamProvider.getSVNWorkspaceRoot();
}