Search in sources :

Example 41 with ISVNRemoteResource

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

the class ResourceEditionNode method matchLocalResource.

private SVNLocalResourceNode matchLocalResource(ISVNRemoteResource remoteNode) {
    if (localResource == null)
        return null;
    ISVNRemoteResource baseFolder = remoteNode;
    if (baseFolder.getParent() != null) {
        baseFolder = baseFolder.getParent();
    }
    Object[] lrn = localResource.getChildren();
    String remotePath = remoteNode.getRepositoryRelativePath();
    remotePath = remotePath.replaceAll(baseFolder.getRepositoryRelativePath(), "");
    for (int i = 0; i < lrn.length; i++) {
        String localPath = ((SVNLocalResourceNode) lrn[i]).getResource().getFullPath().toString();
        localPath = localPath.substring(localResource.getResource().getFullPath().toString().length());
        if (localPath.equals(remotePath)) {
            return (SVNLocalResourceNode) lrn[i];
        }
    }
    return null;
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 42 with ISVNRemoteResource

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

the class ResourceEditionNode method getChildren.

/**
 * Enumerate children of this node (if any).
 *
 * @see IStructureComparator#getChildren
 */
public Object[] getChildren() {
    if (children == null) {
        children = new ResourceEditionNode[0];
        ISVNLocalResource mylocalResource = null;
        if (localResource instanceof SVNLocalResourceNode) {
            mylocalResource = ((SVNLocalResourceNode) localResource).getLocalResource();
            try {
                if (!mylocalResource.isDirty() && mylocalResource.getResource().getProjectRelativePath().toString().equals(getRemoteResource().getProjectRelativePath()) && mylocalResource.getStatus().getLastChangedRevision().equals(getRemoteResource().getLastChangedRevision())) {
                    return children;
                }
            } catch (CoreException e) {
                SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
            }
        }
        if (resource != null) {
            try {
                SVNUIPlugin.runWithProgress(null, true, /* cancelable */
                new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor) throws InvocationTargetException {
                        try {
                            ISVNRemoteResource[] members = resource.members(monitor);
                            List<ResourceEditionNode> nonHiddenChildren = new ArrayList<ResourceEditionNode>();
                            for (int i = 0; i < members.length; i++) {
                                if (!ignoreHiddenChanges || members[i].getResource() == null || !Util.isHidden(members[i].getResource(), false)) {
                                    ResourceEditionNode child = new ResourceEditionNode(members[i], pegRevision);
                                    SVNLocalResourceNode localNode = matchLocalResource((ISVNRemoteResource) members[i]);
                                    if (localNode != null) {
                                        child.setLocalResource(localNode);
                                        localNode.setRemoteResource(child);
                                        try {
                                            child.setCharset(localNode.getCharset());
                                        } catch (CoreException e) {
                                            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
                                        }
                                    }
                                    nonHiddenChildren.add(child);
                                }
                            }
                            children = new ResourceEditionNode[nonHiddenChildren.size()];
                            nonHiddenChildren.toArray(children);
                        } catch (TeamException e) {
                            throw new InvocationTargetException(e);
                        }
                    }
                });
            } catch (InterruptedException e) {
            // operation canceled
            } catch (InvocationTargetException e) {
                Throwable t = e.getTargetException();
                if (t instanceof TeamException) {
                    SVNUIPlugin.log(((TeamException) t).getStatus());
                }
            }
        }
    }
    return children;
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 43 with ISVNRemoteResource

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

the class RevisionAwareDifferencer method compareStatusAndRevisions.

/**
 * Compares two nodes to determine if they are equal. Returns NODE_EQUAL of they are the same,
 * NODE_NOT_EQUAL if they are different, and NODE_UNKNOWN if comparison was not possible.
 */
