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:org.eclipse.team.internal.ccvs.ui.tags.TagConfigurationDialog.java

License:Open Source License

private GridData getStandardButtonData(Button button) {
    GridData data = new GridData();
    data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    //don't crop labels with large font
    //int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    //data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    return data;/* w ww .j av  a  2 s  . c  o m*/
}

From source file:org.org.eclipse.core.utils.platform.tools.WidgetTools.java

License:Open Source License

/**
 * Returns a height hint for a button control.
 * @deprecated button height is now determined by the layout.
 *//*www  .j  a va 2 s .  co m*/
public static int getButtonHeightHint(Button button) {
    button.setFont(JFaceResources.getDialogFont());
    PixelConverter converter = new PixelConverter(button);
    return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
}

From source file:org.s23m.cell.eclipse.preferences.ui.RepositoryPreferencePage.java

License:Mozilla Public License

@Override
public void createFieldEditors() {
    final String[][] array = new String[connectors.size()][2];
    for (int i = 0; i < connectors.size(); i++) {
        final String name = connectors.get(i).getName();
        array[i][0] = name;/* ww  w . ja v  a  2 s.co  m*/
        array[i][1] = name;
    }

    final Composite parent = getFieldEditorParent();

    databaseTypeEditor = new RadioGroupFieldEditorWithSelection(RepositoryPreferences.DATABASE_TYPE,
            "Database &type", 1, array, parent);
    databaseTypeEditor.getSelectedValue();
    addField(databaseTypeEditor);

    hostNameEditor = new StringFieldEditor(RepositoryPreferences.HOSTNAME, "&Hostname", parent);
    addField(hostNameEditor);

    portEditor = new IntegerFieldEditor(RepositoryPreferences.PORT, "P&ort", parent);
    portEditor.setStringValue("3306");
    portEditor.setValidRange(1025, 65536);
    // TODO use default port supplied by connector
    addField(portEditor);

    databaseNameEditor = new StringFieldEditor(RepositoryPreferences.DATABASE_NAME, "Database &name", parent);
    addField(databaseNameEditor);

    usernameEditor = new StringFieldEditor(RepositoryPreferences.USERNAME, "&Username", parent);
    addField(usernameEditor);

    passwordEditor = new PasswordFieldEditor(RepositoryPreferences.PASSWORD, "&Password", parent);
    addField(passwordEditor);

    final Composite buttonGroup = new Composite(parent, SWT.NONE);
    buttonGroup.setLayoutData(new GridData());
    final GridLayout buttonLayout = new GridLayout();
    buttonLayout.marginHeight = 0;
    buttonLayout.marginWidth = 0;
    buttonGroup.setLayout(buttonLayout);

    testConnectionButton = new Button(buttonGroup, SWT.NONE);
    testConnectionButton.setText("&Test connection");
    testConnectionButton.setEnabled(true);
    testConnectionButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {

            final Display display = Display.getCurrent();
            final Runnable connectionTest = new Runnable() {
                public void run() {
                    final String hostname = hostNameEditor.getStringValue();
                    final int port = portEditor.getIntValue();
                    final String databaseName = databaseNameEditor.getStringValue();
                    final String username = usernameEditor.getStringValue();
                    final String password = passwordEditor.getStringValue();
                    final String connectorName = databaseTypeEditor.getSelectedValue();

                    final DatabaseConnector connector = findConnectorByName(connectorName);

                    final String validConnection = DatabaseConnectorSupport.testConnection(connector, hostname,
                            port, databaseName, username, password);

                    final String message;
                    if (validConnection == null) {
                        message = "The connection details are valid";
                    } else {
                        message = "The connection details are invalid:\n" + validConnection;
                    }
                    MessageDialog.openInformation(display.getActiveShell(), "Test connection", message);
                }
            };

            BusyIndicator.showWhile(display, connectionTest);
        }
    });
    final GridData testConnectionButtonData = new GridData(GridData.FILL_HORIZONTAL);
    testConnectionButtonData.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    //removeTagData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    testConnectionButton.setLayoutData(testConnectionButtonData);

    readOnlyEditor = new BooleanFieldEditor(RepositoryPreferences.READ_ONLY, "&Read Only Access", parent);
    addField(readOnlyEditor);

}

From source file:org.talend.commons.ui.swt.colorstyledtext.prefs.BooleanColorFieldEditor.java

License:Open Source License

protected void doFillIntoGrid(Composite parent, int numColumns) {
    Control label = getLabelControl(parent);
    GridData gd = new GridData();
    gd.horizontalSpan = 1;/* w  w w  .jav a2s.  c  om*/
    label.setLayoutData(gd);

    Button colorButton = super.getChangeControl(parent);
    gd = new GridData();
    gd.horizontalSpan = 1;
    gd.heightHint = convertVerticalDLUsToPixels(colorButton, IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(colorButton, IDialogConstants.BUTTON_WIDTH);
    gd.widthHint = Math.max(widthHint, colorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    colorButton.setLayoutData(gd);

    gd = new GridData();
    gd.horizontalSpan = 1;
    getCheck(parent).setLayoutData(gd);
    if (checkText != null) {
        check.setText(checkText);
    }
}