1 /*******************************************************************************
2 * Copyright (c) 2000, 2010 IBM Corporation 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 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.javaeditor;
13 import org.eclipse.swt.graphics.Image;
15 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.jface.text.source.Annotation;
19 import org.eclipse.ui.texteditor.IAnnotationImageProvider;
21 import org.eclipse.jdt.internal.ui.JavaPluginImages;
25 * Image provider for {@link org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager.OverrideIndicator} annotations.
29 public class OverrideIndicatorImageProvider implements IAnnotationImageProvider {
32 * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
34 private static final String OVERRIDE_IMG_DESC_ID= "JavaPluginImages.DESC_OBJ_OVERRIDES"; //$NON-NLS-1$
35 private static final String OVERWRITE_IMG_DESC_ID= "JavaPluginImages.DESC_OBJ_IMPLEMENTS"; //$NON-NLS-1$
36 public Image getManagedImage(Annotation annotation) {
41 * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
43 public String getImageDescriptorId(Annotation annotation) {
44 if (!isImageProviderFor(annotation))
47 if (isOverwriting(annotation))
48 return OVERWRITE_IMG_DESC_ID;
50 return OVERRIDE_IMG_DESC_ID;
54 * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
56 public ImageDescriptor getImageDescriptor(String imageDescritporId) {
57 if (OVERWRITE_IMG_DESC_ID.equals(imageDescritporId))
58 return JavaPluginImages.DESC_OBJ_IMPLEMENTS;
59 else if (OVERRIDE_IMG_DESC_ID.equals(imageDescritporId))
60 return JavaPluginImages.DESC_OBJ_OVERRIDES;
65 private boolean isImageProviderFor(Annotation annotation) {
66 return annotation != null && OverrideIndicatorManager.ANNOTATION_TYPE.equals(annotation.getType());
69 private boolean isOverwriting(Annotation annotation) {
70 return ((OverrideIndicatorManager.OverrideIndicator)annotation).isOverwriteIndicator();