KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > ShowTypesAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.debug.internal.ui.actions;
12
13
14 import org.eclipse.debug.internal.ui.DebugPluginImages;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
17 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
18 import org.eclipse.debug.ui.IDebugModelPresentation;
19 import org.eclipse.debug.ui.IDebugUIConstants;
20 import org.eclipse.debug.ui.IDebugView;
21 import org.eclipse.jface.action.Action;
22 import org.eclipse.jface.action.IAction;
23 import org.eclipse.swt.custom.BusyIndicator;
24 import org.eclipse.ui.PlatformUI;
25
26 /**
27  * An action that toggles the state of a viewer to
28  * show/hide type names of variables.
29  * Only viewers that use a <code>VariableLabelProvider</code> to render its
30  * elements are effected.
31  */

32 public class ShowTypesAction extends Action {
33
34     private IDebugView fView;
35
36     public ShowTypesAction(IDebugView view) {
37         super(ActionMessages.ShowTypesAction_Show__Type_Names_1, IAction.AS_CHECK_BOX); //$NON-NLS-1$
38
setView(view);
39         setToolTipText(ActionMessages.ShowTypesAction_Show_Type_Names); //$NON-NLS-1$
40
setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_TYPE_NAMES));
41         setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TYPE_NAMES));
42         setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TYPE_NAMES));
43         setId(DebugUIPlugin.getUniqueIdentifier() + ".ShowTypesAction"); //$NON-NLS-1$
44
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.SHOW_TYPES_ACTION);
45     }
46
47     /**
48      * @see Action#run()
49      */

50     public void run() {
51         valueChanged(isChecked());
52     }
53
54     private void valueChanged(boolean on) {
55         if (getView().getViewer().getControl().isDisposed()) {
56             return;
57         }
58         
59         IDebugModelPresentation debugLabelProvider= (IDebugModelPresentation)getView().getAdapter(IDebugModelPresentation.class);
60         if (debugLabelProvider != null) {
61             debugLabelProvider.setAttribute(IDebugModelPresentation.DISPLAY_VARIABLE_TYPE_NAMES, (on ? Boolean.TRUE : Boolean.FALSE));
62             BusyIndicator.showWhile(getView().getViewer().getControl().getDisplay(), new Runnable JavaDoc() {
63                 public void run() {
64                     getView().getViewer().refresh();
65                 }
66             });
67         }
68     }
69     
70     protected IDebugView getView() {
71         return fView;
72     }
73
74     protected void setView(IDebugView view) {
75         fView = view;
76     }
77 }
78
79
80
Popular Tags