blob: ba9eeb3b14b16ace594faaeb94fde71bcb0c1b7d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions.context;
import java.util.Iterator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter;
import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
public class ToggleStepFiltersAction extends AbstractDebugContextAction {
public ToggleStepFiltersAction()
{
super();
setEnabled(true);
}
protected void doAction(Object target) {
// do nothing, the action is done by ToggleStepFiltersActionDelegate instead
// since this action does not have access to the checked state of the window button
}
public ImageDescriptor getDisabledImageDescriptor() {
return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TOGGLE_STEP_FILTERS);
}
public String getHelpContextId() {
return "step_with_filters_action_context"; //$NON-NLS-1$
}
public ImageDescriptor getHoverImageDescriptor() {
return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS);
}
public String getId() {
return "org.eclipse.debug.ui.actions.ToggleStepFilters"; //$NON-NLS-1$
}
public ImageDescriptor getImageDescriptor() {
return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS);
}
public String getText() {
// TODO: this #getText method is not currently used, putting non-nl string
// until properties files are opened to be updated again.
return "Toggle Step Filters"; //$NON-NLS-1$
}
public String getToolTipText() {
// TODO: this #getToolTipText method is not currently used, putting non-nl string
// until properties files are opened to be updated again.
return "Toggle Step Filters"; //$NON-NLS-1$
}
protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) {
if (element instanceof IAdaptable)
{
IAsynchronousStepFiltersAdapter stepFilters = (IAsynchronousStepFiltersAdapter)((IAdaptable)element).getAdapter(IAsynchronousStepFiltersAdapter.class);
if (stepFilters != null)
{
stepFilters.supportsStepFilters(element, monitor);
}
else
{
notSupported(monitor);
}
}
}
protected void updateEnableStateForContext(IStructuredSelection selection) {
int size = selection.size();
if (size == 1)
{
BooleanRequestMonitor monitor = new BooleanRequestMonitor(this, size);
Iterator itr = selection.iterator();
while (itr.hasNext()) {
Object element = itr.next();
isEnabledFor(element, monitor);
}
}
else
{
BooleanRequestMonitor monitor = new BooleanRequestMonitor(this, 1);
monitor.setResult(true);
monitor.done();
}
}
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getInitialEnablement()
*/
protected boolean getInitialEnablement() {
return true;
}
}
|