use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.
the class ResolveSynchronizeOperation method run.
protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
boolean folderSelected = false;
propertyConflicts = false;
textConflicts = false;
treeConflicts = false;
canceled = false;
final IResource[] resources = set.getResources();
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IContainer) {
folderSelected = true;
break;
}
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 (folderSelected) {
selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
} else {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (propertyConflicts && !textConflicts) {
String message;
if (resources.length > 1)
// $NON-NLS-1$
message = Policy.bind("ResolveAction.confirmMultiple");
else
message = Policy.bind("ResolveAction.confirm", // $NON-NLS-1$
resources[0].getName());
if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), message)) {
// $NON-NLS-1$
canceled = true;
return;
}
selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
} else {
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) {
canceled = true;
return;
}
selectedResolution = markResolvedPage.getResolution();
}
}
});
}
if (canceled)
return;
run(new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws InvocationTargetException {
ISVNRepositoryLocation repository = null;
ISVNClientAdapter svnClient = null;
try {
for (int i = 0; i < resources.length; i++) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
svnClient.resolve(resources[i].getLocation().toFile(), selectedResolution);
repository.returnSVNClient(svnClient);
repository = null;
svnClient = null;
// for some reason, just refreshing the file won't cut it.
resources[i].getParent().refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} catch (SVNClientException e) {
throw new InvocationTargetException(e);
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
}
use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.
the class RevertSynchronizeOperation method isExternal.
private boolean isExternal(IResource resource) {
IResource parent = resource;
while (parent != null) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
try {
LocalResourceStatus status = svnResource.getStatus();
if (status.isFileExternal() || SVNStatusKind.EXTERNAL.equals(status.getTextStatus())) {
return true;
}
} catch (SVNException e) {
return false;
}
parent = parent.getParent();
}
return false;
}
use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.
the class SVNMarkerListener method resourceSyncInfoChanged.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.IResourceStateChangeListener#resourceSyncInfoChanged(org.eclipse.core.resources.IResource[])
*/
public void resourceSyncInfoChanged(IResource[] changedResources) {
for (int i = 0; i < changedResources.length; i++) {
try {
if (changedResources[i].exists()) {
changedResources[i].deleteMarkers("org.tigris.subversion.subclipse.ui.conflictMarker", true, // $NON-NLS-1$
IResource.DEPTH_ZERO);
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(changedResources[i]);
LocalResourceStatus status = svnResource.getStatus();
if (status.isTextConflicted() || status.isPropConflicted() || status.hasTreeConflict()) {
try {
IMarker marker = changedResources[i].createMarker(// $NON-NLS-1$
"org.tigris.subversion.subclipse.ui.conflictMarker");
setMessage(status, marker);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
// $NON-NLS-1$
marker.setAttribute("textConflict", status.isTextConflicted());
// $NON-NLS-1$
marker.setAttribute("propertyConflict", status.isPropConflicted());
// $NON-NLS-1$
marker.setAttribute("treeConflict", status.hasTreeConflict());
} catch (Exception e) {
SVNUIPlugin.log(e.getMessage());
}
}
}
} catch (Exception e) {
SVNUIPlugin.log(e.getMessage());
}
}
if (!treeConflictsViewRefreshed) {
treeConflictsViewRefreshed = TreeConflictsView.refresh(changedResources);
}
}
use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.
the class BranchTagAction 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 SwitchAction 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;
}
}
Aggregations