Example usage for org.eclipse.jface.dialogs IDialogConstants BUTTON_HEIGHT

List of usage examples for org.eclipse.jface.dialogs IDialogConstants BUTTON_HEIGHT

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants BUTTON_HEIGHT.

Prototype

int BUTTON_HEIGHT

To view the source code for org.eclipse.jface.dialogs IDialogConstants BUTTON_HEIGHT.

Click Source Link

Document

Button height in dialog units (value 14).

Usage

From source file:net.sourceforge.eclipseccase.ui.DialogArea.java

License:Open Source License

protected Button createButton(Composite parent, String label, int style) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(label);//from w w w  . j  a va 2 s  .co m
    // we need to explicitly set the font to the parent's font for dialogs
    button.setFont(parent.getFont());
    GridData data = new GridData(style);
    data.heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_HEIGHT);
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    return button;
}

From source file:net.sourceforge.texlipse.properties.ViewerListFieldEditor.java

License:Open Source License

/**
 * Creates a new editor button for the field editor.
 * @param parent parent component//from w  w w. j ava 2s . co  m
 * @return the "edit"-button
 */
protected Button createEditButton(Composite parent) {

    Button button = new Button(parent, SWT.PUSH);
    button.setText(TexlipsePlugin.getResourceString("openEdit"));
    button.setFont(parent.getFont());
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = convertVerticalDLUsToPixels(button, IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    button.setEnabled(false);
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            openEditorDialog();
        }
    });

    return button;
}

From source file:org.compiere.mfg_scm.eclipse.db.editors.ListFieldEditor.java

License:Apache License

/**
 * Helper method to create a push button.
 * /*from  w  ww  .  j  a va2  s. c o  m*/
 * @param parent
 *            the parent control
 * @param key
 *            the resource name used to supply the button's label text
 */
protected Button createPushButton(Composite parent, String label) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(label);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = convertVerticalDLUsToPixels(button, IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    // data.horizontalSpan = hs; use to have multiple buttons on the same
    // row
    button.setLayoutData(data);
    button.addSelectionListener(getSelectionListener());
    return button;
}

From source file:org.dadacoalition.yedit.preferences.tasktag.SWTUtil.java

License:Open Source License

/**
 * Returns a height hint for a button control.
 * @deprecated/*from   w ww  .j  av a 2 s .  c  om*/
 * @see IDialogConstants#BUTTON_HEIGHT
 */
@Deprecated
public static int getButtonHeigthHint(Button button) {
    if (button.getFont().equals(JFaceResources.getDefaultFont()))
        button.setFont(JFaceResources.getDialogFont());
    PixelConverter converter = new PixelConverter(button);
    return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
}

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

License:Open Source License

/**
 * Sets the layout data of the button to a GridData with appropriate heights
 * and widths.//  w w  w  .j  av a  2s. com
 * <p>
 * The <code>WizardDialog</code> override the method in order to make Help
 * button split with other buttons.
 * 
 * @param button
 *            the button to be set layout data to
 */
protected void setButtonLayoutData(Button button) {
    GridData data;
    if (button.getText().equals(IDialogConstants.HELP_LABEL)) {
        data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
        data.grabExcessHorizontalSpace = true;
    } else {
        data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
    }
    data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
}

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

License:Open Source License

/**
 * Create UI section for custom browser.
 * //from   w w  w .  j  a  va  2  s .  c  om
 * @param mainComposite
 */
private void createCustomBrowserPathPart(Composite mainComposite) {
    Font font = mainComposite.getFont();
    // vertical space
    new Label(mainComposite, SWT.NULL);

    Composite bPathComposite = new Composite(mainComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 3;
    bPathComposite.setLayout(layout);
    bPathComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    customBrowserPathLabel = new Label(bPathComposite, SWT.LEFT);
    customBrowserPathLabel.setFont(font);
    customBrowserPathLabel.setText(Messages.getString("designer.preview.preference.browser.program")); //$NON-NLS-1$

    // Browser path text
    customBrowserPath = new Text(bPathComposite, SWT.BORDER);
    customBrowserPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    customBrowserPath.setFont(font);
    customBrowserPath.setText(
            ViewerPlugin.getDefault().getPluginPreferences().getString(CustomBrowser.CUSTOM_BROWSER_PATH_KEY));
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalAlignment = GridData.FILL;
    data.widthHint = convertWidthInCharsToPixels(10);
    customBrowserPath.setLayoutData(data);

    // Custom browser button
    customBrowserBrowse = new Button(bPathComposite, SWT.NONE);
    customBrowserBrowse.setFont(font);
    customBrowserBrowse.setText(Messages.getString("designer.preview.preference.browser.browse")); //$NON-NLS-1$
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, customBrowserBrowse.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    customBrowserBrowse.setLayoutData(data);
    customBrowserBrowse.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent event) {
        }

        public void widgetSelected(SelectionEvent event) {
            FileDialog d = new FileDialog(getShell());

            d.setText(Messages.getString("designer.preview.preference.browser.details")); //$NON-NLS-1$

            String file = d.open();

            if (file != null) {
                customBrowserPath.setText("\"" + file + "\" %1"); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
    });

    // Toggle custom browser enabled or not
    setCustomBrowserPathEnabled();
}

From source file:org.eclipse.cdt.cpp.ui.internal.dialogs.CustomMessageDialog.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;/*from  w  w  w .j a  v  a 2s. com*/
    button = new Button(parent, SWT.PUSH);

    button.setText(label);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);

    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);
        }
    }
    button.setFont(parent.getFont());
    return button;
}

From source file:org.eclipse.cdt.cpp.ui.internal.dialogs.CustomMessageDialog.java

License:Open Source License

protected Button createExtraButton(Composite parent, int id, String label, int type) {
    Button button;//from   www.jav  a 2 s  .c  om
    button = new Button(parent, type);

    button.setText(label);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);

    if (type == 1 << 5)
        button.setData(new Integer(id));
    else
        button.setData(new Integer(id + 100));

    button.setSelection(false);
    button.addSelectionListener(actionListener);
    button.setFont(parent.getFont());
    return button;
}

From source file:org.eclipse.cdt.internal.cppunit.util.SWTUtil.java

License:Open Source License

/**
 * Returns a height hint for a button control.
 */// ww w.j  a v a 2s . c o  m
public static int getButtonHeigthHint(Button button) {
    PixelConverter converter = new PixelConverter(button);
    return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
}

From source file:org.eclipse.datatools.sqltools.routineeditor.parameter.internal.ParameterTableDialog.java

License:Open Source License

protected void setFillLayoutData(Button button) {
    GridData data = new GridData(GridData.GRAB_HORIZONTAL);
    data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);// w  ww. ja  v a  2s.  c  o m
}