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

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

Introduction

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

Prototype

public Font defaultFont() 

Source Link

Document

Returns the default font data.

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./* w w w. j  a  v  a  2  s . co  m*/
 */
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.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure.java

License:Open Source License

/**
 * get the labe's font from preference./*from  w  ww.j  a  va  2  s  .  c  om*/
 * 
 * @return
 */
private Font getLabelFont() {
    FontRegistry registry = JFaceResources.getFontRegistry();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    FontData fontData = PreferenceConverter.getFontData(store, GEMPreferences.FIGURE_LABEL_FONT);
    if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
        return registry.get(fontData.toString());

    registry.put(fontData.toString(), new FontData[] { fontData });
    return registry.get(fontData.toString());
}

From source file:org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PFLinkFigure.java

License:Open Source License

/**
 * get the label's font from preference/*from w w  w.  j  a  va  2  s  .  c  o  m*/
 * 
 */
private Font getLabelFont() {
    FontRegistry registry = JFaceResources.getFontRegistry();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    FontData fontData = PreferenceConverter.getFontData(store, GEMPreferences.LINE_LABEL_FONT);
    if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
        return registry.get(fontData.toString());

    registry.put(fontData.toString(), new FontData[] { fontData });
    return registry.get(fontData.toString());
}

From source file:org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowEditor.java

License:Open Source License

private Font getLinkLabelFont() {
    FontRegistry registry = JFaceResources.getFontRegistry();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    FontData fontData = PreferenceConverter.getFontData(store, GEMPreferences.LINE_LABEL_FONT);
    if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
        return registry.get(fontData.toString());

    registry.put(fontData.toString(), new FontData[] { fontData });
    return registry.get(fontData.toString());
}

From source file:org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowEditor.java

License:Open Source License

private Font getNodeLabelFont() {
    FontRegistry registry = JFaceResources.getFontRegistry();
    IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
    FontData fontData = PreferenceConverter.getFontData(store, GEMPreferences.FIGURE_LABEL_FONT);
    if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
        return registry.get(fontData.toString());

    registry.put(fontData.toString(), new FontData[] { fontData });
    return registry.get(fontData.toString());
}

From source file:org.eclipse.ui.tests.preferences.FontPreferenceTestCase.java

License:Open Source License

/**
 * The test added to assess results of accessing FontRegistry from a non-UI 
 * thread. See bug 230360.//from  ww  w .  ja va  2  s .c o m
 */
public void testNonUIThreadFontAccess() {
    // create a separate font registry to avoid contaminating other tests
    final FontRegistry fontRegistry = new FontRegistry("org.eclipse.jface.resource.jfacefonts"); //$NON-NLS-1$
    // pre-calculate the default font; calling it in worker thread will only cause SWTException
    Font defaultFont = fontRegistry.defaultFont();
    defaultFont.toString(); // avoids compiler warning

    // redirect logging so that we catch the error log
    final boolean[] errorLogged = new boolean[] { false };
    ILogger logger = Policy.getLog();
    Policy.setLog(new ILogger() {
        public void log(IStatus status) {
            if (status != null && status.getSeverity() == IStatus.ERROR
                    && status.getPlugin().equals(Policy.JFACE))
                errorLogged[0] = true;
        }
    });

    Job job = new Job("Non-UI thread FontRegistry Access Test") {
        protected IStatus run(IProgressMonitor monitor) {
            // this should produce no exception, but should log a error 
            boolean created = checkFont(fontRegistry);
            assertFalse(created);
            return Status.OK_STATUS;
        }
    };
    job.schedule();
    try {
        job.join();
        assertTrue(errorLogged[0]);
    } catch (InterruptedException e) {
        fail("Worker thread was interrupted in the FontRegistry access test");
    } finally {
        Policy.setLog(logger);
    }

    // now let's try to create the same font in the UI thread and check that the correct 
    boolean created = checkFont(fontRegistry);
    assertTrue(created);
}

From source file:org.eclipse.ui.tests.preferences.FontPreferenceTestCase.java

License:Open Source License

public boolean checkFont(final FontRegistry fontRegistry) {
    // Create a font description that will use default font with height increased by 20
    FontData[] data = fontRegistry.defaultFont().getFontData();
    int defaultHeight = data[0].getHeight();
    int testHeight = defaultHeight + 20;
    data[0].setHeight(testHeight);/*from  www.ja v a  2 s  .com*/
    fontRegistry.put("testFont", data);

    // Get the font from the registry
    Font testFont = fontRegistry.get("testFont"); // getItalic("testFont");

    // Check the font size
    FontData[] receivedData = testFont.getFontData();
    int receivedHeight = receivedData[0].getHeight();
    // giving a bit leeway to the OS: the size might not match exactly
    // so test size not being the default rather then being exactly the testHeight
    return (receivedHeight != defaultHeight);
}

From source file:org.openehealth.ipf.tools.manager.jmxexplorer.ui.editor.MBeanAttributeEditor.java

License:Apache License

/**
 * @see org.openehealth.ipf.tools.manager.jmxexplorer.ui.editor.IMBeanNodeEditor#decorateContentsAsSelected()
 *//*www  .ja va2s . c om*/
public boolean decorateContentsAsSelected() {
    FontRegistry fontRegistry = new FontRegistry(Display.getCurrent());
    nameLabel.setFont(fontRegistry.getBold(fontRegistry.defaultFont().toString()));
    return true;
}

From source file:org.openehealth.ipf.tools.manager.jmxexplorer.ui.editor.MBeanOperationEditor.java

License:Apache License

/**
 * @see org.openehealth.ipf.tools.manager.jmxexplorer.ui.editor.IMBeanNodeEditor#decorateContentsAsSelected()
 *//*w ww.j a  va  2  s  .  co m*/
public boolean decorateContentsAsSelected() {
    FontRegistry fontRegistry = new FontRegistry(Display.getCurrent(), true);
    operationButton.setFont(fontRegistry.getBold(fontRegistry.defaultFont().toString()));
    return true;
}