]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2008 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation | |
10 | * (report 36180: Callers/Callees view) | |
11 | *******************************************************************************/ | |
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.corext.callhierarchy.MethodWrapper; | |
23 | ||
24 | import org.eclipse.jdt.internal.ui.JavaPlugin; | |
25 | import org.eclipse.jdt.internal.ui.viewsupport.ImageImageDescriptor; | |
26 | ||
27 | /** | |
28 | * Label decorator that decorates an method's image with recursion overlays. | |
29 | * The viewer using this decorator is responsible for updating the images on element changes. | |
30 | */ | |
31 | public class CallHierarchyLabelDecorator implements ILabelDecorator { | |
32 | ||
33 | /** | |
34 | * Creates a decorator. The decorator creates an own image registry to cache | |
35 | * images. | |
36 | */ | |
37 | public CallHierarchyLabelDecorator() { | |
38 | // Do nothing | |
39 | } | |
40 | ||
41 | /* (non-Javadoc) | |
42 | * @see ILabelDecorator#decorateText(String, Object) | |
43 | */ | |
44 | public String decorateText(String text, Object element) { | |
45 | return text; | |
46 | } | |
47 | ||
48 | /* (non-Javadoc) | |
49 | * @see ILabelDecorator#decorateImage(Image, Object) | |
50 | */ | |
51 | public Image decorateImage(Image image, Object element) { | |
52 | if (image == null) | |
53 | return null; | |
54 | ||
55 | int adornmentFlags= computeAdornmentFlags(element); | |
56 | if (adornmentFlags != 0) { | |
57 | ImageDescriptor baseImage= new ImageImageDescriptor(image); | |
58 | Rectangle bounds= image.getBounds(); | |
59 | return JavaPlugin.getImageDescriptorRegistry().get(new CallHierarchyImageDescriptor(baseImage, adornmentFlags, new Point(bounds.width, bounds.height))); | |
60 | } | |
61 | return image; | |
62 | } | |
63 | ||
64 | /** | |
65 | * Note: This method is for internal use only. Clients should not call this method. | |
66 | * | |
67 | * @param element the element for which to compute the flags | |
68 | * @return the flags | |
69 | */ | |
70 | private int computeAdornmentFlags(Object element) { | |
71 | int flags= 0; | |
72 | if (element instanceof MethodWrapper) { | |
73 | MethodWrapper methodWrapper= (MethodWrapper) element; | |
74 | flags= methodWrapper.generated_6670114876980774710(flags, this); | |
75 | } | |
76 | return flags; | |
77 | } | |
78 | ||
79 | public boolean isMaxCallDepthExceeded(MethodWrapper methodWrapper) { | |
80 | return methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth(); | |
81 | } | |
82 | ||
83 | /* (non-Javadoc) | |
84 | * @see IBaseLabelProvider#addListener(ILabelProviderListener) | |
85 | */ | |
86 | public void addListener(ILabelProviderListener listener) { | |
87 | // Do nothing | |
88 | } | |
89 | ||
90 | /* (non-Javadoc) | |
91 | * @see IBaseLabelProvider#dispose() | |
92 | */ | |
93 | public void dispose() { | |
94 | // Nothing to dispose | |
95 | } | |
96 | ||
97 | /* (non-Javadoc) | |
98 | * @see IBaseLabelProvider#isLabelProperty(Object, String) | |
99 | */ | |
100 | public boolean isLabelProperty(Object element, String property) { | |
101 | return true; | |
102 | } | |
103 | ||
104 | /* (non-Javadoc) | |
105 | * @see IBaseLabelProvider#removeListener(ILabelProviderListener) | |
106 | */ | |
107 | public void removeListener(ILabelProviderListener listener) { | |
108 | // Do nothing | |
109 | } | |
110 | } |