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

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

Introduction

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

Prototype

int BUTTON_WIDTH

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

Click Source Link

Document

Button width in dialog units (value 61).

Usage

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);/*  ww  w  . j  av a  2 s  . com*/
    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

/**
 * Sets the <code>GridData</code> on the specified button to be one that is spaced for the current dialog page units.
 * The method <code>initializeDialogUnits</code> must be called once before calling this method for the first time.
 *
 * @param button/* w  ww .  jav  a  2s. c o  m*/
 *          the button to set the <code>GridData</code>
 * @return the <code>GridData</code> set on the specified button
 */
protected GridData setButtonLayoutData(final Button button) {
    final GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    final int widthHint = IDialogConstants.BUTTON_WIDTH;
    // int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    final Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);
    button.setLayoutData(data);
    return data;
}

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

License:Open Source License

/**
 * Set the layout data of the button to a GridData with appropriate heights and widths.
 *
 * @param button/* w w w . ja  v  a2  s  .co m*/
 */
protected void setButtonLayoutData(final Button button) {
    final GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    final int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    final Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);
    button.setLayoutData(data);
}

From source file:org.kelvinst.psfimport.ui.importWizards.PsfImportWizardWorkingSetsSelectionPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);

    // GridLayout
    GridLayout layout1 = new GridLayout();
    layout1.numColumns = 1;//  w  w w  . ja  v  a2  s .c om
    composite.setLayout(layout1);

    // GridData
    GridData data1 = new GridData();
    data1.verticalAlignment = GridData.FILL;
    data1.horizontalAlignment = GridData.FILL;
    composite.setLayoutData(data1);
    initializeDialogUnits(composite);

    GridData comboData1 = new GridData(GridData.FILL_HORIZONTAL);
    comboData1.verticalAlignment = GridData.CENTER;
    comboData1.grabExcessVerticalSpace = false;
    comboData1.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

    Group workingSetGroup = new Group(composite, SWT.NONE);
    workingSetGroup.setFont(composite.getFont());
    workingSetGroup.setText("Working sets");
    workingSetGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    workingSetGroup.setLayout(new GridLayout(1, false));

    workingSetTypeIds = new String[] { "org.eclipse.ui.resourceWorkingSetPage", //$NON-NLS-1$
            "org.eclipse.jdt.ui.JavaWorkingSetPage" }; //$NON-NLS-1$
    Arrays.sort(workingSetTypeIds); // we'll be performing some searches
    // with these later - presort them
    selectedWorkingSets = EMPTY_WORKING_SET_ARRAY;
    workingSetSelectionHistory = loadSelectionHistory(workingSetTypeIds);
    setSelectedWorkingSets(findApplicableWorkingSets(null));

    createContent(workingSetGroup);

    setControl(composite);
    Dialog.applyDialogFont(parent);
}

From source file:org.kelvinst.psfimport.ui.importWizards.PsfImportWizardWorkingSetsSelectionPage.java

License:Open Source License

/**
 * Add this block to the <code>parent</parent>
 * //from  w w  w.  ja  v  a  2s  .  c o  m
 * @param parent
 *            the parent to add the block to
 */
public void createContent(final Composite parent) {
    int numColumn = 3;

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    composite.setLayout(new GridLayout(3, false));

    workingSetAutomagicModeButton = new Button(composite, SWT.CHECK);
    workingSetAutomagicModeButton.setText("Automagic mode");
    GridData automagicData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    automagicData.horizontalSpan = numColumn;
    workingSetAutomagicModeButton.setLayoutData(automagicData);

    workingSetEnableButton = new Button(composite, SWT.CHECK);
    workingSetEnableButton.setText("Add projec&t to working sets");
    GridData enableData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    enableData.horizontalSpan = numColumn;
    workingSetEnableButton.setLayoutData(enableData);
    workingSetEnableButton.setSelection(selectedWorkingSets.length > 0);

    workingSetLabel = new Label(composite, SWT.NONE);
    workingSetLabel.setText("W&orking sets:");

    workingSetCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER);
    GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    textData.horizontalSpan = numColumn - 2;
    textData.horizontalIndent = 0;
    workingSetCombo.setLayoutData(textData);

    workingSetSelectButton = new Button(composite, SWT.PUSH);
    workingSetSelectButton.setText("S&elect...");
    workingSetSelectButton.setFont(JFaceResources.getDialogFont());

    GC gc = new GC(workingSetSelectButton);
    gc.setFont(workingSetSelectButton.getFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    Point minSize = workingSetSelectButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);
    workingSetSelectButton.setLayoutData(data);

    workingSetSelectButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            SimpleWorkingSetSelectionDialog dialog = new SimpleWorkingSetSelectionDialog(parent.getShell(),
                    workingSetTypeIds, selectedWorkingSets, false);
            dialog.setMessage("The new project will be added to the selected working sets:");

            if (dialog.open() == Window.OK) {
                IWorkingSet[] result = dialog.getSelection();
                if (result != null && result.length > 0) {
                    selectedWorkingSets = result;
                    PlatformUI.getWorkbench().getWorkingSetManager().addRecentWorkingSet(result[0]);
                } else {
                    selectedWorkingSets = EMPTY_WORKING_SET_ARRAY;
                }
                updateWorkingSetSelection();
            }
        }
    });

    workingSetEnableButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateEnableState(workingSetEnableButton.getSelection());
        }
    });
    updateEnableState(workingSetEnableButton.getSelection());

    workingSetCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateSelectedWorkingSets();
        }
    });

    workingSetCombo.setItems(getHistoryEntries());
    if (selectedWorkingSets.length == 0 && workingSetSelectionHistory.size() > 0) {
        workingSetCombo.select(historyIndex(workingSetSelectionHistory.get(0)));
        updateSelectedWorkingSets();
    } else {
        updateWorkingSetSelection();
    }
}

