1 12 13 package org.eclipse.jface.viewers; 14 15 16 26 class TableColumnViewerLabelProvider extends WrappedViewerLabelProvider { 27 28 private ITableLabelProvider tableLabelProvider; 29 30 private ITableColorProvider tableColorProvider; 31 32 private ITableFontProvider tableFontProvider; 33 34 43 public TableColumnViewerLabelProvider(IBaseLabelProvider labelProvider) { 44 super(labelProvider); 45 46 if (labelProvider instanceof ITableLabelProvider) 47 tableLabelProvider = (ITableLabelProvider) labelProvider; 48 49 if (labelProvider instanceof ITableColorProvider) 50 tableColorProvider = (ITableColorProvider) labelProvider; 51 52 if (labelProvider instanceof ITableFontProvider) 53 tableFontProvider = (ITableFontProvider) labelProvider; 54 } 55 56 57 58 61 public void update(ViewerCell cell) { 62 63 Object element = cell.getElement(); 64 int index = cell.getColumnIndex(); 65 66 if (tableLabelProvider == null) { 67 cell.setText(getLabelProvider().getText(element)); 68 cell.setImage(getLabelProvider().getImage(element)); 69 } else { 70 cell.setText(tableLabelProvider.getColumnText(element, index)); 71 cell.setImage(tableLabelProvider.getColumnImage(element, index)); 72 } 73 74 if (tableColorProvider == null) { 75 if (getColorProvider() != null) { 76 cell.setBackground(getColorProvider().getBackground(element)); 77 cell.setForeground(getColorProvider().getForeground(element)); 78 } 79 80 } else { 81 cell.setBackground(tableColorProvider 82 .getBackground(element, index)); 83 cell.setForeground(tableColorProvider 84 .getForeground(element, index)); 85 86 } 87 88 if (tableFontProvider == null) { 89 if (getFontProvider() != null) 90 cell.setFont(getFontProvider().getFont(element)); 91 } else 92 cell.setFont(tableFontProvider.getFont(element, index)); 93 94 } 95 96 97 } 98 | Popular Tags |