Search in sources :

Example 11 with ISVNRemoteResource

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

the class ShowDifferencesAsUnifiedDiffDialogWC method okPressed.

protected void okPressed() {
    success = true;
    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

        public void run() {
            ISVNRepositoryLocation repository = null;
            ISVNClientAdapter svnClient = null;
            try {
                if (toHeadButton.getSelection())
                    toRevision = SVNRevision.HEAD;
                else {
                    int toRevisionInt = Integer.parseInt(toRevisionText.getText().trim());
                    long toRevisionLong = toRevisionInt;
                    toRevision = new SVNRevision.Number(toRevisionLong);
                }
                toUrl = new SVNUrl(toUrlText.getText().trim());
                File path = new File(resource.getLocation().toString());
                svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                pegRevision = null;
                if (toUrlText.getText().equals(selectedResourceUrl)) {
                    ISVNRemoteResource baseResource = svnResource.getBaseResource();
                    if (baseResource != null) {
                        pegRevision = baseResource.getLastChangedRevision();
                    }
                }
                if (pegRevision == null) {
                    pegRevision = toRevision;
                }
                repository = svnResource.getRepository();
                svnClient = repository.getSVNClient();
                ISVNInfo svnInfo = svnClient.getInfo(toUrl, toRevision, pegRevision);
                SVNNodeKind nodeKind = svnInfo.getNodeKind();
                if (resource instanceof IContainer) {
                    if (nodeKind.toInt() == SVNNodeKind.FILE.toInt()) {
                        MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.fileToFolder"));
                        success = false;
                        return;
                    }
                } else {
                    if (nodeKind.toInt() == SVNNodeKind.DIR.toInt()) {
                        MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.fileToFolder"));
                        success = false;
                        return;
                    }
                }
                if (diffButton.getSelection()) {
                    diffToOutputFile = true;
                    file = new File(fileText.getText().trim());
                    if (file.exists()) {
                        if (!MessageDialog.openQuestion(getShell(), Policy.bind("HistoryView.showDifferences"), Policy.bind("HistoryView.overwriteOutfile", file.getName())))
                            return;
                    }
                    operation = new ShowDifferencesAsUnifiedDiffOperationWC(targetPart, path, toUrl, toRevision, file);
                    operation.setGraphicalCompare(true);
                } else {
                    diffToOutputFile = false;
                    success = true;
                }
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
                success = false;
            } finally {
                if (repository != null) {
                    repository.returnSVNClient(svnClient);
                }
            }
        }
    });
    if (!success)
        return;
    toUrlText.saveUrl();
    super.okPressed();
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNNodeKind(org.tigris.subversion.svnclientadapter.SVNNodeKind) ShowDifferencesAsUnifiedDiffOperationWC(org.tigris.subversion.subclipse.ui.operations.ShowDifferencesAsUnifiedDiffOperationWC) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IContainer(org.eclipse.core.resources.IContainer) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 12 with ISVNRemoteResource

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

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

the class RepositoryManager method startup.

/**
 * called when plugin is started
 */
public void startup() {
    commentsManager.loadCommentHistory();
    commentsManager.loadCommentTemplates();
    keyFilesManager.loadKeyFileHistory();
    // we listen to changes to repository so that we can advise concerned views
    SVNProviderPlugin.getPlugin().getRepositoryResourcesManager().addRepositoryListener(new ISVNListener() {

        public void repositoryAdded(ISVNRepositoryLocation root) {
            rootAdded(root);
        }

        public void repositoryRemoved(ISVNRepositoryLocation root) {
            rootRemoved(root);
        }

        public void remoteResourceDeleted(ISVNRemoteResource resource) {
            resourceDeleted(resource);
        }

        public void remoteResourceCreated(ISVNRemoteFolder parent, String resourceName) {
            resourceCreated(parent, resourceName);
        }

        public void remoteResourceCopied(ISVNRemoteResource source, ISVNRemoteFolder destination) {
            resourceCopied(source, destination);
        }

        public void remoteResourceMoved(ISVNRemoteResource resource, ISVNRemoteFolder destinationFolder, String destinationResourceName) {
            resourceMoved(resource, destinationFolder, destinationResourceName);
        }

        public void repositoryModified(ISVNRepositoryLocation root) {
            rootModified(root);
        }
    });
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNListener(org.tigris.subversion.subclipse.core.repo.ISVNListener) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder)

Example 14 with ISVNRemoteResource

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

the class SvnWizardCompareMultipleResourcesWithBranchTagPage 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)

Example 15 with ISVNRemoteResource

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

the class CheckoutWizardCheckoutAsMultiplePage method getCommonParent.

private ISVNRemoteResource getCommonParent() {
    ISVNRemoteFolder[] remoteFolders = ((CheckoutWizard) getWizard()).getRemoteFolders();
    if (remoteFolders.length == 1)
        return remoteFolders[0];
    ISVNRemoteResource commonParent = null;
    ISVNRemoteResource parent = remoteFolders[0];
    while (commonParent == null) {
        parent = parent.getParent();
        if (parent == null)
            break;
        for (int i = 1; i < remoteFolders.length; i++) {
            if (!remoteFolders[i].getUrl().toString().startsWith(parent.getUrl().toString()))
                break;
        }
        commonParent = parent;
    }
    return commonParent;
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder)

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