diff options
author | Jonah Graham | 2017-04-20 14:42:45 +0000 |
---|---|---|
committer | Jonah Graham | 2017-04-20 14:42:45 +0000 |
commit | 8da9b7a0b87a21adf45f71062fa5b93682bdd589 (patch) | |
tree | 7d63f8399b424aed24cd596ef08f68780a426f26 /dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf | |
parent | 65c9e08d68283cef1e3f9e5519b4cb5c0433e0c8 (diff) | |
download | org.eclipse.cdt-8da9b7a0b87a21adf45f71062fa5b93682bdd589.tar.gz org.eclipse.cdt-8da9b7a0b87a21adf45f71062fa5b93682bdd589.tar.xz org.eclipse.cdt-8da9b7a0b87a21adf45f71062fa5b93682bdd589.zip |
Bug 515296: Cosmetics
Reformatted file, added missing braces and removed "non-Javadoc" comments.
This file had suffered particularly badly from mixed spaces and tabs
in a single file, with some lines having both on the same line.
Change-Id: I0bff49effa0225cb6409547d8daa9dbf9c22e1b9
Diffstat (limited to 'dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf')
-rw-r--r-- | dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java | 1302 |
1 files changed, 679 insertions, 623 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java index e37f434d2e9..8069eb40b06 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java @@ -89,25 +89,26 @@ import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; /** - * Source display adapter that performs the source lookup, opens the editor, - * and paints the IP for the given object. + * Source display adapter that performs the source lookup, opens the editor, and + * paints the IP for the given object. * <p> - * The implementation relies on three types of jobs to perform the operations.<br> - * - The first kind, "lookup job" performs the source lookup operation. <br> - * - The second "display job" positions and annotates the editor. <br> - * - The third clears the old IP annotations when a thread or process has resumed - * or exited. + * The implementation relies on three types of jobs to perform the + * operations.<br> + * - The first kind, "lookup job" performs the source lookup operation. <br> + * - The second "display job" positions and annotates the editor. <br> + * - The third clears the old IP annotations when a thread or process has + * resumed or exited. * </p> * <p> - * The the lookup jobs can run in parallel with the display or the clearing job, - * but the clearing job and the display job must not run at the same time. - * Hence there is some involved logic which ensures that the jobs are run in - * proper order. To avoid race conditions, this logic uses the session's - * dispatch thread to synchronize access to the state data of the running jobs. + * The the lookup jobs can run in parallel with the display or the clearing job, + * but the clearing job and the display job must not run at the same time. Hence + * there is some involved logic which ensures that the jobs are run in proper + * order. To avoid race conditions, this logic uses the session's dispatch + * thread to synchronize access to the state data of the running jobs. * </p> * <p> * Debuggers can override the default source editor used by the source display - * adapter by registering their own ISourcePresentation adapter. + * adapter by registering their own ISourcePresentation adapter. * </p> * * @see ISourcePresentation @@ -115,49 +116,56 @@ import org.eclipse.ui.texteditor.ITextEditor; * @since 1.0 */ @ThreadSafe -public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControlParticipant -{ - private static final class FrameData { +public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControlParticipant { + private static final class FrameData { IFrameDMContext fDmc; - int fLine; - int fLevel; + int fLine; + int fLevel; String fFile; - + @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } FrameData other = (FrameData) obj; - if (!fDmc.equals(other.fDmc)) + if (!fDmc.equals(other.fDmc)) { return false; + } if (fFile == null) { - if (other.fFile != null) + if (other.fFile != null) { return false; - } else if (!fFile.equals(other.fFile)) + } + } else if (!fFile.equals(other.fFile)) { return false; + } return true; } /** - * Test whether the given frame data instance refers to the very same location. + * Test whether the given frame data instance refers to the very same + * location. * * @param frameData - * @return <code>true</code> if the frame data refers to the same location + * @return <code>true</code> if the frame data refers to the same + * location */ public boolean isIdentical(FrameData frameData) { return equals(frameData) && fLine == frameData.fLine; } - } - - /** + } + + /** * A job to perform source lookup on the given DMC. */ class LookupJob extends Job { - + private final IWorkbenchPage fPage; private final FrameData fFrameData; private final boolean fEventTriggered; @@ -166,7 +174,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl * Constructs a new source lookup job. */ public LookupJob(FrameData frameData, IWorkbenchPage page, boolean eventTriggered) { - super("DSF Source Lookup"); //$NON-NLS-1$ + super("DSF Source Lookup"); //$NON-NLS-1$ setPriority(Job.INTERACTIVE); setSystem(true); fFrameData = frameData; @@ -174,124 +182,135 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl fEventTriggered = eventTriggered; } - IDMContext getDmc() { return fFrameData.fDmc; } - + IDMContext getDmc() { + return fFrameData.fDmc; + } + @Override - protected IStatus run(final IProgressMonitor monitor) { + protected IStatus run(final IProgressMonitor monitor) { if (monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - + return Status.CANCEL_STATUS; + } + final SourceLookupResult result = performLookup(); - executeFromJob(new DsfRunnable() { @Override - public void run() { - if (!monitor.isCanceled()) { - fPrevResult = result; - fPrevFrameData = fFrameData; - fRunningLookupJob = null; - startDisplayJob(fPrevResult, fFrameData, fPage, fEventTriggered); - } - }}); + executeFromJob(new DsfRunnable() { + @Override + public void run() { + if (!monitor.isCanceled()) { + fPrevResult = result; + fPrevFrameData = fFrameData; + fRunningLookupJob = null; + startDisplayJob(fPrevResult, fFrameData, fPage, fEventTriggered); + } + } + }); return Status.OK_STATUS; } - + private SourceLookupResult performLookup() { - IDMContext dmc = fFrameData.fDmc; - SourceLookupResult result = new SourceLookupResult(dmc , null, null, null); - String editorId = null; - IEditorInput editorInput = null; - Object sourceElement = fSourceLookup.getSourceElement(dmc); - - if (sourceElement == null) { - editorInput = new CSourceNotFoundEditorInput(new CSourceNotFoundElement(dmc, fSourceLookup.getLaunchConfiguration(), fFrameData.fFile)); + IDMContext dmc = fFrameData.fDmc; + SourceLookupResult result = new SourceLookupResult(dmc, null, null, null); + String editorId = null; + IEditorInput editorInput = null; + Object sourceElement = fSourceLookup.getSourceElement(dmc); + + if (sourceElement == null) { + editorInput = new CSourceNotFoundEditorInput( + new CSourceNotFoundElement(dmc, fSourceLookup.getLaunchConfiguration(), fFrameData.fFile)); editorId = ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID; - } else { - ISourcePresentation presentation= null; + } else { + ISourcePresentation presentation = null; if (fSourceLookup instanceof ISourcePresentation) { presentation = (ISourcePresentation) fSourceLookup; } else { - if (dmc != null) { - presentation = dmc.getAdapter(ISourcePresentation.class); - } + if (dmc != null) { + presentation = dmc.getAdapter(ISourcePresentation.class); + } } - if (presentation != null) { - editorInput = presentation.getEditorInput(sourceElement); - if (editorInput != null) { - editorId = presentation.getEditorId(editorInput, sourceElement); - } - } else if (sourceElement instanceof IFile) { - editorId = getEditorIdForFilename(((IFile)sourceElement).getName()); - editorInput = new FileEditorInput((IFile)sourceElement); - } else if (sourceElement instanceof ITranslationUnit) { - try { - URI uriLocation = ((ITranslationUnit)sourceElement).getLocationURI(); - IFileStore fileStore = EFS.getStore(uriLocation); - editorInput = new FileStoreEditorInput(fileStore); - editorId = getEditorIdForFilename(fileStore.getName()); - } catch (CoreException e) { - editorInput = new CSourceNotFoundEditorInput(new CSourceNotFoundElement(dmc, fSourceLookup.getLaunchConfiguration(), fFrameData.fFile)); + if (presentation != null) { + editorInput = presentation.getEditorInput(sourceElement); + if (editorInput != null) { + editorId = presentation.getEditorId(editorInput, sourceElement); + } + } else if (sourceElement instanceof IFile) { + editorId = getEditorIdForFilename(((IFile) sourceElement).getName()); + editorInput = new FileEditorInput((IFile) sourceElement); + } else if (sourceElement instanceof ITranslationUnit) { + try { + URI uriLocation = ((ITranslationUnit) sourceElement).getLocationURI(); + IFileStore fileStore = EFS.getStore(uriLocation); + editorInput = new FileStoreEditorInput(fileStore); + editorId = getEditorIdForFilename(fileStore.getName()); + } catch (CoreException e) { + editorInput = new CSourceNotFoundEditorInput(new CSourceNotFoundElement(dmc, + fSourceLookup.getLaunchConfiguration(), fFrameData.fFile)); editorId = ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID; - } - } else if (sourceElement instanceof LocalFileStorage) { - File file = ((LocalFileStorage)sourceElement).getFile(); - IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file); - editorInput = new FileStoreEditorInput(fileStore); - editorId = getEditorIdForFilename(file.getName()); - } - } - result.setEditorInput(editorInput); - result.setEditorId(editorId); - result.setSourceElement(sourceElement); - - return result; - } - - private String getEditorIdForFilename(String filename) { + } + } else if (sourceElement instanceof LocalFileStorage) { + File file = ((LocalFileStorage) sourceElement).getFile(); + IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file); + editorInput = new FileStoreEditorInput(fileStore); + editorId = getEditorIdForFilename(file.getName()); + } + } + result.setEditorInput(editorInput); + result.setEditorId(editorId); + result.setSourceElement(sourceElement); + + return result; + } + + private String getEditorIdForFilename(String filename) { try { - IEditorDescriptor descriptor= IDE.getEditorDescriptor(filename); - return descriptor.getId(); + IEditorDescriptor descriptor = IDE.getEditorDescriptor(filename); + return descriptor.getId(); } catch (PartInitException exc) { DsfUIPlugin.log(exc); } return "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ - } + } } - /** - * Job that positions the editor and paints the IP Annotation for given DMC. - */ + /** + * Job that positions the editor and paints the IP Annotation for given DMC. + */ class DisplayJob extends UIJob { private final SourceLookupResult fResult; private final IWorkbenchPage fPage; private final FrameData fFrameData; - private final DsfRunnable fDisplayJobFinishedRunnable = new DsfRunnable() { - @Override + private final DsfRunnable fDisplayJobFinishedRunnable = new DsfRunnable() { + @Override public void run() { - // If the current display job does not match up with "this", it means that this job got canceled - // after it already completed and after this runnable was queued into the dispatch thread. - if (fRunningDisplayJob == DisplayJob.this) { - fRunningDisplayJob = null; - if (fEventTriggered && !fDoneStepping.getAndSet(true)) { - doneStepping(fResult.getDmc()); - } - serviceDisplayAndClearingJobs(); - } - } - }; - - private final AtomicBoolean fDoneStepping = new AtomicBoolean(false); - private IRegion fRegion; - private ITextViewer fTextViewer; + /* + * If the current display job does not match up with "this", it + * means that this job got canceled after it already completed + * and after this runnable was queued into the dispatch thread. + */ + if (fRunningDisplayJob == DisplayJob.this) { + fRunningDisplayJob = null; + if (fEventTriggered && !fDoneStepping.getAndSet(true)) { + doneStepping(fResult.getDmc()); + } + serviceDisplayAndClearingJobs(); + } + } + }; + + private final AtomicBoolean fDoneStepping = new AtomicBoolean(false); + private IRegion fRegion; + private ITextViewer fTextViewer; private final boolean fEventTriggered; - - IDMContext getDmc() { return fResult.getDmc(); } - + + IDMContext getDmc() { + return fResult.getDmc(); + } + /** * Constructs a new source display job */ public DisplayJob(SourceLookupResult result, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) { - super("Debug Source Display"); //$NON-NLS-1$ + super("Debug Source Display"); //$NON-NLS-1$ setSystem(true); setPriority(Job.INTERACTIVE); fResult = result; @@ -301,172 +320,177 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl } @Override - public IStatus runInUIThread(final IProgressMonitor monitor) { - - if (monitor.isCanceled()) { - executeFromJob(fDisplayJobFinishedRunnable); - return Status.CANCEL_STATUS; - } - - if (fRegion != null && fTextViewer != null) { - if (fRunningDisplayJob == this) { - if (!shouldCancelSelectionChange()) { - enableLineBackgroundPainter(); - fTextViewer.setSelectedRange(fRegion.getOffset(), 0); - } - executeFromJob(fDisplayJobFinishedRunnable); - } - } else { - IEditorPart editor = openEditor(fResult, fPage); - if (editor == null) { - executeFromJob(fDisplayJobFinishedRunnable); - return Status.OK_STATUS; - } - - ITextEditor textEditor = null; - if (editor instanceof ITextEditor) { - textEditor = (ITextEditor)editor; - } else { - textEditor = editor.getAdapter(ITextEditor.class); - } - if (textEditor != null) { - if (positionEditor(textEditor, fFrameData)) { - return Status.OK_STATUS; - } - } - executeFromJob(fDisplayJobFinishedRunnable); - } + public IStatus runInUIThread(final IProgressMonitor monitor) { + + if (monitor.isCanceled()) { + executeFromJob(fDisplayJobFinishedRunnable); + return Status.CANCEL_STATUS; + } + + if (fRegion != null && fTextViewer != null) { + if (fRunningDisplayJob == this) { + if (!shouldCancelSelectionChange()) { + enableLineBackgroundPainter(); + fTextViewer.setSelectedRange(fRegion.getOffset(), 0); + } + executeFromJob(fDisplayJobFinishedRunnable); + } + } else { + IEditorPart editor = openEditor(fResult, fPage); + if (editor == null) { + executeFromJob(fDisplayJobFinishedRunnable); + return Status.OK_STATUS; + } + + ITextEditor textEditor = null; + if (editor instanceof ITextEditor) { + textEditor = (ITextEditor) editor; + } else { + textEditor = editor.getAdapter(ITextEditor.class); + } + if (textEditor != null) { + if (positionEditor(textEditor, fFrameData)) { + return Status.OK_STATUS; + } + } + executeFromJob(fDisplayJobFinishedRunnable); + } return Status.OK_STATUS; } - + private boolean shouldCancelSelectionChange() { - Query<Boolean> delaySelectionChangeQuery = new Query<Boolean>() { - @Override - protected void execute(DataRequestMonitor<Boolean> rm) { - IExecutionDMContext execCtx = DMContexts.getAncestorOfType(fFrameData.fDmc, - IExecutionDMContext.class); - - IRunControl runControl = fServicesTracker.getService(IRunControl.class); - rm.setData(runControl != null && execCtx != null - && (fController != null && fController.getPendingStepCount(execCtx) != 0 - || runControl.isStepping(execCtx))); - rm.done(); - } - }; - - try { - fExecutor.execute(delaySelectionChangeQuery); - } catch (RejectedExecutionException e) { - return false; - } - - try { - return delaySelectionChangeQuery.get(); - } catch (InterruptedException e) { - return false; - } catch (ExecutionException e) { - return false; - } - } - - /** - * Opens the editor used to display the source for an element selected in - * this view and returns the editor that was opened or <code>null</code> if - * no editor could be opened. - */ - private IEditorPart openEditor(SourceLookupResult result, IWorkbenchPage page) { - IEditorInput input= result.getEditorInput(); - String id= result.getEditorId(); - if (input == null || id == null) { - return null; - } - - return openEditor(page, input, id); - } - - /** - * Opens an editor in the workbench and returns the editor that was opened - * or <code>null</code> if an error occurred while attempting to open the - * editor. - */ - private IEditorPart openEditor(final IWorkbenchPage page, final IEditorInput input, final String id) { - final IEditorPart[] editor = new IEditorPart[] {null}; - Runnable r = new Runnable() { + Query<Boolean> delaySelectionChangeQuery = new Query<Boolean>() { + @Override + protected void execute(DataRequestMonitor<Boolean> rm) { + IExecutionDMContext execCtx = DMContexts.getAncestorOfType(fFrameData.fDmc, + IExecutionDMContext.class); + + IRunControl runControl = fServicesTracker.getService(IRunControl.class); + rm.setData(runControl != null && execCtx != null + && (fController != null && fController.getPendingStepCount(execCtx) != 0 + || runControl.isStepping(execCtx))); + rm.done(); + } + }; + + try { + fExecutor.execute(delaySelectionChangeQuery); + } catch (RejectedExecutionException e) { + return false; + } + + try { + return delaySelectionChangeQuery.get(); + } catch (InterruptedException e) { + return false; + } catch (ExecutionException e) { + return false; + } + } + + /** + * Opens the editor used to display the source for an element selected + * in this view and returns the editor that was opened or + * <code>null</code> if no editor could be opened. + */ + private IEditorPart openEditor(SourceLookupResult result, IWorkbenchPage page) { + IEditorInput input = result.getEditorInput(); + String id = result.getEditorId(); + if (input == null || id == null) { + return null; + } + + return openEditor(page, input, id); + } + + /** + * Opens an editor in the workbench and returns the editor that was + * opened or <code>null</code> if an error occurred while attempting to + * open the editor. + */ + private IEditorPart openEditor(final IWorkbenchPage page, final IEditorInput input, final String id) { + final IEditorPart[] editor = new IEditorPart[] { null }; + Runnable r = new Runnable() { @Override public void run() { - if (!page.getWorkbenchWindow().getWorkbench().isClosing()) { - try { - if (input instanceof CSourceNotFoundEditorInput) - { // Don't open additional source not found editors if - // there is one to reuse. - editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); - if (editor[0] instanceof IReusableEditor) { - IReusableEditor re = (IReusableEditor)editor[0]; - if (! input.equals(re.getEditorInput())) - re.setInput(input); - } - } - else - editor[0] = page.openEditor(input, id, false); - } catch (PartInitException e) {} - } - } - }; - BusyIndicator.showWhile(Display.getDefault(), r); - return editor[0]; - } - - /** - * Positions the text editor for the given stack frame - */ - private boolean positionEditor(ITextEditor editor, final FrameData frameData) { - // Position and annotate the editor. - fRegion= getLineInformation(editor, frameData.fLine); - if (fRegion != null) { - // add annotation - fIPManager.addAnnotation( - editor, frameData.fDmc, new Position(fRegion.getOffset(), fRegion.getLength()), - frameData.fLevel == 0); - - // this is a dirty trick to get access to the ITextViewer of the editor - Object tot = editor.getAdapter(ITextOperationTarget.class); - if (tot instanceof ITextViewer) { - fTextViewer = (ITextViewer)tot; - int widgetLine = frameData.fLine; - if (tot instanceof ITextViewerExtension5) { - ITextViewerExtension5 ext5 = (ITextViewerExtension5) tot; - // expand region if collapsed - ext5.exposeModelRange(fRegion); - widgetLine = ext5.modelLine2WidgetLine(widgetLine); - } - revealLine(fTextViewer, widgetLine); - - if (fStepCount > 0 && fSelectionChangeDelay > 0) { - disableLineBackgroundPainter(); - // reschedule for selection change - schedule(fSelectionChangeDelay); - if (!fDoneStepping.getAndSet(true)) { - doneStepping(getDmc()); - } - return true; - } else { - enableLineBackgroundPainter(); - fTextViewer.setSelectedRange(fRegion.getOffset(), 0); - } - } else { - editor.selectAndReveal(fRegion.getOffset(), 0); - } - } - return false; - } - - /** - * Scroll the given line into the visible area if it is not yet visible. - * @param focusLine - * @see org.eclipse.jface.text.TextViewer#revealRange(int, int) - */ - private void revealLine(ITextViewer viewer, int focusLine) { - StyledText textWidget = viewer.getTextWidget(); + if (!page.getWorkbenchWindow().getWorkbench().isClosing()) { + try { + if (input instanceof CSourceNotFoundEditorInput) { + /* + * Don't open additional source not found + * editors if there is one to reuse. + */ + editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); + if (editor[0] instanceof IReusableEditor) { + IReusableEditor re = (IReusableEditor) editor[0]; + if (!input.equals(re.getEditorInput())) { + re.setInput(input); + } + } + } else { + editor[0] = page.openEditor(input, id, false); + } + } catch (PartInitException e) { + } + } + } + }; + BusyIndicator.showWhile(Display.getDefault(), r); + return editor[0]; + } + + /** + * Positions the text editor for the given stack frame + */ + private boolean positionEditor(ITextEditor editor, final FrameData frameData) { + // Position and annotate the editor. + fRegion = getLineInformation(editor, frameData.fLine); + if (fRegion != null) { + // add annotation + fIPManager.addAnnotation(editor, frameData.fDmc, new Position(fRegion.getOffset(), fRegion.getLength()), + frameData.fLevel == 0); + + // this is a dirty trick to get access to the ITextViewer of the + // editor + Object tot = editor.getAdapter(ITextOperationTarget.class); + if (tot instanceof ITextViewer) { + fTextViewer = (ITextViewer) tot; + int widgetLine = frameData.fLine; + if (tot instanceof ITextViewerExtension5) { + ITextViewerExtension5 ext5 = (ITextViewerExtension5) tot; + // expand region if collapsed + ext5.exposeModelRange(fRegion); + widgetLine = ext5.modelLine2WidgetLine(widgetLine); + } + revealLine(fTextViewer, widgetLine); + + if (fStepCount > 0 && fSelectionChangeDelay > 0) { + disableLineBackgroundPainter(); + // reschedule for selection change + schedule(fSelectionChangeDelay); + if (!fDoneStepping.getAndSet(true)) { + doneStepping(getDmc()); + } + return true; + } else { + enableLineBackgroundPainter(); + fTextViewer.setSelectedRange(fRegion.getOffset(), 0); + } + } else { + editor.selectAndReveal(fRegion.getOffset(), 0); + } + } + return false; + } + + /** + * Scroll the given line into the visible area if it is not yet visible. + * + * @param focusLine + * @see org.eclipse.jface.text.TextViewer#revealRange(int, int) + */ + private void revealLine(ITextViewer viewer, int focusLine) { + StyledText textWidget = viewer.getTextWidget(); int top = textWidget.getTopIndex(); if (top > -1) { @@ -475,13 +499,14 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl int bottom = top + lines; int bottomBuffer = Math.max(1, lines / 3); - + if (focusLine >= top && focusLine <= bottom - bottomBuffer) { // do not scroll at all as it is already visible } else { if (focusLine > bottom - bottomBuffer && focusLine <= bottom) { // focusLine is already in bottom bufferZone - // scroll to top of bottom bufferzone - for smooth down-scrolling + // scroll to top of bottom bufferzone - for smooth + // down-scrolling int scrollDelta = focusLine - (bottom - bottomBuffer); textWidget.setTopIndex(top + scrollDelta); } else { @@ -491,231 +516,247 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl } } } - } - - /** - * @return the number of visible lines in the view port assuming a constant - * line height. - */ - private int getEstimatedVisibleLinesInViewport(StyledText textWidget) { - if (textWidget != null) { - Rectangle clArea= textWidget.getClientArea(); - if (!clArea.isEmpty()) - return clArea.height / textWidget.getLineHeight(); - } - return -1; - } - - /** - * Returns the line information for the given line in the given editor - */ - private IRegion getLineInformation(ITextEditor editor, int lineNumber) { - IDocumentProvider provider= editor.getDocumentProvider(); - IEditorInput input= editor.getEditorInput(); - try { - provider.connect(input); - } catch (CoreException e) { - return null; - } - try { - IDocument document= provider.getDocument(input); - if (document != null) - return document.getLineInformation(lineNumber); - } catch (BadLocationException e) { - } finally { - provider.disconnect(input); - } - return null; - } - - } - - /** - * Job that removes the old IP Annotations associated with given execution - * context. - */ - class ClearingJob extends UIJob { - Set<IRunControl.IExecutionDMContext> fDmcsToClear; - - public ClearingJob(Set<IRunControl.IExecutionDMContext> dmcs) { - super("Debug Source Display"); //$NON-NLS-1$ - setSystem(true); - setPriority(Job.INTERACTIVE); - fDmcsToClear = dmcs; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - DsfRunnable clearingJobFinishedRunnable = new DsfRunnable() { @Override - public void run() { - assert fRunningClearingJob == ClearingJob.this; - fRunningClearingJob = null; - serviceDisplayAndClearingJobs(); - }}; - - enableLineBackgroundPainter(); - - if (monitor.isCanceled()) { - executeFromJob(clearingJobFinishedRunnable); - return Status.CANCEL_STATUS; - } - - for (IRunControl.IExecutionDMContext dmc : fDmcsToClear) { - fIPManager.removeAnnotations(dmc); - } - - executeFromJob(clearingJobFinishedRunnable); - return Status.OK_STATUS; - } - } + } + + /** + * @return the number of visible lines in the view port assuming a + * constant line height. + */ + private int getEstimatedVisibleLinesInViewport(StyledText textWidget) { + if (textWidget != null) { + Rectangle clArea = textWidget.getClientArea(); + if (!clArea.isEmpty()) { + return clArea.height / textWidget.getLineHeight(); + } + } + return -1; + } + + /** + * Returns the line information for the given line in the given editor + */ + private IRegion getLineInformation(ITextEditor editor, int lineNumber) { + IDocumentProvider provider = editor.getDocumentProvider(); + IEditorInput input = editor.getEditorInput(); + try { + provider.connect(input); + } catch (CoreException e) { + return null; + } + try { + IDocument document = provider.getDocument(input); + if (document != null) { + return document.getLineInformation(lineNumber); + } + } catch (BadLocationException e) { + } finally { + provider.disconnect(input); + } + return null; + } + + } + + /** + * Job that removes the old IP Annotations associated with given execution + * context. + */ + class ClearingJob extends UIJob { + Set<IRunControl.IExecutionDMContext> fDmcsToClear; + + public ClearingJob(Set<IRunControl.IExecutionDMContext> dmcs) { + super("Debug Source Display"); //$NON-NLS-1$ + setSystem(true); + setPriority(Job.INTERACTIVE); + fDmcsToClear = dmcs; + } + + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + DsfRunnable clearingJobFinishedRunnable = new DsfRunnable() { + @Override + public void run() { + assert fRunningClearingJob == ClearingJob.this; + fRunningClearingJob = null; + serviceDisplayAndClearingJobs(); + } + }; + + enableLineBackgroundPainter(); + + if (monitor.isCanceled()) { + executeFromJob(clearingJobFinishedRunnable); + return Status.CANCEL_STATUS; + } + + for (IRunControl.IExecutionDMContext dmc : fDmcsToClear) { + fIPManager.removeAnnotations(dmc); + } + + executeFromJob(clearingJobFinishedRunnable); + return Status.OK_STATUS; + } + } private static final boolean DEBUG = false; - private DsfSession fSession; - private DsfExecutor fExecutor; - private DsfServicesTracker fServicesTracker; - private FrameData fPrevFrameData; - private SourceLookupResult fPrevResult; - private ISourceLookupDirector fSourceLookup; - private DsfSourceLookupParticipant fSourceLookupParticipant; - private InstructionPointerManager fIPManager; - - private LookupJob fRunningLookupJob; - private DisplayJob fRunningDisplayJob; - private DisplayJob fPendingDisplayJob; - private ClearingJob fRunningClearingJob; - private Set<IRunControl.IExecutionDMContext> fPendingExecDmcsToClear = new HashSet<IRunControl.IExecutionDMContext>(); + private DsfSession fSession; + private DsfExecutor fExecutor; + private DsfServicesTracker fServicesTracker; + private FrameData fPrevFrameData; + private SourceLookupResult fPrevResult; + private ISourceLookupDirector fSourceLookup; + private DsfSourceLookupParticipant fSourceLookupParticipant; + private InstructionPointerManager fIPManager; + + private LookupJob fRunningLookupJob; + private DisplayJob fRunningDisplayJob; + private DisplayJob fPendingDisplayJob; + private ClearingJob fRunningClearingJob; + private Set<IRunControl.IExecutionDMContext> fPendingExecDmcsToClear = new HashSet<IRunControl.IExecutionDMContext>(); private SteppingController fController; - /** Delay (in milliseconds) before the selection is changed to the IP location */ + /** + * Delay (in milliseconds) before the selection is changed to the IP + * location + */ private int fSelectionChangeDelay = 150; - - private long fStepStartTime = 0; - private long fLastStepTime = 0; - private long fStepCount; - private boolean fEnableLineBackgroundPainter; + private long fStepStartTime = 0; + private long fLastStepTime = 0; + private long fStepCount; - public DsfSourceDisplayAdapter(DsfSession session, ISourceLookupDirector sourceLocator) { - this(session, sourceLocator, null); - } + private boolean fEnableLineBackgroundPainter; - /** + public DsfSourceDisplayAdapter(DsfSession session, ISourceLookupDirector sourceLocator) { + this(session, sourceLocator, null); + } + + /** * @since 1.1 */ - public DsfSourceDisplayAdapter(DsfSession session, ISourceLookupDirector sourceLocator, SteppingController controller) { - fSession = session; - fExecutor = session.getExecutor(); - fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId()); - fSourceLookup = sourceLocator; - fSourceLookupParticipant = new DsfSourceLookupParticipant(session); - fSourceLookup.addParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant} ); - - final IInstructionPointerPresentation ipPresentation = (IInstructionPointerPresentation) session.getModelAdapter(IInstructionPointerPresentation.class); + public DsfSourceDisplayAdapter(DsfSession session, ISourceLookupDirector sourceLocator, + SteppingController controller) { + fSession = session; + fExecutor = session.getExecutor(); + fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId()); + fSourceLookup = sourceLocator; + fSourceLookupParticipant = new DsfSourceLookupParticipant(session); + fSourceLookup.addParticipants(new ISourceLookupParticipant[] { fSourceLookupParticipant }); + + final IInstructionPointerPresentation ipPresentation = (IInstructionPointerPresentation) session + .getModelAdapter(IInstructionPointerPresentation.class); fIPManager = new InstructionPointerManager(ipPresentation); - - fExecutor.execute(new DsfRunnable() { @Override - public void run() { - fSession.addServiceEventListener(DsfSourceDisplayAdapter.this, null); - }}); - fController = controller; + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + fSession.addServiceEventListener(DsfSourceDisplayAdapter.this, null); + } + }); + + fController = controller; if (fController != null) { fController.addSteppingControlParticipant(this); } - } + } /** * Configure the delay (in milliseconds) before the selection in the editor * is changed to the IP location. * - * @param delay the delay in milliseconds, a non-negative integer + * @param delay + * the delay in milliseconds, a non-negative integer * * @since 1.1 */ - public void setSelectionChangeDelay(int delay) { - fSelectionChangeDelay = delay; - } + public void setSelectionChangeDelay(int delay) { + fSelectionChangeDelay = delay; + } - public void dispose() { + public void dispose() { if (fController != null) { fController.removeSteppingControlParticipant(this); fController = null; } - + try { - fExecutor.execute(new DsfRunnable() { @Override - public void run() { - fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this); - }}); + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this); + } + }); } catch (RejectedExecutionException e) { - // Session is shut down. - } - - fServicesTracker.dispose(); - fSourceLookup.removeParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant}); - - // fSourceLookupParticipant is disposed by the source lookup director - - // Need to remove annotations in UI thread. - Display display = PlatformUI.getWorkbench().getDisplay(); - if (display != null && !display.isDisposed()) { - display.asyncExec(new Runnable() { + // Session is shut down. + } + + fServicesTracker.dispose(); + fSourceLookup.removeParticipants(new ISourceLookupParticipant[] { fSourceLookupParticipant }); + + // fSourceLookupParticipant is disposed by the source lookup director + + // Need to remove annotations in UI thread. + Display display = PlatformUI.getWorkbench().getDisplay(); + if (display != null && !display.isDisposed()) { + display.asyncExec(new Runnable() { @Override public void run() { enableLineBackgroundPainter(); - fIPManager.removeAllAnnotations(); - }}); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean) - */ + fIPManager.removeAllAnnotations(); + } + }); + } + } + @Override - public void displaySource(Object context, final IWorkbenchPage page, - final boolean force) { + public void displaySource(Object context, final IWorkbenchPage page, final boolean force) { fStepCount = 0; IFrameDMContext displayFrame = null; if (context instanceof IDMVMContext) { IDMContext dmc = ((IDMVMContext) context).getDMContext(); - if (dmc instanceof IFrameDMContext) + if (dmc instanceof IFrameDMContext) { displayFrame = (IFrameDMContext) dmc; - } else if (context instanceof IFrameDMContext) + } + } else if (context instanceof IFrameDMContext) { displayFrame = (IFrameDMContext) context; + } // Quick test. DMC is checked again in source lookup participant, but // it's much quicker to test here. - if (displayFrame != null) + if (displayFrame != null) { doDisplaySource(displayFrame, page, force, false); + } } - private void doDisplaySource(final IFrameDMContext context, final IWorkbenchPage page, final boolean force, final boolean eventTriggered) { - if (DEBUG) System.out.println("[DsfSourceDisplayAdapter] doDisplaySource ctx="+context+" eventTriggered="+eventTriggered); //$NON-NLS-1$ //$NON-NLS-2$ - if (context.getLevel() < 0) { - return; - } - // Re-dispatch to executor thread before accessing job lists. - fExecutor.execute(new DsfRunnable() { @Override - public void run() { - // We need to retrieve the frame level and line number from the service. - IStack stackService = fServicesTracker.getService(IStack.class); - if (stackService == null) { - return; - } - stackService.getFrameData( - context, - new DataRequestMonitor<IFrameDMData>(fExecutor, null) { + private void doDisplaySource(final IFrameDMContext context, final IWorkbenchPage page, final boolean force, + final boolean eventTriggered) { + if (DEBUG) { + System.out.println( + "[DsfSourceDisplayAdapter] doDisplaySource ctx=" + context + " eventTriggered=" + eventTriggered); //$NON-NLS-1$ //$NON-NLS-2$ + } + if (context.getLevel() < 0) { + return; + } + // Re-dispatch to executor thread before accessing job lists. + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + // We need to retrieve the frame level and line number from the + // service. + IStack stackService = fServicesTracker.getService(IStack.class); + if (stackService == null) { + return; + } + stackService.getFrameData(context, new DataRequestMonitor<IFrameDMData>(fExecutor, null) { @Override public void handleSuccess() { FrameData frameData = new FrameData(); frameData.fDmc = context; frameData.fLevel = context.getLevel(); - // Document line numbers are 0-based. While debugger line numbers are 1-based. + // Document line numbers are 0-based. While debugger + // line numbers are 1-based. IFrameDMData data = getData(); frameData.fLine = data.getLine() - 1; frameData.fFile = data.getFile(); @@ -726,186 +767,198 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl startLookupJob(frameData, page, eventTriggered); } } + @Override protected void handleFailure() { - doneStepping(context); + doneStepping(context); + } + + @Override + protected void handleRejectedExecutionException() { + doneStepping(context); } - - @Override - protected void handleRejectedExecutionException() { - doneStepping(context); - } - }); - }}); + }); + } + }); + } + + private void executeFromJob(Runnable runnable) { + try { + fExecutor.execute(runnable); + } catch (RejectedExecutionException e) { + // Session disposed, ignore + } } - private void executeFromJob(Runnable runnable) { - try { - fExecutor.execute(runnable); - } catch (RejectedExecutionException e) { - // Session disposed, ignore - } - } - private void startLookupJob(final FrameData frameData, final IWorkbenchPage page, boolean eventTriggered) { - // If there is a previous lookup job running, cancel it. - if (fRunningLookupJob != null) { - if (!eventTriggered && frameData.isIdentical(fRunningLookupJob.fFrameData)) { - // identical location - we are done - return; - } - // cancel running lookup job - fRunningLookupJob.cancel(); - // make sure doneStepping() is called even if the job never ran - bug 325394 - if (fRunningLookupJob.fEventTriggered) { - // ... but not if this request is event-triggered for the same context (duplicate suspended event) - if (!eventTriggered || !fRunningLookupJob.getDmc().equals(frameData.fDmc)) { - doneStepping(fRunningLookupJob.getDmc()); - } - } - } - - fRunningLookupJob = new LookupJob(frameData, page, eventTriggered); - fRunningLookupJob.schedule(); - } - - // To be called only on dispatch thread. - private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) { - DisplayJob nextDisplayJob = new DisplayJob(lookupResult, frameData, page, eventTriggered); - if (fRunningDisplayJob != null) { - fPendingDisplayJob = null; - IExecutionDMContext[] execCtxs = DMContexts.getAllAncestorsOfType(frameData.fDmc, IExecutionDMContext.class); - fPendingExecDmcsToClear.removeAll(Arrays.asList(execCtxs)); - - if (!eventTriggered && frameData.isIdentical(fRunningDisplayJob.fFrameData)) { - // identical location - we are done - return; - } - // cancel running display job - fRunningDisplayJob.cancel(); - // make sure doneStepping() is called even if the job never ran - bug 325394 - if (fRunningDisplayJob.fEventTriggered && !fRunningDisplayJob.fDoneStepping.getAndSet(true)) { - // ... but not if this request is event-triggered for the same context (duplicate suspended event) - if (!eventTriggered || !fRunningDisplayJob.getDmc().equals(lookupResult.getDmc())) { - doneStepping(fRunningDisplayJob.getDmc()); - } - } - } - if (fRunningClearingJob != null) { - // Wait for the clearing job to finish, instead, set the - // display job as pending. - fPendingDisplayJob = nextDisplayJob; - } else { - fRunningDisplayJob = nextDisplayJob; - fRunningDisplayJob.schedule(); - } - } + // If there is a previous lookup job running, cancel it. + if (fRunningLookupJob != null) { + if (!eventTriggered && frameData.isIdentical(fRunningLookupJob.fFrameData)) { + // identical location - we are done + return; + } + // cancel running lookup job + fRunningLookupJob.cancel(); + // make sure doneStepping() is called even if the job never ran - + // bug 325394 + if (fRunningLookupJob.fEventTriggered) { + // ... but not if this request is event-triggered for the same + // context (duplicate suspended event) + if (!eventTriggered || !fRunningLookupJob.getDmc().equals(frameData.fDmc)) { + doneStepping(fRunningLookupJob.getDmc()); + } + } + } + + fRunningLookupJob = new LookupJob(frameData, page, eventTriggered); + fRunningLookupJob.schedule(); + } + + // To be called only on dispatch thread. + private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page, + boolean eventTriggered) { + DisplayJob nextDisplayJob = new DisplayJob(lookupResult, frameData, page, eventTriggered); + if (fRunningDisplayJob != null) { + fPendingDisplayJob = null; + IExecutionDMContext[] execCtxs = DMContexts.getAllAncestorsOfType(frameData.fDmc, + IExecutionDMContext.class); + fPendingExecDmcsToClear.removeAll(Arrays.asList(execCtxs)); + + if (!eventTriggered && frameData.isIdentical(fRunningDisplayJob.fFrameData)) { + // identical location - we are done + return; + } + // cancel running display job + fRunningDisplayJob.cancel(); + // make sure doneStepping() is called even if the job never ran - + // bug 325394 + if (fRunningDisplayJob.fEventTriggered && !fRunningDisplayJob.fDoneStepping.getAndSet(true)) { + // ... but not if this request is event-triggered for the same + // context (duplicate suspended event) + if (!eventTriggered || !fRunningDisplayJob.getDmc().equals(lookupResult.getDmc())) { + doneStepping(fRunningDisplayJob.getDmc()); + } + } + } + if (fRunningClearingJob != null) { + // Wait for the clearing job to finish, instead, set the + // display job as pending. + fPendingDisplayJob = nextDisplayJob; + } else { + fRunningDisplayJob = nextDisplayJob; + fRunningDisplayJob.schedule(); + } + } private void doneStepping(IDMContext context) { if (fController != null) { // indicate completion of step - final IExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IExecutionDMContext.class); - if (dmc != null) { - try { - fController.getExecutor().execute(new DsfRunnable() { - @Override + final IExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IExecutionDMContext.class); + if (dmc != null) { + try { + fController.getExecutor().execute(new DsfRunnable() { + @Override public void run() { - fController.doneStepping(dmc, DsfSourceDisplayAdapter.this); - }; - }); - } catch (RejectedExecutionException e) { - // Session is shutdown - } - } - } + fController.doneStepping(dmc, DsfSourceDisplayAdapter.this); + }; + }); + } catch (RejectedExecutionException e) { + // Session is shutdown + } + } + } } - - private void serviceDisplayAndClearingJobs() { - if (!fPendingExecDmcsToClear.isEmpty()) { - // There are annotations to be cleared, run the job first - fRunningClearingJob = new ClearingJob(fPendingExecDmcsToClear); - fRunningClearingJob.schedule(); - fPendingExecDmcsToClear = new HashSet<IRunControl.IExecutionDMContext>(); - } else if (fPendingDisplayJob != null) { - fRunningDisplayJob = fPendingDisplayJob; - fRunningDisplayJob.schedule(); - fPendingDisplayJob = null; - } - } - - private void startAnnotationClearingJob(IRunControl.IExecutionDMContext execDmc) { - // Make sure to add the context to the list. - fPendingExecDmcsToClear.add(execDmc); - - // If lookup job is running, check it against the execution context, - // and cancel it if matches. - if (fRunningLookupJob != null) { - if (DMContexts.isAncestorOf(fRunningLookupJob.getDmc(), execDmc)) { - fRunningLookupJob.cancel(); - fRunningLookupJob = null; - } - } - // If there is a pending display job, make sure it doesn't get - // preempted by this event. If so, just cancel the pending - // display job. - if (fPendingDisplayJob != null) { - if (DMContexts.isAncestorOf(fPendingDisplayJob.getDmc(), execDmc)) { - fPendingDisplayJob = null; - } - } - - // If no display or clearing jobs are running, schedule the clearing job. - if (fRunningClearingJob == null && fRunningDisplayJob == null) { - fRunningClearingJob = new ClearingJob(fPendingExecDmcsToClear); - fRunningClearingJob.schedule(); - fPendingExecDmcsToClear = new HashSet<IRunControl.IExecutionDMContext>(); - } - } - - @DsfServiceEventHandler - public void eventDispatched(IRunControl.IResumedDMEvent e) { - if (e.getReason() != StateChangeReason.STEP) { - startAnnotationClearingJob(e.getDMContext()); - } - } - - @DsfServiceEventHandler - public void eventDispatched(IRunControl.IExitedDMEvent e) { - startAnnotationClearingJob(e.getDMContext()); - } - - /** - * @since 1.1 - */ - @DsfServiceEventHandler - public void eventDispatched(SteppingTimedOutEvent e) { - startAnnotationClearingJob(e.getDMContext()); - } - - @DsfServiceEventHandler - public void eventDispatched(final IRunControl.ISuspendedDMEvent e) { + + private void serviceDisplayAndClearingJobs() { + if (!fPendingExecDmcsToClear.isEmpty()) { + // There are annotations to be cleared, run the job first + fRunningClearingJob = new ClearingJob(fPendingExecDmcsToClear); + fRunningClearingJob.schedule(); + fPendingExecDmcsToClear = new HashSet<IRunControl.IExecutionDMContext>(); + } else if (fPendingDisplayJob != null) { + fRunningDisplayJob = fPendingDisplayJob; + fRunningDisplayJob.schedule(); + fPendingDisplayJob = null; + } + } + + private void startAnnotationClearingJob(IRunControl.IExecutionDMContext execDmc) { + // Make sure to add the context to the list. + fPendingExecDmcsToClear.add(execDmc); + + // If lookup job is running, check it against the execution context, + // and cancel it if matches. + if (fRunningLookupJob != null) { + if (DMContexts.isAncestorOf(fRunningLookupJob.getDmc(), execDmc)) { + fRunningLookupJob.cancel(); + fRunningLookupJob = null; + } + } + // If there is a pending display job, make sure it doesn't get + // preempted by this event. If so, just cancel the pending + // display job. + if (fPendingDisplayJob != null) { + if (DMContexts.isAncestorOf(fPendingDisplayJob.getDmc(), execDmc)) { + fPendingDisplayJob = null; + } + } + + // If no display or clearing jobs are running, schedule the clearing + // job. + if (fRunningClearingJob == null && fRunningDisplayJob == null) { + fRunningClearingJob = new ClearingJob(fPendingExecDmcsToClear); + fRunningClearingJob.schedule(); + fPendingExecDmcsToClear = new HashSet<IRunControl.IExecutionDMContext>(); + } + } + + @DsfServiceEventHandler + public void eventDispatched(IRunControl.IResumedDMEvent e) { + if (e.getReason() != StateChangeReason.STEP) { + startAnnotationClearingJob(e.getDMContext()); + } + } + + @DsfServiceEventHandler + public void eventDispatched(IRunControl.IExitedDMEvent e) { + startAnnotationClearingJob(e.getDMContext()); + } + + /** + * @since 1.1 + */ + @DsfServiceEventHandler + public void eventDispatched(SteppingTimedOutEvent e) { + startAnnotationClearingJob(e.getDMContext()); + } + + @DsfServiceEventHandler + public void eventDispatched(final IRunControl.ISuspendedDMEvent e) { updateStepTiming(); - if (e.getReason() == StateChangeReason.STEP || e.getReason() == StateChangeReason.BREAKPOINT) { - if (DEBUG) System.out.println("[DsfSourceDisplayAdapter] eventDispatched e="+e); //$NON-NLS-1$ - // trigger source display immediately (should be optional?) - Display.getDefault().asyncExec(new Runnable() { + if (e.getReason() == StateChangeReason.STEP || e.getReason() == StateChangeReason.BREAKPOINT) { + if (DEBUG) { + System.out.println("[DsfSourceDisplayAdapter] eventDispatched e=" + e); //$NON-NLS-1$ + } + // trigger source display immediately (should be optional?) + Display.getDefault().asyncExec(new Runnable() { @Override public void run() { - Object context = DebugUITools.getDebugContext(); - if (context instanceof IDMVMContext) { - final IDMContext dmc = ((IDMVMContext)context).getDMContext(); - if (dmc instanceof IFrameDMContext && DMContexts.isAncestorOf(dmc, e.getDMContext())) { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + Object context = DebugUITools.getDebugContext(); + if (context instanceof IDMVMContext) { + final IDMContext dmc = ((IDMVMContext) context).getDMContext(); + if (dmc instanceof IFrameDMContext && DMContexts.isAncestorOf(dmc, e.getDMContext())) { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); doDisplaySource((IFrameDMContext) dmc, page, false, true); return; - } - } - doneStepping(e.getDMContext()); - }}); - } else { - doneStepping(e.getDMContext()); - } - } + } + } + doneStepping(e.getDMContext()); + } + }); + } else { + doneStepping(e.getDMContext()); + } + } private void updateStepTiming() { long now = System.currentTimeMillis(); @@ -918,8 +971,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl ++fStepCount; if (DEBUG) { long delta = now - fStepStartTime; - float meanTime = delta/(float)fStepCount/1000; - System.out.println("[DsfSourceDisplayAdapter] step speed = " + 1/meanTime); //$NON-NLS-1$ + float meanTime = delta / (float) fStepCount / 1000; + System.out.println("[DsfSourceDisplayAdapter] step speed = " + 1 / meanTime); //$NON-NLS-1$ } } @@ -931,9 +984,11 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl */ private void disableLineBackgroundPainter() { if (!fEnableLineBackgroundPainter) { - fEnableLineBackgroundPainter = EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE); + fEnableLineBackgroundPainter = EditorsUI.getPreferenceStore() + .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE); if (fEnableLineBackgroundPainter) { - EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, false); + EditorsUI.getPreferenceStore() + .setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, false); } } } @@ -947,7 +1002,8 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl private void enableLineBackgroundPainter() { if (fEnableLineBackgroundPainter) { fEnableLineBackgroundPainter = false; - EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true); + EditorsUI.getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, + true); } } |