1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.jface.viewers.*; 14 import org.eclipse.swt.graphics.*; 15 16 class MultiLabelDecorator extends LabelProvider implements ILabelDecorator, IFontDecorator, IColorDecorator { 17 private ILabelDecorator[] decorators; 18 19 public MultiLabelDecorator(ILabelDecorator[] decorators) { 20 this.decorators = decorators; 21 } 22 23 26 public Image decorateImage(Image image, Object element) { 27 for (int i = 0; i < decorators.length; i++) { 28 ILabelDecorator decorator = decorators[i]; 29 Image newImage = decorator.decorateImage(image, element); 30 if (newImage != null) { 31 image = newImage; 32 } 33 } 34 return image; 35 } 36 37 40 public String decorateText(String text, Object element) { 41 for (int i = 0; i < decorators.length; i++) { 42 ILabelDecorator decorator = decorators[i]; 43 String newText = decorator.decorateText(text, element); 44 if (newText != null) { 45 text = newText; 46 } 47 } 48 return text; 49 } 50 51 54 public void dispose() { 55 for (int i = 0; i < decorators.length; i++) { 56 ILabelDecorator d = decorators[i]; 57 d.dispose(); 58 } 59 } 60 61 64 public Font decorateFont(Object element) { 65 for (int i = 0; i < decorators.length; i++) { 66 ILabelDecorator decorator = decorators[i]; 67 if(decorator instanceof IFontDecorator) { 68 return ((IFontDecorator)decorator).decorateFont(element); 69 } 70 } 71 return null; 72 } 73 74 77 public Color decorateForeground(Object element) { 78 for (int i = 0; i < decorators.length; i++) { 79 ILabelDecorator decorator = decorators[i]; 80 if(decorator instanceof IColorDecorator) { 81 return ((IColorDecorator)decorator).decorateForeground(element); 82 } 83 } 84 return null; 85 } 86 87 90 public Color decorateBackground(Object element) { 91 for (int i = 0; i < decorators.length; i++) { 92 ILabelDecorator decorator = decorators[i]; 93 if(decorator instanceof IColorDecorator) { 94 return ((IColorDecorator)decorator).decorateBackground(element); 95 } 96 } 97 return null; 98 } 99 } | Popular Tags |