Search in sources :

Example 61 with ISVNRepositoryLocation

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

the class RemoteContentProvider method cancelJobs.

public void cancelJobs(ISVNRepositoryLocation[] roots) {
    if (manager != null) {
        for (int i = 0; i < roots.length; i++) {
            ISVNRepositoryLocation root = roots[i];
            cancelJobs(root);
        }
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)

Example 62 with ISVNRepositoryLocation

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

the class RemoteContentProvider method getChildren.

/**
 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
 */
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof Branches)
        return ((Branches) parentElement).getBranches();
    if (parentElement instanceof Tags)
        return ((Tags) parentElement).getTags();
    if (useDeferredContentManager && manager != null) {
        Object[] children = manager.getChildren(parentElement);
        if (children != null) {
            if (parentElement instanceof ISVNRepositoryLocation && (rootFolder != null || branches != null || tags != null)) {
                ArrayList childrenArray = new ArrayList();
                if (rootFolder != null)
                    childrenArray.add(rootFolder);
                if (branches != null)
                    childrenArray.add(branches);
                if (tags != null)
                    childrenArray.add(tags);
                for (int i = 0; i < children.length; i++) childrenArray.add(children[i]);
                children = new Object[childrenArray.size()];
                childrenArray.toArray(children);
            }
            // that the real children are being fetched
            return children;
        }
    }
    return super.getChildren(parentElement);
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) Branches(org.tigris.subversion.subclipse.core.history.Branches) ArrayList(java.util.ArrayList) Tags(org.tigris.subversion.subclipse.core.history.Tags)

Example 63 with ISVNRepositoryLocation

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

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

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

the class CreateRemoteFolderAction method execute.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#execute(org.eclipse.jface.action.IAction)
   */
protected void execute(IAction action) {
    ISVNRemoteFolder remoteFolder = null;
    if (selection.getFirstElement() instanceof ISVNRemoteFolder)
        remoteFolder = (ISVNRemoteFolder) selection.getFirstElement();
    else if (selection.getFirstElement() instanceof ISVNRepositoryLocation)
        remoteFolder = ((ISVNRepositoryLocation) selection.getFirstElement()).getRootFolder();
    else if (selection.getFirstElement() instanceof ISVNRemoteFile)
        remoteFolder = ((ISVNRemoteFile) selection.getFirstElement()).getParent();
    NewRemoteFolderWizard wizard = new NewRemoteFolderWizard(remoteFolder);
    WizardDialog dialog = new ClosableWizardDialog(shell, wizard);
    wizard.setParentDialog(dialog);
    dialog.open();
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) NewRemoteFolderWizard(org.tigris.subversion.subclipse.ui.wizards.NewRemoteFolderWizard) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog)

Aggregations

ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IResource (org.eclipse.core.resources.IResource)15 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)15 TeamException (org.eclipse.team.core.TeamException)14 ArrayList (java.util.ArrayList)13 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 File (java.io.File)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)8 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)8 Iterator (java.util.Iterator)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 List (java.util.List)6