]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/javaeditor/OverrideIndicatorImageProvider.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / javaeditor / OverrideIndicatorImageProvider.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.javaeditor;
12
13 import org.eclipse.swt.graphics.Image;
14
15 import org.eclipse.jface.resource.ImageDescriptor;
16
17 import org.eclipse.jface.text.source.Annotation;
18
19 import org.eclipse.ui.texteditor.IAnnotationImageProvider;
20
21 import org.eclipse.jdt.internal.ui.JavaPluginImages;
22
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 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) {
37                 return null;
38         }
39
40         /*
41          * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
42          */
43         public String 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 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 }