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:melnorme.util.swt.MetricsUtil.java

License:Open Source License

/** Gets FontMetrics for the given control */
protected static FontMetrics getFontMetrics(Control testControl) {
    FontMetrics fontMetrics;/*from ww  w  .  j  a v  a2  s  .c o m*/
    // Compute and store a font metric
    GC gc = new GC(testControl);
    gc.setFont(JFaceResources.getDialogFont());
    fontMetrics = gc.getFontMetrics();
    gc.dispose();
    return fontMetrics;
}

From source file:name.schedenig.eclipse.grepconsole.view.DefaultSizeDialog.java

License:Open Source License

/**
 * Mostly a copy of the same method in Dialog, but with a call to a separate
 * method for providing a default size that is used if no persisted dialog
 * settings are available./*  w  w w.j ava 2s.  co m*/
 * 
 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
 */
@Override
protected Point getInitialSize() {
    Point result = getDefaultSize();

    if ((getDialogBoundsStrategy() & DIALOG_PERSISTSIZE) != 0) {
        IDialogSettings settings = getDialogBoundsSettings();

        if (settings != null) {
            boolean useStoredBounds = true;
            String previousDialogFontData = settings.get(DIALOG_FONT_DATA);

            if (previousDialogFontData != null && previousDialogFontData.length() > 0) {
                FontData[] fontDatas = JFaceResources.getDialogFont().getFontData();

                if (fontDatas.length > 0) {
                    String currentDialogFontData = fontDatas[0].toString();
                    useStoredBounds = currentDialogFontData.equalsIgnoreCase(previousDialogFontData);
                }
            }

            if (useStoredBounds) {
                try {
                    int width = settings.getInt(DIALOG_WIDTH);
                    int height = settings.getInt(DIALOG_HEIGHT);

                    if (width != DIALOG_DEFAULT_BOUNDS) {
                        result.x = width;
                    }

                    if (height != DIALOG_DEFAULT_BOUNDS) {
                        result.y = height;
                    }
                } catch (NumberFormatException e) {
                }
            }
        }
    }

    return result;
}

From source file:name.schedenig.eclipse.grepconsole.view.DefaultSizeTitleAreaDialog.java

License:Open Source License

/**
 * Mostly a copy of the same method in Dialog, but with a call to a separate
 * method for providing a default size that is used if no persisted dialog
 * settings are available.//from   w  ww .  j a  va2  s.co  m
 * 
 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
 */
@Override
protected Point getInitialSize() {
    Point result = getDefaultSize();

    if ((getDialogBoundsStrategy() & DIALOG_PERSISTSIZE) != 0) {
        IDialogSettings settings = getDialogBoundsSettings();

        if (settings != null) {
            boolean useStoredBounds = true;
            String previousDialogFontData = settings.get(DIALOG_FONT_DATA);

            if (previousDialogFontData != null && previousDialogFontData.length() > 0) {
                FontData[] fontDatas = JFaceResources.getDialogFont().getFontData();
                if (fontDatas.length > 0) {
                    String currentDialogFontData = fontDatas[0].toString();
                    useStoredBounds = currentDialogFontData.equalsIgnoreCase(previousDialogFontData);
                }
            }

            if (useStoredBounds) {
                try {
                    int width = settings.getInt(DIALOG_WIDTH);
                    int height = settings.getInt(DIALOG_HEIGHT);

                    if (width != DIALOG_DEFAULT_BOUNDS) {
                        result.x = width;
                    }

                    if (height != DIALOG_DEFAULT_BOUNDS) {
                        result.y = height;
                    }

                } catch (NumberFormatException e) {
                }
            }
        }
    }

    return result;
}

From source file:name.schedenig.eclipse.grepconsole.view.items.ItemLabelProvider.java

License:Open Source License

/**
 * Returns the font to use for a specific element.
 * /*from  ww  w .ja  va2s. c o  m*/
 * For groups, a bold version of the default font is returned. For all other
 * items, <code>null</code> is returned.
 * 
 * @param element Element.
 * 
 * @return Font, or <code>null</code>.
 */
public Font getFont(Object element) {
    if (element instanceof GrepExpressionFolder) {
        return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
    } else {
        return JFaceResources.getDialogFont();
    }
}

From source file:name.schedenig.eclipse.grepconsole.view.notifications.GrepConsoleNotificationStyle.java

License:Open Source License

/**
 * Refreshes the style's properties based on the current preferences.
 *///from  ww w.j  a  va 2 s .  c  o  m
