/** Uninstall this reconciler from the editor */ public void uninstall() { if (presenter != null) presenter.setCanceled(true); if (sourceViewer.getDocument() != null) { if (calculator != null) { XtextDocument document = (XtextDocument) sourceViewer.getDocument(); document.removeModelListener(this); sourceViewer.removeTextInputListener(this); } } sourceViewer = null; presenter = null; }
/** * Install this reconciler on the given editor and presenter. * * @param editor the editor * @param sourceViewer the source viewer * @param presenter the highlighting presenter */ public void install(XtextSourceViewer sourceViewer, HighlightingPresenter presenter) { this.presenter = presenter; this.sourceViewer = sourceViewer; if (calculator != null) { ((IXtextDocument) sourceViewer.getDocument()).addModelListener(this); sourceViewer.addTextInputListener(this); } refresh(); }
/** Refreshes the highlighting. */ public void refresh() { if (calculator != null) { ((XtextDocument) sourceViewer.getDocument()) .readOnly( new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource state) throws Exception { modelChanged(state); } }); } else { Display display = getDisplay(); display.asyncExec(presenter.createSimpleUpdateRunnable()); } }