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

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

Introduction

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

Prototype

public static Font getDefaultFont() 

Source Link

Document

Returns JFace's standard font.

Usage

From source file:com.bdaum.zoom.ui.internal.widgets.LabelConfigGroup.java

License:Open Source License

public void setSelection(int index, String template, int fontSize) {
    showGroup.setSelection(index - offset);
    if (index == Constants.CUSTOM_LABEL && template != null)
        templateGroup.setText(template);
    if (fontSize == 0)
        fontSize = JFaceResources.getDefaultFont().getFontData()[0].getHeight();
    fontField.setSelection(fontSize);/*from   ww w  .  ja  v a2  s .  c o m*/
    updateControls();
}

From source file:com.bdaum.zoom.ui.paint.DrawExample.java

License:Open Source License

protected void init() {
    numPaletteRows = 1;//  w  ww .  j  a va2 s.  c  om
    numPaletteCols = 16;
    Display display = mainComposite.getDisplay();
    paintColorWhite = new Color(display, 255, 255, 255);
    paintColorBlack = new Color(display, 0, 0, 0);
    paintDefaultFont = JFaceResources.getDefaultFont();
    paintColors = new Color[numPaletteCols * numPaletteRows];
    paintColors[0] = paintColorBlack;
    paintColors[1] = paintColorWhite;
    paintColors[2] = new Color(display, 255, 0, 255);
    paintColors[3] = new Color(display, 255, 0, 144);
    paintColors[4] = new Color(display, 255, 0, 0);
    paintColors[5] = new Color(display, 255, 127, 0);
    paintColors[6] = new Color(display, 255, 185, 0);
    paintColors[7] = new Color(display, 255, 255, 0);
    paintColors[8] = new Color(display, 160, 255, 0);
    paintColors[9] = new Color(display, 82, 255, 0);
    paintColors[10] = new Color(display, 0, 185, 82);
    paintColors[11] = new Color(display, 0, 165, 165);
    paintColors[12] = new Color(display, 0, 127, 255);
    paintColors[13] = new Color(display, 0, 0, 255);
    paintColors[14] = new Color(display, 82, 0, 255);
    paintColors[15] = new Color(display, 165, 0, 255);
    toolSettings = new ToolSettings();
    toolSettings.commonForegroundColor = paintColorBlack;
    toolSettings.commonBackgroundColor = paintColorWhite;
    toolSettings.commonFont = paintDefaultFont;
    undoContext = new UndoContext() {
        @Override
        public String getLabel() {
            return PaintExample.getResourceString("DrawExample.UndoContext.label"); //$NON-NLS-1$
        }
    };
}

From source file:com.bdaum.zoom.ui.paint.PaintExample.java

License:Open Source License

/**
 * Initialize colors, fonts, and tool settings.
 *///from  w ww. j  a va2s.co m
protected void init() {
    numPaletteRows = 3;
    numPaletteCols = 48;

    Display display = mainComposite.getDisplay();

    paintColorWhite = new Color(display, 255, 255, 255);
    paintColorBlack = new Color(display, 0, 0, 0);

    paintDefaultFont = JFaceResources.getDefaultFont();

    paintColors = new Color[numPaletteCols * numPaletteRows];
    paintColors[0] = paintColorBlack;
    paintColors[1] = paintColorWhite;
    for (int i = 2; i < paintColors.length; i++) {
        paintColors[i] = new Color(display, ((i * 7) % 255), ((i * 23) % 255), ((i * 47) % 255));
    }

    toolSettings = new ToolSettings();
    toolSettings.commonForegroundColor = paintColorBlack;
    toolSettings.commonBackgroundColor = paintColorWhite;
    toolSettings.commonFont = paintDefaultFont;
    undoContext = new UndoContext() {
        @Override
        public String getLabel() {
            return PaintExample.getResourceString("PaintExample.UndoContext.label"); //$NON-NLS-1$
        }
    };
}

