upload tizen1.0 source
[sdk/ide/product.git] / org.eclipse.cdt.ui / src / org / eclipse / cdt / internal / ui / editor / OverrideIndicatorImageProvider.java
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
7  *
8  * Contributors:
9  *    Tomasz Wesolowski - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.cdt.internal.ui.editor;
12
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;
17
18 import org.eclipse.cdt.internal.ui.CPluginImages;
19
20 /**
21  * @author Tomasz Wesolowski
22  *
23  */
24 public class OverrideIndicatorImageProvider implements
25                 IAnnotationImageProvider {
26
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$
30
31         /* (non-Javadoc)
32          * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
33          */
34         public Image getManagedImage(Annotation annotation) {
35                 return null;
36         }
37
38         /* (non-Javadoc)
39          * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
40          */
41         public String getImageDescriptorId(Annotation annotation) {
42                 if (!isImageProviderFor(annotation)) {
43                         return null;
44                 }
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;
52                 }
53                 assert false;
54                 return null;
55         }
56
57         /* (non-Javadoc)
58          * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
59          */
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;
67                 }
68                 assert false;
69                 return null;
70         }
71         
72         private boolean isImageProviderFor(Annotation annotation) {
73                 return annotation != null && OverrideIndicatorManager.OverrideIndicator.ANNOTATION_TYPE_ID.equals(annotation.getType());
74         }
75         
76         private int getAnnotationType(Annotation annotation) {
77                 return ((OverrideIndicatorManager.OverrideIndicator)annotation).getIndicationType();
78         }
79
80 }