1 11 12 package org.eclipse.debug.internal.ui.elements.adapters; 13 14 import java.util.Arrays ; 15 import java.util.Iterator ; 16 import java.util.Map ; 17 import java.util.Map.Entry; 18 19 import org.eclipse.core.runtime.CoreException; 20 import org.eclipse.debug.core.model.IDebugElement; 21 import org.eclipse.debug.internal.ui.DelegatingModelPresentation; 22 import org.eclipse.debug.internal.ui.LazyModelPresentation; 23 import org.eclipse.debug.internal.ui.viewers.PartPresentationContext; 24 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 25 import org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousLabelAdapter; 26 import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor; 27 import org.eclipse.debug.internal.ui.views.launch.DebugElementHelper; 28 import org.eclipse.debug.ui.IDebugModelPresentation; 29 import org.eclipse.debug.ui.IDebugView; 30 import org.eclipse.jface.resource.ImageDescriptor; 31 import org.eclipse.swt.graphics.FontData; 32 import org.eclipse.swt.graphics.RGB; 33 import org.eclipse.ui.IWorkbenchPart; 34 35 40 public class AsynchronousDebugLabelAdapter extends AsynchronousLabelAdapter { 41 42 45 protected void computeLabels(Object element, IPresentationContext context, ILabelRequestMonitor monitor) { 46 DelegatingModelPresentation presentation = DebugElementHelper.getPresentation(); 47 if (context instanceof PartPresentationContext) { 51 PartPresentationContext ppc = (PartPresentationContext) context; 52 if (element instanceof IDebugElement && ppc.getPart() instanceof IDebugView) { 53 IWorkbenchPart part = ppc.getPart(); 54 if (part instanceof IDebugView) { 55 IDebugModelPresentation pres = ((IDebugView)part).getPresentation(((IDebugElement)element).getModelIdentifier()); 56 Map settings = null; 57 synchronized (presentation) { 58 if (pres instanceof DelegatingModelPresentation) { 59 settings = ((DelegatingModelPresentation)pres).getAttributes(); 60 } else if (pres instanceof LazyModelPresentation) { 61 settings = ((LazyModelPresentation)pres).getAttributes(); 62 } 63 if (settings != null) { 64 Iterator iterator = settings.entrySet().iterator(); 65 while (iterator.hasNext()) { 66 Map.Entry entry = (Entry) iterator.next(); 67 presentation.setAttribute((String ) entry.getKey(), entry.getValue()); 68 } 69 super.computeLabels(element, context, monitor); 70 return; 71 } 72 } 73 } 74 } 75 } 76 super.computeLabels(element, context, monitor); 77 } 78 79 82 protected String [] getLabels(Object element, IPresentationContext context) throws CoreException { 83 return new String [] {DebugElementHelper.getLabel(element)}; 84 } 85 86 89 protected ImageDescriptor[] getImageDescriptors(Object element, IPresentationContext context) throws CoreException { 90 return new ImageDescriptor[] {DebugElementHelper.getImageDescriptor(element)}; 91 } 92 93 96 protected FontData[] getFontDatas(Object element, IPresentationContext context) throws CoreException { 97 FontData[] datas = new FontData[getNumElements(context)]; 98 Arrays.fill(datas, DebugElementHelper.getFont(element)); 99 return datas; 100 } 101 102 105 protected RGB[] getForegrounds(Object element, IPresentationContext context) throws CoreException { 106 RGB[] rgbs = new RGB[getNumElements(context)]; 107 Arrays.fill(rgbs, DebugElementHelper.getForeground(element)); 108 return rgbs; 109 } 110 111 114 protected RGB[] getBackgrounds(Object element, IPresentationContext context) throws CoreException { 115 RGB[] rgbs = new RGB[getNumElements(context)]; 116 Arrays.fill(rgbs, DebugElementHelper.getBackground(element)); 117 return rgbs; 118 } 119 120 127 protected int getNumElements(IPresentationContext context) { 128 String [] columns = context.getColumns(); 129 if (columns == null) { 130 return 1; 131 } 132 return columns.length; 133 } 134 135 } 136 | Popular Tags |