Java Code Examples for org.eclipse.team.core.RepositoryProvider#getProvider()
The following examples show how to use
org.eclipse.team.core.RepositoryProvider#getProvider() .
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 |
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 |
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: CheckoutCommand.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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 4
Source File: SVNSynchronizeOperation.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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 5
Source File: SVNHistoryPage.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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 6
Source File: SVNWorkspaceSubscriber.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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: FilesInSyncFilter.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * {@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 8
Source File: CommitSynchronizeOperation.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 9
Source File: SVNProviderPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @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 10
Source File: SVNProjectSetCapability.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * 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 11
Source File: SVNWorkspaceRoot.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 12
Source File: SVNWorkspaceSubscriber.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 13
Source File: RelocateWizard.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 14
Source File: SVNWorkspaceSubscriber.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 15
Source File: CommitAction.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 16
Source File: CommitOperation.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 17
Source File: AppraisePluginUtils.java From git-appraise-eclipse with Eclipse Public License 1.0 | 5 votes |
/** * 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 18
Source File: WorkspaceAction.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * The action is enabled for the appropriate resources. This method checks * that: * <ol> * <li>there is no overlap between a selected file and folder (overlapping * folders is allowed because of logical vs. physical mapping problem in * views) * <li>the state of the resources match the conditions provided by: * <ul> * <li>isEnabledForIgnoredResources() * <li>isEnabledForManagedResources() * <li>isEnabledForUnManagedResources() (i.e. not ignored and not managed) * </ul> * </ol> * @see TeamAction#isEnabled() */ 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; // disable properly for single resource enablement if (!isEnabledForMultipleResources() && resources.length != 1) return false; // validate enabled for each resource in the selection List folderPaths = new ArrayList(); List filePaths = new ArrayList(); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; // only enable for accessible resources if ((! resource.isAccessible()) && (!isEnabledForInaccessibleResources())) return false; // 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; } // collect files and folders separately to check for overlap later IPath resourceFullPath = resource.getFullPath(); if(resource.getType() == IResource.FILE) { filePaths.add(resourceFullPath); } else { folderPaths.add(resourceFullPath); } // ensure that resource management state matches what the action requires ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource); if (!isEnabledForSVNResource(svnResource)) { return false; } } // Ensure that there is no overlap between files and folders // NOTE: folder overlap must be allowed because of logical vs. physical if(!folderPaths.isEmpty()) { for (Iterator fileIter = filePaths.iterator(); fileIter.hasNext();) { IPath resourcePath = (IPath) fileIter.next(); for (Iterator it = folderPaths.iterator(); it.hasNext();) { IPath folderPath = (IPath) it.next(); if (folderPath.isPrefixOf(resourcePath)) { return false; } } } } return true; }
Example 19
Source File: LocalResource.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public SVNWorkspaceRoot getWorkspaceRoot() { SVNTeamProvider teamProvider = (SVNTeamProvider)RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId()); if (teamProvider == null) return null; return teamProvider.getSVNWorkspaceRoot(); }
Example 20
Source File: SVNFileModificationValidator.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
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; }