1 11 package org.eclipse.debug.internal.ui.views.breakpoints; 12 13 import org.eclipse.debug.core.DebugPlugin; 14 import org.eclipse.debug.core.model.IBreakpoint; 15 import org.eclipse.debug.internal.ui.CompositeDebugImageDescriptor; 16 import org.eclipse.debug.internal.ui.DebugUIPlugin; 17 import org.eclipse.debug.ui.DebugUITools; 18 import org.eclipse.debug.ui.IDebugModelPresentation; 19 import org.eclipse.jface.viewers.IFontProvider; 20 import org.eclipse.jface.viewers.LabelProvider; 21 import org.eclipse.swt.graphics.Font; 22 import org.eclipse.swt.graphics.Image; 23 import org.eclipse.ui.model.WorkbenchLabelProvider; 24 25 28 public class BreakpointsLabelProvider extends LabelProvider implements IFontProvider { 29 30 private WorkbenchLabelProvider fWorkbenchLabelProvider; 31 private IDebugModelPresentation fPresentation; 32 33 36 public BreakpointsLabelProvider() { 37 fWorkbenchLabelProvider = new WorkbenchLabelProvider(); 38 fPresentation = DebugUITools.newDebugModelPresentation(); 39 } 40 41 44 public void dispose() { 45 fWorkbenchLabelProvider.dispose(); 46 fPresentation.dispose(); 47 super.dispose(); 48 } 49 50 53 public Image getImage(Object element) { 54 if (element instanceof IBreakpoint) { 55 return fPresentation.getImage(element); 56 } 57 Image image = fWorkbenchLabelProvider.getImage(element); 58 if (image != null) { 59 int flags= computeAdornmentFlags(); 60 if (flags > 0) { 61 CompositeDebugImageDescriptor descriptor= new CompositeDebugImageDescriptor(image, flags); 62 return DebugUIPlugin.getImageDescriptorRegistry().get(descriptor); 63 } 64 } 65 return image; 66 } 67 68 74 private int computeAdornmentFlags() { 75 if (!DebugPlugin.getDefault().getBreakpointManager().isEnabled()) { 76 return CompositeDebugImageDescriptor.SKIP_BREAKPOINT; 77 } 78 return 0; 79 } 80 81 84 public String getText(Object element) { 85 if (element instanceof IBreakpoint) { 86 return fPresentation.getText(element); 87 } 88 return fWorkbenchLabelProvider.getText(element); 89 } 90 91 94 public Font getFont(Object element) { 95 if (element instanceof IBreakpoint) { 96 return null; 97 } 98 return fWorkbenchLabelProvider.getFont(element); 99 } 100 101 106 protected IDebugModelPresentation getPresentation() { 107 return fPresentation; 108 } 109 } 110 | Popular Tags |