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

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

Introduction

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

Prototype

String TEXT_FONT

To view the source code for org.eclipse.jface.resource JFaceResources TEXT_FONT.

Click Source Link

Document

The symbolic font name for the text font (value "org.eclipse.jface.textfont").

Usage

From source file:org.ebayopensource.vjet.eclipse.ui.VjetUIPlugin.java

License:Open Source License

/**
 * Because clearcase cq tool cause a wrong font loaded for
 * "JFaceResources.TEXT_FONT", So here if the font is not correct, reload
 * it.//from  ww  w  . jav a 2s  .c om
 */
private void reloadFont() {
    FontRegistry registry = JFaceResources.getFontRegistry();
    if (registry.defaultFont().equals(registry.get(JFaceResources.TEXT_FONT))) {
        FontData[] datas = registry.getFontData(JFaceResources.TEXT_FONT);
        registry.put(JFaceResources.TEXT_FONT, registry.defaultFont().getFontData());
        registry.put(JFaceResources.TEXT_FONT, datas);
    }
}

From source file:org.eclipse.ant.internal.ui.editor.AntSourceViewerInformationControl.java

License:Open Source License

private SourceViewer createViewer(Composite parent) {
    SourceViewer viewer = new SourceViewer(parent, null, SWT.NONE);

    SourceViewerConfiguration configuration = new AntSourceViewerConfiguration();
    viewer.configure(configuration);/*  ww  w  .  ja  v a 2s. co  m*/
    viewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    viewer.getTextWidget().setFont(font);

    return viewer;
}

From source file:org.eclipse.ant.internal.ui.editor.templates.AntTemplatePreferencePage.java

License:Open Source License

@Override
protected SourceViewer createViewer(Composite parent) {
    SourceViewer viewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    SourceViewerConfiguration configuration = new AntTemplateViewerConfiguration();
    IDocument document = new Document();
    new AntDocumentSetupParticipant().setup(document);
    viewer.configure(configuration);/* w ww .ja  v a  2  s  .c  o m*/
    viewer.setDocument(document);
    viewer.setEditable(false);
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    viewer.getTextWidget().setFont(font);

    return viewer;
}

From source file:org.eclipse.ant.internal.ui.preferences.AntCodeFormatterPreferencePage.java

License:Open Source License

private Control createPreviewer(Composite parent) {
    fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    AntSourceViewerConfiguration configuration = new AntSourceViewerConfiguration();

    fPreviewViewer.configure(configuration);
    fPreviewViewer.setEditable(false);//from  w w  w  .ja va 2  s.c o m
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);

    IPreferenceStore store = new ChainedPreferenceStore(
            new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() });
    fPreviewerUpdater = new AntPreviewerUpdater(fPreviewViewer, configuration, store);

    String content = loadPreviewContentFromFile("FormatPreviewCode.txt"); //$NON-NLS-1$
    content = formatContent(content, store);
    IDocument document = new Document(content);
    new AntDocumentSetupParticipant().setup(document);
    fPreviewViewer.setDocument(document);

    return fPreviewViewer.getControl();
}

From source file:org.eclipse.ant.internal.ui.preferences.AntEditorPreferencePage.java

License:Open Source License

private Control createPreviewer(Composite parent) {
    fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    AntSourceViewerConfiguration configuration = new AntSourceViewerConfiguration();

    fPreviewViewer.configure(configuration);
    fPreviewViewer.setEditable(false);/*  w  w w .j av  a2  s. co  m*/
    Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);

    IPreferenceStore store = new ChainedPreferenceStore(
            new IPreferenceStore[] { getOverlayStore(), EditorsUI.getPreferenceStore() });
    fPreviewerUpdater = new AntPreviewerUpdater(fPreviewViewer, configuration, store);

    String content = loadPreviewContentFromFile("SyntaxPreviewCode.txt"); //$NON-NLS-1$
    IDocument document = new Document(content);
    new AntDocumentSetupParticipant().setup(document);
    fPreviewViewer.setDocument(document);

    return fPreviewViewer.getControl();
}

From source file:org.eclipse.ant.internal.ui.preferences.AntPreviewerUpdater.java

License:Open Source License

/**
 * Creates a source preview updater for the given viewer, configuration and preference store.
 * //from  ww  w . j a  va 2s  .  c  o  m
 * @param viewer
 *            the viewer
 * @param configuration
 *            the configuration
 * @param preferenceStore
 *            the preference store
 */
