Example usage for org.eclipse.jface.resource FontDescriptor createFont

List of usage examples for org.eclipse.jface.resource FontDescriptor createFont

Introduction

In this page you can find the example usage for org.eclipse.jface.resource FontDescriptor createFont.

Prototype

public abstract Font createFont(Device device) throws DeviceResourceException;

Source Link

Document

Creates the Font described by this descriptor.

Usage

From source file:at.medevit.elexis.impfplan.ui.VaccinationCompositePaintListener.java

License:Open Source License

public VaccinationCompositePaintListener() {
    Display disp = Display.getCurrent();
    defaultFont = UiDesk.getFont(Preferences.USR_DEFAULTFONT);
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(defaultFont).setStyle(SWT.BOLD);
    boldFont = boldDescriptor.createFont(disp);
    headerFont = new Font(disp, "Helvetica", 16, SWT.BOLD);

    distanceBetweenDiseases = (int) (distanceBetweenDiseases * getScaleFactor());

    fontHeightDefaultFont = (int) ((defaultFont.getFontData()[0].getHeight() + 5) * getScaleFactor());
    fontHeightBoldFont = (int) ((boldFont.getFontData()[0].getHeight() + 5) * getScaleFactor());

    entryHeight = (int) ((fontHeightBoldFont + 4) * getScaleFactor());
    defaultEntryHeight = entryHeight;//w  w w.  java  2 s  .  c o m

    naviVacMap = new TreeMap<Integer, Vaccination>();
    selectedVacc = null;
    showSide = CoreHub.userCfg.get(PreferencePage.VAC_SHOW_SIDE, false);
}

From source file:ch.uzh.ifi.seal.permo.lib.ui.eclipse.Fonts.java

License:Apache License

private static <C extends Control> C setFont(final C control, final FontDescriptor descriptor) {
    control.setFont(descriptor.createFont(Display.getCurrent()));
    return control;
}

From source file:com.arm.cmsis.config.editors.ConfigEditor.java

License:Open Source License

private void buildToolBar(Composite parent) {

    Label imageLabel = new Label(parent, SWT.LEFT);
    imageLabel.setImage(CpPlugInUI.getImage(CpPlugInUI.ICON_DETAILS));

    Label title = new Label(parent, SWT.NONE);
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(title.getFont()).setStyle(SWT.BOLD)
            .increaseHeight(1);/*w w w  . j  av  a 2  s  .com*/
    Font boldFont = boldDescriptor.createFont(title.getDisplay());
    title.setFont(boldFont);
    title.setText(Messages.ConfigEditor_SecondPageText);

    ManagedToolBar toolbar = new ManagedToolBar(parent, SWT.FLAT | SWT.RIGHT_TO_LEFT);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.CONFIG_WIZARD);

    Action help = new Action(Messages.ConfigEditor_Help, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            parent.notifyListeners(SWT.Help, new Event());
        }
    };
    help.setToolTipText(Messages.ConfigEditor_HelpForConfigWizard);
    help.setImageDescriptor(CpPlugInUI.getImageDescriptor(CpPlugInUI.ICON_HELP));
    toolbar.addAction(help, false);

    Action collapseAll = new Action(Messages.ConfigEditor_CollapseAll, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            fViewer.collapseAll();
        }
    };
    collapseAll.setToolTipText(Messages.ConfigEditor_CollapseAllItems);
    collapseAll.setImageDescriptor(CpPlugInUI.getImageDescriptor(CpPlugInUI.ICON_COLLAPSE_ALL));
    toolbar.addAction(collapseAll, false);

    Action expandAll = new Action(Messages.ConfigEditor_ExpandAll, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            fViewer.expandAll();
        }
    };
    expandAll.setToolTipText(Messages.ConfigEditor_ExpandAllItems);
    expandAll.setImageDescriptor(CpPlugInUI.getImageDescriptor(CpPlugInUI.ICON_EXPAND_ALL));
    toolbar.addAction(expandAll, false);
}

