Search in sources :

Example 26 with LocalResourceStatus

use of org.tigris.subversion.subclipse.core.resources.LocalResourceStatus in project subclipse by subclipse.

the class SVNLightweightDecorator method decorate.

/**
 * This method should only be called by the decorator thread.
 *
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
 *     org.eclipse.jface.viewers.IDecoration)
 */
public void decorate(Object element, IDecoration decoration) {
    IResource resource = null;
    try {
        resource = getResource(element);
        if (resource != null && resource.getType() == IResource.ROOT)
            return;
        boolean isIgnored = false;
        SVNTeamProvider svnProvider = null;
        ISVNLocalResource svnResource = null;
        if (resource != null) {
            // get the team provider
            svnProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
            if (svnProvider == null)
                return;
            // if the resource is ignored return an empty decoration. This will
            // force a decoration update event and clear the existing SVN decoration.
            svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                if (svnResource.isIgnored()) {
                    isIgnored = true;
                // return;
                }
            } catch (SVNException e) {
                // todo should log this error
                return;
            }
        }
        // determine a if resource has outgoing changes (e.g. is dirty).
        boolean isDirty = false;
        boolean isUnversioned = false;
        if (resource == null) {
            if (element instanceof ResourceMapping) {
                IProject[] projects = ((ResourceMapping) element).getProjects();
                if (projects != null) {
                    for (IProject project : projects) {
                        ISVNLocalResource svnProjectResource = SVNWorkspaceRoot.getSVNResourceFor(project);
                        if (svnProjectResource != null) {
                            try {
                                if (svnProjectResource.isDirty()) {
                                    decoration.addOverlay(dirty);
                                    return;
                                }
                            } catch (SVNException e) {
                                return;
                            }
                        }
                    }
                }
            }
            return;
        } else {
            LocalResourceStatus status = null;
            if (!isIgnored) {
                try {
                    status = svnResource.getStatusFromCache();
                    isDirty = SVNLightweightDecorator.isDirty(svnResource, status);
                } catch (SVNException e) {
                    if (!e.operationInterrupted()) {
                        SVNUIPlugin.log(e.getStatus());
                        isDirty = true;
                    }
                }
                if (status != null) {
                    isUnversioned = status.isUnversioned();
                }
                // if (resource.getType() == IResource.FILE || computeDeepDirtyCheck) {
                // //			        isDirty = SVNLightweightDecorator.isDirty(svnResource);
                // isDirty = SVNLightweightDecorator.isDirty(svnResource, status);
                // }
                // try {
                // status = svnResource.getStatusFromCache();
                // isUnversioned = status.isUnversioned();
                // } catch (SVNException e1) {
                // if (!e1.operationInterrupted()) {
                // SVNUIPlugin.log(e1.getStatus());
                // }
                // }
                decorateTextLabel(svnResource, status, decoration, isDirty);
            }
            computeColorsAndFonts(isIgnored, isDirty || isUnversioned, decoration);
            if (!isIgnored) {
                ImageDescriptor overlay = getOverlay(svnResource, status, isDirty, svnProvider);
                if (overlay != null) {
                    // actually sending null arg would work but this makes logic clearer
                    decoration.addOverlay(overlay);
                }
            }
        }
    } catch (Exception e) {
        SVNUIPlugin.log(IStatus.ERROR, "Error Decorating " + resource, e);
    }
}
Also used : SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException)

Aggregations

LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)26 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)17 IResource (org.eclipse.core.resources.IResource)12 SVNException (org.tigris.subversion.subclipse.core.SVNException)12 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)7 CoreException (org.eclipse.core.runtime.CoreException)6 TeamException (org.eclipse.team.core.TeamException)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ArrayList (java.util.ArrayList)4 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)4 File (java.io.File)3 List (java.util.List)2 IContainer (org.eclipse.core.resources.IContainer)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Path (org.eclipse.core.runtime.Path)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 OperationManager (org.tigris.subversion.subclipse.core.client.OperationManager)2 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)2