Search in sources :

Example 1 with Preferences

use of org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences in project mylyn.docs by eclipse.

the class MarkupEditor method saveProjectionPreferences.

public void saveProjectionPreferences() {
    if (isFoldingEnabled() != WikiTextUiPlugin.getDefault().getPreferences().isEditorFolding()) {
        Preferences preferences = WikiTextUiPlugin.getDefault().getPreferences().clone();
        preferences.setEditorFolding(isFoldingEnabled());
        preferences.save(WikiTextUiPlugin.getDefault().getPreferenceStore(), false);
    }
}
Also used : Preferences(org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences)

Example 2 with Preferences

use of org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences in project mylyn.docs by eclipse.

the class MarkupViewerPreferencePage method performOk.

@Override
public boolean performOk() {
    Preferences preferences = WikiTextUiPlugin.getDefault().getPreferences().clone();
    preferences.setMarkupViewerCss(sourceViewer.getDocument().get());
    preferences.save(WikiTextUiPlugin.getDefault().getPreferenceStore(), false);
    return super.performOk();
}
Also used : Preferences(org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences)

Example 3 with Preferences

use of org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences 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)

Example 4 with Preferences

use of org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences in project mylyn.docs by eclipse.

the class WikiTextUiPlugin method getPreferences.

public Preferences getPreferences() {
    if (preferences == null) {
        Preferences prefs = new Preferences();
        prefs.load(getPreferenceStore());
        prefs.makeImmutable();
        preferences = prefs;
    }
    return preferences;
}
Also used : Preferences(org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences)

Aggregations

Preferences (org.eclipse.mylyn.internal.wikitext.ui.editor.preferences.Preferences)4 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 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