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.acceleo.ui.interpreter.internal.view.wizards.NewVariableWizardPage.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 * //from  ww  w.  j  a v a  2s. c  o  m
 * @param button
 *            the button
 * @return the width hint
 */
public static int getButtonWidthHint(Button button) {
    Font font = JFaceResources.getDialogFont();
    button.setFont(font);
    GC gc = new GC(font.getDevice());
    gc.setFont(font);
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}

From source file:org.eclipse.birt.report.designer.data.ui.property.AbstractTitlePropertyDialog.java

License:Open Source License

private void createDialogTitleArea(Composite parent) {
    Composite contents = new Composite(parent, SWT.NONE);
    contents.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    FormLayout layout = new FormLayout();
    contents.setLayout(layout);//  w  w w. j a v  a  2s .co  m

    titleArea = new Composite(contents, SWT.NONE);
    initializeDialogUnits(titleArea);

    FormData titleAreaData = new FormData();
    titleAreaData.top = new FormAttachment(0, 0);
    titleAreaData.left = new FormAttachment(0, 0);
    titleAreaData.right = new FormAttachment(100, 0);
    titleArea.setLayoutData(titleAreaData);

    layout = new FormLayout();
    titleArea.setLayout(layout);

    // add a dispose listener
    titleArea.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            if (titleAreaColor != null) {
                titleAreaColor.dispose();
            }
        }
    });
    // Determine the background color of the title bar
    Display display = titleArea.getDisplay();
    Color background;
    Color foreground;
    if (titleAreaRGB != null) {
        titleAreaColor = new Color(display, titleAreaRGB);
        background = titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    titleArea.setBackground(background);
    // Dialog image @ right
    titleImageLabel = new Label(titleArea, SWT.CENTER);
    titleImageLabel.setBackground(background);
    if (titleImage == null || titleImage.isDisposed()) {
        titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    } else {
        titleImageLabel.setImage(titleImage);
    }
    FormData imageData = new FormData();
    imageData.top = new FormAttachment(0, 0);
    // Note: do not use horizontalSpacing on the right as that would be a
    // regression from
    // the R2.x style where there was no margin on the right and images are
    // flush to the right
    // hand side. see reopened comments in 41172
    imageData.right = new FormAttachment(100, 0); // horizontalSpacing
    titleImageLabel.setLayoutData(imageData);
    // Title label @ top, left
    titleLabel = new Label(titleArea, SWT.LEFT);
    JFaceColors.setColors(titleLabel, foreground, background);
    titleLabel.setFont(JFaceResources.getBannerFont());
    titleLabel.setText(" ");//$NON-NLS-1$
    FormData titleData = new FormData();
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(titleImageLabel);
    titleData.left = new FormAttachment(0, horizontalSpacing);
    titleLabel.setLayoutData(titleData);
    messageImageLabel = new Label(titleArea, SWT.CENTER);
    messageImageLabel.setBackground(background);
    messageLabel = new Text(titleArea, SWT.WRAP | SWT.READ_ONLY);
    JFaceColors.setColors(messageLabel, foreground, background);
    messageLabel.setText(" \n "); // two lines//$NON-NLS-1$
    messageLabel.setFont(JFaceResources.getDialogFont());
    messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    leftFillerLabel = new Label(titleArea, SWT.CENTER);
    leftFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();

    Label titleBarSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
    titleBarSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}

From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.FormatLayoutPeer.java

License:Open Source License

