Search in sources :

Example 56 with ISVNRemoteResource

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

the class CompareWithRevisionAction method execute.

/*
   * @see SVNAction#execute(IAction)
   */
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
    refresh = false;
    // Setup holders
    final ISVNRemoteResource[] resource = new ISVNRemoteResource[] { null };
    final ILogEntry[][] entries = new ILogEntry[][] { null };
    // Get the selected resource
    run(new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) {
            resource[0] = getSelectedRemoteResource();
        }
    }, false, /* cancelable */
    PROGRESS_BUSYCURSOR);
    if (resource[0] == null) {
        // No revisions for selected resource
        MessageDialog.openWarning(getShell(), Policy.bind("CompareWithRevisionAction.noRevisions"), // $NON-NLS-1$ //$NON-NLS-2$
        Policy.bind("CompareWithRevisionAction.noRevisionsLong"));
        return;
    }
    if (resource[0] instanceof IFile && !resource[0].getResource().isSynchronized(Depth.immediates)) {
        refresh = MessageDialog.openQuestion(getShell(), Policy.bind("DifferencesDialog.compare"), Policy.bind("CompareWithRemoteAction.fileChanged"));
    }
    // Fetch the log entries
    run(new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                monitor.beginTask(Policy.bind("CompareWithRevisionAction.fetching"), // $NON-NLS-1$
                100);
                AliasManager tagManager = null;
                IResource[] resources = getSelectedResources();
                if (refresh)
                    resources[0].refreshLocal(Depth.immediates, monitor);
                if (resources.length == 1)
                    tagManager = new AliasManager(resources[0]);
                GetLogsCommand logCmd = new GetLogsCommand(resource[0], SVNRevision.HEAD, SVNRevision.HEAD, new SVNRevision.Number(0), false, 0, tagManager, false);
                logCmd.run(Policy.subMonitorFor(monitor, 100));
                entries[0] = logCmd.getLogEntries();
                monitor.done();
            } catch (Exception e) {
                throw new InvocationTargetException(e);
            }
        }
    }, true, /* cancelable */
    PROGRESS_DIALOG);
    if (entries[0] == null)
        return;
    final IResource selectedResource = getSelectedResources()[0];
    if (!(selectedResource instanceof IFile)) {
        HistoryDialog dialog = new HistoryDialog(getShell(), resource[0]);
        if (dialog.open() == HistoryDialog.CANCEL) {
            return;
        }
        ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
        if (selectedEntries.length == 0) {
            return;
        }
        ISVNRemoteFolder remoteFolder = new RemoteFolder(resource[0].getRepository(), selectedEntries[0].getResource().getUrl(), selectedEntries[0].getRevision());
        ((RemoteFolder) remoteFolder).setPegRevision(selectedEntries[0].getRevision());
        ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(selectedResource);
        try {
            SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFolder, SVNRevision.HEAD);
            CompareUI.openCompareEditorOnPage(compareInput, getTargetPage());
        } catch (SVNException e) {
            MessageDialog.openError(getShell(), getErrorTitle(), e.getMessage());
        }
        return;
    }
    // Show the compare viewer
    run(new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            SVNCompareRevisionsInput input = new SVNCompareRevisionsInput((IFile) selectedResource, entries[0]);
            if (SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG)) {
                // running with a null progress monitor is fine because we have already pre-fetched
                // the log entries above.
                input.run(new NullProgressMonitor());
                SaveablePartDialog cd = createCompareDialog(getShell(), input);
                cd.setBlockOnOpen(true);
                cd.open();
            } else {
                CompareUI.openCompareEditorOnPage(input, getTargetPage());
            }
        }
    }, false, /* cancelable */
    PROGRESS_BUSYCURSOR);
}
Also used : HistoryDialog(org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SVNLocalCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput) IFile(org.eclipse.core.resources.IFile) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) AliasManager(org.tigris.subversion.subclipse.core.history.AliasManager) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNCompareRevisionsInput(org.tigris.subversion.subclipse.ui.compare.SVNCompareRevisionsInput) GetLogsCommand(org.tigris.subversion.subclipse.core.commands.GetLogsCommand) IResource(org.eclipse.core.resources.IResource) SaveablePartDialog(org.eclipse.team.ui.SaveablePartDialog)

Example 57 with ISVNRemoteResource

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

the class SVNAction method getSelectedRemoteResources.

/**
 * Returns the selected remote resources
 */
protected ISVNRemoteResource[] getSelectedRemoteResources() {
    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 ISVNRemoteResource) {
                resources.add(next);
                continue;
            }
            if (next instanceof IAdaptable) {
                IAdaptable a = (IAdaptable) next;
                Object adapter = a.getAdapter(ISVNRemoteResource.class);
                if (adapter instanceof ISVNRemoteResource) {
                    resources.add(adapter);
                    continue;
                }
            }
        }
    }
    if (resources != null && !resources.isEmpty()) {
        ISVNRemoteResource[] result = new ISVNRemoteResource[resources.size()];
        resources.toArray(result);
        return result;
    }
    return new ISVNRemoteResource[0];
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 58 with ISVNRemoteResource

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

the class ShowDifferencesAsUnifiedDiffAction method execute.