From source file:com.cisco.yangide.ext.model.editor.preferences.ModelEditorPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite pageArea = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).spacing(LayoutConstants.getSpacing().x, 3).applyTo(pageArea);

    Label label = new Label(pageArea, SWT.NONE);
    label.setText("Diagram Editor Font: ");
    GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).span(1, 3).applyTo(label);

    preview = new Label(pageArea, SWT.BORDER | SWT.SHADOW_NONE);
    GridDataFactory.fillDefaults().grab(true, false).span(1, 2).applyTo(preview);

    Button editBtn = new Button(pageArea, SWT.PUSH);
    GridDataFactory.fillDefaults().hint(100, SWT.DEFAULT).applyTo(editBtn);
    editBtn.setText("Edit...");
    editBtn.addSelectionListener(new SelectionAdapter() {
        @Override/*from   w w w  .ja va2 s. com*/
        public void widgetSelected(SelectionEvent e) {
            FontDialog dialog = new FontDialog(getShell());
            dialog.setFontList(fontData);
            FontData fd = dialog.open();
            if (fd != null) {
                fontData = new FontData[] { fd };
                update();
            }
        }
    });
    Button systemBtn = new Button(pageArea, SWT.PUSH);
    GridDataFactory.fillDefaults().hint(100, SWT.DEFAULT).applyTo(systemBtn);
    systemBtn.setText("Use System Font");
    systemBtn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            fontData = JFaceResources.getDefaultFont().getFontData();
            update();
        }
    });

    Composite note = createNoteComposite(JFaceResources.getDialogFont(), pageArea, "Note: ",
            "Changing the font does not update open editors.");
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(note);

    Dialog.applyDialogFont(pageArea);
    load();
    return pageArea;
}

From source file:com.cisco.yangide.ext.model.editor.preferences.ModelEditorPreferencePage.java

License:Open Source License

private void load() {
    fontData = toFontData(getPreferenceStore().getString(ModelEditorPreferences.DIAGRAM_EDITOR_FONT));
    if (fontData == null) {
        fontData = JFaceResources.getDefaultFont().getFontData();
    }/*  ww  w . j ava 2 s. c  o m*/
    update();
}

From source file:com.cisco.yangide.ext.model.editor.preferences.ModelEditorPreferencePage.java

License:Open Source License

@Override
protected void performDefaults() {
    fontData = toFontData(getPreferenceStore().getDefaultString(ModelEditorPreferences.DIAGRAM_EDITOR_FONT));
    if (fontData == null) {
        fontData = JFaceResources.getDefaultFont().getFontData();
    }/*from ww  w . jav  a  2s. c o m*/
    update();
    super.performDefaults();
}

From source file:com.cisco.yangide.ext.model.editor.util.StyleUtil.java

License:Open Source License

private static FontData getDefaultFont() {
    FontData fontData = null;/*from  w  ww .  j a v  a  2s.  c  o m*/
    try {
        fontData = StringConverter.asFontData(Activator.getDefault().getPreferenceStore()
                .getString(ModelEditorPreferences.DIAGRAM_EDITOR_FONT));
    } catch (DataFormatException e) {
        // ignore incorrect format
    }
    if (fontData == null) {
        FontData fd = JFaceResources.getDefaultFont().getFontData()[0];
        // workaround for issue with MacOS fonts
        if ("Helvetica Neue Deskinterface".equals(fd.getName()) && fd.getHeight() == 11) {
            fd.setName("Helvetica");
        }
        return fd;
    }
    return fontData;
}

From source file:com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposalPopup.java

License:Open Source License

/**
 * Creates the proposal selector.//w w w. j  a v  a2 s  .  c o  m
 */
