1 /*******************************************************************************
2 * Copyright (c) 2010 Tomasz Wesolowski and others
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Tomasz Wesolowski - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.cdt.internal.ui.editor;
13 import org.eclipse.jface.resource.ImageDescriptor;
14 import org.eclipse.jface.text.source.Annotation;
15 import org.eclipse.swt.graphics.Image;
16 import org.eclipse.ui.texteditor.IAnnotationImageProvider;
18 import org.eclipse.cdt.internal.ui.CPluginImages;
21 * @author Tomasz Wesolowski
24 public class OverrideIndicatorImageProvider implements
25 IAnnotationImageProvider {
27 private static final String OVERRIDE_IMG_DESC_ID = "CPluginImages.DESC_OBJS_OVERRIDES"; //$NON-NLS-1$
28 private static final String IMPLEMENT_IMG_DESC_ID = "CPluginImages.DESC_OBJS_IMPLEMENTS"; //$NON-NLS-1$
29 private static final String SHADOW_IMG_DESC_ID = "CPluginImages.DESC_OBJS_SHADOWS"; //$NON-NLS-1$
32 * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
34 public Image getManagedImage(Annotation annotation) {
39 * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
41 public String getImageDescriptorId(Annotation annotation) {
42 if (!isImageProviderFor(annotation)) {
45 switch (getAnnotationType(annotation)) {
46 case OverrideIndicatorManager.RESULT_OVERRIDES:
47 return OVERRIDE_IMG_DESC_ID;
48 case OverrideIndicatorManager.RESULT_IMPLEMENTS:
49 return IMPLEMENT_IMG_DESC_ID;
50 case OverrideIndicatorManager.RESULT_SHADOWS:
51 return SHADOW_IMG_DESC_ID;
58 * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
60 public ImageDescriptor getImageDescriptor(String imageDescritporId) {
61 if (imageDescritporId.equals(OVERRIDE_IMG_DESC_ID)) {
62 return CPluginImages.DESC_OBJS_OVERRIDES;
63 } else if (imageDescritporId.equals(IMPLEMENT_IMG_DESC_ID)) {
64 return CPluginImages.DESC_OBJS_IMPLEMENTS;
65 } else if (imageDescritporId.equals(SHADOW_IMG_DESC_ID)) {
66 return CPluginImages.DESC_OBJS_SHADOWS;
72 private boolean isImageProviderFor(Annotation annotation) {
73 return annotation != null && OverrideIndicatorManager.OverrideIndicator.ANNOTATION_TYPE_ID.equals(annotation.getType());
76 private int getAnnotationType(Annotation annotation) {
77 return ((OverrideIndicatorManager.OverrideIndicator)annotation).getIndicationType();