Search in sources :

Example 96 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class BranchTagWizard method updateTagsProperty.

private void updateTagsProperty(SVNUrl toUrl) {
    ISVNClientAdapter svnClient = null;
    try {
        if (resources.length > 1)
            return;
        ISVNProperty property = null;
        // $NON-NLS-1$
        property = repositoryPage.getSvnResource().getSvnProperty("subclipse:tags");
        if (property == null)
            return;
        newAlias = new Alias();
        // $NON-NLS-1$
        newAlias.setBranch(toUrl.toString().toUpperCase().indexOf("TAGS") == -1);
        String relativePath = toUrl.toString().substring(repositoryPage.getSvnResource().getRepository().getUrl().toString().length());
        newAlias.setRelativePath(relativePath);
        SVNRevision revision = null;
        if (copyPage.revisionButton.getSelection())
            revision = SVNRevision.getRevision(copyPage.getRevision());
        else {
            svnClient = repositoryPage.getSvnResource().getRepository().getSVNClient();
            ISVNInfo svnInfo = svnClient.getInfo(repositoryPage.getUrl());
            revision = SVNRevision.getRevision(svnInfo.getRevision().toString());
        }
        newAlias.setRevision(Integer.parseInt(revision.toString()));
        newAlias.setName(toUrl.getLastPathSegment());
        BranchTagPropertyUpdateDialog dialog = new BranchTagPropertyUpdateDialog(getShell(), getResource(), newAlias, // $NON-NLS-1$
        "BranchTagPropertyUpdateDialog");
        if (dialog.open() == BranchTagPropertyUpdateDialog.OK)
            newAlias = dialog.getNewAlias();
        else
            newAlias = null;
    } catch (Exception e) {
    } finally {
        if (svnClient != null) {
            repositoryPage.getSvnResource().getRepository().returnSVNClient(svnClient);
        }
    }
}
Also used : BranchTagPropertyUpdateDialog(org.tigris.subversion.subclipse.ui.dialogs.BranchTagPropertyUpdateDialog) Alias(org.tigris.subversion.subclipse.core.history.Alias) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 97 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class ResolveSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    boolean folderSelected = false;
    propertyConflicts = false;
    textConflicts = false;
    treeConflicts = false;
    canceled = false;
    final IResource[] resources = set.getResources();
    for (int i = 0; i < resources.length; i++) {
        if (resources[i] instanceof IContainer) {
            folderSelected = true;
            break;
        }
        if (!propertyConflicts || !textConflicts || !treeConflicts) {
            ISVNLocalResource resource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
            try {
                LocalResourceStatus status = resource.getStatus();
                if (status != null && status.isPropConflicted())
                    propertyConflicts = true;
                if (status != null && status.isTextConflicted())
                    textConflicts = true;
                if (status != null && status.hasTreeConflict())
                    treeConflicts = true;
            } catch (SVNException e) {
                SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
            }
        }
    }
    if (folderSelected) {
        selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
    } else {
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                if (propertyConflicts && !textConflicts) {
                    String message;
                    if (resources.length > 1)
                        // $NON-NLS-1$
                        message = Policy.bind("ResolveAction.confirmMultiple");
                    else
                        message = Policy.bind("ResolveAction.confirm", // $NON-NLS-1$
                        resources[0].getName());
                    if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), message)) {
                        // $NON-NLS-1$
                        canceled = true;
                        return;
                    }
                    selectedResolution = ISVNConflictResolver.Choice.chooseMerged;
                } else {
                    SvnWizardMarkResolvedPage markResolvedPage = new SvnWizardMarkResolvedPage(resources);
                    markResolvedPage.setPropertyConflicts(propertyConflicts);
                    markResolvedPage.setTreeConflicts(treeConflicts);
                    SvnWizard wizard = new SvnWizard(markResolvedPage);
                    SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
                    wizard.setParentDialog(dialog);
                    if (dialog.open() == SvnWizardDialog.CANCEL) {
                        canceled = true;
                        return;
                    }
                    selectedResolution = markResolvedPage.getResolution();
                }
            }
        });
    }
    if (canceled)
        return;
    run(new WorkspaceModifyOperation() {

        public void execute(IProgressMonitor monitor) throws InvocationTargetException {
            ISVNRepositoryLocation repository = null;
            ISVNClientAdapter svnClient = null;
            try {
                for (int i = 0; i < resources.length; i++) {
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                    repository = svnResource.getRepository();
                    svnClient = repository.getSVNClient();
                    svnClient.resolve(resources[i].getLocation().toFile(), selectedResolution);
                    repository.returnSVNClient(svnClient);
                    repository = null;
                    svnClient = null;
                    // for some reason, just refreshing the file won't cut it.
                    resources[i].getParent().refreshLocal(IResource.DEPTH_INFINITE, monitor);
                }
            } catch (TeamException e) {
                throw new InvocationTargetException(e);
            } catch (CoreException e) {
                throw new InvocationTargetException(e);
            } catch (SVNClientException e) {
                throw new InvocationTargetException(e);
            } finally {
                if (repository != null) {
                    repository.returnSVNClient(svnClient);
                }
            }
        }
    }, false, /* cancelable */
    PROGRESS_BUSYCURSOR);
}
Also used : WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IContainer(org.eclipse.core.resources.IContainer) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource) SvnWizardMarkResolvedPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardMarkResolvedPage) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 98 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class UnversionedCustomProperty method getSvnRevisionProperties.

