blob: 617a2f226e3cd286fcd14e4608a390600f0bad5b (
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
|
/*******************************************************************************
* Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial implementation
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.views.variables.VariablesView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.IUpdate;
/**
* Action which prompts the user to help them find a variable in
* the variables view.
*/
public class FindVariableAction extends Action implements IUpdate {
private class FindVariableDelegate extends AbstractListenerActionDelegate {
protected void doAction(Object element) {
VariablesView view= (VariablesView) getView();
Shell shell = view.getSite().getShell();
FindVariableDialog dialog= new FindVariableDialog(shell, view);
dialog.open();
}
protected void update(IAction action, ISelection s) {
if (action != null) {
((IUpdate) action).update();
}
}
protected void doHandleDebugEvent(DebugEvent event) {
update(getAction(), null);
}
public void run(IAction action) {
doAction(null);
}
}
private AbstractListenerActionDelegate fDelegate;
public FindVariableAction(VariablesView view) {
setText(ActionMessages.getString("FindVariableAction.0")); //$NON-NLS-1$
setId(DebugUIPlugin.getUniqueIdentifier() + ".FindVariableAction"); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.FIND_VARIABLE_ACTION);
fDelegate= new FindVariableDelegate();
fDelegate.init(view);
fDelegate.setAction(this);
}
public void run() {
fDelegate.run(this);
}
public void update() {
VariablesView view= (VariablesView) fDelegate.getView();
if (view != null) {
Viewer viewer = view.getViewer();
if (viewer != null) {
setEnabled(viewer.getInput() instanceof IStackFrame);
return;
}
}
setEnabled(false);
}
}
|