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

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

Introduction

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

Prototype

public static Font getDialogFont() 

Source Link

Document

Returns the JFace's dialog font.

Usage

From source file:org.eclipse.recommenders.internal.apidocs.rcp.ApidocsView.java

License:Open Source License

private void createContentArea() {
    scrollable = new ScrolledComposite(sash, SWT.H_SCROLL | SWT.V_SCROLL);
    scrollable.getVerticalBar().setIncrement(20);
    scrollable.setExpandHorizontal(true);
    scrollable.setExpandVertical(true);/*from w  w w. j  a  v a2 s  . co  m*/
    content = new Composite(scrollable, SWT.NONE);
    content.setLayout(new GridLayout());
    content.setFont(JFaceResources.getDialogFont());
    ApidocsViewUtils.setInfoBackgroundColor(content);

    scrollable.setContent(content);
}

From source file:org.eclipse.recommenders.internal.apidocs.rcp.ApidocsViewUtils.java

License:Open Source License

public static Link createMethodLink(final Composite parent, final IMethod method, final EventBus workspaceBus) {
    final String text = "<a>" //$NON-NLS-1$
            + JavaElementLabels.getElementLabel(method,
                    JavaElementLabels.M_APP_RETURNTYPE | JavaElementLabels.M_PARAMETER_TYPES)
            + "</a>"; //$NON-NLS-1$
    final String tooltip = JavaElementLabels.getElementLabel(method, JavaElementLabels.DEFAULT_QUALIFIED);

    final Link link = new Link(parent, SWT.NONE);
    link.setText(text);//from  w w  w  . j  av  a2 s.  c  o  m
    link.setBackground(ApidocsViewUtils.createColor(SWT.COLOR_INFO_BACKGROUND));
    link.setToolTipText(tooltip);
    link.setFont(JFaceResources.getDialogFont());
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            final JavaElementSelectionEvent event = new JavaElementSelectionEvent(method, METHOD_DECLARATION);
            workspaceBus.post(event);
        }
    });
    return link;
}

From source file:org.eclipse.recommenders.internal.apidocs.rcp.ApidocsViewUtils.java

License:Open Source License

public static Link createMethodLink(final Composite parent, final IMethodName method,
        final JavaElementResolver resolver, final EventBus workspaceBus) {
    final String text = "<a>" + Names.vm2srcSimpleMethod(method) + "</a>"; //$NON-NLS$ //$NON-NLS-1$ //$NON-NLS-2$
    final String tooltip = Names.vm2srcQualifiedMethod(method);

    final Link link = new Link(parent, SWT.NONE);
    link.setText(text);/*  w w  w .j  a  v  a2s  . com*/
    link.setBackground(ApidocsViewUtils.createColor(SWT.COLOR_INFO_BACKGROUND));
    link.setFont(JFaceResources.getDialogFont());
    link.setToolTipText(tooltip);
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            final Optional<IMethod> opt = resolver.toJdtMethod(method);
            if (opt.isPresent()) {
                final JavaElementSelectionEvent event = new JavaElementSelectionEvent(opt.get(),
                        METHOD_DECLARATION);
                workspaceBus.post(event);
            } else {
                link.setEnabled(false);
            }
        }
    });
    return link;
}

From source file:org.eclipse.sirius.common.ui.tools.api.dialog.AbstractFolderSelectionDialog.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w  ww . ja  va 2s.  c om*/
 * 
 * @see org.eclipse.ui.dialogs.ElementTreeSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 */
@Override
protected Control createDialogArea(final Composite parent) {
    final Composite result = (Composite) super.createDialogArea(parent);

    getTreeViewer().addSelectionChangedListener(this);
    getTreeViewer().expandToLevel(2);
    fNewFolderButton = new Button(result, SWT.PUSH);
    fNewFolderButton.setText("New Folder");
    fNewFolderButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent event) {
            newFolderButtonPressed();
        }
    });
    fNewFolderButton.setFont(parent.getFont());
    fNewFolderButton.setLayoutData(new GridData());

    // Modified by Obeo (copy/paste
    // org.eclipse.pde.internal.ui.util.SWTUtil.setButtonDimensionHint(Button)
    Dialog.applyDialogFont(fNewFolderButton);
    final Object gd = fNewFolderButton.getLayoutData();
    if (gd instanceof GridData) {
        if (fNewFolderButton.getFont().equals(JFaceResources.getDefaultFont())) {
            fNewFolderButton.setFont(JFaceResources.getDialogFont());
        }
        final GC gc = new GC(fNewFolderButton);
        gc.setFont(fNewFolderButton.getFont());
        final FontMetrics fFontMetrics = gc.getFontMetrics();
        gc.dispose();
        final int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH);
        ((GridData) gd).widthHint = Math.max(widthHint,
                fNewFolderButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    }

    Dialog.applyDialogFont(result);
    return result;
}

From source file:org.eclipse.sirius.ui.tools.api.wizards.page.ViewpointsSelectionWizardPage.java

License:Open Source License

private StringBuilder appendCss(StringBuilder content) {
    Font currentFont = JFaceResources.getDialogFont();
    FontData data = currentFont.getFontData()[0];
    String fontName = data.getName();
    int fontHeight = data.getHeight() + 3;
    content.append("<style type=\"text/css\">");
    content.append("body{font-family:" + fontName + ",Arial, sans-serif;}");
    content.append("body{font-size:" + fontHeight + "px;}");
    content.append("</style>");
    return content;
}