public AntPreviewerUpdater(final SourceViewer viewer, final AntSourceViewerConfiguration configuration,
        final IPreferenceStore preferenceStore) {

    initializeViewerColors(viewer, preferenceStore);

    final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() {
        /*
         * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
         */
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(JFaceResources.TEXT_FONT)) {
                Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
                viewer.getTextWidget().setFont(font);
            }
        }
    };
    final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
        /*
         * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
         */
        @Override
        public void propertyChange(PropertyChangeEvent event) {

            String property = event.getProperty();

            if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property)
                    || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT
                            .equals(property)) {
                initializeViewerColors(viewer, preferenceStore);
            }

            if (configuration.affectsTextPresentation(event)) {
                configuration.adaptToPreferenceChange(event);
                viewer.invalidateTextPresentation();
            }

            if (FormattingPreferences.affectsFormatting(event)) {
                format(viewer, preferenceStore);
            }
        }

        /**
         * @param viewer
         * @param preferenceStore
         */
        private void format(final SourceViewer sourceViewer, final IPreferenceStore store) {
            String contents = sourceViewer.getDocument().get();
            FormattingPreferences prefs = new FormattingPreferences();
            prefs.setPreferenceStore(store);
            contents = XmlFormatter.format(contents, prefs);
            viewer.getDocument().set(contents);
        }
    };
    viewer.getTextWidget().addDisposeListener(new DisposeListener() {
        /*
         * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
         */
        @Override
        public void widgetDisposed(DisposeEvent e) {
            preferenceStore.removePropertyChangeListener(propertyChangeListener);
            JFaceResources.getFontRegistry().removeListener(fontChangeListener);
        }
    });
    JFaceResources.getFontRegistry().addListener(fontChangeListener);
    preferenceStore.addPropertyChangeListener(propertyChangeListener);
}

From source file:org.eclipse.birt.report.designer.ui.ide.preferences.ExpressionSyntaxColoringPage.java

License:Open Source License