From source file:com.arm.cmsis.pack.installer.jobs.LicenseDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    GridData layoutData = new GridData();
    layoutData.widthHint = 510;/*from  w  ww  . j  a va2s  .  c  o  m*/
    layoutData.verticalAlignment = SWT.FILL;
    layoutData.horizontalAlignment = SWT.FILL;
    layoutData.grabExcessHorizontalSpace = true;
    composite.setLayoutData(layoutData);

    Label licenseAgreement = new Label(composite, SWT.NONE);
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(licenseAgreement.getFont()).setStyle(SWT.BOLD);
    Font boldFont = boldDescriptor.createFont(licenseAgreement.getDisplay());
    licenseAgreement.setFont(boldFont);
    licenseAgreement
            .setText(Messages.LicenseDialog_LicenseAgreement + System.lineSeparator() + System.lineSeparator());

    Label guidanceText = new Label(composite, SWT.BOLD);
    guidanceText.setText(Messages.LicenseDialog_GuidanceText);

    fText = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    layoutData = new GridData();
    layoutData.widthHint = 500;
    layoutData.heightHint = 250;
    layoutData.verticalAlignment = SWT.FILL;
    layoutData.horizontalAlignment = SWT.FILL;
    layoutData.grabExcessHorizontalSpace = true;
    fText.setLayoutData(layoutData);
    fText.setText(fLicencseText);

    fCheckAgreed = new Button(composite, SWT.CHECK);
    fCheckAgreed.setText(Messages.LicenseDialog_AgreeText);
    fCheckAgreed.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            Button button = ((Button) event.widget);
            okButton.setEnabled(button.getSelection());
        }
    });

    return composite;
}

From source file:com.arm.cmsis.pack.ui.editors.RteEditorPageHeader.java

License:Open Source License

public RteEditorPageHeader(Composite parent, int style) {
    super(parent, style);

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 6;/*from  www  .  ja  v a  2 s. c o m*/
    gridLayout.marginHeight = 1;
    gridLayout.marginTop = 1;
    setLayout(gridLayout);

    imageLabel = new Label(this, SWT.LEFT);

    label = new Label(this, SWT.LEFT);
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(label.getFont()).setStyle(SWT.BOLD)
            .increaseHeight(1);
    Font boldFont = boldDescriptor.createFont(label.getDisplay());
    label.setFont(boldFont);

    gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridLayout.marginHeight = 0;

    // add toolbars
    ManagedToolBar toolbar = new ManagedToolBar(this, SWT.FLAT | SWT.RIGHT); //|SWT.RIGHT_TO_LEFT);
    toolBars.put(SWT.LEFT, toolbar);
    toolbar = new ManagedToolBar(this, SWT.FLAT | SWT.RIGHT_TO_LEFT);
    toolBars.put(SWT.RIGHT, toolbar);

}

From source file:com.arm.cmsis.pack.ui.widgets.RteDeviceInfoWidget.java

License:Open Source License

/**
 * Create the composite./*from www .  ja  va2 s.c o  m*/
 * @param parent
 * @param style
 */
