avoid NPE
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / BreakpointImageProvider.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.phpeditor;
12
13 import org.eclipse.core.resources.IMarker;
14
15 import org.eclipse.debug.ui.DebugUITools;
16 import org.eclipse.debug.ui.IDebugModelPresentation;
17
18 import org.eclipse.swt.graphics.Image;
19
20 import org.eclipse.jface.resource.ImageDescriptor;
21
22 import org.eclipse.jface.text.source.Annotation;
23
24 import org.eclipse.ui.texteditor.IAnnotationImageProvider;
25 import org.eclipse.ui.texteditor.MarkerAnnotation;
26
27 /**
28  * BreakpointImageProvider
29  * @since 3.0
30  */
31 public class BreakpointImageProvider implements IAnnotationImageProvider {
32         
33         private IDebugModelPresentation fPresentation;
34
35         /*
36          * @see org.eclipse.jface.text.source.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
37          */
38         public Image getManagedImage(Annotation annotation) {
39                 if (annotation instanceof MarkerAnnotation) {
40                         MarkerAnnotation markerAnnotation= (MarkerAnnotation) annotation;
41                         IMarker marker= markerAnnotation.getMarker();
42                         if (marker != null && marker.exists())
43                                 return getPresentation().getImage(marker);
44                 }
45                 
46                 return null;
47         }
48
49         /*
50          * @see org.eclipse.jface.text.source.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
51          */
52         public String getImageDescriptorId(Annotation annotation) {
53                 return null;
54         }
55
56         /*
57          * @see org.eclipse.jface.text.source.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
58          */
59         public ImageDescriptor getImageDescriptor(String imageDescritporId) {
60                 return null;
61         }
62         
63         private IDebugModelPresentation getPresentation() {
64                 if (fPresentation == null) 
65                         fPresentation= DebugUITools.newDebugModelPresentation();
66                 return fPresentation;
67         }
68 }