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:edu.uchicago.cs.hao.texdojo.bibeditor.editors.EditorUI.java

License:Open Source License

private void createEditPanel(Composite parent) {
    Composite editPanel = new Composite(parent, SWT.NONE);
    editPanel.setLayout(new FillLayout());
    editText = new StyledText(editPanel, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    editText.setFont(JFaceResources.getTextFont());
    editText.addModifyListener(textModifyListener);
    JFaceResources.getFontRegistry().addListener(new IPropertyChangeListener() {
        @Override//from   w  w w  .j  a  v a 2  s .  c o m
        public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
            if (JFaceResources.getFontRegistry().equals(event.getSource())
                    && JFaceResources.TEXT_FONT.equals(event.getProperty())) {
                editText.setFont(JFaceResources.getTextFont());
            }
            return;
        }
    });
}

From source file:eu.numberfour.n4js.ui.textzoom.TextZoomHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    boolean zoomIn = ZOOM_IN_ID.equals(event.getCommand().getId());
    int delta = zoomIn ? +1 : -1;

    IPreferencesService preferencesService = Platform.getPreferencesService();
    String value = preferencesService.getString(QUALIFIER, JFaceResources.TEXT_FONT, null, null);
    FontData fontData[] = PreferenceConverter.basicGetFontData(value);
    FontData fontdata = fontData[0];//w  w  w .  j a v  a2s. c  o m
    fontdata.setHeight(fontdata.getHeight() + delta);
    Preferences preferences = preferencesService.getRootNode().node("/instance/" + QUALIFIER);
    preferences.put(JFaceResources.TEXT_FONT, fontdata.toString());
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
        // ignore
    }

    return null;
}

From source file:fede.workspace.eclipse.java.fields.JDISourceViewer.java

License:Apache License

/**
* Updates the viewer's font to match the preferences.
*///from  w  w w .  jav  a 2s  .  c om
private void updateViewerFont() {
    IPreferenceStore store = getPreferenceStore();
    if (store != null) {
        FontData data = null;
        if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
            data = PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
        } else {
            data = PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
        }
        if (data != null) {
            Font font = new Font(getTextWidget().getDisplay(), data);
            applyFont(font);
            if (getFont() != null) {
                getFont().dispose();
            }
            setFont(font);
            return;
        }
    }
    // if all the preferences failed
    applyFont(JFaceResources.getTextFont());
}

From source file:fede.workspace.eclipse.java.fields.JDISourceViewer.java

License:Apache License

/**
* Property change.//w  w w . j a  va 2  s. c o  m
* 
* @param event
*            the event
* 
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
    IContentAssistant assistant = getContentAssistant();
    if (assistant instanceof ContentAssistant) {
        JDIContentAssistPreference.changeConfiguration((ContentAssistant) assistant, event);
    }
    String property = event.getProperty();

    if (JFaceResources.TEXT_FONT.equals(property)) {
        updateViewerFont();
    }
    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)) {
        updateViewerColors();
    }
    if (affectsTextPresentation(event)) {
        invalidateTextPresentation();
    }
}

From source file:fontresize.FontSizeController.java

License:Apache License

/**
 * Tries to increase or decrease the general font size in
 * the Eclipse workspace view.//w ww  . j  a v  a2  s.c o m
 * 
 * @param shell SWT shell to display an error message or 
 * <code>null</code> to print the error message to the stdout.
 * @param step Amount of points to change the font size. To
 * decrease the font size negative numbers are used.
 */
public synchronized void crease(Shell shell, int step) {
    try {

        // Get current text font settings
        String[] font = store.getString(JFaceResources.TEXT_FONT).split("\\|");
        StringBuffer buf = new StringBuffer();

        // Go through font settings and replace the font size
        // (a default font string looks like: '1|Monaco|9.0|0|COCOA|1|;')
        for (int i = 0; i < font.length; i++)
            if (i == 2)
                buf.append(String.valueOf(Float.parseFloat(font[i]) + step) + "|");
            else
                buf.append(font[i] + (i < font.length - 1 ? "|" : ""));

        // Store back changed settings
        store.setValue(JFaceResources.TEXT_FONT, buf.toString());

    } catch (Exception e) {
        if (shell != null)
            MessageDialog.openError(shell, "Error", "The font size could not be changed: " + e);
        else
            System.out.println("!ERROR (FontResize) " + e);
    }
}

From source file:fonts.Adjuster.java

License:Apache License

public Adjuster() {
    String font = STORE.getString(JFaceResources.TEXT_FONT);
    split = font.split("\\|");
}

From source file:fonts.Adjuster.java

License:Apache License

public void persist() {
    StringBuilder builder = new StringBuilder(split[0]);
    for (int i = 1; i < split.length; ++i) {
        builder.append('|').append(split[i]);
    }/*from   w w w  .  jav  a  2s .  com*/
    STORE.setValue(JFaceResources.TEXT_FONT, builder.toString());
}

From source file:fonts.FontsControler.java

License:Apache License

public synchronized void increase() {

    String font = store.getString(JFaceResources.TEXT_FONT);
    String[] split = font.split("\\|");
    float fontSize = Float.parseFloat(split[2]) + 1;

    split[2] = Float.toString(fontSize);
    StringBuilder builder = new StringBuilder(split[0]);
    for (int i = 1; i < split.length; ++i) {
        builder.append('|').append(split[i]);
    }//from  w  w w .  j  a va 2  s. co  m
    store.setValue(JFaceResources.TEXT_FONT, builder.toString());

}

From source file:fonts.FontsControler.java

License:Apache License

public synchronized void decrease() {
    String font = store.getString(JFaceResources.TEXT_FONT);
    String[] split = font.split("\\|");
    float fontSize = Float.parseFloat(split[2]) - 1;
    if (fontSize <= 0)
        fontSize = 1;/*from w  w  w .  jav a 2 s. co m*/

    split[2] = Float.toString(fontSize);
    StringBuilder builder = new StringBuilder(split[0]);
    for (int i = 1; i < split.length; ++i) {
        builder.append('|').append(split[i]);
    }
    store.setValue(JFaceResources.TEXT_FONT, builder.toString());
}

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);//  w  w  w  . ja  v a 2  s .  co  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;
}