public void refresh() {
    Display display = manager.getDisplay();
    RGB rgb = GrepConsoleUtil.getNotificationForegroundColor();

    if (rgb != null) {
        setForeground(new Color(display, rgb), true);
    } else {
        setForeground(null, false);
    }

    rgb = GrepConsoleUtil.getNotificationBackgroundColor();

    if (rgb != null) {
        setBackground(new Color(display, rgb), true);
    } else {
        setBackground(null, false);
    }

    IPreferenceStore prefs = activator.getPreferenceStore();

    if (prefs.getString(Activator.PREFS_NOTIFICATION_TITLE_FONT).length() == 0) {
        setTitleFont(JFaceResources.getBannerFont(), false);
    } else {
        Font titleFont = new Font(display,
                PreferenceConverter.getFontData(prefs, Activator.PREFS_NOTIFICATION_TITLE_FONT));
        setTitleFont(titleFont, true);
    }

    if (prefs.getString(Activator.PREFS_NOTIFICATION_MESSAGE_FONT).length() == 0) {
        setMessageFont(JFaceResources.getDialogFont(), false);
    } else {
        Font messageFont = new Font(display,
                PreferenceConverter.getFontData(prefs, Activator.PREFS_NOTIFICATION_MESSAGE_FONT));
        setMessageFont(messageFont, true);
    }
}

From source file:net.bpelunit.framework.client.eclipse.dialog.Field.java

License:Open Source License

protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;
    Button button = new Button(parent, SWT.PUSH);
    button.setText(label);//from w  ww.j  av a 2s  . c o m
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));

    setButtonLayoutData(button);
    return button;
}

From source file:net.bpelunit.toolsupport.editors.wizards.fields.DialogField.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 *//* w  ww.j  a  va 2  s.c  om*/
public int getButtonWidthHint(Button button) {
    button.setFont(JFaceResources.getDialogFont());
    PixelConverter converter = new PixelConverter(button);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}

From source file:net.bpelunit.toolsupport.editors.wizards.pages.ActivityWizardPage.java

License:Open Source License

@Override
protected void initializeDialogUnits(Control testControl) {
    super.initializeDialogUnits(testControl);

    GC gc = new GC(testControl);
    gc.setFont(JFaceResources.getDialogFont());
    fontMetrics = gc.getFontMetrics();/* w ww  . j  a  v  a 2s. co m*/
    gc.dispose();
}

From source file:net.certiv.fluentmark.preferences.AbstractConfigurationBlock.java

License:Open Source License

/**
 * Initializes the computation of horizontal and vertical dialog units based on the size of
 * current font.//www . ja  va2  s.co m
 * <p>
 * This method must be called before any of the dialog unit based conversion methods are called.
 * </p>
 *
 * @param testControl a control from which to obtain the current font
 */
private void initializeDialogUnits(Control testControl) {
    GC gc = new GC(testControl);
    gc.setFont(JFaceResources.getDialogFont());
    fFontMetrics = gc.getFontMetrics();
    gc.dispose();
}

From source file:net.heartsome.cat.common.ui.wizard.TSTitleAreaDialog.java

License:Open Source License

protected Control createContents(Composite parent) {
    // create the overall composite
    Composite contents = new Composite(parent, SWT.NONE);
    contents.setLayoutData(new GridData(GridData.FILL_BOTH));
    // initialize the dialog units
    initializeDialogUnits(contents);/*from w ww  .  j a v a 2s  .c om*/
    FormLayout layout = new FormLayout();
    contents.setLayout(layout);
    // Now create a work area for the rest of the dialog
    workArea = new Composite(contents, SWT.NONE);
    GridLayout childLayout = new GridLayout();
    childLayout.marginHeight = 0;
    childLayout.marginWidth = 0;
    childLayout.verticalSpacing = 0;
    workArea.setLayout(childLayout);
    Control top = createTitleArea(contents);
    resetWorkAreaAttachments(top);
    workArea.setFont(JFaceResources.getDialogFont());
    // initialize the dialog units
    initializeDialogUnits(workArea);
    // create the dialog area and button bar
    dialogArea = createDialogArea(workArea);
    buttonBar = createButtonBar(workArea);

    // computing trim for later
    Point rect = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    xTrim = rect.x - 100;
    yTrim = rect.y - 100;

    // need to react to new size of title area
    getShell().addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            layoutForNewMessage(true);
        }
    });
    return contents;
}