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

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

Introduction

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

Prototype

public static FontRegistry getFontRegistry() 

Source Link

Document

Returns the font registry for JFace itself.

Usage

From source file:net.sourceforge.eclipsetrader.core.ui.PluginPreferencePage.java

License:Open Source License

/**
 * Creates a composite with a highlighted Note entry and a message text.
 * This is designed to take up the full width of the page.
 * //from w w w . j a  v a  2  s. com
 * @param font the font to use
 * @param composite the parent composite
 * @param title the title of the note
 * @param message the message for the note
 * @return the composite for the note
 */
protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
    Composite messageComposite = new Composite(composite, SWT.NONE);
    GridLayout messageLayout = new GridLayout();
    messageLayout.numColumns = 2;
    messageLayout.marginWidth = 0;
    messageLayout.marginHeight = 0;
    messageComposite.setLayout(messageLayout);
    messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    messageComposite.setFont(font);

    final Label noteLabel = new Label(messageComposite, SWT.BOLD);
    noteLabel.setText(title);
    noteLabel.setFont(JFaceResources.getBannerFont());
    noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
                noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
            }
        }
    };
    JFaceResources.getFontRegistry().addListener(fontListener);
    noteLabel.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent event) {
            JFaceResources.getFontRegistry().removeListener(fontListener);
        }
    });

    Label messageLabel = new Label(messageComposite, SWT.WRAP);
    messageLabel.setText(message);
    messageLabel.setFont(font);
    return messageComposite;
}

From source file:net.sourceforge.sqlexplorer.plugin.editors.SQLTextEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {

    super.createPartControl(parent);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(getSourceViewer().getTextWidget(),
            SQLExplorerPlugin.PLUGIN_ID + ".SQLEditor");

    Object adapter = getAdapter(org.eclipse.swt.widgets.Control.class);
    if (adapter instanceof StyledText) {
        StyledText text = (StyledText) adapter;
        text.setWordWrap(//w  w  w  . j  a va 2  s .  c om
                SQLExplorerPlugin.getDefault().getPluginPreferences().getBoolean(IConstants.WORD_WRAP));

        FontData[] fData = PreferenceConverter.getFontDataArray(store, IConstants.FONT);
        if (fData.length > 0) {
            JFaceResources.getFontRegistry().put(fData[0].toString(), fData);
            text.setFont(JFaceResources.getFontRegistry().get(fData[0].toString()));
        }
    }
}

From source file:net.tourbook.chart.ToolTipV1.java

License:Open Source License

void toolTip_10_Show(final int x, final int y, final int hoveredBarSerieIndex, final int hoveredBarValueIndex) {

    _hoveredBarSerieIndex = hoveredBarSerieIndex;
    _hoveredBarValueIndex = hoveredBarValueIndex;

    if (_toolTipShell == null) {

        _toolTipShell = new Shell(_chart.getShell(), SWT.ON_TOP | SWT.TOOL);

        final Display display = _toolTipShell.getDisplay();
        final Color infoColorBackground = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
        final Color infoColorForeground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);

        _toolTipContainer = new Composite(_toolTipShell, SWT.NONE);
        GridLayoutFactory.fillDefaults().extendedMargins(2, 5, 2, 3).applyTo(_toolTipContainer);
        _toolTipContainer.setBackground(infoColorBackground);
        _toolTipContainer.setForeground(infoColorForeground);
        {/* ww w. j  a  v a 2  s  .c o m*/
            _toolTipTitle = new Label(_toolTipContainer, SWT.LEAD);
            _toolTipTitle.setBackground(infoColorBackground);
            _toolTipTitle.setForeground(infoColorForeground);
            _toolTipTitle.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));

            _toolTipLabel = new Label(_toolTipContainer, SWT.LEAD | SWT.WRAP);
            _toolTipLabel.setBackground(infoColorBackground);
            _toolTipLabel.setForeground(infoColorForeground);
        }

        for (final int toolTipEvent : _toolTipEvents) {
            _chart.addListener(toolTipEvent, _toolTipListener);
        }
    }

    if (toolTip_30_Update(x, y)) {
        _toolTipShell.setVisible(true);
    } else {
        toolTip_20_Hide();
    }
}