From source file:org.maven.ide.eclipse.launch.Maven2PropertyAddDialog.java

License:Apache License

protected Control createDialogArea(Composite parent) {
    Composite comp = (Composite) super.createDialogArea(parent);
    ((GridLayout) comp.getLayout()).numColumns = 2;

    fNameLabel = new Label(comp, SWT.NONE);
    fNameLabel.setText(Messages.getString("launch.propertyDialog.name")); //$NON-NLS-1$;
    fNameLabel.setFont(comp.getFont());/*  ww  w.ja va2 s .  c o  m*/

    fNameText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    if (fInitialValues.length >= 1) {
        fNameText.setText(fInitialValues[0]);
    }
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 300;
    fNameText.setLayoutData(gd);
    fNameText.setFont(comp.getFont());
    fNameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updateButtons();
        }
    });

    fValueLabel = new Label(comp, SWT.NONE);
    fValueLabel.setText(Messages.getString("launch.propertyDialog.value")); //$NON-NLS-1$;
    fValueLabel.setFont(comp.getFont());

    fValueText = new Text(comp, SWT.BORDER | SWT.SINGLE);
    if (fInitialValues.length >= 2) {
        fValueText.setText(fInitialValues[1]);
    }
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 300;
    fValueText.setLayoutData(gd);
    fValueText.setFont(comp.getFont());
    fValueText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updateButtons();
        }
    });

    Button variablesButton = new Button(comp, SWT.PUSH);
    variablesButton.setText(Messages.getString("launch.propertyDialog.browseVariables")); //$NON-NLS-1$;
    gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gd.horizontalSpan = 2;
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    gd.widthHint = Math.max(widthHint, variablesButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    variablesButton.setLayoutData(gd);
    variablesButton.setFont(comp.getFont());

    variablesButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent se) {
            getVariable();
        }
    });

    return comp;
}

From source file:org.modelio.api.ui.ModelioWizardDialog.java

License:Apache License

@objid("bc1a871c-120f-11e2-b5c6-002564c97630")
@Override//from  w  w  w  .jav a 2s  .  co m
protected void setButtonLayoutData(final Button button) {
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

    // On large fonts this can make this dialog huge
    widthHint = Math.min(widthHint, button.getDisplay().getBounds().width / 5);
    Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);

    button.setLayoutData(data);
}

From source file:org.mwc.cmap.core.property_support.lengtheditor.preferences.LengthsLookupPreferencesPage.java

License:Open Source License

private void addReloadButton() {
    final Composite parent = getFieldEditorParent();
    final Button reloadButton = new Button(parent, SWT.PUSH);
    reloadButton.setText(Messages.LengthsLookupPreferencesPage_UpdateNow);
    reloadButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(final SelectionEvent e) {
            reloadDataFromFile();//w  ww  .j a  v  a2 s.c o m
        }

        public void widgetDefaultSelected(final SelectionEvent e) {
            // nothing
        }
    });

    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    widthHint = Math.max(widthHint, reloadButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

    GridDataFactory.fillDefaults().hint(widthHint, SWT.DEFAULT).align(SWT.FILL, SWT.CENTER)
            .applyTo(reloadButton);
}

From source file:org.obeonetwork.angularjs.eclipse.tools.ide.ui.internal.wizards.AngularJSSelectionButtonDialogField.java

License:Open Source License

@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
    assertEnoughColumns(nColumns);//w  w w .  j a v a  2s . co m

    Button button = getSelectionButton(parent);
    GridData gd = new GridData();
    gd.horizontalSpan = nColumns;
    gd.horizontalAlignment = GridData.FILL;
    if (this.buttonStyle == SWT.PUSH) {
        this.button.setFont(JFaceResources.getDialogFont());
        PixelConverter converter = new PixelConverter(button);
        int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
        widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
        gd.widthHint = widthHint;
    }

    button.setLayoutData(gd);

    return new Control[] { button };
}

From source file:org.obeonetwork.angularjs.eclipse.tools.ide.ui.internal.wizards.AngularJSStringButtonDialogField.java

License:Open Source License

protected static GridData gridDataForButton(Button button, int span) {
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = false;
    gd.horizontalSpan = span;/* w  w w  .  jav a2  s.c om*/
    button.setFont(JFaceResources.getDialogFont());
    PixelConverter converter = new PixelConverter(button);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    gd.widthHint = widthHint;
    return gd;
}