KickJava   Java API By Example, From Geeks To Geeks.

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


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.views.variables;
12
13 import org.eclipse.debug.core.DebugPlugin;
14 import org.eclipse.debug.core.ILogicalStructureType;
15 import org.eclipse.debug.core.model.IValue;
16 import org.eclipse.jface.action.Action;
17 import org.eclipse.jface.action.IAction;
18 import org.eclipse.swt.custom.BusyIndicator;
19
20 /**
21  * Action to set the logical structure to display for a variable (enables/disables
22  * logical structure types for the same variable).
23  */

24 public class SelectLogicalStructureAction extends Action {
25     
26     private VariablesView fView;
27     private ILogicalStructureType fType;
28     private ILogicalStructureType[] fAvailableTypes;
29
30     /**
31      *
32      * @param view Variables view
33      * @param type the type that this action will turn on/off
34      * @param value the value for which logical structures are to be chosen
35      * @param availableTypes the set of logical structure types that are being offered
36      * to the user in addition to the type controlled by this action
37      */

38     public SelectLogicalStructureAction(VariablesView view, ILogicalStructureType type, IValue value, ILogicalStructureType[] availableTypes) {
39         super(type.getDescription(value), IAction.AS_CHECK_BOX);
40         setView(view);
41         fAvailableTypes= availableTypes;
42         fType= type;
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.jface.action.IAction#run()
47      */

48     public void run() {
49         valueChanged();
50     }
51
52     private void valueChanged() {
53         if (!getView().isAvailable()) {
54             return;
55         }
56         BusyIndicator.showWhile(getView().getViewer().getControl().getDisplay(), new Runnable JavaDoc() {
57             public void run() {
58                 // Checking this action sets the type to fType, unchecking it sets the type
59
// to null ("none selected")
60
ILogicalStructureType type= null;
61                 if (isChecked()) {
62                     type= fType;
63                 }
64                 DebugPlugin.setDefaultStructureType(fAvailableTypes, type);
65                 getView().getViewer().refresh();
66             }
67         });
68     }
69     
70     protected VariablesView getView() {
71         return fView;
72     }
73
74     protected void setView(VariablesView view) {
75         fView = view;
76     }
77 }
78
Popular Tags