1 11 package org.eclipse.jdt.internal.ui.packageview; 12 13 import java.util.HashMap ; 14 import java.util.Iterator ; 15 import java.util.Map ; 16 17 import org.eclipse.swt.graphics.Image; 18 19 import org.eclipse.jface.resource.ImageDescriptor; 20 21 import org.eclipse.ui.IWorkingSet; 22 23 public class WorkingSetAwareLabelProvider extends PackageExplorerLabelProvider { 24 25 private Map fImages= new HashMap (); 26 27 public WorkingSetAwareLabelProvider(long textFlags, int imageFlags, PackageExplorerContentProvider cp) { 28 super(textFlags, imageFlags, cp); 29 } 30 31 34 public String getText(Object element) { 35 if (element instanceof IWorkingSet) { 36 return decorateText(((IWorkingSet)element).getLabel(), element); 37 } 38 return super.getText(element); 39 } 40 41 44 public Image getImage(Object element) { 45 if (element instanceof IWorkingSet) { 46 ImageDescriptor image= ((IWorkingSet)element).getImage(); 47 Image result= (Image)fImages.get(image); 48 if (result == null) { 49 result= image.createImage(); 50 fImages.put(image, result); 51 } 52 return decorateImage(result, element); 53 } 54 return super.getImage(element); 55 } 56 57 60 public void dispose() { 61 for (Iterator iter= fImages.values().iterator(); iter.hasNext();) { 62 ((Image)iter.next()).dispose(); 63 } 64 super.dispose(); 65 } 66 } 67 | Popular Tags |