use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class UndoMergeCommand method run.
public void run(IProgressMonitor monitor) throws SVNException {
ISVNClientAdapter svnClient = null;
ISVNRepositoryLocation repository = null;
try {
final OperationManager operationManager = OperationManager.getInstance();
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
svnClient.addNotifyListener(operationResourceCollector);
operationManager.beginOperation(svnClient);
LocalResourceStatus status = SVNWorkspaceRoot.getSVNResourceFor(resource).getStatus();
if (!status.isManaged()) {
try {
resource.delete(true, monitor);
} catch (CoreException ex) {
throw SVNException.wrapException(ex);
}
} else {
File path = resource.getLocation().toFile();
svnClient.revert(path, true);
if (resource.getType() != IResource.FILE)
operationManager.onNotify(path, SVNNodeKind.UNKNOWN);
monitor.worked(100);
}
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources());
monitor.done();
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class MergeWizard method getCommonRoot.
@SuppressWarnings("unchecked")
public String getCommonRoot() {
if (commonRoot == null) {
ArrayList urlList = new ArrayList();
for (int i = 0; i < resources.length; i++) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
try {
String anUrl = svnResource.getStatus().getUrlString();
if (anUrl != null)
urlList.add(anUrl);
} catch (SVNException e1) {
}
}
urlStrings = new String[urlList.size()];
urlList.toArray(urlStrings);
if (urlStrings.length == 0)
return null;
String urlString = urlStrings[0];
if (urlStrings.length == 1)
return urlString;
commonRoot = null;
tag1: for (int i = 0; i < urlString.length(); i++) {
String partialPath = urlString.substring(0, i + 1);
if (partialPath.endsWith("/")) {
// $NON-NLS-1$
for (int j = 1; j < urlStrings.length; j++) {
if (!urlStrings[j].startsWith(partialPath))
break tag1;
}
commonRoot = partialPath.substring(0, i);
}
}
}
return commonRoot;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class MergeAction method isEnabledForMultipleResources.
/*
* (non-Javadoc)
* @see org.tigris.subversion.subclipse.ui.actions.WorkspaceAction#isEnabledForMultipleResources()
*/
protected boolean isEnabledForMultipleResources() {
try {
// Must all be from same repository.
ISVNRepositoryLocation repository = null;
IResource[] selectedResources = getSelectedResources();
for (int i = 0; i < selectedResources.length; i++) {
ISVNRepositoryLocation compareToRepository = null;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(selectedResources[i]);
if (svnResource == null || !svnResource.isManaged()) {
return false;
}
LocalResourceStatus status = svnResource.getStatusFromCache();
if (status != null) {
compareToRepository = status.getRepository();
}
if (compareToRepository == null) {
return false;
}
if (repository != null && !compareToRepository.equals(repository)) {
return false;
}
repository = compareToRepository;
}
return true;
} catch (Exception e) {
return false;
}
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class AddAction method promptForAddOfIgnored.
/**
* asks the user if he wants to add the resources if some of them are ignored
*
* @return false if he answered no
*/
private boolean promptForAddOfIgnored() {
IResource[] resources = getSelectedResources();
boolean prompt = false;
for (int i = 0; i < resources.length; i++) {
ISVNLocalResource resource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
try {
if (resource.isIgnored()) {
prompt = true;
break;
}
} catch (SVNException e) {
handle(e);
}
}
if (prompt) {
return MessageDialog.openQuestion(getShell(), Policy.bind("AddAction.addIgnoredTitle"), // $NON-NLS-1$ //$NON-NLS-2$
Policy.bind("AddAction.addIgnoredQuestion"));
}
return true;
}
use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.
the class WorkspaceAction method getModifiedResources.
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
final List modified = new ArrayList();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// get adds, deletes, updates and property updates.
GetStatusCommand command = new GetStatusCommand(svnResource, true, false);
command.run(iProgressMonitor);
ISVNStatus[] statuses = command.getStatuses();
for (int j = 0; j < statuses.length; j++) {
if (SVNStatusUtils.isReadyForRevert(statuses[j]) || !SVNStatusUtils.isManaged(statuses[j])) {
IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
if (currentResource != null)
modified.add(currentResource);
}
}
}
return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
Aggregations