use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus 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.resources.LocalResourceStatus 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.resources.LocalResourceStatus in project subclipse by subclipse.
the class WorkspaceAction method isEnabledForSVNResource.
/**
* Method isEnabledForSVNResource.
*
* @param svnResource
* @return boolean
*/
protected boolean isEnabledForSVNResource(ISVNLocalResource svnResource) throws SVNException {
if (isEnabledForIgnoredResources() && isEnabledForManagedResources() && isEnabledForUnmanagedResources() && isEnabledForAddedResources() && isEnabledForCopiedResources()) {
return true;
}
LocalResourceStatus status = svnResource.getStatusFromCache();
boolean managed = false;
boolean ignored = false;
boolean added = false;
boolean copied = false;
if (!isEnabledForIgnoredResources()) {
if (!status.isManaged() && status.isIgnored()) {
ignored = true;
} else {
ignored = svnResource.isIgnored();
}
}
if (!ignored) {
managed = status.isManaged();
if (managed) {
copied = status.isCopied();
added = status.isAdded();
}
}
if (managed && !isEnabledForManagedResources())
return false;
if (!managed && !isEnabledForUnmanagedResources())
return false;
if (ignored && !isEnabledForIgnoredResources())
return false;
if (copied && added) {
if (!isEnabledForCopiedResources())
return false;
} else if (added && !isEnabledForAddedResources()) {
return false;
}
return true;
}
use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.
the class ResolveActionWithChoices method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
boolean folderSelected = false;
boolean propertyConflicts = false;
boolean textConflicts = false;
boolean treeConflicts = false;
boolean treeConflictDialogShown = false;
IResource[] resources = getSelectedResources();
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IContainer) {
folderSelected = true;
}
if (!propertyConflicts || !textConflicts || !treeConflicts) {
ISVNLocalResource resource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
try {
LocalResourceStatus status = resource.getStatus();
if (status != null && status.isPropConflicted())
propertyConflicts = true;
if (status != null && status.isTextConflicted())
textConflicts = true;
if (status != null && status.hasTreeConflict())
treeConflicts = true;
} catch (SVNException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
}
}
if (resources.length == 1 && treeConflicts && !propertyConflicts && !textConflicts) {
treeConflict = getTreeConflict(resources[0]);
if (treeConflict != null) {
ResolveTreeConflictWizard wizard = new ResolveTreeConflictWizard(treeConflict, getTargetPart());
WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, // $NON-NLS-1$
"ResolveTreeConflict");
if (dialog.open() != WizardDialog.OK)
return;
treeConflictDialogShown = true;
}
}
if (resources.length > 1 && treeConflicts) {
if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), Policy.bind("ResolveAction.confirmTreeConflicts")))
// $NON-NLS-1$ //$NON-NLS-2$
return;
setResolution(ISVNConflictResolver.Choice.chooseMerged);
} else if (!treeConflictDialogShown) {
SvnWizardMarkResolvedPage markResolvedPage = new SvnWizardMarkResolvedPage(resources);
markResolvedPage.setPropertyConflicts(propertyConflicts);
markResolvedPage.setTreeConflicts(treeConflicts);
SvnWizard wizard = new SvnWizard(markResolvedPage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.CANCEL)
return;
setResolution(markResolvedPage.getResolution());
}
if (!treeConflictDialogShown)
super.execute(action);
}
use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.
the class StatusCacheManager method getStatus.
/**
* get the status of the given resource
*
* @throws SVNException
*/
private LocalResourceStatus getStatus(IResource resource, StatusUpdateStrategy strategy, boolean getStatusFromSvn) throws SVNException {
if (!resource.exists() && !resource.isPhantom()) {
return null;
}
LocalResourceStatus status = null;
status = statusCache.getStatus(resource);
// we get it using svn
if (status == null && getStatusFromSvn) {
status = basicGetStatus(resource, strategy);
}
return status;
}
Aggregations