Search in sources :

Example 6 with ISVNRemoteFile

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

the class RepositoriesView method getStatusLineMessage.

/**
 * When selection is changed we update the status line
 */
private String getStatusLineMessage(ISelection selection) {
    // $NON-NLS-1$
    if (selection == null || selection.isEmpty())
        return "";
    // $NON-NLS-1$
    if (!(selection instanceof IStructuredSelection))
        return "";
    IStructuredSelection s = (IStructuredSelection) selection;
    if (s.size() > 1)
        return Policy.bind("RepositoriesView.NItemsSelected", // $NON-NLS-1$
        String.valueOf(s.size()));
    Object element = SVNAction.getAdapter(s.getFirstElement(), ISVNResource.class);
    if (element instanceof ISVNRemoteResource) {
        ISVNRemoteResource res = (ISVNRemoteResource) element;
        String name;
        if (res.isContainer()) {
            name = res.getRepositoryRelativePath();
        } else {
            name = res.getRepositoryRelativePath() + " " + // $NON-NLS-1$
            ((ISVNRemoteFile) res).getLastChangedRevision();
        }
        return Policy.bind("RepositoriesView.ResourceInRepository", name, // $NON-NLS-1$
        res.getRepository().getLocation());
    }
    // $NON-NLS-1$
    return Policy.bind("RepositoriesView.OneItemSelected");
}
Also used : ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 7 with ISVNRemoteFile

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

the class SVNCompareEditorInput method getLabel.

/**
 * Returns the label for the given input element (which is a ResourceEditionNode).
 */
private String getLabel(ITypedElement element) {
    if (element instanceof ResourceEditionNode) {
        ISVNRemoteResource edition = ((ResourceEditionNode) element).getRemoteResource();
        SVNRevision revision = edition.getLastChangedRevision();
        if (revision == null) {
            revision = edition.getRevision();
        }
        if (edition instanceof ISVNRemoteFile) {
            return Policy.bind("nameAndRevision", edition.getName(), // $NON-NLS-1$
            revision.toString());
        }
        if (edition.isContainer()) {
            // $NON-NLS-1$
            return Policy.bind("SVNCompareEditorInput.inHead", edition.getName());
        } else {
            return Policy.bind("SVNCompareEditorInput.repository", // $NON-NLS-1$
            new Object[] { edition.getName(), revision.toString() });
        }
    }
    return element.getName();
}
Also used : ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 8 with ISVNRemoteFile

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

the class SVNPristineCopyQuickDiffProvider method readDocument.

/**
 * Creates a document and initializes it with the contents of a SVN remote resource.
 *
 * @param monitor the progress monitor
 * @throws CoreException
 */
private void readDocument(IProgressMonitor monitor) throws CoreException {
    if (!isReferenceInitialized)
        return;
    if (referenceDocument == null)
        referenceDocument = new Document();
    if (computeChange(monitor)) {
        ISVNRemoteFile remoteFile = (ISVNRemoteFile) fLastSyncState.getBase();
        if (remoteFile != null && documentProvider instanceof IStorageDocumentProvider) {
            IStorageDocumentProvider provider = (IStorageDocumentProvider) documentProvider;
            String encoding = provider.getEncoding(editor.getEditorInput());
            if (encoding == null) {
                encoding = provider.getDefaultEncoding();
            }
            if (monitor.isCanceled())
                return;
            InputStream stream = remoteFile.getStorage(monitor).getContents();
            if (stream == null || monitor.isCanceled() || !isReferenceInitialized) {
                return;
            }
            setDocumentContent(referenceDocument, stream, encoding);
        } else {
            // the remote is null, so ensure that the document is null
            if (monitor.isCanceled())
                return;
            // $NON-NLS-1$
            referenceDocument.set("");
        }
        if (DEBUG)
            System.out.println("+ SVNQuickDiff: updating document " + (referenceDocument != null ? "remote found" : // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            "remote empty"));
    }
}
Also used : IStorageDocumentProvider(org.eclipse.ui.editors.text.IStorageDocumentProvider) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) InputStream(java.io.InputStream) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument)

Example 9 with ISVNRemoteFile

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

the class SVNAction method getSelectedRemoteFiles.

/**
 * Returns the selected remote files
 */
protected ISVNRemoteFile[] getSelectedRemoteFiles() {
    ArrayList resources = null;
    if (selection != null && !selection.isEmpty()) {
        resources = new ArrayList();
        Iterator elements = selection.iterator();
        while (elements.hasNext()) {
            Object next = elements.next();
            if (next instanceof ISVNRemoteFile) {
                resources.add(next);
                continue;
            }
            if (next instanceof IAdaptable) {
                IAdaptable a = (IAdaptable) next;
                Object adapter = a.getAdapter(ISVNRemoteFile.class);
                if (adapter instanceof ISVNRemoteFile) {
                    resources.add(adapter);
                    continue;
                }
            }
        }
    }
    if (resources != null && !resources.isEmpty()) {
        ISVNRemoteFile[] result = new ISVNRemoteFile[resources.size()];
        resources.toArray(result);
        return result;
    }
    return new ISVNRemoteFile[0];
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 10 with ISVNRemoteFile

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

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