protected int compareStatusAndRevisions(Object left, Object right) {
    ISVNLocalResource localResource = null;
    if (left instanceof SVNLocalResourceNode) {
        localResource = ((SVNLocalResourceNode) left).getLocalResource();
    }
    ISVNRemoteResource edition = null;
    if (right instanceof ResourceEditionNode)
        edition = ((ResourceEditionNode) right).getRemoteResource();
    if (localResource == null || edition == null) {
        return NODE_UNKNOWN;
    }
    // if they're both non-files, they're the same
    if (localResource.isFolder() && edition.isContainer()) {
        return NODE_EQUAL;
    }
    // if they have different types, they're different
    if (localResource.isFolder() != edition.isContainer()) {
        return NODE_NOT_EQUAL;
    }
    String leftLocation = localResource.getRepository().getLocation();
    String rightLocation = edition.getRepository().getLocation();
    if (!leftLocation.equals(rightLocation)) {
        return NODE_UNKNOWN;
    }
    LocalResourceStatus localStatus = null;
    try {
        localStatus = localResource.getStatus();
        if (localStatus == null) {
            return NODE_UNKNOWN;
        }
        if (!localResource.isDirty() && localResource.getResource().getProjectRelativePath().toString().equals(edition.getProjectRelativePath()) && localStatus.getLastChangedRevision().equals(edition.getLastChangedRevision())) {
            return NODE_EQUAL;
        }
        if (!localResource.isDirty() && !localResource.isFolder()) {
            if (changedResources == null && diffFiles != null) {
                parseDiffs();
            }
            if (changedResources == null) {
                for (int i = 0; i < diffSummary.length; i++) {
                    if (localResource.getResource().getProjectRelativePath().toString().equals(projectRelativePath) || localResource.getResource().getProjectRelativePath().toString().equals(projectRelativePath + diffSummary[i].getPath())) {
                        return NODE_NOT_EQUAL;
                    }
                }
                return NODE_EQUAL;
            }
            if (changedResources.contains(localResource.getResource().getLocation().toString())) {
                return NODE_NOT_EQUAL;
            }
            return NODE_EQUAL;
        }
    } catch (SVNException e) {
        return NODE_UNKNOWN;
    }
    return NODE_UNKNOWN;
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)

Example 44 with ISVNRemoteResource

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

the class SVNCompareRevisionsInput method initializeActions.

/**
 * initialize the actions : - getContentsAction : get the contents for the selected revision -
 * getRevisionAction : updates to the given revision
 */
private void initializeActions() {
    getContentsAction = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Policy.bind("HistoryView.getContentsAction"), // $NON-NLS-1$
    null) {

        public void run() {
            try {
                new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation() {

                    protected void execute(IProgressMonitor monitor) throws InvocationTargetException {
                        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                        if (selection.size() != 1)
                            return;
                        VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
                        ResourceEditionNode right = (ResourceEditionNode) node.getRight();
                        ISVNRemoteResource edition = right.getRemoteResource();
                        // actually want to change the base.
                        try {
                            monitor.beginTask(null, 100);
                            InputStream in = ((IResourceVariant) edition).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
                            resource.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
                        } catch (TeamException e) {
                            throw new InvocationTargetException(e);
                        } catch (CoreException e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (InterruptedException e) {
                // Do nothing
                return;
            } catch (InvocationTargetException e) {
                handle(e);
            }
            // recompute the labels on the viewer
            updateCurrentEdition();
            viewer.refresh();
        }
    };
    getRevisionAction = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Policy.bind("HistoryView.getRevisionAction"), // $NON-NLS-1$
    null) {

        public void run() {
            try {
                new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation(null) {

                    protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                        if (selection.size() != 1)
                            return;
                        VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
                        ResourceEditionNode right = (ResourceEditionNode) node.getRight();
                        final ISVNRemoteFile edition = (ISVNRemoteFile) right.getRemoteResource();
                        new UpdateOperation(null, resource, edition.getLastChangedRevision()).run(monitor);
                        // recompute the labels on the viewer
                        getHistoryTableProvider().setRemoteResource(edition);
                        viewer.refresh();
                    }
                });
            } catch (InterruptedException e) {
                // Do nothing
                return;
            } catch (InvocationTargetException e) {
                handle(e);
            }
        }
    };
}
Also used : WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) UpdateOperation(org.tigris.subversion.subclipse.ui.operations.UpdateOperation)

Example 45 with ISVNRemoteResource

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

the class SvnWizardSwitchPage method showLog.

protected void showLog() {
    ISVNRemoteResource remoteResource = null;
    try {
        remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]).getRepository().getRemoteFile(new SVNUrl(urlCombo.getText()));
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
        e.toString());
        return;
    }
    if (remoteResource == null) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        urlCombo.getText());
        return;
    }
    HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
    if (dialog.open() == HistoryDialog.CANCEL)
        return;
    ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
    if (selectedEntries.length == 0)
        return;
    revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
    setPageComplete(canFinish());
}
Also used : HistoryDialog(org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) ParseException(java.text.ParseException) MalformedURLException(java.net.MalformedURLException)

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