1 12 package org.eclipse.jdt.internal.ui.callhierarchy; 13 14 import org.eclipse.swt.graphics.Image; 15 import org.eclipse.swt.graphics.Point; 16 import org.eclipse.swt.graphics.Rectangle; 17 18 import org.eclipse.jface.resource.ImageDescriptor; 19 import org.eclipse.jface.viewers.ILabelDecorator; 20 import org.eclipse.jface.viewers.ILabelProviderListener; 21 22 import org.eclipse.jdt.internal.ui.JavaPlugin; 23 import org.eclipse.jdt.internal.ui.viewsupport.ImageImageDescriptor; 24 25 import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper; 26 27 31 public class CallHierarchyLabelDecorator implements ILabelDecorator { 32 33 37 public CallHierarchyLabelDecorator() { 38 } 40 41 44 public String decorateText(String text, Object element) { 45 return text; 46 } 47 48 51 public Image decorateImage(Image image, Object element) { 52 int adornmentFlags= computeAdornmentFlags(element); 53 if (adornmentFlags != 0) { 54 ImageDescriptor baseImage= new ImageImageDescriptor(image); 55 Rectangle bounds= image.getBounds(); 56 return JavaPlugin.getImageDescriptorRegistry().get(new CallHierarchyImageDescriptor(baseImage, adornmentFlags, new Point(bounds.width, bounds.height))); 57 } 58 return image; 59 } 60 61 64 private int computeAdornmentFlags(Object element) { 65 int flags= 0; 66 if (element instanceof MethodWrapper) { 67 MethodWrapper methodWrapper= (MethodWrapper) element; 68 if (methodWrapper.isRecursive()) { 69 flags= CallHierarchyImageDescriptor.RECURSIVE; 70 } 71 if (isMaxCallDepthExceeded(methodWrapper)) { 72 flags|= CallHierarchyImageDescriptor.MAX_LEVEL; 73 } 74 } 75 return flags; 76 } 77 78 private boolean isMaxCallDepthExceeded(MethodWrapper methodWrapper) { 79 return methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth(); 80 } 81 82 85 public void addListener(ILabelProviderListener listener) { 86 } 88 89 92 public void dispose() { 93 } 95 96 99 public boolean isLabelProperty(Object element, String property) { 100 return true; 101 } 102 103 106 public void removeListener(ILabelProviderListener listener) { 107 } 109 } 110 | Popular Tags |