1 11 package org.eclipse.debug.internal.ui.actions; 12 13 import org.eclipse.debug.core.DebugEvent; 14 import org.eclipse.debug.core.model.IStackFrame; 15 import org.eclipse.debug.internal.ui.DebugUIPlugin; 16 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 17 import org.eclipse.debug.internal.ui.views.variables.VariablesView; 18 import org.eclipse.jface.action.Action; 19 import org.eclipse.jface.action.IAction; 20 import org.eclipse.jface.viewers.ISelection; 21 import org.eclipse.jface.viewers.Viewer; 22 import org.eclipse.swt.widgets.Shell; 23 import org.eclipse.ui.PlatformUI; 24 import org.eclipse.ui.texteditor.IUpdate; 25 import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; 26 27 31 public class FindVariableAction extends Action implements IUpdate { 32 33 private class FindVariableDelegate extends AbstractListenerActionDelegate { 34 35 protected void doAction(Object element) { 36 VariablesView view= (VariablesView) getView(); 37 Shell shell = view.getSite().getShell(); 38 FindVariableDialog dialog= new FindVariableDialog(shell, view); 39 dialog.open(); 40 } 41 42 protected void update(IAction action, ISelection s) { 43 if (action != null) { 44 ((IUpdate) action).update(); 45 } 46 } 47 48 protected void doHandleDebugEvent(DebugEvent event) { 49 update(getAction(), null); 50 } 51 52 public void run(IAction action) { 53 doAction(null); 54 } 55 } 56 57 private AbstractListenerActionDelegate fDelegate; 58 59 public FindVariableAction(VariablesView view) { 60 setText(ActionMessages.FindVariableAction_0); setId(DebugUIPlugin.getUniqueIdentifier() + ".FindVariableAction"); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.FIND_VARIABLE_ACTION); 63 setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_REPLACE); 64 fDelegate= new FindVariableDelegate(); 65 fDelegate.init(view); 66 fDelegate.setAction(this); 67 } 68 69 public void run() { 70 fDelegate.run(this); 71 } 72 73 public void update() { 74 VariablesView view= (VariablesView) fDelegate.getView(); 75 if (view != null) { 76 Viewer viewer = view.getViewer(); 77 if (viewer != null) { 78 setEnabled(viewer.getInput() instanceof IStackFrame); 79 return; 80 } 81 } 82 setEnabled(false); 83 } 84 85 public void dispose() { 86 fDelegate.dispose(); 87 } 88 } 89 | Popular Tags |