Search in sources :

Example 1 with RemoteFile

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

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

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

the class SVNRepositoryLocation method getRemoteFile.

/*
   * (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNRepositoryLocation#getRemoteFile(org.tigris.subversion.svnclientadapter.SVNUrl)
   */
public ISVNRemoteFile getRemoteFile(SVNUrl url) throws SVNException {
    ISVNClientAdapter svnClient = getSVNClient();
    ISVNInfo info = null;
    try {
        if (this.getRepositoryRoot().equals(url))
            return new RemoteFile(this, url, SVNRevision.HEAD);
        else
            info = svnClient.getInfo(url, SVNRevision.HEAD, SVNRevision.HEAD);
    } catch (SVNClientException e) {
        throw new SVNException("Can't get latest remote resource for " + url);
    }
    if (// no remote file
    info == null)
        // no remote file
        return null;
    else {
        return new RemoteFile(// we don't know its parent
        null, this, url, SVNRevision.HEAD, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 4 with RemoteFile

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

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

the class RepositoriesView method createPartControl.

/*
   * @see WorkbenchPart#createPartControl
   */
public void createPartControl(Composite parent) {
    treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    contentProvider = new RemoteContentProvider();
    treeViewer.setContentProvider(contentProvider);
    final RepositoriesViewDecorator decorator = new RepositoriesViewDecorator();
    DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), new ILabelDecorator() {

        public Image decorateImage(Image image, Object obj) {
            if (obj instanceof RemoteFile) {
                RemoteFile remoteFile = (RemoteFile) obj;
                if (remoteFile.getLock() != null) {
                    return decorator.getImage(image);
                }
            }
            return null;
        }

        public String decorateText(String text, Object obj) {
            return null;
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object obj, String prop) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    treeViewer.setLabelProvider(labelProvider);
    getSite().setSelectionProvider(treeViewer);
    root = new AllRootsElement();
    treeViewer.setInput(root);
    treeViewer.setSorter(new RepositorySorter());
    drillPart = new DrillDownAdapter(treeViewer);
    contributeActions();
    // F1 Help
    String helpID = getHelpContextId();
    if (helpID != null)
        PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getControl(), helpID);
    initializeListeners();
    SVNUIPlugin.getPlugin().getRepositoryManager().addRepositoryListener(repositoryListener);
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) ILabelDecorator(org.eclipse.jface.viewers.ILabelDecorator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DecoratingLabelProvider(org.eclipse.jface.viewers.DecoratingLabelProvider) Image(org.eclipse.swt.graphics.Image) RemoteContentProvider(org.tigris.subversion.subclipse.ui.repository.model.RemoteContentProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) AllRootsElement(org.tigris.subversion.subclipse.ui.repository.model.AllRootsElement) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile)

Aggregations

RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)18 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)10 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)9 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)9 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)8 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)7 SVNException (org.tigris.subversion.subclipse.core.SVNException)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 TeamException (org.eclipse.team.core.TeamException)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IContainer (org.eclipse.core.resources.IContainer)3 IFile (org.eclipse.core.resources.IFile)3 IResource (org.eclipse.core.resources.IResource)3 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)3 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)3 LogEntryChangePath (org.tigris.subversion.subclipse.core.history.LogEntryChangePath)3 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2