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:com.iw.plugins.spindle.ui.CheckboxTreeAndList.java

License:Mozilla Public 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 = new Button(parent, SWT.PUSH);
    button.setFont(parent.getFont());//  w  w  w .j  a v  a 2s  . c  om

    button.setText(label);

    PixelConverter converter = new PixelConverter(button);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    data.heightHint = converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = converter.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);
        }
    }

    return button;
}

From source file:com.iw.plugins.spindle.ui.dialogfields.StringButtonDefaultField.java

License:Mozilla Public License

public void fillIntoGrid(Composite parent, int numcols) {

    Assert.isLegal(defaultLabelControl == null, "can't use GridLayout, already used FormLayout!");

    Assert.isTrue(numcols >= 5);//from   w w w  . ja  va 2 s  .  co  m

    GridData data;

    PixelConverter converter = new PixelConverter(parent);

    Label labelControl = getLabelControl(parent);
    data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    data.horizontalSpan = 1;
    labelControl.setLayoutData(data);

    Text textControl = getTextControl(parent);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = numcols - 3;
    textControl.setLayoutData(data);

    Label defaultLabel = getDefaultLabelControl(parent);
    defaultLabel.setText("(default)");
    defaultLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    data.horizontalSpan = 1;
    data.widthHint = Math.max(converter.convertHorizontalDLUsToPixels("(default)".length()),
            defaultLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    defaultLabel.setLayoutData(data);

    int heightHint = converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

    Button buttonControl = getButtonControl(parent);
    data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    data.horizontalSpan = 1;
    data.heightHint = heightHint;
    data.widthHint = Math.max(widthHint, buttonControl.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    buttonControl.setLayoutData(data);
}

From source file:com.iw.plugins.spindle.ui.dialogfields.StringButtonField.java

License:Mozilla Public License

public void fillIntoGrid(Composite parent, int numcols) {
    Assert.isTrue(numcols >= 3);/*from ww w .  j a  v a 2  s .  co m*/
    super.fillIntoGrid(parent, numcols - 1);

    PixelConverter converter = new PixelConverter(parent);
    int heightHint = converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

    Button buttonControl = getButtonControl(parent);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    data.horizontalSpan = 1;
    data.heightHint = heightHint;
    data.widthHint = Math.max(widthHint, buttonControl.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    buttonControl.setLayoutData(data);
}

From source file:com.iw.plugins.spindle.ui.preferences.SpindleEditorPreferencePage.java

License:Mozilla Public License

protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);/*from   w  w  w . j ava  2s . c  o m*/
    Font font = parent.getFont();
    GridData gd;

    Composite top = new Composite(parent, SWT.LEFT);
    top.setFont(font);
    int numColumns = 2;
    Composite result = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    top.setLayout(layout);

    // Sets the layout data for the top composite's
    // place in its parent's layout.
    top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Group group = createGroup(2, top, "Content Assist");
    Label spacer = new Label(group, SWT.NULL);
    spacer.setText(" ");
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    data.heightHint = 5;
    spacer.setLayoutData(data);
    fAutoActivateContentAssist = new BooleanFieldEditor(AUTO_ACTIVATE_CONTENT_ASSIST,
            UIPlugin.getString("preference-editor-auto-insert-assist"), BooleanFieldEditor.DEFAULT, group);

    fAutoActivateContentAssist.setPreferencePage(this);
    fAutoActivateContentAssist.setPreferenceStore(UIPlugin.getDefault().getPreferenceStore());
    fAutoActivateContentAssist.load();
    fAutoActivateContentAssist.setPropertyChangeListener(this);

    fOfferXHTML = new RadioGroupFieldEditor(OFFER_XHTML, UIPlugin.getString("preference-offer-xhtml-proposals"),
            4, OFFER_XHTML_OPTIONS, group);

    fOfferXHTML.setPreferencePage(this);
    fOfferXHTML.setPreferenceStore(UIPlugin.getDefault().getPreferenceStore());
    fOfferXHTML.load();
    fOfferXHTML.setPropertyChangeListener(this);

    int heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);

    spacer = new Label(top, SWT.NULL);
    spacer.setText(" ");
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    data.heightHint = heightHint;
    spacer.setLayoutData(data);

    Group revalidationGroup = createGroup(2, top, "Enable 'As-You-Type' Validation (requires editor restart)");

    // Label restart = new Label(revalidationGroup, SWT.NULL);
    // restart.setText(UIPlugin.getString("preference-editor-as-you-type-requires-restart"));
    // data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    // data.horizontalSpan = 2;
    // restart.setLayoutData(data);

    spacer = new Label(revalidationGroup, SWT.NULL);
    spacer.setText(" ");
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    data.heightHint = 5;
    spacer.setLayoutData(data);

    fAsYouTypeSpec = new BooleanFieldEditor(AS_YOU_TYPE_SPEC,
            UIPlugin.getString("preference-editor-as-you-type-spec"), BooleanFieldEditor.DEFAULT,
            revalidationGroup);

    fAsYouTypeSpec.setPreferencePage(this);
    fAsYouTypeSpec.setPreferenceStore(UIPlugin.getDefault().getPreferenceStore());
    fAsYouTypeSpec.load();
    fAsYouTypeSpec.setPropertyChangeListener(this);

    fAsYouTypeTemplate = new BooleanFieldEditor(AS_YOU_TYPE_TEMPLATE,
            UIPlugin.getString("preference-editor-as-you-type-template"), BooleanFieldEditor.DEFAULT,
            revalidationGroup);

    fAsYouTypeTemplate.setPreferencePage(this);
    fAsYouTypeTemplate.setPreferenceStore(UIPlugin.getDefault().getPreferenceStore());
    fAsYouTypeTemplate.load();
    fAsYouTypeTemplate.setPropertyChangeListener(this);

    spacer = new Label(revalidationGroup, SWT.NULL);
    spacer.setText(" ");
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    data.heightHint = 5;
    spacer.setLayoutData(data);

    Label warning = new Label(revalidationGroup, SWT.WRAP);
    warning.setText(
            "WARNING: If 'As-You-Type' is disabled, things like syntax completion may stop or give wrong results until you save the file.");
    data = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
    data.widthHint = convertWidthInCharsToPixels(30);
    warning.setLayoutData(data);

    Label warning2 = new Label(revalidationGroup, SWT.NULL);
    warning2.setText("");
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    warning2.setLayoutData(data);

    spacer = new Label(top, SWT.NULL);
    spacer.setText(" ");
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    data.heightHint = heightHint;
    spacer.setLayoutData(data);

    Label message = new Label(top, SWT.NULL);
    message.setText("Spindle Editors respond to changes on page: ");
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    message.setLayoutData(data);

    Label message2 = new Label(top, SWT.NULL);
    message2.setText("  Workbench -> Editors -> Text Editor ");
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    message2.setLayoutData(data);

    return top;
}

