Search in sources :

Example 1 with SVNLocalCompareSummaryInput

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);
    }
}
Also used : SVNLocalCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput) IFile(org.eclipse.core.resources.IFile) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ShowDifferencesAsUnifiedDiffOperationWC(org.tigris.subversion.subclipse.ui.operations.ShowDifferencesAsUnifiedDiffOperationWC) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) SVNLocalBaseCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalBaseCompareInput) SVNLocalCompareSummaryInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareSummaryInput) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) File(java.io.File) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) IFile(org.eclipse.core.resources.IFile) IResource(org.eclipse.core.resources.IResource) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Aggregations

File (java.io.File)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)1 SVNLocalBaseCompareInput (org.tigris.subversion.subclipse.ui.compare.SVNLocalBaseCompareInput)1 SVNLocalCompareInput (org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput)1 SVNLocalCompareSummaryInput (org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareSummaryInput)1 ShowDifferencesAsUnifiedDiffOperationWC (org.tigris.subversion.subclipse.ui.operations.ShowDifferencesAsUnifiedDiffOperationWC)1