From source file:org.eclipse.tcf.te.ui.forms.CustomFormToolkit.java

License:Open Source License

/**
 * Returns the number of pixels corresponding to the height of the given
 * number of characters.//from w w w.ja va 2s.com
 * <p>
 * This methods uses the static {@link Dialog#convertHeightInCharsToPixels(org.eclipse.swt.graphics.FontMetrics, int)}
 * method for calculation.
 * <p>
 * @param chars The number of characters
 * @return The corresponding height in pixels
 */
protected int convertHeightInCharsToPixels(Control control, int chars) {
    int height = 0;
    if (control != null && !control.isDisposed()) {
        GC gc = new GC(control);
        gc.setFont(JFaceResources.getDialogFont());
        height = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), chars);
        gc.dispose();
    }

    return height;
}

From source file:org.eclipse.tcf.te.ui.forms.parts.AbstractPartWithButtons.java

License:Open Source License

/**
 * Create the buttons panel./* w  w  w . j a  v a  2  s  .c  o m*/
 *
 * @param parent The parent composite. Must not be <code>null</code>.
 * @param toolkit The form toolkit or <code>null</code>.
 *
 * @return The buttons panel composite or <code>null</code>.
 */
protected Composite createButtonsPanel(Composite parent, FormToolkit toolkit) {
    if (labels == null || labels.size() == 0) {
        return null;
    }

    buttons = new Button[labels.size()];

    Composite panel = createComposite(parent, toolkit);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    panel.setLayout(layout);
    GridData layoutData = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
    panel.setLayoutData(layoutData);
    panel.setBackground(parent.getBackground());

    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            AbstractPartWithButtons.this.onButtonSelected((Button) e.widget);
        }
    };

    for (int i = 0; i < labels.size(); i++) {
        if (labels.get(i) != null) {
            Button button = toolkit != null ? toolkit.createButton(panel, null, SWT.PUSH)
                    : new Button(panel, SWT.PUSH);
            Assert.isNotNull(button);

            button.setFont(JFaceResources.getDialogFont());
            button.setText(labels.get(i));
            button.setData(Integer.valueOf(i));
            button.setBackground(panel.getBackground());
            button.addSelectionListener(listener);

            onButtonCreated(button);

            layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            layoutData.widthHint = Math.max(
                    new PixelConverter(button).convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
                    button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
            button.setLayoutData(layoutData);

            buttons[i] = button;
        } else {
            createEmptySpace(panel, 1, toolkit);
        }
    }

    return panel;
}

From source file:org.eclipse.tcf.te.ui.swt.SWTControlUtil.java

License:Open Source License

/**
 * Returns the number of pixels corresponding to the height of the given
 * number of characters./*w  w w .  j  ava2 s  . co m*/
 * <p>
 * This methods uses the static {@link Dialog#convertHeightInCharsToPixels(org.eclipse.swt.graphics.FontMetrics, int)}
 * method for calculation.
 * <p>
 * @param chars The number of characters
 * @return The corresponding height in pixels
 */
public static int convertHeightInCharsToPixels(Control control, int chars) {
    int height = 0;
    if (control != null && !control.isDisposed()) {
        GC gc = new GC(control);
        gc.setFont(JFaceResources.getDialogFont());
        height = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), chars);
        gc.dispose();
    }

    return height;
}

From source file:org.eclipse.tcf.te.ui.swt.SWTControlUtil.java

License:Open Source License

/**
 * Returns the number of pixels corresponding to the width of the given
 * number of characters.//from w  ww .java2  s . c o m
 * <p>
 * This methods uses the static {@link Dialog#convertWidthInCharsToPixels(org.eclipse.swt.graphics.FontMetrics, int)}
 * method for calculation.
 * <p>
 * @param chars The number of characters
 * @return The corresponding width in pixels
 */
public static int convertWidthInCharsToPixels(Control control, int chars) {
    int width = 0;
    if (control != null && !control.isDisposed()) {
        GC gc = new GC(control);
        gc.setFont(JFaceResources.getDialogFont());
        width = Dialog.convertWidthInCharsToPixels(gc.getFontMetrics(), chars);
        gc.dispose();
    }

    return width;
}

From source file:org.eclipse.team.internal.ui.dialogs.PreferencePageContainerDialog.java

License:Open Source License

/**
 * @see IPreferencePageContainer#updateMessage()
 *///from  w  w  w .  java2s  .c om
public void updateMessage() {
    if (currentPage != null) {
        String pageMessage = currentPage.getMessage();
        String pageErrorMessage = currentPage.getErrorMessage();

        // Adjust the font
        if (pageMessage == null && pageErrorMessage == null)
            fMessageLabel.setFont(JFaceResources.getBannerFont());
        else
            fMessageLabel.setFont(JFaceResources.getDialogFont());

        // Set the message and error message   
        if (pageMessage == null) {
            if (isSinglePage()) {
                setMessage(TeamUIMessages.PreferencePageContainerDialog_6);
            } else {
                //remove mnemonic see bug 75886
                String title = currentPage.getTitle();
                title = title.replaceAll("&", "");//$NON-NLS-1$ //$NON-NLS-2$
                setMessage(title);
            }
        } else {
            setMessage(pageMessage);
        }
        setErrorMessage(pageErrorMessage);
    }
}