From source file:com.iw.plugins.spindle.ui.preferences.WizardTemplatesPreferencePage.java

License:Mozilla Public License

protected void contributeButtons(Composite parent) {
    Font font = parent.getFont();
    GridLayout layout = (GridLayout) parent.getLayout();
    layout.numColumns += 2;/*ww w .j  a  v  a 2 s  .co m*/

    int heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

    fImport = new Button(parent, SWT.PUSH);
    fImport.setText("Import");
    Dialog.applyDialogFont(fImport);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.heightHint = heightHint;
    data.widthHint = Math.max(widthHint, fImport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fImport.setLayoutData(data);
    fImport.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            performImport();
        }
    });

    fExport = new Button(parent, SWT.PUSH);
    fExport.setText("Export");
    Dialog.applyDialogFont(fImport);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.heightHint = heightHint;
    data.widthHint = Math.max(widthHint, fExport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fExport.setLayoutData(data);
    fExport.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            performExport();
        }
    });

}

From source file:com.iw.plugins.spindle.ui.properties.ProjectTemplatesPropertyPage.java

License:Mozilla Public License

protected void contributeButtons(Composite parent) {
    Font font = parent.getFont();
    GridLayout layout = (GridLayout) parent.getLayout();
    layout.numColumns += 3;/*  w w  w.  j ava  2  s.c  o  m*/

    int heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

    fImport = new Button(parent, SWT.PUSH);
    fImport.setText("Import");
    Dialog.applyDialogFont(fImport);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.heightHint = heightHint;
    data.widthHint = Math.max(widthHint, fImport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fImport.setLayoutData(data);
    fImport.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            performImport();
        }
    });

    fExport = new Button(parent, SWT.PUSH);
    fExport.setText("Export");
    Dialog.applyDialogFont(fImport);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.heightHint = heightHint;
    data.widthHint = Math.max(widthHint, fExport.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fExport.setLayoutData(data);
    fExport.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            performExport();
        }
    });

    fExportProject = new Button(parent, SWT.PUSH);
    fExportProject.setText("Export to Project");
    Dialog.applyDialogFont(fImport);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.heightHint = heightHint;
    data.widthHint = Math.max(widthHint, fExportProject.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fExportProject.setLayoutData(data);
    fExportProject.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            performProjectExport();
        }
    });

}

