use of org.eclipse.mylyn.internal.wikitext.ui.util.css.editor.CssConfiguration in project mylyn.docs by eclipse.
the class MarkupViewerPreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
colorRegistry = new Colors();
colorRegistry.put(WHITE, new RGB(255, 255, 255));
Composite composite = new Composite(parent, SWT.NULL);
GridLayoutFactory.fillDefaults().margins(5, 5).numColumns(1).applyTo(composite);
Label label = new Label(composite, SWT.WRAP);
label.setText(Messages.MarkupViewerPreferencePage_appearanceInfo);
GridDataFactory.fillDefaults().applyTo(label);
Preferences preferences = WikiTextUiPlugin.getDefault().getPreferences();
Composite viewerContainer = new Composite(composite, SWT.BORDER);
GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(1).applyTo(viewerContainer);
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewerContainer);
{
sourceViewer = new SourceViewer(viewerContainer, new VerticalRuler(0), SWT.WRAP | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(sourceViewer.getControl());
Document document = new Document(preferences.getMarkupViewerCss());
CssPartitioner partitioner = new CssPartitioner();
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
sourceViewer.setDocument(document);
CssConfiguration configuration = new CssConfiguration(colorRegistry);
sourceViewer.configure(configuration);
}
label = new Label(composite, SWT.WRAP);
label.setText(Messages.MarkupViewerPreferencePage_preview);
GridDataFactory.fillDefaults().applyTo(label);
applyDialogFont(composite);
Composite previewViewerContainer = new Composite(composite, SWT.BORDER);
GridLayoutFactory.fillDefaults().margins(0, 0).numColumns(1).applyTo(previewViewerContainer);
GridDataFactory.fillDefaults().grab(true, true).applyTo(previewViewerContainer);
{
previewViewer = new HtmlViewer(previewViewerContainer, new VerticalRuler(0), SWT.WRAP | SWT.V_SCROLL);
previewViewer.getTextWidget().setBackground(colorRegistry.get(WHITE));
GridDataFactory.fillDefaults().grab(true, true).applyTo(previewViewer.getControl());
htmlViewerConfiguration = new HtmlViewerConfiguration(previewViewer);
previewViewer.configure(htmlViewerConfiguration);
previewViewer.getTextWidget().setEditable(false);
previewViewer.setStylesheet(preferences.getStylesheet());
if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT)) {
previewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT));
}
if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT)) {
previewViewer.setDefaultMonospaceFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT));
}
previewViewer.setHtml(createPreviewHtml());
sourceViewer.getDocument().addDocumentListener(new IDocumentListener() {
public void documentAboutToBeChanged(DocumentEvent event) {
}
public void documentChanged(DocumentEvent event) {
schedulePreviewUpdate();
}
});
}
return composite;
}
Aggregations