From source file:net.tourbook.common.font.FontFieldEditorExtended.java

License:Open Source License

private void onChangeFontSize() {

    final FontData[] selectedFont = chosenFont;

    final FontData font = selectedFont[0];
    font.setHeight(_spinFontSize.getSelection());

    final FontData[] validFont = JFaceResources.getFontRegistry().filterData(selectedFont,
            _lblSelectedFont.getDisplay());

    fireFontChanged(validFont[0]);//from  w w  w .java  2  s. c o  m
}

From source file:net.tourbook.common.font.FontFieldEditorExtended.java

License:Open Source License

/**
 * Updates the change font button and the previewer to reflect the newly selected font.
 * //w  w  w . j ava  2s  . c om
 * @param font
 *            The FontData[] to update with.
 */
private void updateFont(final FontData font[]) {

    FontData[] bestFont = JFaceResources.getFontRegistry().filterData(font, _lblSelectedFont.getDisplay());

    //if we have nothing valid do as best we can
    if (bestFont == null) {
        bestFont = getDefaultFontData();
    }

    //Now cache this value in the receiver
    this.chosenFont = bestFont;

    if (_lblSelectedFont != null) {
        _lblSelectedFont.setText(StringConverter.asString(chosenFont[0]));
    }
    if (_fontPreviewer != null) {
        _fontPreviewer.setFont(bestFont);
    }

    // update font size widget
    final int fontHeight = bestFont[0].getHeight();
    _spinFontSize.setSelection(fontHeight);
}

From source file:net.tourbook.map2.view.WayPointToolTipProvider.java

License:Open Source License

@Override
public Composite createToolTipContentArea(final Event event, final Composite parent) {

    if (_hoveredWayPoint == null) {
        // this case should not happen
        return null;
    }/*from w w  w .  ja va 2  s.c om*/

    final Display display = parent.getDisplay();

    _bgColor = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    _fgColor = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    _boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);

    return createUI(parent);
}

From source file:net.tourbook.map3.ui.DialogLayerViewerToolTip.java

License:Open Source License

public DialogLayerViewerToolTip(final ContainerCheckedTreeViewer propViewer) {

    super(propViewer.getTree());

    _propViewer = propViewer;//w w w.  j av a 2 s .co  m

    _tree = propViewer.getTree();
    _tree.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(final DisposeEvent e) {
            onDispose();
        }
    });

    final Device display = _tree.getDisplay();

    _bgColor = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    _fgColor = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    _boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
}

From source file:net.tourbook.map3.ui.SlideoutMap3LayerTooltip.java

License:Open Source License

public SlideoutMap3LayerTooltip(final ContainerCheckedTreeViewer layerViewer) {

    super(layerViewer.getTree());

    _layerViewer = layerViewer;//from   w  ww  .ja  va  2s  . co  m
    _tree = _layerViewer.getTree();

    final Device display = _tree.getDisplay();

    _bgColor = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    _fgColor = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    _boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);

    _cursorHand = new Cursor(display, SWT.CURSOR_HAND);

}

From source file:net.tourbook.mapping.WayPointToolTipProvider.java

License:Open Source License

public Composite createToolTipContentArea(final Event event, final Composite parent) {

    if (_hoveredWayPoint == null) {
        // this case should not happen
        return null;
    }//w ww  . ja  va  2  s  .c  o m

    final Display display = parent.getDisplay();

    _bgColor = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    _fgColor = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    _boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);

    return createUI(parent);
}

From source file:net.tourbook.preferences.PrefPagePeople.java

License:Open Source License

private void initUI(final Composite parent) {

    initializeDialogUnits(parent);/* w  w  w  . j a v a  2 s . c  o m*/

    _fontItalic = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);

    _defaultSelectionListener = new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            onModifyPerson();
        }
    };

    _defaultModifyListener = new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            onModifyPerson();
        }
    };

    _hrZoneMouseListener = new MouseListener() {

        @Override
        public void mouseDoubleClick(final MouseEvent e) {
            onEditHrZones();
        }

        @Override
        public void mouseDown(final MouseEvent e) {
        }

        @Override
        public void mouseUp(final MouseEvent e) {
        }
    };

    createDeviceList();
}