From source file:de.loskutov.eclipse.jdepend.preferences.JDependPreferencePage.java

License:Open Source License

private GridData getButtonGridData(Button button) {
    GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    GC gc = new GC(button);
    gc.setFont(button.getFont());/*from   ww  w .  ja  va  2 s  .c  o m*/
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

    gd.heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_HEIGHT);
    return gd;
}

From source file:descent.internal.ui.util.SWTUtil.java

License:Open Source License

/**
 * Returns a height hint for a button control.
 *//*from ww  w .  j a  v a2  s .co  m*/
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:gov.redhawk.ide.ui.preferences.IdlListEditor.java

License:Open Source License

@Override
protected void doFillIntoGrid(final Composite parent, final int numColumns) {
    final Control control = getLabelControl(parent);
    GridData gd = new GridData();
    gd.horizontalSpan = numColumns;//from ww w . j  a v a 2 s  . co  m
    control.setLayoutData(gd);

    this.list = new ListViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    this.list.setContentProvider(new ArrayContentProvider());
    this.list.setLabelProvider(new LabelProvider());
    this.list.setInput(this.idlLocations);
    this.list.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            IdlListEditor.this.removeButton.setEnabled(!event.getSelection().isEmpty());
            IdlListEditor.this.enableButtons();
        }
    });

    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.verticalAlignment = GridData.FILL;
    gd.horizontalSpan = numColumns - 1;
    gd.grabExcessHorizontalSpace = true;
    final int heightHint = convertVerticalDLUsToPixels(this.list.getList(),
            IDialogConstants.BUTTON_HEIGHT * IdlListEditor.NUM_BUTTONS);
    gd.heightHint = Math.max(heightHint, this.list.getList().computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    this.list.getList().setLayoutData(gd);

    this.buttonBox = getButtonBoxControl(parent);
    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    this.buttonBox.setLayoutData(gd);
}

From source file:gov.redhawk.sca.ui.preferences.DomainListEditor.java

License:Open Source License

@Override
protected void doFillIntoGrid(final Composite parent, final int numColumns) {
    final Control control = getLabelControl(parent);
    GridData gd = new GridData();
    gd.horizontalSpan = numColumns;/* w ww  . ja v a 2 s  . c om*/
    control.setLayoutData(gd);

    this.list = new ListViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    this.list.setContentProvider(new ArrayContentProvider());
    this.list.setLabelProvider(new LabelProvider());
    this.list.setInput(this.domainConnectionDefs);
    this.list.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            DomainListEditor.this.editButton.setEnabled(!event.getSelection().isEmpty());
            DomainListEditor.this.removeButton.setEnabled(!event.getSelection().isEmpty());
            DomainListEditor.this.autoConnectButton.setEnabled(!event.getSelection().isEmpty());
        }
    });

    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.verticalAlignment = GridData.FILL;
    gd.horizontalSpan = numColumns - 1;
    gd.grabExcessHorizontalSpace = true;
    final int heightHint = convertVerticalDLUsToPixels(this.list.getList(),
            IDialogConstants.BUTTON_HEIGHT * DomainListEditor.NUM_BUTTONS);
    gd.heightHint = Math.max(heightHint, this.list.getList().computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    this.list.getList().setLayoutData(gd);

    this.buttonBox = getButtonBoxControl(parent);
    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    this.buttonBox.setLayoutData(gd);
}