private void createCustomPreviewPart(Composite parent, boolean needGuideLabel, String customPreviewLabelText) {
    Group group;/*from   ww  w.j a v a 2 s.  c  o m*/
    if (isFormStyle) {
        group = FormWidgetFactory.getInstance().createGroup(parent, ""); //$NON-NLS-1$
    } else {
        group = new Group(parent, SWT.NONE);
    }
    group.setText(LABEL_CUSTOM_PREVIEW_GROUP);
    if (pageAlignment == PAGE_ALIGN_HORIZONTAL) {
        group.setLayoutData(new GridData(GridData.FILL_BOTH));
        group.setLayout(new GridLayout(1, false));
    } else {
        group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        group.setLayout(new GridLayout(2, false));
    }

    FormWidgetFactory.getInstance().createLabel(group, isFormStyle).setText(customPreviewLabelText);
    if (isFormStyle) {
        customPreviewTextBox = FormWidgetFactory.getInstance().createText(group, "", SWT.SINGLE); //$NON-NLS-1$
    } else {
        customPreviewTextBox = new Text(group, SWT.SINGLE | SWT.BORDER);
    }
    customPreviewTextBox.setText(getDefaultPreviewText());
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    if (pageAlignment == PAGE_ALIGN_HORIZONTAL) {
        data.horizontalIndent = 10;
    }
    customPreviewTextBox.setLayoutData(data);
    customPreviewTextBox.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setDefaultPreviewText(customPreviewTextBox.getText());
            if (hasLoaded) {
                updatePreview();
            }

            if (customGuideLabel != null) {
                if (StringUtil.isBlank(customPreviewTextBox.getText())) {
                    customGuideLabel.setText(""); //$NON-NLS-1$
                } else {
                    customGuideLabel.setText(getCustomGuideText());
                }
            }
        }
    });

    if (needGuideLabel) {
        if (pageAlignment == PAGE_ALIGN_VIRTICAL) {
            FormWidgetFactory.getInstance().createLabel(group, isFormStyle);
        }

        customGuideLabel = FormWidgetFactory.getInstance().createLabel(group, isFormStyle);
        customGuideLabel.setText(""); //$NON-NLS-1$
        Font font = JFaceResources.getDialogFont();
        FontData fData = font.getFontData()[0];
        fData.setHeight(fData.getHeight() - 1);
        customGuideLabel.setFont(FontManager.getFont(fData));

        data = new GridData(GridData.FILL_HORIZONTAL);
        data.horizontalIndent = 10;
        customGuideLabel.setLayoutData(data);
    }

    Label label = FormWidgetFactory.getInstance().createLabel(group, isFormStyle);
    label.setText(LABEL_CUSTOM_PREVIEW_LABEL);
    label.setLayoutData(new GridData());

    customPreviewLabel = FormWidgetFactory.getInstance().createLabel(group,
            SWT.CENTER | SWT.HORIZONTAL | SWT.VIRTUAL, isFormStyle);
    customPreviewLabel.setText(""); //$NON-NLS-1$
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 1;
    customPreviewLabel.setLayoutData(data);
}

From source file:org.eclipse.birt.report.designer.internal.ui.preferences.TreeListDialogField.java

License:Open Source License

public static 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:org.eclipse.birt.report.designer.internal.ui.views.attributes.page.GeneralPage.java

License:Open Source License

public void refresh() {
    if (input instanceof List && DEUtil.getMultiSelectionHandle((List) input).isExtendedElements()) {

        librarySection.setHidden(false);

        if (hasLocalProperties()) {

            noteSection.setHidden(false);
            Font font = JFaceResources.getDialogFont();
            FontData fData = font.getFontData()[0];
            fData.setHeight(fData.getHeight() - 1);
            noteSection.getTextControl().setFont(FontManager.getFont(fData));
        } else// w  w  w. j a v  a2s.  co  m
            noteSection.setHidden(true);

        seperatorSection.setHidden(false);
        librarySection.load();
    } else {
        librarySection.setHidden(true);
        noteSection.setHidden(true);
        seperatorSection.setHidden(true);
    }
    super.refresh();
    container.layout(true);
    container.redraw();

}

From source file:org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder.java

License:Open Source License

private void createDialogTitleArea(Composite parent) {

    Composite contents = new Composite(parent, SWT.NONE);
    contents.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    FormLayout layout = new FormLayout();
    contents.setLayout(layout);//from   w  w w . ja  va 2 s . c  om

    dialogTitleArea = new Composite(contents, SWT.NONE);
    initializeDialogUnits(dialogTitleArea);

    FormData titleAreaData = new FormData();
    titleAreaData.top = new FormAttachment(0, 0);
    titleAreaData.left = new FormAttachment(0, 0);
    titleAreaData.right = new FormAttachment(100, 0);
    dialogTitleArea.setLayoutData(titleAreaData);

    layout = new FormLayout();
    dialogTitleArea.setLayout(layout);

    // add a dispose listener
    dialogTitleArea.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            if (titleAreaColor != null) {
                titleAreaColor.dispose();
            }
        }
    });
    // Determine the background color of the title bar
    Display display = dialogTitleArea.getDisplay();
    Color background;
    Color foreground;
    if (titleAreaRGB != null) {
        titleAreaColor = new Color(display, titleAreaRGB);
        background = titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }

    dialogTitleArea.setBackground(background);
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    // Dialog image @ right
    titleImageLabel = new Label(dialogTitleArea, SWT.CENTER);
    titleImageLabel.setBackground(background);
    if (titleAreaImage == null)
        titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    else
        titleImageLabel.setImage(titleAreaImage);

    FormData imageData = new FormData();
    imageData.top = new FormAttachment(0, 0);
    // Note: do not use horizontalSpacing on the right as that would be a
    // regression from
    // the R2.x style where there was no margin on the right and images are
    // flush to the right
    // hand side. see reopened comments in 41172
    imageData.right = new FormAttachment(100, 0); // horizontalSpacing
    titleImageLabel.setLayoutData(imageData);
    // Title label @ top, left
    titleLabel = new Label(dialogTitleArea, SWT.LEFT);
    JFaceColors.setColors(titleLabel, foreground, background);
    titleLabel.setFont(JFaceResources.getBannerFont());
    titleLabel.setText(" ");//$NON-NLS-1$
    FormData titleData = new FormData();
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(titleImageLabel);
    titleData.left = new FormAttachment(0, horizontalSpacing);
    titleLabel.setLayoutData(titleData);
    // Message image @ bottom, left
    messageImageLabel = new Label(dialogTitleArea, SWT.CENTER);
    messageImageLabel.setBackground(background);
    // Message label @ bottom, center
    messageLabel = new Text(dialogTitleArea, SWT.WRAP | SWT.READ_ONLY);
    JFaceColors.setColors(messageLabel, foreground, background);
    messageLabel.setText(" \n "); // two lines//$NON-NLS-1$
    messageLabel.setFont(JFaceResources.getDialogFont());
    messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    // Filler labels
    leftFillerLabel = new Label(dialogTitleArea, SWT.CENTER);
    leftFillerLabel.setBackground(background);
    bottomFillerLabel = new Label(dialogTitleArea, SWT.CENTER);
    bottomFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();

    Label titleBarSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
    titleBarSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}

