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.entirej.applicationframework.tmt.pages.EJTMTScreenPage.java

License:Apache License

public 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  w  w. j ava2s . co  m*/
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));
    button.addSelectionListener(new SelectionAdapter() {
        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:org.erlide.ui.util.eclipse.text.BrowserInformationControl.java

License:Open Source License

/**
 * Creates and initializes the text layout used to compute the size hint.
 * /*w  w w .  j a v  a  2  s  .co  m*/
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout = new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    Font font = fSymbolicFontName == null ? JFaceResources.getDialogFont()
            : JFaceResources.getFont(fSymbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    final FontData[] fontData = font.getFontData();
    for (int i = 0; i < fontData.length; i++) {
        fontData[i].setStyle(SWT.BOLD);
    }
    font = new Font(getShell().getDisplay(), fontData);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    "); //$NON-NLS-1$
    final int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] { tabWidth });

    fTextLayout.setText(""); //$NON-NLS-1$
}

From source file:org.fusesource.ide.foundation.ui.form.FormSupport.java

License:Open Source License

protected void initializeFontMetrics(Control control) {
    // Compute and store a font metric
    GC gc = new GC(control);
    gc.setFont(JFaceResources.getDialogFont());
    fontMetrics = gc.getFontMetrics();//from  ww  w. ja  v a  2s  .com
    gc.dispose();
}

From source file:org.gw4e.eclipse.studio.editor.properties.edge.EdgeJavaScriptSection.java

License:Open Source License

public static int setHeight(FormData fd, Control control, int rowcount) {
    int height = 0;
    if (control != null && !control.isDisposed()) {
        GC gc = new GC(control);
        try {//from ww  w.ja v a 2s . c  o  m
            gc.setFont(JFaceResources.getDialogFont());
            fd.height = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), rowcount);
        } finally {
            gc.dispose();
        }
    }
    return height;
}

From source file:org.jboss.tools.common.model.ui.reporting.ReportProblemWizard.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 *///from  w  w w  .j  a  va 2  s . com
private 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.jboss.tools.forge.ui.ext.quickaccess.QuickAccessContents.java

License:Open Source License

/**
 * @param composite/* ww  w . jav  a2s  . c  o  m*/
 */
public Table createTable(Composite composite, int defaultOrientation) {
    composite.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            doDispose();
        }
    });
    Composite tableComposite = new Composite(composite, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tableComposite);
    TableColumnLayout tableColumnLayout = new TableColumnLayout();
    tableComposite.setLayout(tableColumnLayout);
    table = new Table(tableComposite, SWT.SINGLE | SWT.FULL_SELECTION);
    textLayout = new TextLayout(table.getDisplay());
    textLayout.setOrientation(defaultOrientation);
    Font boldFont = resourceManager
            .createFont(FontDescriptor.createFrom(JFaceResources.getDialogFont()).setStyle(SWT.BOLD));
    textLayout.setFont(table.getFont());
    textLayout.setText("Available Categories:");
    int maxProviderWidth = (int) (textLayout.getBounds().width * 1.1);
    textLayout.setFont(boldFont);
    for (int i = 0; i < providers.length; i++) {
        QuickAccessProvider provider = providers[i];
        textLayout.setText(provider.getName());
        int width = (int) (textLayout.getBounds().width * 1.1);
        if (width > maxProviderWidth) {
            maxProviderWidth = width;
        }
    }
    tableColumnLayout.setColumnData(new TableColumn(table, SWT.NONE),
            new ColumnWeightData(0, maxProviderWidth));
    tableColumnLayout.setColumnData(new TableColumn(table, SWT.NONE), new ColumnWeightData(100, 100));
    table.getShell().addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            if (!showAllMatches) {
                if (!resized) {
                    resized = true;
                    e.display.timerExec(100, new Runnable() {
                        @Override
                        public void run() {
                            if (table != null && !table.isDisposed()) {
                                refresh(filterText.getText().toLowerCase());
                            }
                            resized = false;
                        }
                    });
                }
            }
        }
    });

    table.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.ARROW_UP && table.getSelectionIndex() == 0) {
                filterText.setFocus();
            } else if (e.character == SWT.ESC) {
                doClose();
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            // do nothing
        }
    });
    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent e) {

            if (table.getSelectionCount() < 1)
                return;

            if (e.button != 1)
                return;

            if (table.equals(e.getSource())) {
                Object o = table.getItem(new Point(e.x, e.y));
                TableItem selection = table.getSelection()[0];
                if (selection.equals(o))
                    handleSelection();
            }
        }
    });

    table.addMouseMoveListener(new MouseMoveListener() {
        TableItem lastItem = null;

        @Override
        public void mouseMove(MouseEvent e) {
            if (table.equals(e.getSource())) {
                Object o = table.getItem(new Point(e.x, e.y));
                if (lastItem == null ^ o == null) {
                    table.setCursor(o == null ? null : table.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
                }
                if (o instanceof TableItem) {
                    if (!o.equals(lastItem)) {
                        lastItem = (TableItem) o;
                        table.setSelection(new TableItem[] { lastItem });
                        table.setToolTipText(((QuickAccessEntry) lastItem.getData()).element.getTooltip());
                    }
                } else if (o == null) {
                    lastItem = null;
                    table.setToolTipText("");
                }
            }
        }
    });

    table.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // do nothing
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleSelection();
        }
    });

    final TextStyle boldStyle;
    if (PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        boldStyle = new TextStyle(boldFont, null, null);
        // italicsFont =
        // resourceManager.createFont(FontDescriptor.createFrom(
        // table.getFont()).setStyle(SWT.ITALIC));
        grayColor = resourceManager
                .createColor(ColorUtil.blend(table.getBackground().getRGB(), table.getForeground().getRGB()));
    } else {
        boldStyle = null;
    }
    Listener listener = new Listener() {
        @Override
        public void handleEvent(Event event) {
            QuickAccessEntry entry = (QuickAccessEntry) event.item.getData();
            if (entry != null) {
                switch (event.type) {
                case SWT.MeasureItem:
                    entry.measure(event, textLayout, resourceManager, boldStyle);
                    break;
                case SWT.PaintItem:
                    entry.paint(event, textLayout, resourceManager, boldStyle, grayColor);
                    break;
                case SWT.EraseItem:
                    entry.erase(event);
                    break;
                }
            }
        }
    };
    table.addListener(SWT.MeasureItem, listener);
    table.addListener(SWT.EraseItem, listener);
    table.addListener(SWT.PaintItem, listener);

    return table;
}

