Search in sources :

Example 6 with ISVNLocalFolder

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

the class UnmanageAction method getOperation.

/**
 * get the WorkspaceModifyOperation. The operation will : - delete svn directories if this option
 * has been chosen - unmap the project
 *
 * @return
 */
private IRunnableWithProgress getOperation() {
    return new WorkspaceModifyOperation() {

        public void execute(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                // maps the selected resources (projects) to their providers
                Hashtable table = getProviderMapping(getSelectedResources());
                Set keySet = table.keySet();
                // $NON-NLS-1$
                monitor.beginTask("", keySet.size() * 1000);
                // $NON-NLS-1$
                monitor.setTaskName(Policy.bind("Unmanage.unmanaging"));
                Iterator iterator = keySet.iterator();
                while (iterator.hasNext()) {
                    IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1000);
                    subMonitor.beginTask(null, 100);
                    SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
                    // get the resources (projects) to unmanage for the given provider
                    List list = (List) table.get(provider);
                    IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
                    for (int i = 0; i < providerResources.length; i++) {
                        // get the folder for the project
                        IResource resource = providerResources[i];
                        ISVNLocalFolder folder = SVNWorkspaceRoot.getSVNFolderFor((IContainer) resource);
                        try {
                            if (deleteContent) {
                                folder.unmanage(Policy.subMonitorFor(subMonitor, 10));
                            }
                        } finally {
                            // We want to remove the nature even if the unmanage operation fails
                            RepositoryProvider.unmap((IProject) resource);
                        }
                    }
                }
            } catch (TeamException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    };
}
Also used : Set(java.util.Set) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Hashtable(java.util.Hashtable) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) InfiniteSubProgressMonitor(org.tigris.subversion.subclipse.core.internal.InfiniteSubProgressMonitor) Iterator(java.util.Iterator) List(java.util.List) IResource(org.eclipse.core.resources.IResource)

Example 7 with ISVNLocalFolder

use of org.tigris.subversion.subclipse.core.ISVNLocalFolder 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)

Example 8 with ISVNLocalFolder

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

the class LocalResource method isIgnored.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNLocalResource#isIgnored()
   */
@SuppressWarnings("deprecation")
public boolean isIgnored() throws SVNException {
    // If the resource is a team private or linked resource, it is ignored
    if (resource.isTeamPrivateMember() || resource.isLinked()) {
        return true;
    }
    // always ignore .svn folder
    if ((resource.getType() == IResource.FOLDER) && SVNProviderPlugin.getPlugin().isAdminDirectory(getName())) {
        // $NON-NLS-1$
        return true;
    }
    if (resource.getType() == IResource.ROOT || resource.getType() == IResource.PROJECT) {
        return false;
    }
    if (isParentInSvnIgnore()) {
        return true;
    }
    if (hasSymlinkParent()) {
        return true;
    }
    LocalResourceStatus status = getStatusFromCache();
    // managed derived resources.
    if (resource.isDerived()) {
        if (SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_IGNORE_MANAGED_DERIVED_RESOURCES) || !status.isManaged()) {
            return true;
        }
    }
    // a managed resource is never ignored
    if (status.isManaged()) {
        return false;
    }
    // check ignore patterns from the .cvsignore file.
    if (status.isIgnored()) {
        return true;
    }
    // check the global ignores from Team
    if (Team.isIgnoredHint(resource)) {
        return true;
    }
    // check the parent, if the parent is ignored
    // then this resource is ignored also
    ISVNLocalFolder parent = getParent();
    if (parent == null) {
        return false;
    }
    if (parent.isIgnored()) {
        return true;
    }
    return false;
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder)

Example 9 with ISVNLocalFolder

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

the class Util method getParentUrl.

/**
 * Get the url string of the parent resource
 *
 * @param svnResource
 * @return parent's url, null if none of parents has an url
 * @throws SVNException
 */
public static String getParentUrl(ISVNLocalResource svnResource) throws SVNException {
    ISVNLocalFolder parent = svnResource.getParent();
    while (parent != null) {
        String url = parent.getStatus().getUrlString();
        if (url != null)
            return url;
        parent = parent.getParent();
    }
    return null;
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder)

Aggregations

ISVNLocalFolder (org.tigris.subversion.subclipse.core.ISVNLocalFolder)9 SVNException (org.tigris.subversion.subclipse.core.SVNException)5 CoreException (org.eclipse.core.runtime.CoreException)4 TeamException (org.eclipse.team.core.TeamException)3 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ISVNLocalFile (org.tigris.subversion.subclipse.core.ISVNLocalFile)2 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)2 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)2 SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)2 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)2 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 Iterator (java.util.Iterator)1 List (java.util.List)1