From source file:org.eclipse.birt.report.designer.ui.preferences.OptionsConfigurationBlock.java

License:Open Source License

protected RadioComposite addRadioButton(Composite parent, String[] labels, Key key, String[] values,
        int indent) {
    ControlData data = new ControlData(key, values);

    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 3;//w w w  .ja v a 2 s  .com
    gd.horizontalIndent = indent;

    RadioComposite composite = new RadioComposite(parent, SWT.NONE);
    composite.setLayoutData(gd);
    GridLayout layout = new GridLayout(3, false);
    composite.setLayout(layout);
    composite.setText(labels[0]);

    for (int i = 1; i < labels.length; i++) {
        Button radioBtn = new Button(composite, SWT.RADIO);
        radioBtn.setFont(JFaceResources.getDialogFont());
        radioBtn.setLayoutData(new GridData());
        radioBtn.setText(labels[i]);
    }

    composite.setData(data);
    composite.addSelectionListener(getSelectionListener());
    String currValue = getValue(key);
    composite.setSelection(data.getSelection(currValue));
    fRadioButtons.add(composite);

    updateRadioComposite(composite);

    return composite;
}

From source file:org.eclipse.birt.report.designer.ui.preferences.OptionsConfigurationBlock.java

License:Open Source License

protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
    ControlData data = new ControlData(key, values);

    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 3;//from   ww  w  .  j a  v a 2  s . c  o  m
    gd.horizontalIndent = indent;

    Button checkBox = new Button(parent, SWT.CHECK);
    checkBox.setFont(JFaceResources.getDialogFont());
    checkBox.setText(label);
    checkBox.setData(data);
    checkBox.setLayoutData(gd);
    checkBox.addSelectionListener(getSelectionListener());

    String currValue = getValue(key);
    checkBox.setSelection(data.getSelection(currValue) == 0);

    fCheckBoxes.add(checkBox);

    updateCheckBox(checkBox);

    return checkBox;
}

From source file:org.eclipse.birt.report.designer.ui.preferences.OptionsConfigurationBlock.java

License:Open Source License

protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values, int indent,
        int widthHint, SelectionListener listener) {
    ControlData data = new ControlData(key, values);

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
    gd.horizontalSpan = 3;/*from w w w .j av a  2  s.c o  m*/
    gd.horizontalIndent = indent;

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    composite.setLayout(layout);
    composite.setLayoutData(gd);

    Button checkBox = new Button(composite, SWT.CHECK);
    checkBox.setFont(JFaceResources.getDialogFont());
    checkBox.setData(data);
    checkBox.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
    checkBox.addSelectionListener(getSelectionListener());

    gd = new GridData(GridData.FILL, GridData.CENTER, true, false);
    gd.widthHint = widthHint;

    Link link = new Link(composite, SWT.NONE);
    link.setText(label);
    link.setLayoutData(gd);
    if (listener != null) {
        link.addSelectionListener(listener);
    }

    String currValue = getValue(key);
    checkBox.setSelection(data.getSelection(currValue) == 0);

    fCheckBoxes.add(checkBox);

    updateCheckBox(checkBox);

    return checkBox;
}

From source file:org.eclipse.birt.report.designer.ui.preferences.OptionsConfigurationBlock.java

License:Open Source License

protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels,
        int indent) {
    GridData gd = new GridData();
    gd.horizontalIndent = indent;/*w ww . j  a v  a2  s.  com*/

    Label labelControl = new Label(parent, SWT.NONE);
    labelControl.setFont(JFaceResources.getDialogFont());
    labelControl.setText(label);
    labelControl.setLayoutData(gd);

    Combo comboBox = newComboControl(parent, key, values, valueLabels);
    gd = new GridData();
    gd.widthHint = 200;
    comboBox.setLayoutData(gd);

    fLabels.put(comboBox, labelControl);

    updateCombo(comboBox);

    return comboBox;
}