1 11 package org.eclipse.ui.dialogs; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.jface.viewers.ITableLabelProvider; 18 import org.eclipse.jface.viewers.LabelProvider; 19 import org.eclipse.osgi.util.TextProcessor; 20 import org.eclipse.swt.graphics.Image; 21 import org.eclipse.ui.IFileEditorMapping; 22 23 38 public class FileEditorMappingLabelProvider extends LabelProvider implements 39 ITableLabelProvider { 40 41 44 public final static FileEditorMappingLabelProvider INSTANCE = new FileEditorMappingLabelProvider(); 45 46 49 private List imagesToDispose = new ArrayList (); 50 51 55 private FileEditorMappingLabelProvider() { 56 super(); 57 } 58 59 62 public void dispose() { 63 super.dispose(); 64 for (Iterator e = imagesToDispose.iterator(); e.hasNext();) { 65 ((Image) e.next()).dispose(); 66 } 67 imagesToDispose.clear(); 68 } 69 70 76 public Image getColumnImage(Object element, int row) { 77 return getImage(element); 78 } 79 80 83 public String getColumnText(Object element, int row) { 84 return getText(element); 85 } 86 87 92 public Image getImage(Object element) { 93 if (element instanceof IFileEditorMapping) { 94 Image image = ((IFileEditorMapping) element).getImageDescriptor() 95 .createImage(); 96 imagesToDispose.add(image); 97 return image; 98 } 99 return null; 100 } 101 102 105 public String getText(Object element) { 106 if (element instanceof IFileEditorMapping) { 107 return TextProcessor.process(((IFileEditorMapping) element) 108 .getLabel(), "*."); } 110 111 return null; 112 } 113 } 114 | Popular Tags |