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);
}
}
Aggregations