Search in sources :

Example 1 with HtmlViewerConfiguration

use of org.eclipse.mylyn.wikitext.ui.viewer.HtmlViewerConfiguration 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;
}
Also used : VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) CssConfiguration(org.eclipse.mylyn.internal.wikitext.ui.util.css.editor.CssConfiguration) SourceViewer(org.eclipse.jface.text.source.SourceViewer) Composite(org.eclipse.swt.widgets.Composite) HtmlViewerConfiguration(org.eclipse.mylyn.wikitext.ui.viewer.HtmlViewerConfiguration) IDocumentListener(org.eclipse.jface.text.IDocumentListener) Label(org.eclipse.swt.widgets.Label) CssPartitioner(org.eclipse.mylyn.internal.wikitext.ui.util.css.editor.CssPartitioner) RGB(org.eclipse.swt.graphics.RGB) Document(org.eclipse.jface.text.Document) DocumentEvent(org.eclipse.jface.text.DocumentEvent) Preferences(org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences) HtmlViewer(org.eclipse.mylyn.wikitext.ui.viewer.HtmlViewer)

Aggregations

Document (org.eclipse.jface.text.Document)1 DocumentEvent (org.eclipse.jface.text.DocumentEvent)1 IDocumentListener (org.eclipse.jface.text.IDocumentListener)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 VerticalRuler (org.eclipse.jface.text.source.VerticalRuler)1 Preferences (org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences)1 CssConfiguration (org.eclipse.mylyn.internal.wikitext.ui.util.css.editor.CssConfiguration)1 CssPartitioner (org.eclipse.mylyn.internal.wikitext.ui.util.css.editor.CssPartitioner)1 HtmlViewer (org.eclipse.mylyn.wikitext.ui.viewer.HtmlViewer)1 HtmlViewerConfiguration (org.eclipse.mylyn.wikitext.ui.viewer.HtmlViewerConfiguration)1 RGB (org.eclipse.swt.graphics.RGB)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1