protected Control createContents(final Composite parent) {
    initializeDialogUnits(parent);//from   w  w  w.  ja  v a 2  s. c o  m

    fDefaultForeground = UIUtil.getEclipseEditorForeground();
    fDefaultBackground = UIUtil.getEclipseEditorBackground();
    Composite pageComponent = createComposite(parent, 2);
    UIUtil.bindHelp(getControl(), IHelpContextIds.PREFERENCE_BIRT_EXPRESSION_SYNTAX_COLOR_ID);

    Link link = new Link(pageComponent, SWT.WRAP);
    link.setText(Messages.getString("ExpressionSyntaxColoringPage.Link.ColorAndFont")); //$NON-NLS-1$
    link.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
        }
    });

    GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
    linkData.widthHint = 150; // only expand further if anyone else requires
    // it
    link.setLayoutData(linkData);

    new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
    new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());

    SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
    GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData2.horizontalSpan = 2;
    editor.setLayoutData(gridData2);
    SashForm top = new SashForm(editor, SWT.HORIZONTAL);
    Composite styleEditor = createComposite(top, 1);
    ((GridLayout) styleEditor.getLayout()).marginRight = 5;
    ((GridLayout) styleEditor.getLayout()).marginLeft = 0;
    createLabel(styleEditor, Messages.getString("ExpressionSyntaxColoringPage.Label.SyntaxElement")); //$NON-NLS-1$
    fStylesViewer = createStylesViewer(styleEditor);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.horizontalIndent = 0;
    Iterator iterator = fStyleToDescriptionMap.values().iterator();
    while (iterator.hasNext()) {
        gridData.widthHint = Math.max(gridData.widthHint,
                convertWidthInCharsToPixels(iterator.next().toString().length()));
    }
    gridData.heightHint = convertHeightInCharsToPixels(5);
    fStylesViewer.getControl().setLayoutData(gridData);

    Composite editingComposite = createComposite(top, 1);
    ((GridLayout) styleEditor.getLayout()).marginLeft = 5;
    createLabel(editingComposite, ""); //$NON-NLS-1$
    Button enabler = createCheckbox(editingComposite,
            Messages.getString("ExpressionSyntaxColoringPage.Button.Enable")); //$NON-NLS-1$
    enabler.setEnabled(false);
    enabler.setSelection(true);
    Composite editControls = createComposite(editingComposite, 2);
    ((GridLayout) editControls.getLayout()).marginLeft = 20;

    fForegroundLabel = createLabel(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Label.Foreground")); //$NON-NLS-1$
    ((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
    fForegroundLabel.setEnabled(false);

    fForegroundColorEditor = new ColorSelector(editControls);
    Button fForegroundColor = fForegroundColorEditor.getButton();
    GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
    fForegroundColor.setLayoutData(gd);
    fForegroundColorEditor.setEnabled(false);
    fForegroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(final AccessibleEvent e) {
            e.result = Messages.getString("ExpressionSyntaxColoringPage.Accessible.Name.Foreground"); //$NON-NLS-1$
        }
    });

    fBackgroundLabel = createLabel(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Label.Background")); //$NON-NLS-1$
    ((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
    fBackgroundLabel.setEnabled(false);

    fBackgroundColorEditor = new ColorSelector(editControls);
    Button fBackgroundColor = fBackgroundColorEditor.getButton();
    gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
    fBackgroundColor.setLayoutData(gd);
    fBackgroundColorEditor.setEnabled(false);
    fBackgroundColorEditor.getButton().getAccessible().addAccessibleListener(new AccessibleAdapter() {

        public void getName(final AccessibleEvent e) {
            e.result = Messages.getString("ExpressionSyntaxColoringPage.Accessible.Name.Background"); //$NON-NLS-1$
        }
    });

    fBold = createCheckbox(editControls, Messages.getString("ExpressionSyntaxColoringPage.Button.Bold")); //$NON-NLS-1$
    fBold.setEnabled(false);
    ((GridData) fBold.getLayoutData()).horizontalSpan = 2;
    fItalic = createCheckbox(editControls, Messages.getString("ExpressionSyntaxColoringPage.Button.Italic")); //$NON-NLS-1$
    fItalic.setEnabled(false);
    ((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
    fStrike = createCheckbox(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Button.Strikethrough")); //$NON-NLS-1$
    fStrike.setEnabled(false);
    ((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
    fUnderline = createCheckbox(editControls,
            Messages.getString("ExpressionSyntaxColoringPage.Button.Underline")); //$NON-NLS-1$
    fUnderline.setEnabled(false);
    ((GridData) fUnderline.getLayoutData()).horizontalSpan = 2;
    fClearStyle = new Button(editingComposite, SWT.PUSH);
    fClearStyle.setText(Messages.getString("ExpressionSyntaxColoringPage.Button.Restore")); //$NON-NLS-1$
    fClearStyle.setLayoutData(new GridData(SWT.BEGINNING));
    ((GridData) fClearStyle.getLayoutData()).horizontalIndent = 20;
    fClearStyle.setEnabled(false);

    Composite sampleArea = createComposite(editor, 1);

    ((GridLayout) sampleArea.getLayout()).marginLeft = 5;
    ((GridLayout) sampleArea.getLayout()).marginTop = 5;
    createLabel(sampleArea, Messages.getString("ExpressionSyntaxColoringPage.Label.SampleText")); //$NON-NLS-1$
    fPreviewViewer = new SourceViewer(sampleArea, null,
            SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
    fPreviewViewer.configure(new JSSourceViewerConfiguration());
    fText = fPreviewViewer.getTextWidget();
    GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData3.widthHint = convertWidthInCharsToPixels(20);
    gridData3.heightHint = convertHeightInCharsToPixels(5);
    gridData3.horizontalSpan = 2;
    fText.setLayoutData(gridData3);
    fText.setEditable(false);
    fText.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    fText.addKeyListener(getTextKeyListener());
    fText.addSelectionListener(getTextSelectionListener());
    fText.addMouseListener(getTextMouseListener());
    fText.addTraverseListener(getTraverseListener());
    setAccessible(fText, Messages.getString("ExpressionSyntaxColoringPage.Label.SampleText")); //$NON-NLS-1$

    JSEditorInput editorInput = new JSEditorInput(loadPreviewContentFromFile());
    JSDocumentProvider documentProvider = new JSDocumentProvider();

    try {
        documentProvider.connect(editorInput);
    } catch (CoreException e) {
        ExceptionHandler.handle(e);
    }

    fDocument = documentProvider.getDocument(editorInput);

    initializeSourcePreviewColors(fPreviewViewer);

    fPreviewViewer.setDocument(fDocument);

    top.setWeights(new int[] { 1, 1 });
    editor.setWeights(new int[] { 1, 1 });

    fStylesViewer.setInput(getStylePreferenceKeys());

    applyStyles();

    fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                activate(namedStyle);
                if (namedStyle == null)
                    return;
            }
        }
    });

    fForegroundColorEditor.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
                Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                String prefString = getOverlayStore().getString(namedStyle);
                String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
                if (stylePrefs != null) {
                    String oldValue = stylePrefs[0];
                    // open color dialog to get new color
                    String newValue = ColorHelper.toRGBString(fForegroundColorEditor.getColorValue());

                    if (!newValue.equals(oldValue)) {
                        stylePrefs[0] = newValue;
                        String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                        getOverlayStore().setValue(namedStyle, newPrefString);
                        applyStyles();
                        fText.redraw();
                    }
                }
            }
        }
    });

    fBackgroundColorEditor.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
                Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                String prefString = getOverlayStore().getString(namedStyle);
                String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
                if (stylePrefs != null) {
                    String oldValue = stylePrefs[1];
                    // open color dialog to get new color
                    String newValue = ColorHelper.toRGBString(fBackgroundColorEditor.getColorValue());

                    if (!newValue.equals(oldValue)) {
                        stylePrefs[1] = newValue;
                        String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                        getOverlayStore().setValue(namedStyle, newPrefString);
                        applyStyles();
                        fText.redraw();
                        activate(namedStyle);
                    }
                }
            }
        }
    });

    fBold.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[2];
                String newValue = String.valueOf(fBold.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[2] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fItalic.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[3];
                String newValue = String.valueOf(fItalic.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[3] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fStrike.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[4];
                String newValue = String.valueOf(fStrike.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[4] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fUnderline.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[5];
                String newValue = String.valueOf(fUnderline.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[5] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    fText.redraw();
                }
            }
        }
    });

    fClearStyle.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (fStylesViewer.getSelection().isEmpty())
                return;
            String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement()
                    .toString();
            getOverlayStore().setToDefault(namedStyle);
            applyStyles();
            fText.redraw();
            activate(namedStyle);
        }
    });

    return pageComponent;
}