// 
// private IResource localResource;
// 
// public void setLocalResource(IResource localResource) {
// this.localResource = localResource;
// }
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    pegRevision1 = null;
    pegRevision2 = null;
    String fromRevision = null;
    String toRevision = null;
    ISVNResource[] selectedResources = getSelectedRemoteResources();
    SVNUrl fromUrl = null;
    SVNUrl toUrl = null;
    if (selectedResources == null || (selectedResources.length == 0)) {
        Object[] selectedObjects = selection.toArray();
        if (selectedObjects[0] instanceof ILogEntry) {
            selectedResources = new ISVNResource[2];
            selectedResources[0] = ((ILogEntry) selectedObjects[0]).getResource();
            fromRevision = ((ILogEntry) selectedObjects[0]).getRevision().toString();
            ILogEntry logEntry1 = (ILogEntry) selectedObjects[0];
            RemoteResource remoteResource;
            IResource resource1 = logEntry1.getResource().getResource();
            if (resource1 != null) {
                try {
                    ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource1);
                    if (baseResource != null) {
                        pegRevision1 = baseResource.getLastChangedRevision();
                    }
                } catch (Exception e) {
                }
            }
            if (logEntry1.getResource().getResource() instanceof IContainer) {
                remoteResource = new RemoteFolder(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
            } else {
                remoteResource = new RemoteFile(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
            }
            fromUrl = remoteResource.getUrl();
            if (selectedObjects.length > 1) {
                selectedResources[1] = ((ILogEntry) selectedObjects[1]).getResource();
                toRevision = ((ILogEntry) selectedObjects[1]).getRevision().toString();
                ILogEntry logEntry2 = (ILogEntry) selectedObjects[1];
                IResource resource2 = logEntry2.getResource().getResource();
                if (resource2 != null) {
                    try {
                        ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource2);
                        if (baseResource != null) {
                            pegRevision2 = baseResource.getLastChangedRevision();
                        }
                    } catch (Exception e) {
                    }
                }
                if (logEntry2.getResource().getResource() instanceof IContainer) {
                    remoteResource = new RemoteFolder(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
                } else {
                    remoteResource = new RemoteFile(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
                }
                toUrl = remoteResource.getUrl();
            } else {
                int from = Integer.parseInt(fromRevision);
                from--;
                toRevision = Integer.toString(from);
                toUrl = remoteResource.getUrl();
            }
        }
    } else {
        if (selectedResources[0] instanceof ISVNRemoteResource)
            fromRevision = ((ISVNRemoteResource) selectedResources[0]).getRevision().toString();
        if (selectedResources.length > 1 && selectedResources[1] instanceof ISVNRemoteResource)
            toRevision = ((ISVNRemoteResource) selectedResources[1]).getRevision().toString();
    }
    if (pegRevision1 == null) {
        pegRevision1 = SVNRevision.HEAD;
    }
    if (pegRevision2 == null) {
        pegRevision2 = pegRevision1;
    }
    DifferencesDialog dialog = new DifferencesDialog(getShell(), null, selectedResources, new SVNRevision[] { pegRevision1, pegRevision2 }, getTargetPart());
    dialog.setUsePegRevision(usePegRevision);
    dialog.setFromUrl(fromUrl);
    dialog.setToUrl(toUrl);
    IResource localResource = null;
    IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    if (part instanceof GenericHistoryView) {
        IHistoryPage historyPage = ((GenericHistoryView) part).getHistoryPage();
        if (historyPage instanceof SVNHistoryPage) {
            localResource = ((SVNHistoryPage) historyPage).getResource();
        }
    }
    dialog.setLocalResource(localResource);
    // $NON-NLS-1$
    if (!fromRevision.equals("HEAD"))
        dialog.setFromRevision(fromRevision);
    if (toRevision != null && !toRevision.equals("HEAD"))
        // $NON-NLS-1$
        dialog.setToRevision(toRevision);
    dialog.open();
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) RemoteResource(org.tigris.subversion.subclipse.core.resources.RemoteResource) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) IHistoryPage(org.eclipse.team.ui.history.IHistoryPage) DifferencesDialog(org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SVNHistoryPage(org.tigris.subversion.subclipse.ui.history.SVNHistoryPage) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Example 59 with ISVNRemoteResource

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

the class ExportRemoteFolderAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    ISVNRemoteResource[] resources = getSelectedRemoteResources();
    ExportRemoteFolderDialog dialog = new ExportRemoteFolderDialog(getShell(), resources[0], getTargetPart());
    dialog.open();
}
Also used : ExportRemoteFolderDialog(org.tigris.subversion.subclipse.ui.dialogs.ExportRemoteFolderDialog) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 60 with ISVNRemoteResource

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

the class RemoteResourcePropertiesAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    ISVNRemoteResource[] remoteResources = getSelectedRemoteResources();
    RemoteResourcePropertiesDialog dialog = new RemoteResourcePropertiesDialog(getShell(), remoteResources[0]);
    dialog.open();
}
Also used : RemoteResourcePropertiesDialog(org.tigris.subversion.subclipse.ui.dialogs.RemoteResourcePropertiesDialog) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Aggregations

ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)69 SVNException (org.tigris.subversion.subclipse.core.SVNException)23 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)21 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 TeamException (org.eclipse.team.core.TeamException)16 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)16 IResource (org.eclipse.core.resources.IResource)15 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)14 ArrayList (java.util.ArrayList)12 ParseException (java.text.ParseException)11 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)10 CoreException (org.eclipse.core.runtime.CoreException)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)8 MalformedURLException (java.net.MalformedURLException)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)7 HistoryDialog (org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog)6 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)6