public RteDeviceInfoWidget(Composite parent) {
    super(parent, SWT.BORDER);

    GridLayout gridLayout = new GridLayout(6, false);
    gridLayout.horizontalSpacing = 8;
    setLayout(gridLayout);

    Label lblDeviceLabel = new Label(this, SWT.NONE);
    lblDeviceLabel.setText(CpStringsUI.RteDeviceSelectorWidget_DeviceLabel);

    lblDevice = new Label(this, SWT.NONE);
    lblDevice.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(lblDevice.getFont()).setStyle(SWT.BOLD)
            .increaseHeight(1);
    Font boldFont = boldDescriptor.createFont(lblDevice.getDisplay());
    lblDevice.setFont(boldFont);

    btnSelect = new Button(this, SWT.NONE);
    btnSelect.setText(CpStringsUI.RteDeviceInfoWidget_btnSelect_text);
    new Label(this, SWT.NONE);
    new Label(this, SWT.NONE);
    new Label(this, SWT.NONE);

    lblFamilyLabel = new Label(this, SWT.NONE);
    lblFamilyLabel.setText(CpStringsUI.RteDeviceInfoWidget_lblFamily_text);

    lblFamily = new Label(this, SWT.NONE);
    lblFamily.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblCpuLabel = new Label(this, SWT.NONE);
    lblCpuLabel.setText(CpStringsUI.RteDeviceSelectorWidget_CPULabel);
    lblCpuLabel.setBounds(0, 0, 36, 13);

    lblCpu = new Label(this, SWT.NONE);
    lblCpu.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblCpu.setBounds(0, 0, 32, 13);
    new Label(this, SWT.NONE);

    lblSubfamilyLabel = new Label(this, SWT.NONE);
    lblSubfamilyLabel.setText(CpStringsUI.RteDeviceInfoWidget_lblSubFamily_text);

    lblSubfamily = new Label(this, SWT.NONE);
    lblSubfamily.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblClocklabel = new Label(this, SWT.NONE);
    lblClocklabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblClocklabel_text);

    lblClock = new Label(this, SWT.NONE);
    lblClock.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblVendorLabel = new Label(this, SWT.NONE);
    lblVendorLabel.setText(CpStringsUI.RteDeviceSelectorWidget_VendorLabel);

    lblVendor = new Label(this, SWT.NONE);
    lblVendor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblMemoryLabel = new Label(this, SWT.NONE);
    lblMemoryLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblMemory);

    lblMemory = new Label(this, SWT.NONE);
    lblMemory.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblPackLabel = new Label(this, SWT.NONE);
    lblPackLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblPack_text);

    lblPack = new Label(this, SWT.NONE);
    lblPack.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblFpuLabel = new Label(this, SWT.NONE);
    lblFpuLabel.setText(CpStringsUI.RteDeviceSelectorWidget_FPULabel);
    lblFpuLabel.setBounds(0, 0, 38, 13);

    lblFpu = new Label(this, SWT.NONE);
    lblFpu.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblUrlLabel = new Label(this, SWT.NONE);
    lblUrlLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblUrl);

    linkUrl = new Link(this, SWT.NONE);
    linkUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    linkUrl.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            OpenURL.open(url, getShell());
        }
    });
    new Label(this, SWT.NONE);

    Label lblEndianLabel = new Label(this, SWT.NONE);
    lblEndianLabel.setText(CpStringsUI.RteDeviceSelectorWidget_Endian);
    lblEndianLabel.setBounds(0, 0, 37, 13);

    lblEndian = new Label(this, SWT.NONE);
    lblEndian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    new Label(this, SWT.NONE);

    Label lblBooks = new Label(this, SWT.NONE);
    lblBooks.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    lblBooks.setText(CpStringsUI.RteDeviceInfoWidget_lblBooks_text);
    new Label(this, SWT.NONE);

    lblDescription = new Label(this, SWT.NONE);
    lblDescription.setText(CpStringsUI.RteDeviceInfoWidget_lblDescription_text);
    new Label(this, SWT.NONE);
    new Label(this, SWT.NONE);

    tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
    table = tableViewer.getTable();
    table.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1));

    fBookColumnAdvisor = new RteBookColumnAdvisor(tableViewer);
    ColumnViewerToolTipSupport.enableFor(tableViewer);

    tableViewer.setContentProvider(new RteBookContentProvider());
    //   tableViewer.setLabelProvider(new RteBookLabelProvider());
    tableViewer.setLabelProvider(new AdvisedCellLabelProvider(fBookColumnAdvisor, 0));

    text = new Text(this, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    GridData gd_text = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 3);
    gd_text.widthHint = 240;
    gd_text.minimumWidth = 200;
    text.setLayoutData(gd_text);
    text.setEditable(false);

    lblBoards = new Label(this, SWT.NONE);
    lblBoards.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    lblBoards.setText(CpStringsUI.RteDeviceInfoWidget_lblBoards_text);
    new Label(this, SWT.NONE);

    treeViewer = new TreeViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
    tree = treeViewer.getTree();
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));

    treeViewer.setContentProvider(new RteBoardContentProvider());
    //      treeViewer.setLabelProvider(new RteBoardLabelProvider());

    fBoardColumnAdvisor = new RteBookColumnAdvisor(treeViewer);
    ColumnViewerToolTipSupport.enableFor(treeViewer);
    treeViewer.setLabelProvider(new AdvisedCellLabelProvider(fBoardColumnAdvisor, 0));

}

