Search in sources :

Example 1 with ShowDifferencesAsUnifiedDiffDialogWC

use of org.tigris.subversion.subclipse.ui.dialogs.ShowDifferencesAsUnifiedDiffDialogWC 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());
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SVNLocalCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput) IFile(org.eclipse.core.resources.IFile) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) ShowDifferencesAsUnifiedDiffDialogWC(org.tigris.subversion.subclipse.ui.dialogs.ShowDifferencesAsUnifiedDiffDialogWC) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) InvocationTargetException(java.lang.reflect.InvocationTargetException) SVNLocalBranchTagCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalBranchTagCompareInput) CoreException(org.eclipse.core.runtime.CoreException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) SvnWizardCompareMultipleResourcesWithBranchTagPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardCompareMultipleResourcesWithBranchTagPage) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)1 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)1 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)1 SVNLocalBranchTagCompareInput (org.tigris.subversion.subclipse.ui.compare.SVNLocalBranchTagCompareInput)1 SVNLocalCompareInput (org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput)1 ShowDifferencesAsUnifiedDiffDialogWC (org.tigris.subversion.subclipse.ui.dialogs.ShowDifferencesAsUnifiedDiffDialogWC)1 SvnWizard (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard)1 SvnWizardCompareMultipleResourcesWithBranchTagPage (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardCompareMultipleResourcesWithBranchTagPage)1 SvnWizardDialog (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog)1 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)1