private void createProposalSelector() {
    if (Helper.okToUse(fProposalShell))
        return;

    Control control = fContentAssistSubjectControlAdapter.getControl();
    fProposalShell = new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE);
    fProposalShell.setFont(JFaceResources.getDefaultFont());
    if (USE_VIRTUAL) {
        fProposalTable = new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL);

        Listener listener = new Listener() {
            public void handleEvent(Event event) {
                handleSetData(event);
            }
        };
        fProposalTable.addListener(SWT.SetData, listener);
    } else {
        fProposalTable = new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
    }

    fIsColoredLabelsSupportEnabled = fContentAssistant.isColoredLabelsSupportEnabled();
    if (fIsColoredLabelsSupportEnabled)
        TableOwnerDrawSupport.install(fProposalTable);

    fProposalTable.setLocation(0, 0);
    if (fAdditionalInfoController != null)
        fAdditionalInfoController.setSizeConstraints(50, 10, true, true);

    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 1;
    fProposalShell.setLayout(layout);

    if (fContentAssistant.isStatusLineVisible()) {
        createMessageText();
    }

    GridData data = new GridData(GridData.FILL_BOTH);

    Point size = fContentAssistant.restoreCompletionProposalPopupSize();
    if (size != null) {
        fProposalTable.setLayoutData(data);
        fProposalShell.setSize(size);
    } else {
        int height = fProposalTable.getItemHeight() * 10;
        // use golden ratio as default aspect ratio
        final double aspectRatio = (1 + Math.sqrt(5)) / 2;
        int width = (int) (height * aspectRatio);
        Rectangle trim = fProposalTable.computeTrim(0, 0, width, height);
        data.heightHint = trim.height;
        data.widthHint = trim.width;
        fProposalTable.setLayoutData(data);
        fProposalShell.pack();
    }
    fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant.LayoutManager.LAYOUT_PROPOSAL_SELECTOR,
            fContentAssistant.getSelectionOffset());

    fProposalShell.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            if (fAdditionalInfoController != null) {
                // reset the cached resize constraints
                fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
                fAdditionalInfoController.hideInformationControl();
                fAdditionalInfoController.handleTableSelectionChanged();
            }

            fSize = fProposalShell.getSize();
        }
    });

    fProposalShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_GRAY));

    Color c = getBackgroundColor(control);
    fProposalTable.setBackground(c);

    c = getForegroundColor(control);
    fProposalTable.setForeground(c);

    fProposalTable.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            insertSelectedProposalWithMask(e.stateMask);
        }
    });

    fProposalTable.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            insertSelectedProposalWithMask(e.stateMask);
        }
    });

    fPopupCloser.install(fContentAssistant, fProposalTable, fAdditionalInfoController);

    fProposalShell.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            unregister(); // but don't dispose the shell, since we're being called from its disposal event!
        }
    });

    fProposalTable.setHeaderVisible(false);

    addCommandSupport(fProposalTable);
}

From source file:com.foglyn.ui.FoglynSingleSelectionAttributeEditor.java

License:Open Source License

@Override
public void createControl(Composite parent, FormToolkit toolkit) {
    if (isReadOnly()) {
        Text text = new Text(parent, SWT.FLAT | SWT.READ_ONLY);
        text.setFont(JFaceResources.getDefaultFont());
        toolkit.adapt(text, false, false);
        text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
        String label = getValueLabel();
        if ("".equals(label)) { //$NON-NLS-1$
            // if set to the empty string the label will use 64px on GTK 
            text.setText(" "); //$NON-NLS-1$
        } else {//  w  w w .  j a va 2s . c  o m
            text.setText(label);
        }
        setControl(text);
    } else {
        combo = new Combo(parent, SWT.FLAT | SWT.READ_ONLY);
        toolkit.adapt(combo, false, false);
        combo.setFont(JFaceResources.getDefaultFont());
        combo.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);

        Map<String, String> labelByValue = getAttributeMapper().getOptions(getTaskAttribute());
        if (labelByValue != null) {
            values = labelByValue.keySet().toArray(new String[0]);
            for (String value : values) {
                combo.add(labelByValue.get(value));
            }
        }

        combo.setVisibleItemCount(Constants.NUMBER_OF_ENTRIES_IN_COMBOBOX);

        select(getValue(), getValueLabel());

        if (values != null) {
            combo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent event) {
                    int index = combo.getSelectionIndex();
                    if (index > -1) {
                        Assert.isNotNull(values);
                        Assert.isLegal(index >= 0 && index <= values.length - 1);
                        setValue(values[index]);
                    }
                }
            });
        }

        setControl(combo);
    }
}

From source file:com.foglyn.ui.FoglynSingleSelectionWithDependenciesAttributeEditor.java

License:Open Source License

@Override
public void createControl(Composite parent, FormToolkit toolkit) {
    combo = new Combo(parent, SWT.FLAT | SWT.READ_ONLY);
    toolkit.adapt(combo, false, false);//  w  w  w .  j a v  a 2s.c  om
    combo.setFont(JFaceResources.getDefaultFont());
    combo.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
    combo.setVisibleItemCount(Constants.NUMBER_OF_ENTRIES_IN_COMBOBOX);

    combo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            int index = combo.getSelectionIndex();
            if (index > -1) {
                Assert.isNotNull(options);
                setSelectedOption(options.get(index));
            }
        }
    });

    setValues();

    setControl(combo);
}