KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > variables > ToggleShowColumnsAction


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.debug.internal.ui.views.variables;
12
13 import org.eclipse.debug.internal.ui.DebugUIPlugin;
14 import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
15 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16 import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
17 import org.eclipse.debug.ui.DebugUITools;
18 import org.eclipse.jface.action.Action;
19 import org.eclipse.jface.action.IAction;
20 import org.eclipse.swt.custom.BusyIndicator;
21 import org.eclipse.ui.PlatformUI;
22 import org.eclipse.ui.texteditor.IUpdate;
23
24 /**
25  * Action to toggle the use of contributed variables content providers on and off.
26  * When on, all registered variables content providers for the current debug model
27  * are used. When off, the default content provider (that shows all children)
28  * is used for all debug models.
29  */

30 public class ToggleShowColumnsAction extends Action implements IUpdate {
31     
32     private TreeModelViewer fViewer;
33
34     public ToggleShowColumnsAction(TreeModelViewer viewew) {
35         super(VariablesViewMessages.ToggleShowColumnsAction_0, IAction.AS_CHECK_BOX);
36         fViewer = viewew;
37         setToolTipText(VariablesViewMessages.ToggleShowColumnsAction_1);
38         setImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_OBJS_COMMON_TAB));
39         setId(DebugUIPlugin.getUniqueIdentifier() + ".ToggleShowColumsAction"); //$NON-NLS-1$
40
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.SHOW_COLUMNS_ACTION);
41     }
42
43     /* (non-Javadoc)
44      * @see org.eclipse.jface.action.Action#run()
45      */

46     public void run() {
47         if (fViewer.getControl().isDisposed()) {
48             return;
49         }
50         BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable JavaDoc() {
51             public void run() {
52                 fViewer.setShowColumns(isChecked());
53             }
54         });
55     }
56     
57     /* (non-Javadoc)
58      * @see org.eclipse.ui.texteditor.IUpdate#update()
59      */

60     public void update() {
61         setEnabled(fViewer.canToggleColumns());
62         setChecked(fViewer.isShowColumns());
63     }
64     
65
66 }
67
Popular Tags