use of org.eclipse.wst.sse.ui.internal.provisional.style.ReconcilerHighlighter in project webtools.sourceediting by eclipse.
the class StructuredTextViewer method configure.
/**
* Should be identical to superclass version. Plus, we get our own special
* Highlighter. Plus we uninstall before installing.
*/
public void configure(SourceViewerConfiguration configuration) {
if (getTextWidget() == null)
return;
setDocumentPartitioning(configuration.getConfiguredDocumentPartitioning(this));
// always uninstall highlighter and null it out on new configuration
if (fHighlighter != null) {
fHighlighter.uninstall();
fHighlighter = null;
}
if (fRecHighlighter != null) {
fRecHighlighter.uninstall();
fRecHighlighter = null;
}
// Bug 230297 - Uninstall presentation reconciler in preparation of a new one
if (fPresentationReconciler != null) {
fPresentationReconciler.uninstall();
fPresentationReconciler = null;
}
IReconciler newReconciler = configuration.getReconciler(this);
if (newReconciler != fReconciler || newReconciler == null || fReconciler == null) {
if (fReconciler != null) {
fReconciler.uninstall();
}
fReconciler = newReconciler;
if (fReconciler != null) {
fReconciler.install(this);
// still need set document on the reconciler (strategies)
if (fReconciler instanceof StructuredRegionProcessor)
((StructuredRegionProcessor) fReconciler).setDocument(getDocument());
}
}
IContentAssistant newAssistant = configuration.getContentAssistant(this);
if (newAssistant != fContentAssistant || newAssistant == null || fContentAssistant == null) {
if (fContentAssistant != null)
fContentAssistant.uninstall();
fContentAssistant = newAssistant;
if (fContentAssistant != null) {
fContentAssistant.install(this);
if (fContentAssistant instanceof IContentAssistantExtension2 && fContentAssistant instanceof IContentAssistantExtension4)
fContentAssistantFacade = new ContentAssistantFacade(fContentAssistant);
fContentAssistantInstalled = true;
} else {
// 248036
// disable the content assist operation if no content
// assistant
enableOperation(CONTENTASSIST_PROPOSALS, false);
fContentAssistantInstalled = false;
}
}
IQuickAssistAssistant quickAssistant = configuration.getQuickAssistAssistant(this);
if (quickAssistant != fQuickAssistAssistant || quickAssistant == null || fQuickAssistAssistant == null) {
if (fQuickAssistAssistant != null)
fQuickAssistAssistant.uninstall();
fQuickAssistAssistant = quickAssistant;
if (fQuickAssistAssistant != null) {
fQuickAssistAssistant.install(this);
fQuickAssistAssistantInstalled = true;
} else {
// 248036
// disable the content assist operation if no content
// assistant
enableOperation(QUICK_ASSIST, false);
fQuickAssistAssistantInstalled = false;
}
}
fContentFormatter = configuration.getContentFormatter(this);
// do not uninstall old information presenter if it's the same
IInformationPresenter newInformationPresenter = configuration.getInformationPresenter(this);
if (newInformationPresenter == null || fInformationPresenter == null || !(newInformationPresenter.equals(fInformationPresenter))) {
if (fInformationPresenter != null)
fInformationPresenter.uninstall();
fInformationPresenter = newInformationPresenter;
if (fInformationPresenter != null)
fInformationPresenter.install(this);
}
// disconnect from the old undo manager before setting the new one
if (fUndoManager != null) {
fUndoManager.disconnect();
}
setUndoManager(configuration.getUndoManager(this));
// release old annotation hover before setting new one
if (fAnnotationHover instanceof StructuredTextAnnotationHover) {
((StructuredTextAnnotationHover) fAnnotationHover).release();
}
setAnnotationHover(configuration.getAnnotationHover(this));
// release old annotation hover before setting new one
if (fOverviewRulerAnnotationHover instanceof StructuredTextAnnotationHover) {
((StructuredTextAnnotationHover) fOverviewRulerAnnotationHover).release();
}
setOverviewRulerAnnotationHover(configuration.getOverviewRulerAnnotationHover(this));
getTextWidget().setTabs(configuration.getTabWidth(this));
setHoverControlCreator(configuration.getInformationControlCreator(this));
// if hyperlink manager has already been created, uninstall it
if (fHyperlinkManager != null) {
setHyperlinkDetectors(null, SWT.NONE);
}
setHyperlinkPresenter(configuration.getHyperlinkPresenter(this));
IHyperlinkDetector[] hyperlinkDetectors = configuration.getHyperlinkDetectors(this);
int eventStateMask = configuration.getHyperlinkStateMask(this);
setHyperlinkDetectors(hyperlinkDetectors, eventStateMask);
String[] types = configuration.getConfiguredContentTypes(this);
// clear autoindent/autoedit strategies
fAutoIndentStrategies = null;
for (int i = 0; i < types.length; i++) {
String t = types[i];
setAutoEditStrategies(configuration.getAutoEditStrategies(this, t), t);
setTextDoubleClickStrategy(configuration.getDoubleClickStrategy(this, t), t);
int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(this, t);
if (stateMasks != null) {
for (int j = 0; j < stateMasks.length; j++) {
int stateMask = stateMasks[j];
setTextHover(configuration.getTextHover(this, t, stateMask), t, stateMask);
}
} else {
setTextHover(configuration.getTextHover(this, t), t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
}
String[] prefixes = configuration.getIndentPrefixes(this, t);
if (prefixes != null && prefixes.length > 0)
setIndentPrefixes(prefixes, t);
prefixes = configuration.getDefaultPrefixes(this, t);
if (prefixes != null && prefixes.length > 0)
setDefaultPrefixes(prefixes, t);
// the document is set
if (getDocument() != null) {
// add highlighter/linestyleprovider
LineStyleProvider[] providers = ((StructuredTextViewerConfiguration) configuration).getLineStyleProviders(this, t);
if (providers != null) {
for (int j = 0; j < providers.length; ++j) {
if (fRecHighlighter == null) {
fRecHighlighter = new ReconcilerHighlighter();
((StructuredTextViewerConfiguration) configuration).setHighlighter(fRecHighlighter);
}
if (providers[j] instanceof AbstractLineStyleProvider) {
((AbstractLineStyleProvider) providers[j]).init((IStructuredDocument) getDocument(), fRecHighlighter);
fRecHighlighter.addProvider(t, providers[j]);
} else {
// init with compatibility instance
if (fHighlighter == null) {
fHighlighter = new CompatibleHighlighter();
}
// $NON-NLS-1$
Logger.log(Logger.INFO_DEBUG, "CompatibleHighlighter installing compatibility for " + providers[j].getClass());
providers[j].init((IStructuredDocument) getDocument(), fHighlighter);
fHighlighter.addProvider(t, providers[j]);
}
}
}
}
}
// initialize highlighter after linestyleproviders were added
if (fHighlighter != null) {
fHighlighter.setDocumentPartitioning(configuration.getConfiguredDocumentPartitioning(this));
fHighlighter.setDocument((IStructuredDocument) getDocument());
fHighlighter.install(this);
}
if (fRecHighlighter != null)
fRecHighlighter.install(this);
activatePlugins();
fConfiguration = configuration;
// Update the viewer's presentation reconciler
fPresentationReconciler = configuration.getPresentationReconciler(this);
if (fPresentationReconciler != null)
fPresentationReconciler.install(this);
}
use of org.eclipse.wst.sse.ui.internal.provisional.style.ReconcilerHighlighter in project webtools.sourceediting by eclipse.
the class StructuredTextViewer method updateHighlighter.
private void updateHighlighter(IStructuredDocument document) {
boolean documentSet = false;
// if highlighter has not been created yet, initialize and install it
if (fRecHighlighter == null && fConfiguration instanceof StructuredTextViewerConfiguration) {
String[] types = fConfiguration.getConfiguredContentTypes(this);
for (int i = 0; i < types.length; i++) {
String t = types[i];
// add highlighter/linestyleprovider
LineStyleProvider[] providers = ((StructuredTextViewerConfiguration) fConfiguration).getLineStyleProviders(this, t);
if (providers != null) {
for (int j = 0; j < providers.length; ++j) {
if (fRecHighlighter == null) {
fRecHighlighter = new ReconcilerHighlighter();
((StructuredTextViewerConfiguration) fConfiguration).setHighlighter(fRecHighlighter);
}
if (providers[j] instanceof AbstractLineStyleProvider) {
((AbstractLineStyleProvider) providers[j]).init(document, fRecHighlighter);
fRecHighlighter.addProvider(t, providers[j]);
} else {
// init with compatibility instance
if (fHighlighter == null) {
fHighlighter = new CompatibleHighlighter();
}
// $NON-NLS-1$
Logger.log(Logger.INFO_DEBUG, "CompatibleHighlighter installing compatibility for " + providers[j].getClass());
providers[j].init(document, fHighlighter);
fHighlighter.addProvider(t, providers[j]);
}
}
}
}
if (fRecHighlighter != null)
fRecHighlighter.install(this);
if (fHighlighter != null) {
fHighlighter.setDocumentPartitioning(fConfiguration.getConfiguredDocumentPartitioning(this));
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=203347
// make sure to set document before install
fHighlighter.setDocument(document);
fHighlighter.install(this);
documentSet = true;
}
}
if (fHighlighter != null && !documentSet)
fHighlighter.setDocument(document);
// install content type independent plugins
if (fPresentationReconciler != null)
fPresentationReconciler.uninstall();
// 228847 - XSL Content Assist tests fail with Null Pointer on Highlighter
if (fConfiguration != null)
fPresentationReconciler = fConfiguration.getPresentationReconciler(this);
if (fPresentationReconciler != null)
fPresentationReconciler.install(this);
}
Aggregations