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:com.atlassian.connector.eclipse.ui.dialogs.ProgressDialog.java

License:Open Source License

@Override
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 .  ja  va2 s  . co m
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            buttonPressed(((Integer) event.widget.getData()).intValue());
        }
    });
    if (defaultButton) {
        Shell shell = parent.getShell();
        if (shell != null) {
            shell.setDefaultButton(button);
        }
    }
    buttons.put(new Integer(id), button);
    setButtonLayoutData(button);
    return button;
}

From source file:com.bdaum.zoom.rcp.internal.intro.Intro.java

License:Open Source License

public void standbyStateChanged(boolean sb) {
    this.standby = sb;
    if (sb) {//from w w w  .  j av  a2 s. com
        sectionGroupLayout.minNumColumns = sectionGroupLayout.maxNumColumns = 1;
        sectionGroupLayout.bottomMargin = sectionGroupLayout.leftMargin = sectionGroupLayout.topMargin = sectionGroupLayout.rightMargin = 3;
        buttonCanvas.setVisible(false);
        boolean firstOpen = false;
        for (Section section : sections) {
            if (section.isExpanded())
                if (firstOpen)
                    section.setExpanded(false);
                else
                    firstOpen = true;
            ((ColumnLayoutData) section.getLayoutData()).widthHint = 250;
            ((FormText) section.getClient()).setFont(JFaceResources.getDefaultFont());
        }
        form.setText(Constants.APPLICATION_NAME);
        form.setImage(titleImage32);
        form.setSeparatorVisible(false);
        form.setHeadClient(null);
        ((TableWrapLayout) form.getBody().getLayout()).topMargin = 3;
    } else {
        sectionGroupLayout.minNumColumns = 2;
        sectionGroupLayout.maxNumColumns = 4;
        sectionGroupLayout.bottomMargin = sectionGroupLayout.leftMargin = sectionGroupLayout.topMargin = sectionGroupLayout.rightMargin = 10;
        buttonCanvas.setVisible(true);
        for (Section section : sections) {
            ((ColumnLayoutData) section.getLayoutData()).widthHint = 400;
            ((FormText) section.getClient()).setFont(JFaceResources.getDialogFont());
        }
        form.setText(NLS.bind('\n' + Messages.Intro_welcome, Constants.APPLICATION_NAME));
        form.setImage(titleImage64);
        form.setSeparatorVisible(true);
        form.setHeadClient(subtitle);
        ((TableWrapLayout) form.getBody().getLayout()).topMargin = 10;
    }
    form.getBody().layout();
    form.redraw();
}

From source file:com.cisco.yangide.editor.preferences.YangEditorColoringConfigurationBlock.java

License:Open Source License

/**
 * Initializes the computation of horizontal and vertical dialog units based on the size of
 * current font./* w w  w  . j  a va 2 s.c  o  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) {
    // Compute and store a font metric
    GC gc = new GC(testControl);
    gc.setFont(JFaceResources.getDialogFont());
    fFontMetrics = gc.getFontMetrics();
    gc.dispose();
}

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.  j av  a2s .c  o  m
        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.codesourcery.installer.ui.ChoiceDialog.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    GridLayout layout;//from w ww.  j a v  a  2 s  . c om
    GridData data;

    if (width == -1) {
        GC gc = new GC(parent);
        gc.setFont(JFaceResources.getDialogFont());
        FontMetrics fontMetrics = gc.getFontMetrics();
        gc.dispose();
        width = convertHorizontalDLUsToPixels(fontMetrics, 185);
    }

    // Initialize element colors
    initColors();

    // Main area
    Composite area = new Composite(parent, SWT.NONE);
    layout = new GridLayout(1, true);
    layout.marginHeight = 5;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    area.setLayout(layout);
    area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // Title text
    if (getTitleText() != null) {
        // Title text font
        FontData fontData = JFaceResources.getDialogFont().getFontData()[0];
        fontData.setHeight(fontData.getHeight() + 2);
        titleFont = new Font(getShell().getDisplay(), fontData);

        // Title text area
        Composite titleArea = new Composite(area, SWT.NONE);
        layout = new GridLayout(1, true);
        titleArea.setLayout(layout);
        titleArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

        // Title text label
        Label label = new Label(titleArea, SWT.WRAP);
        data = new GridData(SWT.FILL, SWT.CENTER, true, false);
        data.widthHint = getWidth();
        label.setLayoutData(data);
        label.setText(getTitleText());
        label.setFont(titleFont);

        // Separator
        label = new Label(titleArea, SWT.NONE);
        label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

        // Prompt
        if (getPromptText() != null) {
            label = new Label(titleArea, SWT.WRAP);
            label.setForeground(promptColor);
            data = new GridData(SWT.FILL, SWT.CENTER, true, false);
            data.widthHint = getWidth();
            label.setLayoutData(data);
            label.setText(getPromptText());
            label.setFont(titleFont);
            label.setForeground(promptColor);
        }
    }

    // Add choices
    for (Option option : options) {
        InfoButton button = new InfoButton(area, SWT.RADIO);
        button.setData(option);
        button.setImage(option.getImage());
        button.setText(option.getLabel());
        button.setDescription(option.getDescription());
        data = new GridData(SWT.FILL, SWT.CENTER, true, false);
        data.widthHint = getWidth();
        button.setLayoutData(data);
        // Set label colors
        for (int index = 0; index < colors.length; index++) {
            button.setColor(ElementColor.values()[index], colors[index]);
        }

        // Default option
        if (option.equals(defaultOption)) {
            button.setSelection(true);
            selectedOption = option.getId();
        }

        // Selected option listener
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                InfoButton button = (InfoButton) e.widget;
                selectedOption = ((Option) button.getData()).getId();
                updateButtons();
            }
        });
        // Close dialog on option double-click
        button.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDoubleClick(MouseEvent e) {
                InfoButton button = (InfoButton) e.widget;
                selectedOption = ((Option) button.getData()).getId();
                updateButtons();
                okPressed();
            }
        });
    }

    applyDialogFont(area);

    // Set dialog background color
    Composite contents = (Composite) super.createContents(parent);
    setBackground(parent, backgroundColor);
    return contents;
}

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

License:Open Source License

private void createStatusLabel(final String statusFieldText, Color foreground, Color background) {
    fStatusLabel = new Label(fStatusComposite, SWT.RIGHT);
    fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    fStatusLabel.setText(statusFieldText);

    FontData[] fontDatas = JFaceResources.getDialogFont().getFontData();
    for (int i = 0; i < fontDatas.length; i++) {
        fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
    }/* w ww .ja  va  2  s  . c o m*/
    fStatusLabelFont = new Font(fStatusLabel.getDisplay(), fontDatas);
    fStatusLabel.setFont(fStatusLabelFont);

    fStatusLabelForeground = new Color(fStatusLabel.getDisplay(),
            Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f));
    fStatusLabel.setForeground(fStatusLabelForeground);
    fStatusLabel.setBackground(background);
    setColor(fStatusComposite, foreground, background);
}

