Search in sources :

Example 6 with MergeResultsFolder

use of com.collabnet.subversion.merge.MergeResultsFolder in project subclipse by subclipse.

the class ShowRemoteHistoryAction method getSelectedRemoteResources.

protected ISVNRemoteResource[] getSelectedRemoteResources() {
    MergeOutput mergeOutput = null;
    ISVNRemoteResource remoteResource = null;
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof MergeResult) {
            MergeResult mergeResult = (MergeResult) object;
            IResource resource = mergeResult.getResource();
            mergeOutput = mergeResult.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                String resourceSubString = resource.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
        if (object instanceof MergeResultsFolder) {
            MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) object;
            IContainer folder = mergeResultsFolder.getFolder();
            mergeOutput = mergeResultsFolder.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(folder);
            try {
                String resourceSubString = folder.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
    }
    if (remoteResource != null) {
        ISVNRemoteResource[] selectedResource = { remoteResource };
        SVNRevision.Number startRevision = null;
        try {
            startRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getLowerRevision()));
        } catch (ParseException e) {
        }
        SVNRevision.Number endRevision = null;
        if (mergeOutput.getUpperRevision() > 0) {
            try {
                endRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getUpperRevision()));
            } catch (ParseException e) {
            }
        }
        HistorySearchViewerFilter historySearchViewerFilter = new HistorySearchViewerFilter(null, null, null, null, true, startRevision, endRevision);
        SVNHistoryPage.setHistorySearchViewerFilter(historySearchViewerFilter);
        return selectedResource;
    }
    return new ISVNRemoteResource[0];
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) MergeResult(com.collabnet.subversion.merge.MergeResult) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ParseException(java.text.ParseException) MergeOutput(com.collabnet.subversion.merge.MergeOutput) Iterator(java.util.Iterator) HistorySearchViewerFilter(org.tigris.subversion.subclipse.ui.history.HistorySearchViewerFilter) MergeOptions(com.collabnet.subversion.merge.MergeOptions) ParseException(java.text.ParseException) IContainer(org.eclipse.core.resources.IContainer) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

Aggregations

MergeResult (com.collabnet.subversion.merge.MergeResult)6 MergeResultsFolder (com.collabnet.subversion.merge.MergeResultsFolder)6 MergeOutput (com.collabnet.subversion.merge.MergeOutput)5 Iterator (java.util.Iterator)3 ArrayList (java.util.ArrayList)2 IResource (org.eclipse.core.resources.IResource)2 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)2 SVNException (org.tigris.subversion.subclipse.core.SVNException)2 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)2 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)2 AdaptableMergeResult (com.collabnet.subversion.merge.AdaptableMergeResult)1 AdaptableMergeResultsFolder (com.collabnet.subversion.merge.AdaptableMergeResultsFolder)1 MergeOptions (com.collabnet.subversion.merge.MergeOptions)1 DialogWizard (com.collabnet.subversion.merge.wizards.DialogWizard)1 MergeWizardDialog (com.collabnet.subversion.merge.wizards.MergeWizardDialog)1 ParseException (java.text.ParseException)1 List (java.util.List)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IOpenListener (org.eclipse.jface.viewers.IOpenListener)1