Search in sources :

Example 1 with ImageRef

use of org.eclipse.n4js.ui.ImageDescriptorCache.ImageRef in project n4js by eclipse.

the class ProjectTypeLabelDecorator method decorate.

@Override
public void decorate(final Object element, final IDecoration decoration) {
    try {
        if (element instanceof IProject) {
            final URI uri = createPlatformResourceURI(((IProject) element).getName(), true);
            final IN4JSProject project = core.findProject(uri).orNull();
            if (null != project) {
                final ImageRef imageRef = IMAGE_REF_CACHE.get(project.getProjectType());
                if (null != imageRef) {
                    final ImageDescriptor descriptor = imageRef.asImageDescriptor().orNull();
                    if (null != descriptor) {
                        decoration.addOverlay(descriptor);
                    }
                }
            }
        }
    } catch (final Exception e) {
        // Exception should not propagate from here, otherwise the lightweight decorator stops working once till
        // next application startup.
        LOGGER.error("Error while trying to get decorator for " + element, e);
    }
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ImageRef(org.eclipse.n4js.ui.ImageDescriptorCache.ImageRef) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) URI(org.eclipse.emf.common.util.URI) URI.createPlatformResourceURI(org.eclipse.emf.common.util.URI.createPlatformResourceURI) IProject(org.eclipse.core.resources.IProject)

Aggregations

IProject (org.eclipse.core.resources.IProject)1 URI (org.eclipse.emf.common.util.URI)1 URI.createPlatformResourceURI (org.eclipse.emf.common.util.URI.createPlatformResourceURI)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)1 ImageRef (org.eclipse.n4js.ui.ImageDescriptorCache.ImageRef)1