use of org.tigris.subversion.subclipse.ui.compare.SVNLocalBranchTagCompareInput in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffActionWC method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
IResource[] resources = getSelectedResources();
boolean refreshFile = false;
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFile && !resources[i].isSynchronized(Depth.immediates)) {
if (refreshFile || MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"))) {
refreshFile = true;
try {
resources[i].refreshLocal(Depth.immediates, new NullProgressMonitor());
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
} else {
break;
}
}
}
if (resources.length > 1) {
SvnWizardCompareMultipleResourcesWithBranchTagPage comparePage = new SvnWizardCompareMultipleResourcesWithBranchTagPage(resources);
SvnWizard wizard = new SvnWizard(comparePage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
if (dialog.open() == SvnWizardDialog.OK) {
ISVNLocalResource[] localResources = new ISVNLocalResource[resources.length];
for (int i = 0; i < resources.length; i++) {
localResources[i] = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
}
try {
SVNLocalBranchTagCompareInput compareInput = new SVNLocalBranchTagCompareInput(localResources, comparePage.getUrls(), comparePage.getRevision(), getTargetPart());
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} catch (SVNException e) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), e.getMessage());
}
}
return;
}
ShowDifferencesAsUnifiedDiffDialogWC dialog = new ShowDifferencesAsUnifiedDiffDialogWC(getShell(), resources[0], getTargetPart());
if (dialog.open() == ShowDifferencesAsUnifiedDiffDialogWC.OK) {
try {
if (dialog.isDiffToOutputFile())
dialog.getOperation().run();
if (!dialog.isDiffToOutputFile()) {
SVNRevision pegRevision = dialog.getPegRevision();
if (pegRevision == null) {
pegRevision = SVNRevision.HEAD;
}
if (resources[0] instanceof IContainer) {
ISVNRemoteFolder remoteFolder = new RemoteFolder(dialog.getSvnResource().getRepository(), dialog.getToUrl(), dialog.getToRevision());
((RemoteFolder) remoteFolder).setPegRevision(pegRevision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(dialog.getSvnResource(), remoteFolder, pegRevision);
compareInput.setDiffOperation(dialog.getOperation());
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
} else {
ISVNRemoteFile remoteFile = new RemoteFile(dialog.getSvnResource().getRepository(), dialog.getToUrl(), dialog.getToRevision());
((RemoteFile) remoteFile).setPegRevision(pegRevision);
SVNLocalCompareInput compareInput = new SVNLocalCompareInput(dialog.getSvnResource(), remoteFile, pegRevision);
CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
}
}
} catch (SVNException e) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), e.getMessage());
}
}
}
Aggregations