1 11 package org.eclipse.jdt.internal.ui.browsing; 12 13 import org.eclipse.core.runtime.CoreException; 14 15 import org.eclipse.swt.graphics.Image; 16 17 import org.eclipse.jface.viewers.DecoratingLabelProvider; 18 import org.eclipse.jface.viewers.ILabelDecorator; 19 import org.eclipse.jface.viewers.ILabelProvider; 20 21 import org.eclipse.ui.IDecoratorManager; 22 import org.eclipse.ui.PlatformUI; 23 24 29 class ExcludingDecoratingLabelProvider extends DecoratingLabelProvider { 30 31 private String fExcludedDecoratorId; 32 33 public ExcludingDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator, String excludedDecoratorId) { 34 super(provider, decorator); 35 fExcludedDecoratorId= excludedDecoratorId; 36 } 37 38 39 42 public Image getImage(Object element) { 43 IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager(); 44 boolean isDecoratorEnabled= decoratorMgr.getEnabled(fExcludedDecoratorId); 45 46 if (isDecoratorEnabled) 47 try { 48 decoratorMgr.setEnabled(fExcludedDecoratorId, false); 49 } catch (CoreException e) { 50 } 52 53 Image image= super.getImage(element); 54 55 if (isDecoratorEnabled) 56 try { 57 decoratorMgr.setEnabled(fExcludedDecoratorId, true); 58 } catch (CoreException e) { 59 } 61 62 return image; 63 } 64 65 68 public String getText(Object element) { 69 IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager(); 70 boolean isDecoratorEnabled= decoratorMgr.getEnabled(fExcludedDecoratorId); 71 72 if (isDecoratorEnabled) 73 try { 74 decoratorMgr.setEnabled(fExcludedDecoratorId, false); 75 } catch (CoreException e) { 76 } 78 79 String text= super.getText(element); 80 81 if (isDecoratorEnabled) 82 try { 83 decoratorMgr.setEnabled(fExcludedDecoratorId, true); 84 } catch (CoreException e) { 85 } 87 88 return text; 89 } 90 } 91 | Popular Tags |