From source file:org.jboss.tools.windup.ui.internal.editor.RulesetEditorRulesSection.java

License:Open Source License

private Button createButton(Composite parent, String label) {
    Button button = toolkit.createButton(parent, label, SWT.PUSH);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    button.setLayoutData(gd);//from   w ww .j a v a  2  s  .  c om
    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:org.kalypso.contribs.eclipse.jface.dialog.ListSelectionComposite.java

License:Open Source License

/**
 * Creates a new button with the given id.
 * <p>//from w  w  w .ja  v a2 s  . c  om
 * The <code>Dialog</code> implementation of this framework method creates a standard push button, registers it for
 * selection events including button presses, and registers default buttons with its shell. The button id is stored as
 * the button's client data. If the button id is <code>IDialogConstants.CANCEL_ID</code>, the new button will be
 * accessible from <code>getCancelButton()</code>. If the button id is <code>IDialogConstants.OK_ID</code>, the new
 * button will be accessible from <code>getOKButton()</code>. Note that the parent's layout is assumed to be a
 * <code>GridLayout</code> and the number of columns in this layout is incremented. Subclasses may override.
 * </p>
 *
 * @param parent
 *          the parent composite
 * @param id
 *          the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard dialog button ids)
 * @param label
 *          the label from the button
 * @param defaultButton
 *          <code>true</code> if the button is to be the default button, and <code>false</code> otherwise
 * @return the new button
 * @see #getCancelButton
 * @see #getOKButton()
 */
protected Button createButton(final Composite parent, final int id, final String label,
        final boolean defaultButton) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;
    final Button button = new Button(parent, SWT.PUSH);
    button.setText(label);
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));
    if (defaultButton) {
        final Shell shell = parent.getShell();
        if (shell != null) {
            shell.setDefaultButton(button);
        }
    }
    setButtonLayoutData(button);
    return button;
}

From source file:org.kalypso.contribs.eclipse.jface.wizard.TreeSelectionPage.java

License:Open Source License

/**
 * Creates a new button with the given id.
 * <p>/* w  ww  .j  av a  2  s.c  o  m*/
 * The <code>Dialog</code> implementation of this framework method creates a standard push button, registers it for
 * selection events including button presses, and registers default buttons with its shell. The button id is stored as
 * the button's client data. If the button id is <code>IDialogConstants.CANCEL_ID</code>, the new button will be
 * accessible from <code>getCancelButton()</code>. If the button id is <code>IDialogConstants.OK_ID</code>, the new
 * button will be accesible from <code>getOKButton()</code>. Note that the parent's layout is assumed to be a
 * <code>GridLayout</code> and the number of columns in this layout is incremented. Subclasses may override.
 * </p>
 *
 * @param parent
 *          the parent composite
 * @param id
 *          the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard dialog button ids)
 * @param label
 *          the label from the button
 * @param defaultButton
 *          <code>true</code> if the button is to be the default button, and <code>false</code> otherwise
 * @return the new button
 */
protected Button createButton(final Composite parent, final int id, final String label,
        final boolean defaultButton) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;
    final Button button = new Button(parent, SWT.PUSH);
    button.setText(label);
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));
    if (defaultButton) {
        final Shell shell = parent.getShell();
        if (shell != null) {
            shell.setDefaultButton(button);
        }
    }
    m_buttons.put(new Integer(id), button);
    setButtonLayoutData(button);
    return button;
}

From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java

License:Open Source License

/**
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 *//*  ww w  .j ava2 s .  c  om*/
@Override
public void createPartControl(final Composite parent) {
    // initialize the dialog units
    initializeDialogUnits(parent);

    final FormLayout layout = new FormLayout();
    parent.setLayout(layout);
    final FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    parent.setLayoutData(data);

    // Now create a work area for the rest of the dialog
    m_workArea = new Composite(parent, SWT.NULL);
    GridLayoutFactory.fillDefaults().spacing(5, 0).applyTo(m_workArea);

    m_workArea.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));

    final Control top = createTitleArea(parent);
    resetWorkAreaAttachments(top);

    m_workArea.setFont(JFaceResources.getDialogFont());

    // initialize the dialog units
    initializeDialogUnits(m_workArea);

    final Label titleBarSeparator = new Label(m_workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    titleBarSeparator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    m_mainSash = new SashForm(m_workArea, SWT.HORIZONTAL);
    m_mainSash.setFont(m_workArea.getFont());
    m_mainSash.setLayoutData(new GridData(GridData.FILL_BOTH));

    m_browserPanel = new NavigationPanel(this, m_mainSash, SWT.BORDER);

    final MenuManager menuManager = m_browserPanel.getContextMenu();
    getSite().registerContextMenu(menuManager, getSite().getSelectionProvider());

    m_pageAndButtonArea = new Composite(m_mainSash, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(m_pageAndButtonArea);
    m_pageAndButtonArea.setFont(m_mainSash.getFont());

    setWizard(m_wizard);
}