KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > typehierarchy > 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.typehierarchy;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.resource.ImageDescriptor;
15
16 import org.eclipse.ui.PlatformUI;
17
18 import org.eclipse.jdt.core.IJavaElement;
19
20 import org.eclipse.jdt.internal.corext.util.Messages;
21
22 import org.eclipse.jdt.ui.JavaElementLabels;
23
24 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
25 import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
26
27 /**
28  * Action used for the type hierarchy forward / backward buttons
29  */

30 public class HistoryAction extends Action {
31
32     private TypeHierarchyViewPart fViewPart;
33     private IJavaElement fElement;
34     
35     public HistoryAction(TypeHierarchyViewPart viewPart, IJavaElement element) {
36         super("", AS_RADIO_BUTTON); //$NON-NLS-1$
37
fViewPart= viewPart;
38         fElement= element;
39         
40         String JavaDoc elementName= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_POST_QUALIFIED | JavaElementLabels.ALL_DEFAULT);
41         setText(elementName);
42         setImageDescriptor(getImageDescriptor(element));
43                 
44         setDescription(Messages.format(TypeHierarchyMessages.HistoryAction_description, elementName));
45         setToolTipText(Messages.format(TypeHierarchyMessages.HistoryAction_tooltip, elementName));
46         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.HISTORY_ACTION);
47     }
48     
49     private ImageDescriptor getImageDescriptor(IJavaElement elem) {
50         JavaElementImageProvider imageProvider= new JavaElementImageProvider();
51         ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
52         imageProvider.dispose();
53         return desc;
54     }
55     
56     /*
57      * @see Action#run()
58      */

59     public void run() {
60         fViewPart.gotoHistoryEntry(fElement);
61     }
62     
63 }
64
Popular Tags