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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.typehierarchy;
13 import org.eclipse.core.runtime.Assert;
15 import org.eclipse.jface.action.Action;
17 import org.eclipse.ui.PlatformUI;
19 import org.eclipse.jdt.ui.ITypeHierarchyViewPart;
21 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
22 import org.eclipse.jdt.internal.ui.JavaPluginImages;
25 * Toggles the orientationof the layout of the type hierarchy
27 public class ToggleOrientationAction extends Action {
29 private ITypeHierarchyViewPart fView;
30 private int fActionOrientation;
32 public ToggleOrientationAction(ITypeHierarchyViewPart v, int orientation) {
33 super("", AS_RADIO_BUTTON); //$NON-NLS-1$
34 if (orientation == ITypeHierarchyViewPart.VIEW_LAYOUT_HORIZONTAL) {
35 setText(TypeHierarchyMessages.ToggleOrientationAction_horizontal_label);
36 setDescription(TypeHierarchyMessages.ToggleOrientationAction_horizontal_description);
37 setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_horizontal_tooltip);
38 JavaPluginImages.setLocalImageDescriptors(this, "th_horizontal.gif"); //$NON-NLS-1$
39 } else if (orientation == ITypeHierarchyViewPart.VIEW_LAYOUT_VERTICAL) {
40 setText(TypeHierarchyMessages.ToggleOrientationAction_vertical_label);
41 setDescription(TypeHierarchyMessages.ToggleOrientationAction_vertical_description);
42 setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_vertical_tooltip);
43 JavaPluginImages.setLocalImageDescriptors(this, "th_vertical.gif"); //$NON-NLS-1$
44 } else if (orientation == ITypeHierarchyViewPart.VIEW_LAYOUT_AUTOMATIC) {
45 setText(TypeHierarchyMessages.ToggleOrientationAction_automatic_label);
46 setDescription(TypeHierarchyMessages.ToggleOrientationAction_automatic_description);
47 setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_automatic_tooltip);
48 JavaPluginImages.setLocalImageDescriptors(this, "th_automatic.gif"); //$NON-NLS-1$
49 } else if (orientation == ITypeHierarchyViewPart.VIEW_LAYOUT_SINGLE) {
50 setText(TypeHierarchyMessages.ToggleOrientationAction_single_label);
51 setDescription(TypeHierarchyMessages.ToggleOrientationAction_single_description);
52 setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_single_tooltip);
53 JavaPluginImages.setLocalImageDescriptors(this, "th_single.gif"); //$NON-NLS-1$
58 fActionOrientation= orientation;
59 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.TOGGLE_ORIENTATION_ACTION);
62 public int getOrientation() {
63 return fActionOrientation;
67 * @see Action#actionPerformed
72 fView.setViewLayout(fActionOrientation);