Search in sources :

Example 1 with RemoteFolder

use of org.tigris.subversion.subclipse.core.resources.RemoteFolder 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 RemoteFolder

use of org.tigris.subversion.subclipse.core.resources.RemoteFolder in project subclipse by subclipse.

the class GetRemoteResourceCommand method run.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
   */
public void run(IProgressMonitor monitor) throws SVNException {
    monitor = Policy.monitorFor(monitor);
    // $NON-NLS-1$
    monitor.beginTask(Policy.bind("GetRemoteResourceCommand.getLogEntries"), 100);
    remoteResource = null;
    ISVNClientAdapter svnClient = repository.getSVNClient();
    ISVNInfo info;
    try {
        info = svnClient.getInfo(url, revision, revision);
    } catch (SVNClientException e) {
        throw new SVNException("Can't get remote resource " + url + " at revision " + revision, e);
    } finally {
        repository.returnSVNClient(svnClient);
    }
    if (info == null) {
        // no remote file
        remoteResource = null;
    } else {
        if (info.getNodeKind() == SVNNodeKind.FILE)
            remoteResource = new RemoteFile(// we don't know its parent
            null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
        else
            remoteResource = new RemoteFolder(// we don't know its parent
            null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
    }
    monitor.done();
}
Also used : RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 3 with RemoteFolder

use of org.tigris.subversion.subclipse.core.resources.RemoteFolder in project subclipse by subclipse.

the class SVNHistoryPage method getCompareWithPreviousChangedPathAction.

private IAction getCompareWithPreviousChangedPathAction() {
    if (compareWithPreviousChangedPathAction == null) {
        compareWithPreviousChangedPathAction = new Action() {

            public void run() {
                CompareRemoteResourcesAction delegate = new CompareRemoteResourcesAction();
                delegate.init(this);
                ISVNRemoteResource remoteResource1 = null;
                Object firstSelection = ((IStructuredSelection) changePathsViewer.getSelection()).getFirstElement();
                if (firstSelection instanceof LogEntryChangePath) {
                    LogEntryChangePath logEntryChangePath = (LogEntryChangePath) firstSelection;
                    try {
                        remoteResource1 = logEntryChangePath.getRemoteResource();
                    } catch (SVNException e1) {
                        SVNUIPlugin.openError(getSite().getShell(), null, null, e1, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
                        return;
                    }
                } else if (firstSelection instanceof HistoryFolder) {
                    HistoryFolder historyFolder = (HistoryFolder) firstSelection;
                    Object[] children = historyFolder.getChildren();
                    if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                        LogEntryChangePath logEntryChangePath = (LogEntryChangePath) children[0];
                        try {
                            SVNUrl svnUrl = logEntryChangePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath()).getUrl();
                            SVNRevision.Number selectedRevision = (SVNRevision.Number) getSelectedRevision();
                            remoteResource1 = new RemoteFolder(null, logEntryChangePath.getLogEntry().getRemoteResource().getRepository(), svnUrl, selectedRevision, selectedRevision, null, null);
                        } catch (Exception e) {
                        }
                    }
                }
                if (remoteResource1 == null) {
                    return;
                }
                int from = Integer.parseInt(remoteResource1.getRevision().toString());
                from--;
                String to = Integer.toString(from);
                SVNRevision toRevision = null;
                try {
                    toRevision = SVNRevision.getRevision(to);
                } catch (ParseException e) {
                }
                ISVNRemoteResource[] remoteResources = new ISVNRemoteResource[2];
                ISVNRemoteResource remoteResource2;
                if (firstSelection instanceof HistoryFolder || remoteResource1.getResource() instanceof IContainer) {
                    remoteResource2 = new RemoteFolder(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
                } else {
                    remoteResource2 = new RemoteFile(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
                }
                remoteResources[0] = remoteResource1;
                remoteResources[1] = remoteResource2;
                delegate.selectionChanged(this, new StructuredSelection(remoteResources));
                delegate.setRemoteResources(remoteResources);
                delegate.setLocalResource(remoteResource1.getResource());
                delegate.setLocalResources(remoteResources);
                SVNRevision[] pegRevisions = { remoteResource1.getRevision() };
                delegate.setPegRevisions(pegRevisions);
                delegate.run(this);
            }
        };
    }
    return compareWithPreviousChangedPathAction;
}
Also used : CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) ExportRemoteFolderAction(org.tigris.subversion.subclipse.ui.actions.ExportRemoteFolderAction) ShowDifferencesAsUnifiedDiffAction(org.tigris.subversion.subclipse.ui.actions.ShowDifferencesAsUnifiedDiffAction) TextViewerAction(org.tigris.subversion.subclipse.ui.console.TextViewerAction) ShowAnnotationAction(org.tigris.subversion.subclipse.ui.actions.ShowAnnotationAction) ShowHistoryAction(org.tigris.subversion.subclipse.ui.actions.ShowHistoryAction) WorkspaceAction(org.tigris.subversion.subclipse.ui.actions.WorkspaceAction) IAction(org.eclipse.jface.action.IAction) OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) GenerateChangeLogAction(org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction) Action(org.eclipse.jface.action.Action) CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) ParseException(java.text.ParseException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IContainer(org.eclipse.core.resources.IContainer) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile)

