use of org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider in project webtools.sourceediting by eclipse.
the class NewJSPTemplatesWizardPage method createViewer.
/**
* Creates, configures and returns a source viewer to present the template
* pattern on the preference page. Clients may override to provide a
* custom source viewer featuring e.g. syntax coloring.
*
* @param parent
* the parent control
* @return a configured source viewer
*/
private SourceViewer createViewer(Composite parent) {
SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {
StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationJSP();
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return baseConfiguration.getConfiguredContentTypes(sourceViewer);
}
public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
}
};
SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
// $NON-NLS-1$
viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
IDocument document = scratchModel.getStructuredDocument();
viewer.configure(sourceViewerConfiguration);
viewer.setDocument(document);
return viewer;
}
use of org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider 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);
}
use of org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider in project webtools.sourceediting by eclipse.
the class TestXSLLineStyleProvider method initializeProvider.
private LineStyleProvider initializeProvider() {
LineStyleProvider[] lineStyleProviders = getLineStyleProviders();
LineStyleProvider lineStyleProvider = lineStyleProviders[0];
Highlighter highlighter = new Highlighter();
lineStyleProvider.init(document, highlighter);
return lineStyleProvider;
}
Aggregations