Example usage for org.eclipse.jface.resource FontRegistry put

List of usage examples for org.eclipse.jface.resource FontRegistry put

Introduction

In this page you can find the example usage for org.eclipse.jface.resource FontRegistry put.

Prototype

public void put(String symbolicName, FontData[] fontData) 

Source Link

Document

Adds (or replaces) a font to this font registry under the given symbolic name.

Usage

From source file:ch.elexis.core.ui.UiDesk.java

License:Open Source License

public static void updateFont(String cfgName) {
    FontRegistry fr = JFaceResources.getFontRegistry();
    FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg), cfgName);
    fr.put(cfgName, fd);
}

From source file:ch.elexis.core.ui.UiDesk.java

License:Open Source License

public static Font getFont(String cfgName) {
    FontRegistry fr = JFaceResources.getFontRegistry();
    if (!fr.hasValueFor(cfgName)) {
        FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
                cfgName);/*  w w  w. j a  v a 2  s.  c o  m*/
        fr.put(cfgName, fd);
    }
    return fr.get(cfgName);
}

From source file:ch.elexis.core.ui.UiDesk.java

License:Open Source License

public static Font getFont(String name, int height, int style) {
    String key = name + ":" + Integer.toString(height) + ":" + Integer.toString(style); //$NON-NLS-1$ //$NON-NLS-2$
    FontRegistry fr = JFaceResources.getFontRegistry();
    if (!fr.hasValueFor(key)) {
        FontData[] fd = new FontData[] { new FontData(name, height, style) };
        fr.put(key, fd);
    }//from ww  w  .  j av  a  2  s.  c om
    return fr.get(key);
}

From source file:ch.elexis.Desk.java

License:Open Source License

public static void updateFont(String cfgName) {
    FontRegistry fr = JFaceResources.getFontRegistry();
    FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(Hub.userCfg), cfgName);
    fr.put(cfgName, fd);
}

From source file:ch.elexis.Desk.java

License:Open Source License

public static Font getFont(String cfgName) {
    FontRegistry fr = JFaceResources.getFontRegistry();
    if (!fr.hasValueFor(cfgName)) {
        FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(Hub.userCfg), cfgName);
        fr.put(cfgName, fd);
    }/* w w  w.  ja v  a2  s.c  om*/
    return fr.get(cfgName);
}

From source file:com.archimatetool.editor.ui.FontFactory.java

License:Open Source License

/**
 * @param fontName//from   w ww .  j a v a2 s .co  m
 * @return A FOnt for the fontName or the default user font if null or exception occurs
 */
public static Font get(String fontName) {
    if (fontName == null) {
        return getDefaultUserViewFont();
    }

    if (!FontRegistry.hasValueFor(fontName)) {
        try {
            FontData fd = new FontData(fontName);
            FontRegistry.put(fontName, new FontData[] { fd });
        }
        // Can cause exception if using font name from different OS platform
        catch (Exception ex) {
            return getDefaultUserViewFont();
        }
    }

    return FontRegistry.get(fontName);
}

From source file:com.archimatetool.editor.ui.FontFactory.java

License:Open Source License

public static FontData getDefaultUserViewFontData() {
    // We don't have it
    if (!FontRegistry.hasValueFor(DEFAULT_VIEW_FONT_NAME)) {
        // So check user prefs...
        String fontDetails = Preferences.getDefaultViewFont();
        if (StringUtils.isSet(fontDetails)) {
            try {
                // Put font details from user prefs
                FontData fd = new FontData(fontDetails);
                FontRegistry.put(DEFAULT_VIEW_FONT_NAME, new FontData[] { fd });
            } catch (Exception ex) {
                //ex.printStackTrace();
                setDefaultViewOSFontData();
            }/* ww w.j av a  2s .co m*/
        }
        // Not set in user prefs, so set default font data
        else {
            setDefaultViewOSFontData();
        }
    }

    return FontRegistry.getFontData(DEFAULT_VIEW_FONT_NAME)[0];
}

From source file:com.archimatetool.editor.ui.FontFactory.java

License:Open Source License

public static void setDefaultUserViewFont(FontData fd) {
    // Do this first!
    FontRegistry.put(DEFAULT_VIEW_FONT_NAME, new FontData[] { fd });

    // Then set value as this will send property change
    Preferences.setDefaultViewFont(fd.toString());
}

From source file:com.archimatetool.editor.ui.FontFactory.java

License:Open Source License

private static void setDefaultViewOSFontData() {
    FontData fd = getDefaultViewOSFontData();
    FontRegistry.put(DEFAULT_VIEW_FONT_NAME, new FontData[] { fd });
}

From source file:com.bdaum.zoom.rcp.internal.ApplicationWorkbenchAdvisor.java

License:Open Source License

private static void createApplicationFonts() {
    FontRegistry fontRegistry = JFaceResources.getFontRegistry();
    FontData fontData = fontRegistry.defaultFontDescriptor().getFontData()[0];
    fontRegistry.put(UiConstants.MESSAGEFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight() + 4, fontData.getStyle()) });
    fontRegistry.put(UiConstants.SELECTIONFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD) });
    fontRegistry.put(UiConstants.ITALICFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC) });
    fontRegistry.put(UiConstants.VIEWERFONT,
            new FontData[] { new FontData(fontData.getName(), 18, fontData.getStyle()) });
    fontRegistry.put(UiConstants.VIEWERTITLEFONT,
            new FontData[] { new FontData(fontData.getName(), 24, SWT.BOLD) });
    fontRegistry.put(UiConstants.VIEWERBANNERFONT,
            new FontData[] { new FontData(fontData.getName(), 36, SWT.BOLD) });
    fontData = fontRegistry.getDescriptor(JFaceResources.HEADER_FONT).getFontData()[0];
    fontRegistry.put(UiConstants.MESSAGETITLEFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight() + 4, fontData.getStyle()) });
}