1 20 package org.apache.directory.ldapstudio.schemas.view.views; 21 22 23 import org.eclipse.jface.viewers.DecoratingLabelProvider; 24 import org.eclipse.jface.viewers.ILabelDecorator; 25 import org.eclipse.jface.viewers.ILabelProvider; 26 import org.eclipse.jface.viewers.ITableLabelProvider; 27 import org.eclipse.jface.viewers.LabelDecorator; 28 import org.eclipse.swt.graphics.Image; 29 30 31 37 public class TableDecoratingLabelProvider extends DecoratingLabelProvider implements ITableLabelProvider 38 { 39 ITableLabelProvider provider; 40 ILabelDecorator decorator; 41 42 43 47 public TableDecoratingLabelProvider( ILabelProvider provider, ILabelDecorator decorator ) 48 { 49 super( provider, decorator ); 50 this.provider = ( ITableLabelProvider ) provider; 51 this.decorator = decorator; 52 } 53 54 55 58 public Image getColumnImage( Object element, int columnIndex ) 59 { 60 Image image = provider.getColumnImage( element, columnIndex ); 61 if ( decorator != null ) 62 { 63 if ( decorator instanceof LabelDecorator ) 64 { 65 LabelDecorator ld2 = ( LabelDecorator ) decorator; 66 Image decorated = ld2.decorateImage( image, element, getDecorationContext() ); 67 if ( decorated != null ) 68 { 69 return decorated; 70 } 71 } 72 else 73 { 74 Image decorated = decorator.decorateImage( image, element ); 75 if ( decorated != null ) 76 { 77 return decorated; 78 } 79 } 80 } 81 return image; 82 } 83 84 85 88 public String getColumnText( Object element, int columnIndex ) 89 { 90 String text = provider.getColumnText( element, columnIndex ); 91 if ( decorator != null ) 92 { 93 if ( decorator instanceof LabelDecorator ) 94 { 95 LabelDecorator ld2 = ( LabelDecorator ) decorator; 96 String decorated = ld2.decorateText( text, element, getDecorationContext() ); 97 if ( decorated != null ) 98 { 99 return decorated; 100 } 101 } 102 else 103 { 104 String decorated = decorator.decorateText( text, element ); 105 if ( decorated != null ) 106 { 107 return decorated; 108 } 109 } 110 } 111 return text; 112 } 113 } | Popular Tags |