Search in sources :

Example 96 with ISVNLocalResource

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

the class IgnoreSynchronizeAction method getSyncInfoFilter.

/* (non-Javadoc)
   * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
   */
protected FastSyncInfoFilter getSyncInfoFilter() {
    return new FastSyncInfoFilter() {

        public boolean select(SyncInfo info) {
            SyncInfoDirectionFilter filter = new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING });
            if (!filter.select(info))
                return false;
            IStructuredSelection selection = getStructuredSelection();
            ISynchronizeModelElement element = (ISynchronizeModelElement) selection.getFirstElement();
            IResource resource = element.getResource();
            if (resource == null)
                return false;
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                // If the resource is a IProject then the action should not be enabled.
                if (svnResource.getIResource() instanceof IProject)
                    return false;
                // If the parent is not managed there is no way to set the svn:ignore property
                if (!svnResource.getParent().isManaged()) {
                    return false;
                }
                return !svnResource.getStatus().isManaged() && resource.exists();
            } catch (SVNException e) {
                return false;
            }
        }
    };
}
Also used : SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) ISynchronizeModelElement(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

Example 97 with ISVNLocalResource

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

the class CommentProperties method getCommentProperties.

public static CommentProperties getCommentProperties(IResource resource) throws SVNException {
    CommentProperties properties = null;
    IResource parent = resource;
    ISVNLocalResource svnResource = null;
    while (parent != null) {
        svnResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
        if (parent instanceof IProject || (svnResource.exists() && svnResource.isManaged() && !svnResource.getStatusFromCache().isDeleted())) {
            break;
        }
        parent = parent.getParent();
    }
    if (svnResource == null || !svnResource.exists() || !svnResource.isManaged() || svnResource.getStatusFromCache().isDeleted()) {
        return null;
    }
    properties = new CommentProperties();
    ISVNProperty[] commentProperties = svnResource.getPropertiesIncludingInherited(false, true, commentPropertiesFilterList);
    for (ISVNProperty commentProperty : commentProperties) {
        if (commentProperty.getName().equals("tsvn:logminsize")) {
            int minSize = 0;
            try {
                minSize = Integer.parseInt(commentProperty.getValue());
            } catch (Exception e) {
            }
            properties.setMinimumLogMessageSize(minSize);
        } else if (commentProperty.getName().equals("tsvn:lockmsgminsize")) {
            int minSize = 0;
            try {
                minSize = Integer.parseInt(commentProperty.getValue());
            } catch (Exception e) {
            }
            properties.setMinimumLockMessageSize(minSize);
        } else if (commentProperty.getName().equals("tsvn:logwidthmarker")) {
            int width = 0;
            try {
                width = Integer.parseInt(commentProperty.getValue());
            } catch (Exception e) {
            }
            properties.setLogWidthMarker(width);
        } else if (commentProperty.getName().equals("tsvn:logtemplate")) {
            properties.setLogTemplate(commentProperty.getValue());
        }
    }
    return properties;
}
Also used : ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) SVNException(org.tigris.subversion.subclipse.core.SVNException)

Example 98 with ISVNLocalResource

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

the class AddSynchronizeAction method getSyncInfoFilter.

protected FastSyncInfoFilter getSyncInfoFilter() {
    return new FastSyncInfoFilter() {

        public boolean select(SyncInfo info) {
            SyncInfoDirectionFilter filter = new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING });
            if (!filter.select(info))
                return false;
            IStructuredSelection selection = getStructuredSelection();
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                ISynchronizeModelElement element = (ISynchronizeModelElement) iter.next();
                IResource resource = element.getResource();
                if (resource == null)
                    return false;
                if (resource.isLinked())
                    return false;
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                try {
                    if (svnResource.isManaged())
                        return false;
                } catch (SVNException e) {
                    return false;
                }
            }
            return true;
        }
    };
}
Also used : SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) Iterator(java.util.Iterator) ISynchronizeModelElement(org.eclipse.team.ui.synchronize.ISynchronizeModelElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) FastSyncInfoFilter(org.eclipse.team.core.synchronize.FastSyncInfoFilter)

Example 99 with ISVNLocalResource

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

the class CommitAction method getUnaddedResources.

/**
 * get the unadded resources in resources parameter
 */
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];
        }
    }
    if (unadded.size() > 0)
        hasUnaddedResources = true;
    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 100 with ISVNLocalResource

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

the class CommitAction method onTagPath.

private boolean onTagPath(IResource[] modifiedResources) throws SVNException {
    // Multiple resources selected.
    if (url == null) {
        IResource resource = modifiedResources[0];
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        String firstUrl = svnResource.getStatus().getUrlString();
        if ((firstUrl == null) || (resource.getType() == IResource.FILE))
            firstUrl = Util.getParentUrl(svnResource);
        // $NON-NLS-1$
        if (firstUrl.indexOf("/tags/") != -1)
            return true;
    } else // One resource selected.
    if (url.indexOf("/tags/") != -1)
        // $NON-NLS-1$
        return true;
    return false;
}
Also used : ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

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