Search in sources :

Example 1 with ISVNRemoteFile

use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.

the class GetLogsCommand method run.

/**
 * execute the command
 *
 * @param aMonitor
 * @throws SVNException
 */
public void run(IProgressMonitor aMonitor) throws SVNException {
    ISVNRepositoryLocation repository = null;
    ISVNClientAdapter svnClient = null;
    logEntries = null;
    IProgressMonitor monitor = Policy.monitorFor(aMonitor);
    // $NON-NLS-1$
    monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100);
    ISVNLogMessage[] logMessages;
    try {
        if (callback == null) {
            logMessages = remoteResource.getLogMessages(pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions);
        } else {
            repository = remoteResource.getRepository();
            svnClient = repository.getSVNClient();
            if (remoteResource instanceof BaseResource) {
                boolean logMessagesRetrieved = false;
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(remoteResource.getResource());
                if (svnResource != null) {
                    LocalResourceStatus status = svnResource.getStatus();
                    if (status != null && status.isCopied()) {
                        ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
                        SVNUrl copiedFromUrl = info.getCopyUrl();
                        if (copiedFromUrl != null) {
                            svnClient.getLogMessages(copiedFromUrl, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
                            logMessagesRetrieved = true;
                            GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(remoteResource.getRepository(), copiedFromUrl, SVNRevision.HEAD);
                            getRemoteResourceCommand.run(null);
                            remoteResource = getRemoteResourceCommand.getRemoteResource();
                        }
                    }
                }
                if (!logMessagesRetrieved)
                    svnClient.getLogMessages(((BaseResource) remoteResource).getFile(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
            } else {
                svnClient.getLogMessages(remoteResource.getUrl(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
            }
            logMessages = callback.getLogMessages();
        }
        if (remoteResource.isFolder()) {
            logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFolder) remoteResource, logMessages, getTags(logMessages));
        } else {
            logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFile) remoteResource, logMessages, getTags(logMessages), getUrls(logMessages));
        }
    } catch (Exception e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        monitor.done();
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) BaseResource(org.tigris.subversion.subclipse.core.resources.BaseResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 2 with ISVNRemoteFile

use of org.tigris.subversion.subclipse.core.ISVNRemoteFile 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 3 with ISVNRemoteFile

use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.

the class SVNHistoryPage method getGetContentsAction.

// get contents Action (context menu)
private IAction getGetContentsAction() {
    if (getContentsAction == null) {
        getContentsAction = getContextMenuAction(Policy.bind("HistoryView.getContentsAction"), new // $NON-NLS-1$
        IWorkspaceRunnable() {

            public void run(IProgressMonitor monitor) throws CoreException {
                ISelection selection = getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                IStructuredSelection ss = (IStructuredSelection) selection;
                ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
                monitor.beginTask(null, 100);
                try {
                    if (remoteFile != null) {
                        if (confirmOverwrite()) {
                            if (remoteFile instanceof RemoteResource) {
                                if (resource != null) {
                                    ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                                    ((RemoteResource) remoteFile).setPegRevision(localResource.getRevision());
                                } else {
                                    ((RemoteResource) remoteFile).setPegRevision(SVNRevision.HEAD);
                                }
                            }
                            InputStream in = ((IResourceVariant) remoteFile).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
                            IFile file = (IFile) resource;
                            file.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
                        }
                    }
                } catch (TeamException e) {
                    throw new CoreException(e.getStatus());
                } finally {
                    monitor.done();
                }
            }
        });
        PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION);
    }
    return getContentsAction;
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RemoteResource(org.tigris.subversion.subclipse.core.resources.RemoteResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) InputStream(java.io.InputStream) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 4 with ISVNRemoteFile

use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.

the class SVNHistoryPage method getUpdateToRevisionAction.

// update to the selected revision (context menu)
private IAction getUpdateToRevisionAction() {
    if (updateToRevisionAction == null) {
        updateToRevisionAction = getContextMenuAction(Policy.bind("HistoryView.getRevisionAction"), new // $NON-NLS-1$
        IWorkspaceRunnable() {

            public void run(IProgressMonitor monitor) throws CoreException {
                ISelection selection = getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                IStructuredSelection ss = (IStructuredSelection) selection;
                ISVNRemoteFile remoteFile = (ISVNRemoteFile) getLogEntry(ss).getRemoteResource();
                try {
                    if (remoteFile != null) {
                        if (confirmOverwrite()) {
                            IFile file = (IFile) resource;
                            new ReplaceOperation(getSite().getPage().getActivePart(), file, remoteFile.getLastChangedRevision()).run(monitor);
                            historyTableProvider.setRemoteResource(remoteFile);
                            historyTableProvider.setProjectProperties(ProjectProperties.getProjectProperties(resource));
                            Display.getDefault().asyncExec(new Runnable() {

                                public void run() {
                                    tableHistoryViewer.refresh();
                                }
                            });
                        }
                    }
                } catch (InvocationTargetException e) {
                    throw new CoreException(new SVNStatus(IStatus.ERROR, 0, e.getMessage()));
                } catch (InterruptedException e) {
                // Cancelled by user
                }
            }
        });
        PlatformUI.getWorkbench().getHelpSystem().setHelp(updateToRevisionAction, IHelpContextIds.GET_FILE_REVISION_ACTION);
    }
    return updateToRevisionAction;
}
Also used : SVNStatus(org.tigris.subversion.subclipse.core.SVNStatus) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) ReplaceOperation(org.tigris.subversion.subclipse.ui.operations.ReplaceOperation) CoreException(org.eclipse.core.runtime.CoreException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 5 with ISVNRemoteFile

use of org.tigris.subversion.subclipse.core.ISVNRemoteFile in project subclipse by subclipse.

the class RepositoriesView method handleDoubleClick.

/**
 * The mouse has been double-clicked in the tree, perform appropriate behaviour.
 */
private void handleDoubleClick(DoubleClickEvent e) {
    // Only act on single selection
    ISelection selection = e.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structured = (IStructuredSelection) selection;
        if (structured.size() == 1) {
            Object first = structured.getFirstElement();
            if (first instanceof ISVNRemoteFile) {
                // It's a file, open it.
                openAction.selectionChanged(null, selection);
                openAction.run(null);
            } else {
                // Try to expand/contract
                treeViewer.setExpandedState(first, !treeViewer.getExpandedState(first));
            }
        }
    }
}
Also used : ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IFile (org.eclipse.core.resources.IFile)5 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)5 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 CoreException (org.eclipse.core.runtime.CoreException)4 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)4 SVNException (org.tigris.subversion.subclipse.core.SVNException)4 InputStream (java.io.InputStream)3 ISelection (org.eclipse.jface.viewers.ISelection)3 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)3 Iterator (java.util.Iterator)2 IResource (org.eclipse.core.resources.IResource)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2