KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > callhierarchy > HistoryAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.core.runtime.Assert;
15
16 import org.eclipse.jface.action.Action;
17 import org.eclipse.jface.resource.ImageDescriptor;
18
19 import org.eclipse.ui.PlatformUI;
20
21 import org.eclipse.jdt.core.IJavaElement;
22 import org.eclipse.jdt.core.IMethod;
23
24 import org.eclipse.jdt.internal.corext.util.Messages;
25
26 import org.eclipse.jdt.ui.JavaElementLabelProvider;
27
28 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
29 import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
30
31 /**
32  * Action used for the type hierarchy forward / backward buttons
33  */

34 class HistoryAction extends Action {
35     private static JavaElementLabelProvider fLabelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_POST_QUALIFIED |
36             JavaElementLabelProvider.SHOW_PARAMETERS |
37             JavaElementLabelProvider.SHOW_RETURN_TYPE);
38     private CallHierarchyViewPart fView;
39     private IMethod fMethod;
40
41     public HistoryAction(CallHierarchyViewPart viewPart, IMethod element) {
42         super("", AS_RADIO_BUTTON); //$NON-NLS-1$
43
fView = viewPart;
44         fMethod = element;
45
46         String JavaDoc elementName = getElementLabel(element);
47         setText(elementName);
48         setImageDescriptor(getImageDescriptor(element));
49
50         setDescription(Messages.format(CallHierarchyMessages.HistoryAction_description, elementName));
51         setToolTipText(Messages.format(CallHierarchyMessages.HistoryAction_tooltip, elementName));
52         
53         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_HISTORY_ACTION);
54     }
55
56     private ImageDescriptor getImageDescriptor(IJavaElement elem) {
57         JavaElementImageProvider imageProvider = new JavaElementImageProvider();
58         ImageDescriptor desc = imageProvider.getBaseImageDescriptor(elem, 0);
59         imageProvider.dispose();
60
61         return desc;
62     }
63
64     /*
65      * @see Action#run()
66      */

67     public void run() {
68         fView.gotoHistoryEntry(fMethod);
69     }
70
71     /**
72      * @param element
73      * @return String
74      */

75     private String JavaDoc getElementLabel(IJavaElement element) {
76         Assert.isNotNull(element);
77         return fLabelProvider.getText(element);
78     }
79 }
80
Popular Tags