From source file:com.dubture.composer.ui.parts.SharedPartWithButtons.java

License:Open Source License

protected Button createButton(Composite parent, String label, int index, FormToolkit toolkit) {
    Button button;/*  w  w  w  .  ja v  a2s  .  co  m*/
    if (toolkit != null)
        button = toolkit.createButton(parent, label, SWT.PUSH);
    else {
        button = new Button(parent, SWT.PUSH);
        button.setText(label);
    }
    GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    button.setLayoutData(gd);
    button.setData(new Integer(index));

    // Set the default button size
    button.setFont(JFaceResources.getDialogFont());
    PixelConverter converter = new PixelConverter(button);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

    return button;
}

From source file:com.flagleader.builder.dialogs.AboutLicenseDialog.java

protected void createButtonsForButtonBar(Composite paramComposite) {
    if ((!r.g()) && (!r.h())) {
        ((GridLayout) paramComposite.getLayout()).numColumns += 1;
        Button localButton1 = new Button(paramComposite, 8);
        localButton1.setText(c.b("RequireLicense"));
        localButton1.setFont(JFaceResources.getDialogFont());
        localButton1.addSelectionListener(new a(this));
        setButtonLayoutData(localButton1);
        ((GridLayout) paramComposite.getLayout()).numColumns += 1;
        Button localButton2 = new Button(paramComposite, 8);
        localButton2.setText(c.b("RegisterLicense"));
        localButton2.setFont(JFaceResources.getDialogFont());
        localButton2.addSelectionListener(new b(this));
        setButtonLayoutData(localButton2);
    }/*from  www .  j  av  a2 s . c o m*/
    createButton(paramComposite, 0, ResourceTools.getMessage("Ok"), true);
    createButton(paramComposite, 1, ResourceTools.getMessage("Cancel"), false);
}

From source file:com.flagleader.builder.dialogs.AboutLicenseDialog1.java

protected void createButtonsForButtonBar(Composite paramComposite) {
    ((GridLayout) paramComposite.getLayout()).numColumns += 1;
    Button localButton1 = new Button(paramComposite, 8);
    localButton1.setText(com.flagleader.manager.d.c.b("RequireLicense"));
    localButton1.setFont(JFaceResources.getDialogFont());
    localButton1.addSelectionListener(new c(this));
    setButtonLayoutData(localButton1);//from w w  w .  j  a va  2 s  .  c  om
    ((GridLayout) paramComposite.getLayout()).numColumns += 1;
    Button localButton2 = new Button(paramComposite, 8);
    localButton2.setText(com.flagleader.manager.d.c.b("importLicense.text"));
    localButton2.setFont(JFaceResources.getDialogFont());
    localButton2.addSelectionListener(new d(this));
    setButtonLayoutData(localButton2);
    createButton(paramComposite, 0, ResourceTools.getMessage("Ok"), true);
    createButton(paramComposite, 1, ResourceTools.getMessage("Cancel"), false);
}

From source file:com.google.dart.tools.ui.actions.AbstractOpenWizardAction.java

License:Open Source License

@Override
public void run() {
    EmitInstrumentationCommand();//from   w  w  w . ja  v a2  s.com
    Shell shell = getShell();
    try {
        INewWizard wizard = createWizard();
        wizard.init(PlatformUI.getWorkbench(), getSelection());

        WizardDialog dialog = new WizardDialog(shell, wizard);
        PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont());
        dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70),
                converter.convertHeightInCharsToPixels(20));
        dialog.create();
        int res = dialog.open();
        notifyResult(res == Window.OK);
    } catch (CoreException e) {
        String title = ActionMessages.AbstractOpenWizardAction_createerror_title;
        String message = ActionMessages.AbstractOpenWizardAction_createerror_message;
        ExceptionHandler.handle(e, shell, title, message);
    }
}