Search in sources :

Example 56 with ISVNLocalResource

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

the class EditConflictsAction method execute.

/*
   * (non-Javadoc)
   *
   * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#execute(org.eclipse.jface.action.IAction)
   */
protected void execute(final IAction action) throws InvocationTargetException, InterruptedException {
    IFile resource;
    if (selectedResource == null)
        resource = (IFile) getSelectedResources()[0];
    else
        resource = selectedResource;
    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    try {
        IFile conflictNewFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictNew());
        IFile conflictOldFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictOld());
        IFile conflictWorkingFile = (IFile) File2Resource.getResource(svnResource.getStatus().getConflictWorking());
        if (conflictWorkingFile == null) {
            conflictWorkingFile = resource;
        }
        MergeFileAssociation mergeFileAssociation = null;
        try {
            mergeFileAssociation = SVNUIPlugin.getPlugin().getMergeFileAssociation(resource.getName());
        } catch (BackingStoreException e) {
            mergeFileAssociation = new MergeFileAssociation();
        }
        if (mergeFileAssociation.getType() == MergeFileAssociation.BUILT_IN) {
            editConflictsInternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile);
        } else if (mergeFileAssociation.getType() == MergeFileAssociation.DEFAULT_EXTERNAL) {
            IPreferenceStore preferenceStore = SVNUIPlugin.getPlugin().getPreferenceStore();
            String mergeProgramLocation = preferenceStore.getString(ISVNUIConstants.PREF_MERGE_PROGRAM_LOCATION);
            String mergeProgramParameters = preferenceStore.getString(ISVNUIConstants.PREF_MERGE_PROGRAM_PARAMETERS);
            editConflictsExternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile, mergeProgramLocation, mergeProgramParameters);
        } else {
            editConflictsExternal(resource, conflictOldFile, conflictWorkingFile, conflictNewFile, mergeFileAssociation.getMergeProgram(), mergeFileAssociation.getParameters());
        }
    } catch (Exception e) {
        exception = e;
    }
    if (exception != null) {
        throw new InvocationTargetException(exception);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) BackingStoreException(org.osgi.service.prefs.BackingStoreException) MergeFileAssociation(org.tigris.subversion.subclipse.ui.conflicts.MergeFileAssociation) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SVNException(org.tigris.subversion.subclipse.core.SVNException) BackingStoreException(org.osgi.service.prefs.BackingStoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 57 with ISVNLocalResource

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

the class GenerateDiffFileAction method getUnaddedResources.

private IResource[] getUnaddedResources(List resources, IProgressMonitor iProgressMonitor) throws SVNException {
    final List unadded = new ArrayList();
    final SVNException[] exception = new SVNException[] { null };
    for (Iterator iter = resources.iterator(); iter.hasNext(); ) {
        IResource resource = (IResource) iter.next();
        if (resource.exists()) {
            // visit each resource deeply
            try {
                resource.accept(new IResourceVisitor() {

                    public boolean visit(IResource aResource) {
                        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(aResource);
                        // skip ignored resources and their children
                        try {
                            if (svnResource.isIgnored())
                                return false;
                            // visit the children of shared resources
                            if (svnResource.isManaged())
                                return true;
                            if ((aResource.getType() == IResource.FOLDER) && // don't traverse into symlink folders
                            isSymLink(aResource))
                                return false;
                        } catch (SVNException e) {
                            exception[0] = e;
                        }
                        // file/folder is unshared so record it
                        unadded.add(aResource);
                        return aResource.getType() == IResource.FOLDER;
                    }
                }, IResource.DEPTH_INFINITE, false);
            } catch (CoreException e) {
                throw SVNException.wrapException(e);
            }
            if (exception[0] != null)
                throw exception[0];
        }
    }
    return (IResource[]) unadded.toArray(new IResource[unadded.size()]);
}
Also used : IResourceVisitor(org.eclipse.core.resources.IResourceVisitor) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 58 with ISVNLocalResource

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

the class ResolveActionWithChoices method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    boolean folderSelected = false;
    boolean propertyConflicts = false;
    boolean textConflicts = false;
    boolean treeConflicts = false;
    boolean treeConflictDialogShown = false;
    IResource[] resources = getSelectedResources();
    for (int i = 0; i < resources.length; i++) {
        if (resources[i] instanceof IContainer) {
            folderSelected = true;
        }
        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 (resources.length == 1 && treeConflicts && !propertyConflicts && !textConflicts) {
        treeConflict = getTreeConflict(resources[0]);
        if (treeConflict != null) {
            ResolveTreeConflictWizard wizard = new ResolveTreeConflictWizard(treeConflict, getTargetPart());
            WizardDialog dialog = new SizePersistedWizardDialog(Display.getDefault().getActiveShell(), wizard, // $NON-NLS-1$
            "ResolveTreeConflict");
            if (dialog.open() != WizardDialog.OK)
                return;
            treeConflictDialogShown = true;
        }
    }
    if (resources.length > 1 && treeConflicts) {
        if (!MessageDialog.openConfirm(getShell(), Policy.bind("ResolveOperation.taskName"), Policy.bind("ResolveAction.confirmTreeConflicts")))
            // $NON-NLS-1$	//$NON-NLS-2$
            return;
        setResolution(ISVNConflictResolver.Choice.chooseMerged);
    } else if (!treeConflictDialogShown) {
        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)
            return;
        setResolution(markResolvedPage.getResolution());
    }
    if (!treeConflictDialogShown)
        super.execute(action);
}
Also used : SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) ResolveTreeConflictWizard(org.tigris.subversion.subclipse.ui.conflicts.ResolveTreeConflictWizard) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) IContainer(org.eclipse.core.resources.IContainer) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) IResource(org.eclipse.core.resources.IResource) SvnWizardMarkResolvedPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardMarkResolvedPage)