From source file:com.b3dgs.lionengine.editor.toolbar.FormulaItem.java

License:Open Source License

/**
 * Construct the item./*from w  ww . ja v a 2s .c o  m*/
 * 
 * @param parent The parent reference.
 */
@PostConstruct
public void create(Composite parent) {
    final FontDescriptor boldDescriptor = FontDescriptor.createFrom(parent.getFont()).setHeight(TEXT_HEIGHT);
    final Font font = boldDescriptor.createFont(parent.getDisplay());

    final GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    parent.setLayout(layout);

    final Label label = new Label(parent, SWT.NONE);
    label.setFont(font);
    label.setText(Messages.Formula);

    combo = new Combo(parent, SWT.SINGLE | SWT.READ_ONLY);
    combo.setFont(font);
    combo.setLayoutData(new GridData(COMBO_MIN_WIDTH, TEXT_HEIGHT));
    UtilCombo.setAction(combo, () -> combo.setData(values.get(combo.getText())));
    values.clear();
    values.put("Line", LINE);
    values.put("Slope", SLOPE);

    final String[] formulas = values.keySet().toArray(new String[values.size()]);
    Arrays.sort(formulas);
    combo.setItems(formulas);
}

From source file:com.b3dgs.lionengine.editor.world.view.ZoomItem.java

License:Open Source License

/**
 * Construct the item.//from w w  w.j  a  v a2 s.co  m
 * 
 * @param parent The parent reference.
 */
@PostConstruct
public void create(Composite parent) {
    final FontDescriptor boldDescriptor = FontDescriptor.createFrom(parent.getFont()).setHeight(TEXT_HEIGHT);
    final Font font = boldDescriptor.createFont(parent.getDisplay());

    final GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    parent.setLayout(layout);

    zoomValue = new Text(parent, SWT.SINGLE | SWT.CENTER | SWT.BORDER);
    zoomValue.setFont(font);
    UtilText.addVerify(zoomValue, InputValidator.INTEGER_POSITIVE_STRICT_MATCH);
    zoomValue.setText(String.valueOf(WorldZoomUpdater.ZOOM_DEFAULT));
    zoomValue.addTraverseListener(event -> {
        if (event.detail == SWT.TRAVERSE_RETURN) {
            chooseZoom();
        }
    });
    zoomValue.pack();

    final Label label = new Label(parent, SWT.NONE);
    label.setFont(font);
    label.setText(Constant.PERCENT);
}

From source file:com.eclipsesource.tabris.demos.entrypoints.ButtonControlsDemo.java

License:Open Source License

public void createQuestion(Composite parent) {
    labelQuestion = new Label(parent, SWT.WRAP | SWT.CENTER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(labelQuestion);
    FontDescriptor labelFontDescriptor = FontDescriptor.createFrom(labelQuestion.getFont());
    FontDescriptor bigFontDescriptor = labelFontDescriptor.setStyle(SWT.BOLD).increaseHeight(7);
    labelQuestion.setFont(bigFontDescriptor.createFont(parent.getDisplay()));
    labelQuestion.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
}

From source file:com.google.cloud.tools.eclipse.ui.util.FontUtil.java

License:Apache License

/**
 * Changes the font style of the control to bold unless it already is bold.
 * <p>//from   ww  w .ja  v a 2 s .co m
 * If the font is converted to bold, it will attach a {@link DisposeListener}
 * to the <code>control</code> to dispose the font when it's not needed anymore.
 * <p>
 * <em>If converting fonts to bold is a frequent operation, this method will create
 * several {@link DisposeListener}s that can lead to high resource allocation</em>
 */
public static void convertFontToBold(Control control) {
    for (FontData fontData : control.getFont().getFontData()) {
        if ((fontData.getStyle() & SWT.BOLD) != 0) {
            return;
        }
    }
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(control.getFont()).setStyle(SWT.BOLD);
    final Font boldFont = boldDescriptor.createFont(control.getDisplay());
    control.setFont(boldFont);
    control.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent event) {
            boldFont.dispose();
        }
    });
}