KickJava   Java API By Example, From Geeks To Geeks.

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


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
18 import org.eclipse.ui.PlatformUI;
19
20 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
21 import org.eclipse.jdt.internal.ui.JavaPluginImages;
22
23 /**
24  * Toggles the orientationof the layout of the call hierarchy
25  */

26 class ToggleOrientationAction extends Action {
27
28     private CallHierarchyViewPart fView;
29     private int fActionOrientation;
30     
31     public ToggleOrientationAction(CallHierarchyViewPart v, int orientation) {
32         super("", AS_RADIO_BUTTON); //$NON-NLS-1$
33
if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL) {
34             setText(CallHierarchyMessages.ToggleOrientationAction_horizontal_label);
35             setDescription(CallHierarchyMessages.ToggleOrientationAction_horizontal_description);
36             setToolTipText(CallHierarchyMessages.ToggleOrientationAction_horizontal_tooltip);
37             JavaPluginImages.setLocalImageDescriptors(this, "th_horizontal.gif"); //$NON-NLS-1$
38
} else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_VERTICAL) {
39             setText(CallHierarchyMessages.ToggleOrientationAction_vertical_label);
40             setDescription(CallHierarchyMessages.ToggleOrientationAction_vertical_description);
41             setToolTipText(CallHierarchyMessages.ToggleOrientationAction_vertical_tooltip);
42             JavaPluginImages.setLocalImageDescriptors(this, "th_vertical.gif"); //$NON-NLS-1$
43
} else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC) {
44             setText(CallHierarchyMessages.ToggleOrientationAction_automatic_label);
45             setDescription(CallHierarchyMessages.ToggleOrientationAction_automatic_description);
46             setToolTipText(CallHierarchyMessages.ToggleOrientationAction_automatic_tooltip);
47             JavaPluginImages.setLocalImageDescriptors(this, "th_automatic.gif"); //$NON-NLS-1$
48
} else if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_SINGLE) {
49             setText(CallHierarchyMessages.ToggleOrientationAction_single_label);
50             setDescription(CallHierarchyMessages.ToggleOrientationAction_single_description);
51             setToolTipText(CallHierarchyMessages.ToggleOrientationAction_single_tooltip);
52             JavaPluginImages.setLocalImageDescriptors(this, "th_single.gif"); //$NON-NLS-1$
53
} else {
54             Assert.isTrue(false);
55         }
56         fView= v;
57         fActionOrientation= orientation;
58         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_ORIENTATION_ACTION);
59     }
60     
61     public int getOrientation() {
62         return fActionOrientation;
63     }
64     
65     /*
66      * @see Action#actionPerformed
67      */

68     public void run() {
69         if (isChecked()) {
70             fView.fOrientation= fActionOrientation;
71             fView.computeOrientation();
72         }
73     }
74     
75 }
76
Popular Tags