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:de.loskutov.eclipseskins.sessions.dialogs.ManageSessionsDialog.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 w w  w . j  a v  a2s  .c  om*/
    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, 14 /*IDialogConstants.BUTTON_HEIGHT*/);
    return gd;
}

From source file:de.plugins.eclipse.depclipse.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  .j a va  2s  .  co 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);
    return gd;
}

From source file:de.uni_hildesheim.sse.qmApp.dialogs.AboutDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(final Composite composite) {
    //Create apply - button we will use instead of the original one
    final Button applyButton = new Button(composite, SWT.PUSH);
    applyButton.setText("OK");

    final int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    final GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false);
    final org.eclipse.swt.graphics.Point minButtonSize = applyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT,
            true);/*  w  w w.j  a  v a 2s.c o m*/

    data.widthHint = Math.max(widthHint, minButtonSize.x);
    applyButton.setLayoutData(data);

    applyButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent exc) {
            composite.getShell().close();
        }
    });

    final GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns++;
}

From source file:de.walware.ecommons.ui.util.LayoutUtil.java

License:Open Source License

public static int hintWidth(final Button button) {
    button.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT));
    final PixelConverter converter = new PixelConverter(button);
    final int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}

From source file:de.walware.eutils.autorun.internal.AutoRunPreferencePage.java

License:Open Source License

@Override
protected Control createContents(final Composite parent) {
    this.launchManager = DebugPlugin.getDefault().getLaunchManager();

    final Composite composite = new Composite(parent, SWT.NONE);
    {/*from  ww  w  .  j  a va 2 s .  c  o  m*/
        final GridLayout gd = new GridLayout();
        gd.marginWidth = 0;
        gd.marginHeight = 0;
        gd.numColumns = 3;
        composite.setLayout(gd);
    }
    {
        this.enableButton = new Button(composite, SWT.CHECK);
        this.enableButton.setText("Enable &launch at startup of:");
        this.enableButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    }
    {
        this.entryViewer = new TreeViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
        final Tree tree = this.entryViewer.getTree();
        final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
        Dialog.applyDialogFont(this.entryViewer.getControl());
        gd.heightHint = tree.getItemHeight() * 10;
        this.entryViewer.getControl().setLayoutData(gd);

        this.entryViewer.setLabelProvider(DebugUITools.newDebugModelPresentation());
        this.entryViewer.setContentProvider(
                new LaunchConfigurationTreeContentProvider(ILaunchManager.RUN_MODE, getShell()) {
                    @Override
                    public Object[] getElements(final Object parentElement) {
                        final Object[] children = super.getChildren(parentElement);
                        final List<Object> filtered = new ArrayList<>(children.length);
                        for (int i = 0; i < children.length; i++) {
                            if (super.hasChildren(children[i])) {
                                filtered.add(children[i]);
                            }
                        }
                        return filtered.toArray();
                    }
                });
        this.entryViewer.setComparator(new LaunchConfigurationComparator());
    }
    {
        this.viewButton = new Button(composite, SWT.PUSH);
        this.viewButton.setText("View/&Edit...");
        final GridData gd = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
        Dialog.applyDialogFont(this.viewButton);
        gd.widthHint = Math.max(this.viewButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
                convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH));
        this.viewButton.setLayoutData(gd);
        this.viewButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                final Object element = ((IStructuredSelection) AutoRunPreferencePage.this.entryViewer
                        .getSelection()).getFirstElement();
                if (element instanceof ILaunchConfiguration) {
                    DebugUITools.openLaunchConfigurationPropertiesDialog(getShell(),
                            (ILaunchConfiguration) element, IDebugUIConstants.ID_RUN_LAUNCH_GROUP);
                }
            }
        });
    }
    {
        this.modeLabel = new Label(composite, SWT.NONE);
        this.modeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        this.modeLabel.setText("Launch &Mode:");

        this.modeViewer = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        this.modeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        this.modeViewer.setContentProvider(new ArrayContentProvider());
        this.modeViewer.setLabelProvider(new LabelProvider() {

            private final StringBuilder fStringBuilder = new StringBuilder();

            @Override
            public String getText(final Object element) {
                this.fStringBuilder.setLength(0);
                final Iterator<String> iter = ((Set<String>) element).iterator();
                if (iter.hasNext()) {
                    append(AutoRunPreferencePage.this.launchManager.getLaunchMode(iter.next()));
                    while (iter.hasNext()) {
                        this.fStringBuilder.append("+");
                        append(AutoRunPreferencePage.this.launchManager.getLaunchMode(iter.next()));
                    }
                }
                return this.fStringBuilder.toString();
            }

            private void append(final ILaunchMode mode) {
                final String s = mode.getLabel();
                for (int i = 0; i < s.length(); i++) {
                    final char c = s.charAt(i);
                    if (c == '&') {
                        i++;
                        if (i < s.length()) {
                            this.fStringBuilder.append(s.charAt(i));
                        }
                    } else {
                        this.fStringBuilder.append(c);
                    }
                }
            }
        });

        this.entryViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                updateModes();
            }
        });
        this.modeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                final Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
                if (element != null) {
                    AutoRunPreferencePage.this.lastMode = (Set<String>) element;
                }
            }
        });
    }

    Dialog.applyDialogFont(composite);

    loadConfigs();
    loadPrefs();

    return composite;
}

From source file:descent.internal.unittest.ui.LayoutUtil.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 * @param button   the button for which to set the dimension hint
 * @return the width hint//  ww  w.  java 2 s. c  o  m
 */
private static 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:fr.inria.atlanmod.emfviews.ui.wizard.view.CreateViewScreen.java

License:Open Source License

private Button createButton(Composite parent, String text) {
    Button button = new Button(parent, SWT.PUSH);
    button.setAlignment(SWT.CENTER);//from ww w .jav a 2 s .  co  m
    button.setText(text);
    button.setFont(parent.getFont());
    GridData data = new GridData();
    data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    button.setLayoutData(data);
    return button;
}

From source file:gov.nasa.ensemble.common.ui.PickListFieldEditor.java

License:Open Source License

/**
 * Helper method to create a push button.
 * //w w w  .  ja va 2  s  .com
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @return Button
 */
private Button createPushButton(Composite parent, String text) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(text);
    button.setFont(parent.getFont());
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    button.addSelectionListener(getSelectionListener());
    return button;
}

From source file:gov.redhawk.ide.ui.preferences.IdlListEditor.java

License:Open Source License

/**
 * Helper method to create a push button.
 * //from w  w w. ja  va2 s  .c om
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @return Button
 */
private Button createPushButton(final Composite parent, final String text) {
    final Button button = new Button(parent, SWT.PUSH);
    button.setText(text);
    button.setFont(parent.getFont());
    final GridData data = new GridData(GridData.FILL_HORIZONTAL);
    final int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    return button;
}

From source file:gov.redhawk.ui.util.SWTUtil.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 * //from www.ja va2  s  . c om
 * @param button the button
 * @return the button width hint
 */
public static int getButtonWidthHint(final Button button) {
    if (button.getFont().equals(JFaceResources.getDefaultFont())) {
        button.setFont(JFaceResources.getDialogFont());
    }
    final PixelConverter converter = new PixelConverter(button);
    final int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}