/** * Returns a local variable in the given frame based on the the given name or <code>null</code> if * none. * * @return local variable or <code>null</code> */ private IVariable findLocalVariable(IJavaScriptStackFrame frame, String variableName) { if (frame != null) { try { IVariable[] vars = frame.getVariables(); for (int i = 0; i < vars.length; i++) { if (vars[i].getName().equals(variableName)) { return vars[i]; } } } catch (DebugException x) { JavaScriptDebugUIPlugin.log(x); } } return null; }
/* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { try { ScriptSelectionDialog dialog = new ScriptSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), false, ResourcesPlugin.getWorkspace().getRoot()); dialog.setTitle(Messages.add_script_load_bp); if (dialog.open() == IDialogConstants.OK_ID) { final IFile file = (IFile) dialog.getFirstResult(); final String scriptname = file.getName(); final String scriptpath = file.getFullPath().makeRelative().toString(); IJavaScriptLoadBreakpoint breakpoint = findBreakpoint(scriptpath, scriptname); if (breakpoint != null) { breakpoint.setEnabled(true); return; } // spawn a job to create a new one Job job = new Job(Messages.creating_script_load_bp) { protected IStatus run(IProgressMonitor monitor) { HashMap attributes = new HashMap(); attributes.put(IJavaScriptBreakpoint.TYPE_NAME, scriptname); attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, scriptpath); try { JavaScriptDebugModel.createScriptLoadBreakpoint(file, -1, -1, attributes, true); } catch (DebugException de) { JavaScriptDebugUIPlugin.log(de); return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }; job.setPriority(Job.INTERACTIVE); job.setSystem(true); job.schedule(); } } catch (CoreException ce) { JavaScriptDebugUIPlugin.log(ce); } }