Example 59 with ISVNLocalResource

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

the class SVNMoveDeleteHook method moveFile.

/*
   * (non-Javadoc)
   *
   * @see org.eclipse.core.resources.team.IMoveDeleteHook#moveFile(org.eclipse.core.resources.team.IResourceTree,
   *      org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile,
   *      int, org.eclipse.core.runtime.IProgressMonitor)
   */
public boolean moveFile(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor) {
    if (SVNWorkspaceRoot.isLinkedResource(source))
        return false;
    try {
        RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(destination.getProject());
        if (repositoryProvider == null || // target is not SVN project
        !(repositoryProvider instanceof SVNTeamProvider))
            return false;
        ISVNLocalFile resource = new LocalFile(source);
        // pass
        if (!resource.isManaged())
            return false;
        ISVNRepositoryLocation sourceRepository = resource.getRepository();
        ISVNClientAdapter svnClient = sourceRepository.getSVNClient();
        ISVNLocalResource parent = SVNWorkspaceRoot.getSVNResourceFor(destination.getParent());
        ISVNRepositoryLocation targetRepository = parent.getRepository();
        if (!sourceRepository.equals(targetRepository)) {
            return false;
        }
        monitor.beginTask(null, 1000);
        try {
            OperationManager.getInstance().beginOperation(svnClient);
            // see bug #15
            if (!SVNWorkspaceRoot.getSVNFolderFor(destination.getParent()).isManaged()) {
                SVNTeamProvider provider = (SVNTeamProvider) repositoryProvider;
                provider.add(new IResource[] { destination.getParent() }, IResource.DEPTH_ZERO, new NullProgressMonitor());
                if (parent != null)
                    parent.refreshStatus();
            }
            // force is set to true because when we rename (refactor) a
            // java class, the file is modified before being moved
            // A modified file cannot be moved without force
            svnClient.move(source.getLocation().toFile(), destination.getLocation().toFile(), true);
            // movedFile must be done before endOperation because
            // destination file must not already exist in the workspace
            // resource tree.
            tree.movedFile(source, destination);
            destination.refreshLocal(IResource.DEPTH_ZERO, monitor);
        } catch (SVNClientException e) {
            throw SVNException.wrapException(e);
        } catch (TeamException e) {
            throw SVNException.wrapException(e);
        } catch (CoreException e) {
            throw SVNException.wrapException(e);
        } finally {
            resource.getRepository().returnSVNClient(svnClient);
            OperationManager.getInstance().endOperation(false, null, false);
        }
    } catch (SVNException e) {
        tree.failed(e.getStatus());
    } finally {
        monitor.done();
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TeamException(org.eclipse.team.core.TeamException) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) SVNException(org.tigris.subversion.subclipse.core.SVNException) RepositoryProvider(org.eclipse.team.core.RepositoryProvider) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 60 with ISVNLocalResource

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

the class SVNMoveDeleteHook method moveFolder.

public boolean moveFolder(IResourceTree tree, IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor) {
    if (SVNWorkspaceRoot.isLinkedResource(source))
        return false;
    try {
        ISVNLocalFolder resource = new LocalFolder(source);
        if (!resource.isManaged())
            return false;
        RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(destination.getProject());
        if (repositoryProvider == null || // target is not SVN project
        !(repositoryProvider instanceof SVNTeamProvider))
            return false;
        ISVNRepositoryLocation sourceRepository = resource.getRepository();
        ISVNLocalResource parent = SVNWorkspaceRoot.getSVNResourceFor(destination.getParent());
        ISVNRepositoryLocation targetRepository = parent.getRepository();
        if (!sourceRepository.equals(targetRepository)) {
            return false;
        }
        monitor.beginTask(null, 1000);
        ISVNClientAdapter svnClient = sourceRepository.getSVNClient();
        try {
            OperationManager.getInstance().beginOperation(svnClient);
            // see bug #15
            if (!SVNWorkspaceRoot.getSVNFolderFor(destination.getParent()).isManaged()) {
                SVNTeamProvider provider = (SVNTeamProvider) repositoryProvider;
                provider.add(new IResource[] { destination.getParent() }, IResource.DEPTH_ZERO, new NullProgressMonitor());
                if (parent != null)
                    parent.refreshStatus();
            }
            svnClient.move(source.getLocation().toFile(), destination.getLocation().toFile(), true);
            tree.movedFolderSubtree(source, destination);
            destination.refreshLocal(IResource.DEPTH_INFINITE, monitor);
        } catch (SVNClientException e) {
            throw SVNException.wrapException(e);
        } catch (CoreException e) {
            throw SVNException.wrapException(e);
        } finally {
            resource.getRepository().returnSVNClient(svnClient);
            OperationManager.getInstance().endOperation(false);
        }
    } catch (SVNException e) {
        tree.failed(e.getStatus());
    } finally {
        monitor.done();
    }
    return true;
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNException(org.tigris.subversion.subclipse.core.SVNException) RepositoryProvider(org.eclipse.team.core.RepositoryProvider) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)120 IResource (org.eclipse.core.resources.IResource)77 SVNException (org.tigris.subversion.subclipse.core.SVNException)76 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)24 Iterator (java.util.Iterator)20 IFile (org.eclipse.core.resources.IFile)20 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 List (java.util.List)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)17 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)17 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)17 File (java.io.File)16 TeamException (org.eclipse.team.core.TeamException)16 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IContainer (org.eclipse.core.resources.IContainer)13 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)11