Example 4 with RemoteFolder

use of org.tigris.subversion.subclipse.core.resources.RemoteFolder in project subclipse by subclipse.

the class ComparePropertiesDialog method okPressed.

@Override
protected void okPressed() {
    try {
        if (fromWorkingCopyButton.getSelection()) {
            left = new PropertyCompareLocalResourceNode(fromLocalResource, recursiveButton.getSelection(), null);
        } else {
            SVNRevision revision = null;
            if (fromHeadButton.getSelection()) {
                revision = SVNRevision.HEAD;
            } else {
                revision = new SVNRevision.Number(Long.parseLong(fromRevisionText.getText()));
            }
            RemoteFolder remoteFolder = new RemoteFolder(repository, new SVNUrl(fromRepositoryText.getText().trim()), revision);
            left = new PropertyCompareRemoteResourceNode(remoteFolder, revision, recursiveButton.getSelection(), null);
        }
        if (toWorkingCopyButton.getSelection()) {
            right = new PropertyCompareLocalResourceNode(toLocalResource, recursiveButton.getSelection(), null);
        } else {
            SVNRevision revision = null;
            if (toHeadButton.getSelection()) {
                revision = SVNRevision.HEAD;
            } else {
                revision = new SVNRevision.Number(Long.parseLong(toRevisionText.getText()));
            }
            RemoteFolder remoteFolder = new RemoteFolder(repository, new SVNUrl(toRepositoryText.getText().trim()), revision);
            right = new PropertyCompareRemoteResourceNode(remoteFolder, revision, recursiveButton.getSelection(), null);
        }
        input = new PropertyCompareInput(left, right, recursiveButton.getSelection());
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("ComparePropertiesDialog.1"), // $NON-NLS-1$
        e.getMessage());
        return;
    }
    super.okPressed();
}
Also used : PropertyCompareLocalResourceNode(org.tigris.subversion.subclipse.ui.compare.PropertyCompareLocalResourceNode) PropertyCompareInput(org.tigris.subversion.subclipse.ui.compare.PropertyCompareInput) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) PropertyCompareRemoteResourceNode(org.tigris.subversion.subclipse.ui.compare.PropertyCompareRemoteResourceNode) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 5 with RemoteFolder

use of org.tigris.subversion.subclipse.core.resources.RemoteFolder 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

RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)11 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)9 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)5 TeamException (org.eclipse.team.core.TeamException)4 SVNException (org.tigris.subversion.subclipse.core.SVNException)4 IContainer (org.eclipse.core.resources.IContainer)3 IResource (org.eclipse.core.resources.IResource)3 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)2 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)2 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)2 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)2 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)2 RemoteResource (org.tigris.subversion.subclipse.core.resources.RemoteResource)2