Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [Common Navigator] Image Decorators with Custom Resource Backed Models
[Common Navigator] Image Decorators with Custom Resource Backed Models [message #537303] Tue, 01 June 2010 20:47
Terran Gilman is currently offline Terran GilmanFriend
Messages: 67
Registered: July 2009
Member
I have been converting the VTP homebrew resource viewer to use the CNF by contributing to the built in Project Explorer view. Our model is completely custom from the project level and below. However, each item in our model is resource backed. I'd like to use the image/text labels that the platform creates for these items except the ones that need to be overridden for visual effect.

For example, there are several xml based files (registered under the content types extension) that have special builders attached that produce custom error markers (extends problem marker). I'd like to have the icon for this item be the platform default including any applicable decorations, such as the error markers. On the other hand I want to be able to intercept some folder types and provide VTP specific icons.

I have been able to accomplish these goals except for one. The decorations do not seem to be applied to the default icons. Here is the current incarnation for the getImage method of my label provider:

	public Image getImage(Object element)
	{
		Image ret = null;
		if(element instanceof IDependencySet)
			ret = org.eclipse.vtp.desktop.core.Activator.getDefault().getImageRegistry().get("ICON_LIBRARY");
		if(element instanceof IDesignDocument)
			ret = getInheritedImage(element);
		if(element instanceof IWorkflowResourceContainer)
			ret = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
		if(ret != null)
		{
			ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager()
            .getLabelDecorator();
	        if (decorator != null)
	        {
	        	Object obj = element;
				IResource resource = (IResource)((IAdaptable)element).getAdapter(IResource.class);
				if(resource != null)
					obj = resource;
	        	if (decorator instanceof LabelDecorator) {
					LabelDecorator ld2 = (LabelDecorator) decorator;
		            Image decorated = ld2.decorateImage(ret, obj, DecorationContext.DEFAULT_CONTEXT);
		            if (decorated != null) {
		                return decorated;
		            }
				} else {
		            Image decorated = decorator.decorateImage(ret, obj);
		            if (decorated != null) {
		                return decorated;
		            }
				}
	        }
	        return ret;
		}
		return getInheritedImage(element);
	}
	
	private Image getInheritedImage(Object element)
	{
		Image ret = null;//parentlabelProvider.getImage(element);
		if(ret == null)
		{
			if(element instanceof IAdaptable)
			{
				IResource resource = (IResource)((IAdaptable)element).getAdapter(IResource.class);
				if(resource != null)
					ret = parentlabelProvider.getImage(resource);
			}
		}
		return ret;
	}



The parent label provider was created by:

		parentlabelProvider = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider();


I'm at a loss as to how to proceed. Any help you guys can give is always appreciated.
Previous Topic:Standalone use of Eclipse tools creating workspace at runtime
Next Topic:toolbar inside a toolbar
Goto Forum:
  


Current Time: Thu Apr 25 17:24:06 GMT 2024

Powered by FUDForum. Page generated in 0.03310 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top