Example usage for org.eclipse.jface.resource JFaceResources getFont

List of usage examples for org.eclipse.jface.resource JFaceResources getFont

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getFont.

Prototype

public static Font getFont(String symbolicName) 

Source Link

Document

Returns the font in JFace's font registry with the given symbolic font name.

Usage

From source file:ext.org.eclipse.jdt.internal.ui.refactoring.PullUpMethodPage.java

License:Open Source License

private void createSourceViewer(final Composite c) {
    final IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
    fSourceViewer = new JavaSourceViewer(c, null, null, false,
            SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, store);
    fSourceViewer.configure(new JavaSourceViewerConfiguration(
            JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
    fSourceViewer.setEditable(false);/*  w ww  .ja v a 2  s  .c  om*/
    fSourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
}

From source file:ext.org.eclipse.jdt.internal.ui.refactoring.reorg.RenameTypeWizardSimilarElementsPage.java

License:Open Source License

private void createSourceViewer(Composite c) {
    IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
    fSourceViewer = new JavaSourceViewer(c, null, null, false,
            SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, store);
    fSourceViewer.configure(/*from   w w w .jav  a 2s  .co m*/
            new JavaSourceViewerConfiguration(getJavaTextTools().getColorManager(), store, null, null));
    fSourceViewer.setEditable(false);
    fSourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
    Document document = new Document();
    getJavaTextTools().setupJavaDocumentPartitioner(document);
    fSourceViewer.setDocument(document);
}

From source file:fr.obeo.timeline.editpart.BranchEditPart.java

License:Open Source License

@Override
protected IFigure createFigure() {
    final LineLayout layout = new LineLayout();
    layout.setHorizontal(true);/*from   w w  w . j a v a2s. c  o  m*/
    layout.setMajorAlignment(FlowLayout.ALIGN_TOPLEFT);
    layout.setMinorAlignment(FlowLayout.ALIGN_BOTTOMRIGHT);
    layout.setMinorSpacing(SPACING);
    layout.setMargin(MARGIN);

    FreeformLayer res = new FreeformLayer();
    final Label toolTip = new Label();
    toolTip.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    toolTip.setBackgroundColor(ColorConstants.tooltipBackground);
    toolTip.setForegroundColor(ColorConstants.tooltipForeground);
    toolTip.setText(getModel().getTimelineWindow().getProvider().getTextAt(getModel().getBranch()));
    res.setToolTip(toolTip);
    res.setLayoutManager(layout);
    return res;
}

From source file:melnorme.lang.ide.ui.text.AbstractLangBasicSourceViewerConfiguration.java

License:Open Source License

public void configureViewer(ProjectionViewerExt sourceViewer) {
    StyledText textWidget = sourceViewer.getTextWidget();
    if (textWidget != null) {
        textWidget.setFont(JFaceResources.getFont(getFontPropertyPreferenceKey()));
        // TODO: respond to font changes
    }/*  ww  w. j a v  a 2 s .  co  m*/

    new ViewerColorUpdater(fPreferenceStore, sourceViewer).configureViewer();
}

From source file:melnorme.lang.ide.ui.text.coloring.AbstractSourceColoringConfigurationBlock.java

License:Open Source License

protected ProjectionViewer createPreviewViewer(Composite parent, boolean showAnnotationsOverview, int styles,
        IPreferenceStore store) {/*from ww w.j a va2 s  .c  o  m*/
    ProjectionViewer sourceViewer = new ProjectionViewer(parent, null, null, showAnnotationsOverview, styles);
    AbstractLangSourceViewerConfiguration configuration = createSimpleSourceViewerConfiguration(store);
    sourceViewer.configure(configuration);
    sourceViewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    configuration.setupViewerForTextPresentationPrefChanges(sourceViewer);
    return sourceViewer;
}

From source file:name.schedenig.eclipse.grepconsole.view.items.ItemLabelProvider.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.OwnerDrawLabelProvider#measure(org.eclipse.swt.widgets.Event, java.lang.Object)
 *//*from ww w . j ava2  s .c  om*/
@Override
protected void measure(Event event, Object element) {
    GC gc = event.gc;
    Image image = getImage(element);
    String text = getText(element);

    Font oldFont = gc.getFont();
    Font font = getFont(element);

    if (font == null) {
        font = JFaceResources.getFont(JFaceResources.DEFAULT_FONT);
    }

    gc.setFont(font);
    Point size = gc.textExtent(text);
    gc.setFont(oldFont);

    if (image != null) {
        Rectangle imageBounds = image.getBounds();

        size.x += imageBounds.width + SPACE;
        size.y = Math.max(size.y, imageBounds.height);
    }

    event.setBounds(new Rectangle(event.x, event.y, size.x, size.y));
}

From source file:name.schedenig.eclipse.grepconsole.view.items.ItemLabelProvider.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.OwnerDrawLabelProvider#paint(org.eclipse.swt.widgets.Event, java.lang.Object)
 *///  w w w  .j a  va 2 s .c  o  m
@Override
protected void paint(Event event, Object element) {
    Image image = getImage(element);
    String text = getText(element);

    boolean enabled = isElementEnabled((AbstractGrepModelElement) element);
    boolean selected = (event.detail & SWT.SELECTED) != 0;
    Color color;

    if (enabled) {
        Display display = viewer.getControl().getDisplay();
        color = selected ? display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)
                : display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
    } else {
        color = colorRegistry.get(RGB_DISABLED);
    }

    int x = event.x;

    if (image != null) {
        Rectangle imageBounds = image.getBounds();
        event.gc.drawImage(image, event.x, event.y + (event.height - imageBounds.height) / 2);
        int imageWidth = imageBounds.width + SPACE;
        x += imageWidth;
    }

    Device device = event.gc.getDevice();
    TextLayout layout = new TextLayout(device);

    try {
        Font font = getFont(element);

        if (font == null) {
            font = JFaceResources.getFont(JFaceResources.DEFAULT_FONT);
        }

        TextStyle style = new TextStyle(font, color, null);

        layout.setText(text);
        layout.setStyle(style, 0, text.length());
        layout.draw(event.gc, x, event.y + (event.height - layout.getBounds().height) / 2);
    } finally {
        layout.dispose();
    }
}

From source file:net.certiv.fluentmark.editor.FluentSourceViewer.java

License:Open Source License

@Override
public void configure(SourceViewerConfiguration configuration) {
    StyledText textWidget = getTextWidget();

    // Prevent access to colors disposed in unconfigure().
    if (textWidget != null && !textWidget.isDisposed()) {
        Color foregroundColor = textWidget.getForeground();
        if (foregroundColor != null && foregroundColor.isDisposed()) {
            textWidget.setForeground(null);
        }/*from  w w w  . ja  v a 2s  .  c  o m*/
        Color backgroundColor = textWidget.getBackground();
        if (backgroundColor != null && backgroundColor.isDisposed()) {
            textWidget.setBackground(null);
        }
    }

    super.configure(configuration);

    if (configuration instanceof FluentSourceViewerConfiguration) {

        // FluentSourceViewerConfiguration cConfiguration = (FluentSourceViewerConfiguration)
        // configuration;
        //
        // fOutlinePresenter = cConfiguration.getOutlinePresenter(this, false);
        // if (fOutlinePresenter != null) {
        // fOutlinePresenter.install(this);
        // }
        // fStructurePresenter = cConfiguration.getOutlinePresenter(this, true);
        // if (fStructurePresenter != null) {
        // fStructurePresenter.install(this);
        // }
        // fHierarchyPresenter = cConfiguration.getHierarchyPresenter(this);
        // if (fHierarchyPresenter != null) {
        // fHierarchyPresenter.install(this);
        // }

        if (textWidget != null) {
            textWidget.setFont(JFaceResources.getFont(Prefs.EDITOR_TEXT_FONT));
        }
    }
    if (store != null) {
        this.store.addPropertyChangeListener(this);
        initializeViewerColors();
    }
    isConfigured = true;
}

From source file:net.certiv.fluentmark.editor.FluentSourceViewerInfoControl.java

License:Open Source License

private void initializeFont() {
    textFont = JFaceResources.getFont(Prefs.EDITOR_TEXT_FONT);
    StyledText styledText = getViewer().getTextWidget();
    styledText.setFont(textFont);
}

From source file:net.certiv.fluentmark.preferences.pages.AppearanceConfigurationBlock.java

License:Open Source License

private Control createPreviewer(Composite parent) {

    IPreferenceStore generalTextStore = FluentUI.getDefault().getPreferenceStore();
    IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(),
            new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
    fPreviewViewer = new FluentSourceViewer(parent, null, null, false, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER,
            store);//  w  ww .  j a  va  2 s. co  m
    FluentSimpleSourceViewerConfiguration configuration = new FluentSimpleSourceViewerConfiguration(
            fColorManager, store, null, Partitions.MK_PARTITIONING, false);
    fPreviewViewer.configure(configuration);
    Font font = JFaceResources.getFont(Prefs.EDITOR_TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);
    new PreviewSourceUpdater(fPreviewViewer, configuration, store);

    fPreviewViewer.setEditable(false);
    Cursor arrowCursor = fPreviewViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
    fPreviewViewer.getTextWidget().setCursor(arrowCursor);

    // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263
    // fPreviewViewer.getTextWidget().setCaret(null);

    String content = loadPreviewContentFromFile("ColorsPreview.md"); //$NON-NLS-1$
    IDocument document = new Document(content);
    FluentUI.getDefault().getTextTools().setupDocumentPartitioner(document, Partitions.MK_PARTITIONING);
    fPreviewViewer.setDocument(document);

    return fPreviewViewer.getControl();
}