org.eclipse.xtext.ui.editor.syntaxcoloring
Class HighlightingPresenter

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter
All Implemented Interfaces:
org.eclipse.jface.text.IDocumentListener, org.eclipse.jface.text.ITextInputListener, org.eclipse.jface.text.ITextPresentationListener

public class HighlightingPresenter
extends java.lang.Object
implements org.eclipse.jface.text.ITextPresentationListener, org.eclipse.jface.text.ITextInputListener, org.eclipse.jface.text.IDocumentListener

Highlighting presenter - UI thread implementation. Initially copied from org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingPresenter

Author:
Sebastian Zarnekow

Constructor Summary
HighlightingPresenter()
           
 
Method Summary
 void addAllPositions(java.util.List<AttributedPosition> list)
          Adds all current positions to the given list.
 void applyTextPresentation(org.eclipse.jface.text.TextPresentation textPresentation)
           
 AttributedPosition createHighlightedPosition(int offset, int length, org.eclipse.jface.text.TextAttribute highlighting)
          Creates and returns a new highlighted position with the given offset, length and highlighting.
 org.eclipse.jface.text.TextPresentation createPresentation(java.util.List<AttributedPosition> addedPositions, java.util.List<AttributedPosition> removedPositions)
          Create a text presentation in the background.
 java.lang.Runnable createSimpleUpdateRunnable()
           
 java.lang.Runnable createUpdateRunnable(org.eclipse.jface.text.TextPresentation textPresentation, java.util.List<AttributedPosition> addedPositions, java.util.List<AttributedPosition> removedPositions)
          Create a runnable for updating the presentation.
 void documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent event)
           
 void documentChanged(org.eclipse.jface.text.DocumentEvent event)
           
 void highlightingStyleChanged(org.eclipse.jface.text.TextAttribute highlighting)
          Invalidate text presentation of positions with the given highlighting.
 void inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument oldInput, org.eclipse.jface.text.IDocument newInput)
           
 void inputDocumentChanged(org.eclipse.jface.text.IDocument oldInput, org.eclipse.jface.text.IDocument newInput)
           
 void install(XtextSourceViewer sourceViewer, XtextPresentationReconciler backgroundPresentationReconciler)
          Install this presenter on the given source viewer and background presentation reconciler.
 boolean isCanceled()
           
 void setCanceled(boolean isCanceled)
          Set whether or not the current reconcile is canceled.
 void uninstall()
          Uninstall this presenter.
 void updatePresentation(org.eclipse.jface.text.TextPresentation textPresentation, AttributedPosition[] addedPositions, AttributedPosition[] removedPositions)
          Invalidate the presentation of the positions based on the given added positions and the existing deleted positions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighlightingPresenter

public HighlightingPresenter()
Method Detail

createHighlightedPosition

public AttributedPosition createHighlightedPosition(int offset,
                                                    int length,
                                                    org.eclipse.jface.text.TextAttribute highlighting)
Creates and returns a new highlighted position with the given offset, length and highlighting.

NOTE: Also called from background thread.

Parameters:
offset - The offset
length - The length
highlighting - The highlighting
Returns:
The new highlighted position

addAllPositions

public void addAllPositions(java.util.List<AttributedPosition> list)
Adds all current positions to the given list.

NOTE: Called from background thread.

Parameters:
list - The list

createPresentation

public org.eclipse.jface.text.TextPresentation createPresentation(java.util.List<AttributedPosition> addedPositions,
                                                                  java.util.List<AttributedPosition> removedPositions)
Create a text presentation in the background.

NOTE: Called from background thread.

Parameters:
addedPositions - the added positions
removedPositions - the removed positions
Returns:
the text presentation or null, if reconciliation should be canceled

createUpdateRunnable

public java.lang.Runnable createUpdateRunnable(org.eclipse.jface.text.TextPresentation textPresentation,
                                               java.util.List<AttributedPosition> addedPositions,
                                               java.util.List<AttributedPosition> removedPositions)
Create a runnable for updating the presentation.

NOTE: Called from background thread.

Parameters:
textPresentation - the text presentation
addedPositions - the added positions
removedPositions - the removed positions
Returns:
the runnable or null, if reconciliation should be canceled

createSimpleUpdateRunnable

public java.lang.Runnable createSimpleUpdateRunnable()

updatePresentation

public void updatePresentation(org.eclipse.jface.text.TextPresentation textPresentation,
                               AttributedPosition[] addedPositions,
                               AttributedPosition[] removedPositions)
Invalidate the presentation of the positions based on the given added positions and the existing deleted positions. Also unregisters the deleted positions from the document and patches the positions of this presenter.

NOTE: Indirectly called from background thread by UI runnable.

Parameters:
textPresentation - the text presentation or null, if the presentation should computed in the UI thread
addedPositions - the added positions
removedPositions - the removed positions

applyTextPresentation

public void applyTextPresentation(org.eclipse.jface.text.TextPresentation textPresentation)
Specified by:
applyTextPresentation in interface org.eclipse.jface.text.ITextPresentationListener

inputDocumentAboutToBeChanged

public void inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument oldInput,
                                          org.eclipse.jface.text.IDocument newInput)
Specified by:
inputDocumentAboutToBeChanged in interface org.eclipse.jface.text.ITextInputListener

inputDocumentChanged

public void inputDocumentChanged(org.eclipse.jface.text.IDocument oldInput,
                                 org.eclipse.jface.text.IDocument newInput)
Specified by:
inputDocumentChanged in interface org.eclipse.jface.text.ITextInputListener

documentAboutToBeChanged

public void documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent event)
Specified by:
documentAboutToBeChanged in interface org.eclipse.jface.text.IDocumentListener

documentChanged

public void documentChanged(org.eclipse.jface.text.DocumentEvent event)
Specified by:
documentChanged in interface org.eclipse.jface.text.IDocumentListener

isCanceled

public boolean isCanceled()
Returns:
Returns true iff the current reconcile is canceled.

NOTE: Also called from background thread.


setCanceled

public void setCanceled(boolean isCanceled)
Set whether or not the current reconcile is canceled.

Parameters:
isCanceled - true iff the current reconcile is canceled

install

public void install(XtextSourceViewer sourceViewer,
                    XtextPresentationReconciler backgroundPresentationReconciler)
Install this presenter on the given source viewer and background presentation reconciler.

Parameters:
sourceViewer - the source viewer
backgroundPresentationReconciler - the background presentation reconciler, can be null, in that case createPresentation(List, List) should not be called

uninstall

public void uninstall()
Uninstall this presenter.


highlightingStyleChanged

public void highlightingStyleChanged(org.eclipse.jface.text.TextAttribute highlighting)
Invalidate text presentation of positions with the given highlighting.

Parameters:
highlighting - The highlighting