]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2011 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.core.runtime.Assert; | |
14 | ||
15 | import org.eclipse.jface.action.Action; | |
16 | ||
17 | import org.eclipse.ui.PlatformUI; | |
18 | ||
19 | import org.eclipse.jdt.ui.ITypeHierarchyViewPart; | |
20 | ||
21 | import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; | |
22 | import org.eclipse.jdt.internal.ui.JavaPluginImages; | |
23 | ||
24 | /** | |
25 | * Action to switch between the different hierarchy views. | |
26 | */ | |
27 | public class ToggleViewAction extends Action { | |
28 | ||
29 | private ITypeHierarchyViewPart fViewPart; | |
30 | private int fViewerIndex; | |
31 | ||
32 | public ToggleViewAction(ITypeHierarchyViewPart v, int viewerIndex) { | |
33 | super("", AS_RADIO_BUTTON); //$NON-NLS-1$ | |
34 | String contextHelpId= null; | |
35 | if (viewerIndex == ITypeHierarchyViewPart.HIERARCHY_MODE_SUPERTYPES) { | |
36 | setText(TypeHierarchyMessages.ToggleViewAction_supertypes_label); | |
37 | contextHelpId= IJavaHelpContextIds.SHOW_SUPERTYPES; | |
38 | setDescription(TypeHierarchyMessages.ToggleViewAction_supertypes_description); | |
39 | setToolTipText(TypeHierarchyMessages.ToggleViewAction_supertypes_tooltip); | |
40 | JavaPluginImages.setLocalImageDescriptors(this, "super_co.gif"); //$NON-NLS-1$ | |
41 | } else if (viewerIndex == ITypeHierarchyViewPart.HIERARCHY_MODE_SUBTYPES) { | |
42 | setText(TypeHierarchyMessages.ToggleViewAction_subtypes_label); | |
43 | contextHelpId= IJavaHelpContextIds.SHOW_SUBTYPES; | |
44 | setDescription(TypeHierarchyMessages.ToggleViewAction_subtypes_description); | |
45 | setToolTipText(TypeHierarchyMessages.ToggleViewAction_subtypes_tooltip); | |
46 | JavaPluginImages.setLocalImageDescriptors(this, "sub_co.gif"); //$NON-NLS-1$ | |
47 | } else if (viewerIndex == ITypeHierarchyViewPart.HIERARCHY_MODE_CLASSIC) { | |
48 | setText(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_label); | |
49 | contextHelpId= IJavaHelpContextIds.SHOW_HIERARCHY; | |
50 | setDescription(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_description); | |
51 | setToolTipText(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_tooltip); | |
52 | JavaPluginImages.setLocalImageDescriptors(this, "hierarchy_co.gif"); //$NON-NLS-1$ | |
53 | } else { | |
54 | Assert.isTrue(false); | |
55 | } | |
56 | ||
57 | fViewPart= v; | |
58 | fViewerIndex= viewerIndex; | |
59 | ||
60 | PlatformUI.getWorkbench().getHelpSystem().setHelp(this, contextHelpId); | |
61 | } | |
62 | ||
63 | public int getViewerIndex() { | |
64 | return fViewerIndex; | |
65 | } | |
66 | ||
67 | /* | |
68 | * @see Action#actionPerformed | |
69 | */ | |
70 | @Override | |
71 | public void run() { | |
72 | fViewPart.setHierarchyMode(fViewerIndex); | |
73 | } | |
74 | } |