use of org.tigris.subversion.subclipse.core.commands.LockResourcesCommand 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.commands.LockResourcesCommand in project subclipse by subclipse.
the class LockAction 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();
SvnWizardLockPage lockPage = new SvnWizardLockPage(resources);
SvnWizard wizard = new SvnWizard(lockPage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.OK) {
final String comment = lockPage.getComment();
final boolean stealLock = lockPage.isStealLock();
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();
LockResourcesCommand command = new LockResourcesCommand(provider.getSVNWorkspaceRoot(), resources, stealLock, comment);
command.run(Policy.subMonitorFor(monitor, 1000));
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
}, true, /* cancelable */
PROGRESS_DIALOG);
}
}
}
}
Aggregations