public static ISVNProperty[] getSvnRevisionProperties(final SVNUrl url, final SVNRevision revision, final SVNRevision peg, final boolean customOnly) throws SVNException {
    ISVNClientAdapter svnClient = null;
    try {
        svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
        SVNProviderPlugin.disableConsoleLogging();
        ISVNProperty[] props = svnClient.getRevProperties(url, (SVNRevision.Number) revision);
        if (customOnly)
            return stripNonCustom(props);
        return props;
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        SVNProviderPlugin.enableConsoleLogging();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 99 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class CopyAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    final IResource[] resources = getSelectedResources();
    final IProject project = resources[0].getProject();
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), project, false, // $NON-NLS-1$
    Policy.bind("CopyAction.selectionLabel"));
    if (dialog.open() == ContainerSelectionDialog.CANCEL)
        return;
    Object[] result = dialog.getResult();
    if (result == null || result.length == 0)
        return;
    final Path path = (Path) result[0];
    IProject selectedProject;
    File target = null;
    if (path.segmentCount() == 1) {
        selectedProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.toString());
        target = selectedProject.getLocation().toFile();
    } else {
        IFile targetFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        selectedProject = targetFile.getProject();
        target = targetFile.getLocation().toFile();
    }
    final IProject targetProject = selectedProject;
    final File destPath = target;
    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

        public void run() {
            ISVNClientAdapter client = null;
            ISVNRepositoryLocation repository = null;
            try {
                ISVNLocalResource svnTargetResource = SVNWorkspaceRoot.getSVNResourceFor(targetProject);
                for (int i = 0; i < resources.length; i++) {
                    final IResource resource = resources[i];
                    if (client == null) {
                        repository = SVNWorkspaceRoot.getSVNResourceFor(resources[i]).getRepository();
                        client = repository.getSVNClient();
                    }
                    File checkFile = new File(destPath.getPath() + File.separator + resource.getName());
                    File srcPath = new File(resource.getLocation().toString());
                    File newDestPath = new File(destPath.getPath() + File.separator + resource.getName());
                    if (checkFile.exists()) {
                        IInputValidator inputValidator = new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.equals(resource.getName()))
                                    // $NON-NLS-1$
                                    return Policy.bind("CopyAction.nameConflictSame");
                                return null;
                            }
                        };
                        InputDialog inputDialog = new InputDialog(getShell(), Policy.bind("CopyAction.nameConflictTitle"), Policy.bind("CopyAction.nameConflictMessage", resource.getName()), "Copy of " + resource.getName(), // $NON-NLS-1$
                        inputValidator);
                        if (inputDialog.open() == InputDialog.CANCEL)
                            return;
                        String newName = inputDialog.getValue();
                        if (newName == null || newName.trim().length() == 0)
                            return;
                        newDestPath = new File(destPath.getPath() + File.separator + newName);
                    }
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                    boolean sameRepository = svnTargetResource != null && svnTargetResource.getRepository() != null && svnTargetResource.getRepository().getLocation().equals(svnResource.getRepository().getLocation());
                    if (sameRepository)
                        client.copy(srcPath, newDestPath);
                    else
                        client.doExport(srcPath, newDestPath, true);
                    SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
                }
                targetProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("CopyAction.copy"), // $NON-NLS-1$
                e.getMessage());
            } finally {
                if (repository != null) {
                    repository.returnSVNClient(client);
                }
            }
        }
    });
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) InputDialog(org.eclipse.jface.dialogs.InputDialog) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IProject(org.eclipse.core.resources.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) File(java.io.File) IFile(org.eclipse.core.resources.IFile) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 100 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class EditPropertyConflictsAction method execute.

protected void execute(final IAction action) throws InvocationTargetException, InterruptedException {
    error = null;
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            IResource resource = getSelectedResources()[0];
            svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            ISVNClientAdapter client = null;
            try {
                conflictSummary = PropertyConflict.getConflictSummary(svnResource);
                propertyConflicts = PropertyConflict.getPropertyConflicts(svnResource);
                client = svnResource.getRepository().getSVNClient();
                remoteProperties = client.getProperties(svnResource.getUrl(), svnResource.getRevision(), svnResource.getRevision());
            } catch (Exception e) {
                error = e;
            } finally {
                svnResource.getRepository().returnSVNClient(client);
            }
        }
    });
    if (error != null) {
        handle(error);
        return;
    }
    EditPropertyConflictsWizard wizard = new EditPropertyConflictsWizard(svnResource, conflictSummary, propertyConflicts, remoteProperties, getTargetPart());
    WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, // $NON-NLS-1$
    "EditPropertyConflicts");
    dialog.open();
}
Also used : SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) EditPropertyConflictsWizard(org.tigris.subversion.subclipse.ui.conflicts.EditPropertyConflictsWizard)

Aggregations

ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)108 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)67 SVNException (org.tigris.subversion.subclipse.core.SVNException)37 File (java.io.File)28 IResource (org.eclipse.core.resources.IResource)27 CoreException (org.eclipse.core.runtime.CoreException)22 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 TeamException (org.eclipse.team.core.TeamException)21 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)20 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)20 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)19 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)19 ArrayList (java.util.ArrayList)18 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)13 OperationProgressNotifyListener (org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)9 IProject (org.eclipse.core.resources.IProject)8 List (java.util.List)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7