KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > context > ToggleStepFiltersAction


1 /*******************************************************************************
2  * Copyright (c) 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.actions.context;
12
13 import java.util.Iterator JavaDoc;
14
15 import org.eclipse.core.runtime.IAdaptable;
16 import org.eclipse.debug.internal.ui.DebugPluginImages;
17 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
18 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter;
19 import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor;
20 import org.eclipse.jface.resource.ImageDescriptor;
21 import org.eclipse.jface.viewers.IStructuredSelection;
22
23 public class ToggleStepFiltersAction extends AbstractDebugContextAction {
24
25     public ToggleStepFiltersAction()
26     {
27         super();
28         setEnabled(true);
29     }
30     
31     protected void doAction(Object JavaDoc target) {
32         // do nothing, the action is done by ToggleStepFiltersActionDelegate instead
33
// since this action does not have access to the checked state of the window button
34
}
35
36     public ImageDescriptor getDisabledImageDescriptor() {
37         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TOGGLE_STEP_FILTERS);
38     }
39
40     public String JavaDoc getHelpContextId() {
41         return "step_with_filters_action_context"; //$NON-NLS-1$
42
}
43
44     public ImageDescriptor getHoverImageDescriptor() {
45         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS);
46     }
47
48     public String JavaDoc getId() {
49         return "org.eclipse.debug.ui.actions.ToggleStepFilters"; //$NON-NLS-1$
50
}
51
52     public ImageDescriptor getImageDescriptor() {
53         return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS);
54     }
55
56     public String JavaDoc getText() {
57         // TODO: this #getText method is not currently used, putting non-nl string
58
// until properties files are opened to be updated again.
59
return "Toggle Step Filters"; //$NON-NLS-1$
60
}
61
62     public String JavaDoc getToolTipText() {
63         // TODO: this #getToolTipText method is not currently used, putting non-nl string
64
// until properties files are opened to be updated again.
65
return "Toggle Step Filters"; //$NON-NLS-1$
66
}
67
68     protected void isEnabledFor(Object JavaDoc element, IBooleanRequestMonitor monitor) {
69         if (element instanceof IAdaptable)
70         {
71             IAsynchronousStepFiltersAdapter stepFilters = (IAsynchronousStepFiltersAdapter)((IAdaptable)element).getAdapter(IAsynchronousStepFiltersAdapter.class);
72             if (stepFilters != null)
73             {
74                 stepFilters.supportsStepFilters(element, monitor);
75             }
76             else
77             {
78                 notSupported(monitor);
79             }
80         }
81
82     }
83
84     protected void updateEnableStateForContext(IStructuredSelection selection) {
85         
86        int size = selection.size();
87        if (size == 1)
88        {
89            BooleanRequestMonitor monitor = new BooleanRequestMonitor(this, size);
90     
91             Iterator JavaDoc itr = selection.iterator();
92             while (itr.hasNext()) {
93                 Object JavaDoc element = itr.next();
94                 isEnabledFor(element, monitor);
95             }
96         }
97         else
98         {
99             BooleanRequestMonitor monitor = new BooleanRequestMonitor(this, 1);
100             monitor.setResult(true);
101             monitor.done();
102         }
103     }
104
105     /* (non-Javadoc)
106      * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getInitialEnablement()
107      */

108     protected boolean getInitialEnablement() {
109         return true;
110     }
111     
112     
113
114 }
115
Popular Tags