use of org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareSummaryInput in project subclipse by subclipse.
the class CompareWithRemoteAction method execute.
public void execute(IAction action) {
refresh = false;
fileSelected = false;
final IResource[] resources = getSelectedResources();
if (resources.length != 1 && !SVNRevision.BASE.equals(revision) && !SVNRevision.HEAD.equals(revision)) {
return;
}
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFile) {
fileSelected = true;
if (!resources[i].isSynchronized(Depth.immediates)) {
refresh = MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"));
break;
}
}
}
try {
final ISVNLocalResource[] localResources = new ISVNLocalResource[resources.length];
for (int i = 0; i < resources.length; i++) {
localResources[i] = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
}
final ISVNLocalResource localResource = localResources[0];
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
try {
if (refresh) {
for (int i = 0; i < localResources.length; i++) {
if (resources[i] instanceof IFile) {
localResources[i].getResource().refreshLocal(Depth.immediates, monitor);
}
}
}
if (SVNRevision.BASE.equals(revision)) {
if (localResources.length == 1 && localResource.getResource() instanceof IFile) {
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
SVNLocalBaseCompareInput compareInput = new SVNLocalBaseCompareInput(localResources, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
} else {
if (!fileSelected) {
SVNLocalCompareSummaryInput compareInput = new SVNLocalCompareSummaryInput(localResources, revision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
ISVNRemoteFile remoteFile = new RemoteFile(localResource.getRepository(), localResource.getUrl(), revision);
((RemoteFile) remoteFile).setPegRevision(revision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFile);
ShowDifferencesAsUnifiedDiffOperationWC operation = null;
if (SVNRevision.HEAD.equals(revision)) {
File file = File.createTempFile("revision", ".diff");
file.deleteOnExit();
operation = new ShowDifferencesAsUnifiedDiffOperationWC(getTargetPart(), localResource.getFile(), localResource.getUrl(), SVNRevision.HEAD, file);
operation.setGraphicalCompare(true);
operation.run();
}
compareInput.setDiffOperation(operation);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
}
} catch (Exception e) {
handle(e, null, null);
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
} catch (Exception e) {
handle(e, null, null);
}
}
Aggregations