Search in sources :

Example 1 with DifferencesDialog

use of org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog in project subclipse by subclipse.

the class CompareRevisionsAction method run.

public void run() {
    RevisionGraphEditorInput input = (RevisionGraphEditorInput) editor.getEditorInput();
    boolean isFolder = (input.getResource() != null && input.getResource().getType() != IResource.FILE) || (input.getRemoteResource() != null && input.getRemoteResource().isFolder());
    ISVNInfo info = input.getInfo();
    try {
        ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
        ISVNRemoteResource remoteResource1;
        ISVNRemoteResource remoteResource2;
        if (isFolder) {
            remoteResource1 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
            remoteResource2 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
        } else {
            remoteResource1 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
            remoteResource2 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
        }
        ISVNRemoteResource[] selectedResources = { remoteResource1, remoteResource2 };
        DifferencesDialog dialog = new DifferencesDialog(Display.getDefault().getActiveShell(), null, selectedResources, editor.getEditorSite().getPart());
        dialog.setFromRevision(Long.toString(node1.getRevision()));
        dialog.setToRevision(Long.toString(node2.getRevision()));
        dialog.open();
    } catch (Exception e) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Compare Revisions", e.getMessage());
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) DifferencesDialog(org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Example 2 with DifferencesDialog

use of org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog in project subclipse by subclipse.

the class ShowDifferencesAsUnifiedDiffAction method execute.

// 
// private IResource localResource;
// 
// public void setLocalResource(IResource localResource) {
// this.localResource = localResource;
// }
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    pegRevision1 = null;
    pegRevision2 = null;
    String fromRevision = null;
    String toRevision = null;
    ISVNResource[] selectedResources = getSelectedRemoteResources();
    SVNUrl fromUrl = null;
    SVNUrl toUrl = null;
    if (selectedResources == null || (selectedResources.length == 0)) {
        Object[] selectedObjects = selection.toArray();
        if (selectedObjects[0] instanceof ILogEntry) {
            selectedResources = new ISVNResource[2];
            selectedResources[0] = ((ILogEntry) selectedObjects[0]).getResource();
            fromRevision = ((ILogEntry) selectedObjects[0]).getRevision().toString();
            ILogEntry logEntry1 = (ILogEntry) selectedObjects[0];
            RemoteResource remoteResource;
            IResource resource1 = logEntry1.getResource().getResource();
            if (resource1 != null) {
                try {
                    ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource1);
                    if (baseResource != null) {
                        pegRevision1 = baseResource.getLastChangedRevision();
                    }
                } catch (Exception e) {
                }
            }
            if (logEntry1.getResource().getResource() instanceof IContainer) {
                remoteResource = new RemoteFolder(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
            } else {
                remoteResource = new RemoteFile(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
            }
            fromUrl = remoteResource.getUrl();
            if (selectedObjects.length > 1) {
                selectedResources[1] = ((ILogEntry) selectedObjects[1]).getResource();
                toRevision = ((ILogEntry) selectedObjects[1]).getRevision().toString();
                ILogEntry logEntry2 = (ILogEntry) selectedObjects[1];
                IResource resource2 = logEntry2.getResource().getResource();
                if (resource2 != null) {
                    try {
                        ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource2);
                        if (baseResource != null) {
                            pegRevision2 = baseResource.getLastChangedRevision();
                        }
                    } catch (Exception e) {
                    }
                }
                if (logEntry2.getResource().getResource() instanceof IContainer) {
                    remoteResource = new RemoteFolder(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
                } else {
                    remoteResource = new RemoteFile(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
                }
                toUrl = remoteResource.getUrl();
            } else {
                int from = Integer.parseInt(fromRevision);
                from--;
                toRevision = Integer.toString(from);
                toUrl = remoteResource.getUrl();
            }
        }
    } else {
        if (selectedResources[0] instanceof ISVNRemoteResource)
            fromRevision = ((ISVNRemoteResource) selectedResources[0]).getRevision().toString();
        if (selectedResources.length > 1 && selectedResources[1] instanceof ISVNRemoteResource)
            toRevision = ((ISVNRemoteResource) selectedResources[1]).getRevision().toString();
    }
    if (pegRevision1 == null) {
        pegRevision1 = SVNRevision.HEAD;
    }
    if (pegRevision2 == null) {
        pegRevision2 = pegRevision1;
    }
    DifferencesDialog dialog = new DifferencesDialog(getShell(), null, selectedResources, new SVNRevision[] { pegRevision1, pegRevision2 }, getTargetPart());
    dialog.setUsePegRevision(usePegRevision);
    dialog.setFromUrl(fromUrl);
    dialog.setToUrl(toUrl);
    IResource localResource = null;
    IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    if (part instanceof GenericHistoryView) {
        IHistoryPage historyPage = ((GenericHistoryView) part).getHistoryPage();
        if (historyPage instanceof SVNHistoryPage) {
            localResource = ((SVNHistoryPage) historyPage).getResource();
        }
    }
    dialog.setLocalResource(localResource);
    // $NON-NLS-1$
    if (!fromRevision.equals("HEAD"))
        dialog.setFromRevision(fromRevision);
    if (toRevision != null && !toRevision.equals("HEAD"))
        // $NON-NLS-1$
        dialog.setToRevision(toRevision);
    dialog.open();
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) RemoteResource(org.tigris.subversion.subclipse.core.resources.RemoteResource) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) IHistoryPage(org.eclipse.team.ui.history.IHistoryPage) DifferencesDialog(org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SVNHistoryPage(org.tigris.subversion.subclipse.ui.history.SVNHistoryPage) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Aggregations

ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)2 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)2 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)2 DifferencesDialog (org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog)2 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IContainer (org.eclipse.core.resources.IContainer)1 IResource (org.eclipse.core.resources.IResource)1 TeamException (org.eclipse.team.core.TeamException)1 GenericHistoryView (org.eclipse.team.internal.ui.history.GenericHistoryView)1 IHistoryPage (org.eclipse.team.ui.history.IHistoryPage)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)1 ISVNResource (org.tigris.subversion.subclipse.core.ISVNResource)1 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)1 RemoteResource (org.tigris.subversion.subclipse.core.resources.RemoteResource)1 RevisionGraphEditorInput (org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput)1 SVNHistoryPage (org.tigris.subversion.subclipse.ui.history.SVNHistoryPage)1 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)1