KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javaeditor > OverrideIndicatorImageProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.javaeditor;
13
14 import org.eclipse.swt.graphics.Image;
15
16 import org.eclipse.jface.resource.ImageDescriptor;
17
18 import org.eclipse.jface.text.source.Annotation;
19
20 import org.eclipse.ui.texteditor.IAnnotationImageProvider;
21
22 import org.eclipse.jdt.internal.ui.JavaPluginImages;
23
24 /**
25  * Image provider for {@link org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager.OverrideIndicator} annotations.
26  *
27  * @since 3.0
28  */

29 public class OverrideIndicatorImageProvider implements IAnnotationImageProvider {
30
31     /*
32      * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
33      */

34     private static final String JavaDoc OVERRIDE_IMG_DESC_ID= "JavaPluginImages.DESC_OBJ_OVERRIDES"; //$NON-NLS-1$
35
private static final String JavaDoc OVERWRITE_IMG_DESC_ID= "JavaPluginImages.DESC_OBJ_IMPLEMENTS"; //$NON-NLS-1$
36
public Image getManagedImage(Annotation annotation) {
37         return null;
38     }
39
40     /*
41      * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
42      */

43     public String JavaDoc getImageDescriptorId(Annotation annotation) {
44         if (!isImageProviderFor(annotation))
45             return null;
46
47         if (isOverwriting(annotation))
48             return OVERWRITE_IMG_DESC_ID;
49         else
50             return OVERRIDE_IMG_DESC_ID;
51     }
52
53     /*
54      * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
55      */

56     public ImageDescriptor getImageDescriptor(String JavaDoc 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;
61
62         return null;
63     }
64
65     private boolean isImageProviderFor(Annotation annotation) {
66         return annotation != null && OverrideIndicatorManager.ANNOTATION_TYPE.equals(annotation.getType());
67     }
68
69     private boolean isOverwriting(Annotation annotation) {
70         return ((OverrideIndicatorManager.OverrideIndicator)annotation).isOverwriteIndicator();
71     }
72 }
73
Popular Tags