Search in sources :

Example 1 with SVNException

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

the class SVNMoveDeleteHook method deleteFolder.

public boolean deleteFolder(IResourceTree tree, IFolder folder, int updateFlags, IProgressMonitor monitor) {
    if (SVNWorkspaceRoot.isLinkedResource(folder))
        return false;
    ISVNLocalFolder resource = new LocalFolder(folder);
    try {
        if (!resource.isManaged()) {
            return false;
        }
        monitor.beginTask(null, 1000);
        deleteResource(resource);
        tree.deletedFolder(folder);
    } 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) SVNException(org.tigris.subversion.subclipse.core.SVNException)

Example 2 with SVNException

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

the class SVNMoveDeleteHook method getDeferFileDelete.

// Get the DeferFileDelete Property for selected resource.
private boolean getDeferFileDelete(IResource resource) {
    ISVNProperty property = null;
    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    ISVNLocalResource parent = svnResource;
    try {
        while (parent != null) {
            if (parent.isManaged()) {
                break;
            }
            parent = parent.getParent();
        }
        if (parent == null || !parent.isManaged()) {
            return false;
        }
        ISVNProperty[] deferFileDeleteProperties = parent.getPropertiesIncludingInherited(false, true, deferFileDeleteFilterList);
        if (deferFileDeleteProperties != null && deferFileDeleteProperties.length > 0) {
            return deferFileDeleteProperties[0].getValue().equalsIgnoreCase("true");
        }
    } catch (SVNException e) {
        return false;
    }
    return false;
}
Also used : ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

Example 3 with SVNException

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

the class SVNWorkspaceRoot method getRepositoryFor.

/**
 * Gets the repository which the local filesystem <code>location</code> belongs to.
 */
public static ISVNRepositoryLocation getRepositoryFor(IPath location) {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject[] projects = root.getProjects();
    for (IProject project : projects) {
        if (SVNWorkspaceRoot.isManagedBySubclipse(project) && project.getLocation().isPrefixOf(location)) {
            try {
                SVNTeamProvider teamProvider = (SVNTeamProvider) RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
                return teamProvider.getSVNWorkspaceRoot().getRepository();
            } catch (SVNException e) {
                // an exception is thrown when resource	is not managed
                SVNProviderPlugin.log(e);
                return null;
            }
        }
    }
    return null;
}
Also used : SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) SVNException(org.tigris.subversion.subclipse.core.SVNException) IProject(org.eclipse.core.resources.IProject)

Example 4 with SVNException

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

the class FileModificationManager method refreshStatus.

/**
 * Refresh (reset/reload) the status of all the given resources.
 *
 * @param resources Array of IResources to refresh
 */
private void refreshStatus(IResource[] resources) {
    // We are not able to get the status for a single file anyway,
    // so from the performance reasons we collect the parent folders of the files
    // and we refresh only those folders then.
    // All immediate child resources (files) are refreshed automatically
    Set<IContainer> foldersToRefresh = new HashSet<IContainer>(resources.length);
    for (IResource resource : resources) {
        if (resources.length == 1 && resources[0].getType() == IResource.FILE) {
            try {
                SVNProviderPlugin.getPlugin().getStatusCacheManager().refreshStatus(resource, false);
            } catch (SVNException e) {
                SVNProviderPlugin.log(IStatus.ERROR, e.getMessage(), e);
            }
        } else {
            if (resource.getType() == IResource.FILE) {
                foldersToRefresh.add(resource.getParent());
            } else {
                foldersToRefresh.add((IContainer) resource);
            }
        }
    }
    refreshStatusInfinite(foldersToRefresh);
}
Also used : SVNException(org.tigris.subversion.subclipse.core.SVNException) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Example 5 with SVNException

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

the class FileModificationManager method refreshStatusInfinite.

/**
 * Refresh (reset/reload) the status of all the given resources.
 *
 * @param resources List of IResource to refresh
 */
private void refreshStatusInfinite(Collection<? extends IResource> resources) {
    Set<IResource> alreadyRefreshedResources = new HashSet<IResource>();
    for (IResource resource : resources) {
        if (!alreadyRefreshedResources.contains(resource)) {
            try {
                IResource[] refreshedResources = SVNProviderPlugin.getPlugin().getStatusCacheManager().refreshStatus(resource, true);
                alreadyRefreshedResources.addAll(Arrays.asList(refreshedResources));
            } catch (SVNException e) {
                SVNProviderPlugin.log(IStatus.ERROR, e.getMessage(), e);
            }
        }
    }
}
Also used : SVNException(org.tigris.subversion.subclipse.core.SVNException) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Aggregations

SVNException (org.tigris.subversion.subclipse.core.SVNException)162 IResource (org.eclipse.core.resources.IResource)68 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)68 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)25 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)25 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)23 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 Iterator (java.util.Iterator)18 TeamException (org.eclipse.team.core.TeamException)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)17 IContainer (org.eclipse.core.resources.IContainer)16 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)16 File (java.io.File)15 IProject (org.eclipse.core.resources.IProject)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IFile (org.eclipse.core.resources.IFile)13 GridData (org.eclipse.swt.layout.GridData)13 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)13