From source file:org.eclipse.cdt.core.testplugin.util.FailureDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    // page group
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Label label = new Label(composite, SWT.WRAP);
    label.setText("&Enter a note regarding the failure:");

    _text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    _text.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = SIZING_TEXT_WIDTH;//w w  w. j  ava 2 s.c  o  m
    data.heightHint = SIZING_TEXT_HEIGHT;
    _text.setLayoutData(data);

    return composite;
}

From source file:org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart.java

License:Open Source License

protected final String getFontPropertyPreferenceKey() {
    String symbolicFontName = getSymbolicFontName();

    if (symbolicFontName != null)
        return symbolicFontName;
    else/*from  www .  j  av  a  2  s .c om*/
        return JFaceResources.TEXT_FONT;
}

From source file:org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart.java

License:Open Source License

/**
 * Initializes the given viewer's font.//from w w w . j a  v a 2s  .  c  o  m
 *
 * @param viewer
 *            the viewer
 */
private void initializeViewerFont(ISourceViewer viewer) {

    boolean isSharedFont = true;
    Font font = null;
    String symbolicFontName = getSymbolicFontName();

    if (symbolicFontName != null)
        font = JFaceResources.getFont(symbolicFontName);
    else if (fPreferenceStore != null) {
        // Backward compatibility
        if (fPreferenceStore.contains(JFaceResources.TEXT_FONT)
                && !fPreferenceStore.isDefault(JFaceResources.TEXT_FONT)) {
            FontData data = PreferenceConverter.getFontData(fPreferenceStore, JFaceResources.TEXT_FONT);

            if (data != null) {
                isSharedFont = false;
                font = new Font(viewer.getTextWidget().getDisplay(), data);
            }
        }
    }
    if (font == null)
        font = JFaceResources.getTextFont();

    setFont(viewer, font);

    if (fFont != null) {
        fFont.dispose();
        fFont = null;
    }

    if (!isSharedFont)
        fFont = font;
}