use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class SVNSynchronizeOperation method run.
/* (non-Javadoc)
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
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();
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class UnmanageAction method getOperation.
/**
* get the WorkspaceModifyOperation. The operation will : - delete svn directories if this option
* has been chosen - unmap the project
*
* @return
*/
private IRunnableWithProgress getOperation() {
return new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws InvocationTargetException {
try {
// maps the selected resources (projects) to their providers
Hashtable table = getProviderMapping(getSelectedResources());
Set keySet = table.keySet();
// $NON-NLS-1$
monitor.beginTask("", keySet.size() * 1000);
// $NON-NLS-1$
monitor.setTaskName(Policy.bind("Unmanage.unmanaging"));
Iterator iterator = keySet.iterator();
while (iterator.hasNext()) {
IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1000);
subMonitor.beginTask(null, 100);
SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
// get the resources (projects) to unmanage for the given provider
List list = (List) table.get(provider);
IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
for (int i = 0; i < providerResources.length; i++) {
// get the folder for the project
IResource resource = providerResources[i];
ISVNLocalFolder folder = SVNWorkspaceRoot.getSVNFolderFor((IContainer) resource);
try {
if (deleteContent) {
folder.unmanage(Policy.subMonitorFor(subMonitor, 10));
}
} finally {
// We want to remove the nature even if the unmanage operation fails
RepositoryProvider.unmap((IProject) resource);
}
}
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
};
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class UnlockAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
if (action != null && !action.isEnabled()) {
action.setEnabled(true);
} else {
if (getSelectedResources() != null && getSelectedResources().length > 0) {
final IResource[] resources = getSelectedResources();
run(new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
try {
Hashtable table = getProviderMapping(getSelectedResources());
Set keySet = table.keySet();
Iterator iterator = keySet.iterator();
while (iterator.hasNext()) {
SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
UnlockResourcesCommand command = new UnlockResourcesCommand(provider.getSVNWorkspaceRoot(), resources, false);
command.run(Policy.subMonitorFor(monitor, 1000));
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
}, true, /* cancelable */
PROGRESS_DIALOG);
}
}
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class SVNFileModificationValidator method validateEdit.
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;
}
use of org.tigris.subversion.subclipse.core.SVNTeamProvider in project subclipse by subclipse.
the class SVNMoveDeleteHook method moveFile.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.team.IMoveDeleteHook#moveFile(org.eclipse.core.resources.team.IResourceTree,
* org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile,
* int, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean moveFile(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor) {
if (SVNWorkspaceRoot.isLinkedResource(source))
return false;
try {
RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(destination.getProject());
if (repositoryProvider == null || // target is not SVN project
!(repositoryProvider instanceof SVNTeamProvider))
return false;
ISVNLocalFile resource = new LocalFile(source);
// pass
if (!resource.isManaged())
return false;
ISVNRepositoryLocation sourceRepository = resource.getRepository();
ISVNClientAdapter svnClient = sourceRepository.getSVNClient();
ISVNLocalResource parent = SVNWorkspaceRoot.getSVNResourceFor(destination.getParent());
ISVNRepositoryLocation targetRepository = parent.getRepository();
if (!sourceRepository.equals(targetRepository)) {
return false;
}
monitor.beginTask(null, 1000);
try {
OperationManager.getInstance().beginOperation(svnClient);
// see bug #15
if (!SVNWorkspaceRoot.getSVNFolderFor(destination.getParent()).isManaged()) {
SVNTeamProvider provider = (SVNTeamProvider) repositoryProvider;
provider.add(new IResource[] { destination.getParent() }, IResource.DEPTH_ZERO, new NullProgressMonitor());
if (parent != null)
parent.refreshStatus();
}
// force is set to true because when we rename (refactor) a
// java class, the file is modified before being moved
// A modified file cannot be moved without force
svnClient.move(source.getLocation().toFile(), destination.getLocation().toFile(), true);
// movedFile must be done before endOperation because
// destination file must not already exist in the workspace
// resource tree.
tree.movedFile(source, destination);
destination.refreshLocal(IResource.DEPTH_ZERO, monitor);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} catch (TeamException e) {
throw SVNException.wrapException(e);
} catch (CoreException e) {
throw SVNException.wrapException(e);
} finally {
resource.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation(false, null, false);
}
} catch (SVNException e) {
tree.failed(e.getStatus());
} finally {
monitor.done();
}
return true;
}
Aggregations