@Override public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { contextActivated(event.getContext()); } }
@Override public IStatus runInUIThread(IProgressMonitor monitor) { if (!isDisposed()) { IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (int i = 0; i < workbenchWindows.length; i++) { IWorkbenchWindow window = workbenchWindows[i]; // Virtual viewer may have a null control. Control control = viewer.getControl(); if (control != null && control.getShell().equals(window.getShell())) { fWindow = window; break; } } if (fWindow == null) { fWindow = DebugUIPlugin.getActiveWorkbenchWindow(); } IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(fWindow); contextService.addDebugContextListener(DefaultWatchExpressionModelProxy.this); ISelection activeContext = contextService.getActiveContext(); if (activeContext != null) { contextActivated(activeContext); } } return Status.OK_STATUS; }
/** * Handles the activation of the specified debug context (i.e. the selection) * @param selection the specified context to 'activate' */ protected void contextActivated(ISelection selection) { if (fWindow != null) { if (selection instanceof IStructuredSelection) { IDebugElement context = null; IStructuredSelection ss = (IStructuredSelection)selection; if (ss.size() < 2) { Object object = ss.getFirstElement(); if (object instanceof IDebugElement) { context= (IDebugElement) object; } else if (object instanceof ILaunch) { context= ((ILaunch) object).getDebugTarget(); } } IWatchExpression expression = (IWatchExpression)getExpression(); if (expression != null){ expression.setExpressionContext(context); } } } }
return new DefaultWatchExpressionModelProxy((IWatchExpression)element);