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.spearce.egit.ui.internal.preferences.GitDecoratorPreferencePage.java

License:Open Source License

private TextPair createFormatEditorControl(Composite composite, String title, String buttonText,
        final Map supportedBindings, int labelWidth) {

    Label label = SWTUtils.createLabel(composite, title);
    GridData labelGridData = new GridData();
    labelGridData.widthHint = labelWidth;
    label.setLayoutData(labelGridData);// w w  w.j a va  2s.co m

    Text format = new Text(composite, SWT.BORDER);
    GridData textGridData = new GridData(GridData.FILL_HORIZONTAL);
    textGridData.widthHint = 200;
    format.setLayoutData(textGridData);
    format.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updatePreview();
        }
    });
    Button b = new Button(composite, SWT.NONE);
    b.setText(buttonText);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, b.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    b.setLayoutData(data);
    final Text formatToInsert = format;
    b.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            addVariables(formatToInsert, supportedBindings);
        }
    });

    return new TextPair(format, null);
}

From source file:org.springframework.extensions.surf.alfresco.model.editor.control.ModelListEditor.java

License:Apache License

/**
 * Set the GridData on button to be one that is spaced for the
 * current font.//from   w ww . ja  v a 2  s.com
 * @param button the button the data is being set on.
 */

protected void setButtonLayoutData(Button button) {

    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);

    // Compute and store a font metric
    GC gc = new GC(button);
    gc.setFont(button.getFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    int widthHint = org.eclipse.jface.dialogs.Dialog.convertVerticalDLUsToPixels(fontMetrics,
            IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
}

From source file:org.springframework.ide.eclipse.ui.SpringUIUtils.java

License:Open Source License

/**
 * Returns a button with the given label, indentation, enablement and selection listener.
 *//*from   w w w  .  j  a v  a 2 s. co m*/
public static Button createButton(Composite parent, String labelText, SelectionListener listener,
        int indentation, boolean enabled) {
    Button button = new Button(parent, SWT.PUSH);
    button.setFont(parent.getFont());
    button.setText(labelText);
    button.addSelectionListener(listener);
    button.setEnabled(enabled);

    FontMetrics fontMetrics = getFontMetrics(button);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    gd.horizontalIndent = indentation;
    button.setLayoutData(gd);
    return button;
}

From source file:org.springsource.ide.eclipse.commons.frameworks.ui.internal.plugins.PluginManagerDialog.java

License:Open Source License

/**
 * Creates a button and adds appropriate listeners for a given operation
 * /*from www .j  a v a2  s .  com*/
 * @param parent
 * @param type
 * @return
 */
protected Button createSelectionButton(Composite parent, PluginOperation type) {
    if (type == null) {
        return null;
    }

    Button button = new Button(parent, SWT.PUSH);
    button.setText(type.getName());

    Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

    GridDataFactory.fillDefaults().hint(Math.max(widthHint, minSize.x), SWT.DEFAULT).applyTo(button);

    button.setData(type);
    button.addSelectionListener(new PluginSelectionButtonListener());
    return button;
}

From source file:org.talend.commons.ui.swt.advanced.composite.ArchiveDirectoryChooser.java

License:Open Source License

protected GridData setButtonLayoutData(Button button) {
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    int widthHint = IDialogConstants.BUTTON_WIDTH;
    Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);
    button.setLayoutData(data);/*  w  ww. ja v  a 2s  .c om*/
    return data;
}

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;/*from   w w w .  j av a2s  .  co m*/
    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);
    }
}

From source file:org.talend.commons.ui.swt.preferences.TableEditor.java

License:Open Source License

/**
 * Helper method to create a push button.
 * //from w  w w .  ja v a  2  s  .  c  om
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @return Button
 */
protected Button createPushButton(Composite parent, String key) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(JFaceResources.getString(key));
    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:org.talend.designer.core.ui.preferences.MetadataTalendTypeEditor.java

License:Open Source License

/**
 * Helper method to create a push button.
 * // ww w .j av  a 2 s.c  o  m
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @return Button
 */
protected 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);
    return button;
}

From source file:org.talend.designer.fileoutputxml.ui.footer.FooterComposite.java

License:Open Source License

/**
 * amaumont Comment method "createComponents".
 *///from   w ww. jav a 2  s  . c om
private void createComponents() {

    GridData footerCompositeGridData = new GridData(GridData.FILL_HORIZONTAL);
    this.setLayoutData(footerCompositeGridData);

    FormLayout formLayout = new FormLayout();
    this.setLayout(formLayout);

    Button okButton = new Button(this, SWT.NONE);
    okButton.setText(Messages.getString("FooterComposite.0")); //$NON-NLS-1$
    FormData okFormData = new FormData();
    Point minSize = okButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    okFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);

    okButton.setLayoutData(okFormData);
    okButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            if (foxManager.getUiManager().validateRootElement()) {
                foxManager.getUiManager().closeFOX(SWT.OK);
            } else {
                MessageDialog warningMessageDialog = new MessageDialog(composite.getShell(),
                        Messages.getString("FooterComposite.RootElementError.Title"), null, //$NON-NLS-1$
                        Messages.getString("FooterComposite.RootElementError.Message"), MessageDialog.ERROR, //$NON-NLS-1$
                        new String[] { Messages.getString("FooterComposite.0") }, 0); //$NON-NLS-1$
                warningMessageDialog.open();
            }
        }

    });

    Button cancelButton = new Button(this, SWT.NONE);
    cancelButton.setText(Messages.getString("FooterComposite.1")); //$NON-NLS-1$
    cancelButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            foxManager.getUiManager().closeFOX(SWT.CANCEL);
        }

    });

    FormData cancelFormData = new FormData();
    minSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    cancelFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);
    cancelButton.setLayoutData(cancelFormData);

    Button autoMapButton = new Button(this, SWT.NONE);
    // see bug 7087
    if (foxManager != null) {
        boolean canModify = foxManager.getFoxComponent().getProcess().isReadOnly();
        if (foxManager.getFoxComponent().getOriginalNode().getJobletNode() != null) {
            canModify = foxManager.getFoxComponent().isReadOnly();
        }
        if (canModify) {
            autoMapButton.setEnabled(false);
        }
    }
    autoMapButton.setToolTipText(Messages.getString("FooterComposite.AutoMapTip")); //$NON-NLS-1$
    autoMapButton.setText(Messages.getString("FooterComposite.AutoMap")); //$NON-NLS-1$
    autoMapButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            foxManager.getUiManager().autoMap();
        }

    });
    FormData autoMapFormData = new FormData();
    minSize = autoMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    autoMapFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);
    autoMapButton.setLayoutData(autoMapFormData);

    cancelFormData.right = new FormAttachment(100, -5);
    okFormData.right = new FormAttachment(cancelButton, -5);
    autoMapFormData.left = new FormAttachment(0, 5);

    // tree operation buttons
    FormData treeNodeData = new FormData();
    moveDown = new MoveDownTreeNodeButton(this, foxManager);
    treeNodeData.right = new FormAttachment(okButton, -5);
    moveDown.getButton().setLayoutData(treeNodeData);

    moveUpBtn = new MoveUpTreeNodeButton(this, foxManager);
    treeNodeData = new FormData();
    treeNodeData.right = new FormAttachment(moveDown.getButton(), -5);
    moveUpBtn.getButton().setLayoutData(treeNodeData);

    removeNodeBtn = new RemoveTreeNodeButton(this, foxManager);
    treeNodeData = new FormData();
    treeNodeData.right = new FormAttachment(moveUpBtn.getButton(), -5);
    removeNodeBtn.getButton().setLayoutData(treeNodeData);

    addNodeBtn = new AddTreeNodeButton(this, foxManager);
    treeNodeData = new FormData();
    treeNodeData.right = new FormAttachment(removeNodeBtn.getButton(), -5);
    addNodeBtn.getButton().setLayoutData(treeNodeData);

}

From source file:org.talend.designer.hl7.ui.footer.FooterComposite.java

License:Open Source License

private void createComponents() {

    GridData footerCompositeGridData = new GridData(GridData.FILL_HORIZONTAL);
    this.setLayoutData(footerCompositeGridData);

    FormLayout formLayout = new FormLayout();
    this.setLayout(formLayout);

    Button okButton = new Button(this, SWT.NONE);
    okButton.setText(Messages.getString("FooterComposite.0")); //$NON-NLS-1$
    FormData okFormData = new FormData();
    Point minSize = okButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    okFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);

    okButton.setLayoutData(okFormData);/*from  w w  w.  j  a  v  a  2 s . c  o  m*/
    okButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            // if (hl7Manager.getUiManager().validateRootElement()) {
            hl7Manager.getUiManager().closeHL7(SWT.OK);
            // } else {
            // MessageDialog warningMessageDialog = new MessageDialog(composite.getShell(), Messages
            //                            .getString("FooterComposite.RootElementError.Title"), null, //$NON-NLS-1$
            //                            Messages.getString("FooterComposite.RootElementError.Message"), MessageDialog.ERROR, //$NON-NLS-1$
            //                            new String[] { Messages.getString("FooterComposite.0") }, 0); //$NON-NLS-1$
            // warningMessageDialog.open();
            // }
        }

    });

    Button cancelButton = new Button(this, SWT.NONE);
    cancelButton.setText(Messages.getString("FooterComposite.1")); //$NON-NLS-1$
    cancelButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            hl7Manager.getUiManager().closeHL7(SWT.CANCEL);
        }

    });

    FormData cancelFormData = new FormData();
    minSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    cancelFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);
    cancelButton.setLayoutData(cancelFormData);

    Button autoMapButton = new Button(this, SWT.NONE);
    if (hl7Manager != null) {
        boolean canModify = hl7Manager.getHl7Component().getProcess().isReadOnly();
        if (hl7Manager.getHl7Component().getOriginalNode().getJobletNode() != null) {
            canModify = hl7Manager.getHl7Component().getOriginalNode().isReadOnly();
        }
        if (canModify) {
            autoMapButton.setEnabled(false);
        }
    }
    autoMapButton.setToolTipText(Messages.getString("FooterComposite.AutoMapTip")); //$NON-NLS-1$
    autoMapButton.setText(Messages.getString("FooterComposite.AutoMap")); //$NON-NLS-1$
    autoMapButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            hl7Manager.getUiManager().autoMap(hl7Manager.getCurrentSchema(false));
        }

    });
    FormData autoMapFormData = new FormData();
    minSize = autoMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    autoMapFormData.width = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x);
    autoMapButton.setLayoutData(autoMapFormData);

    cancelFormData.right = new FormAttachment(100, -5);
    okFormData.right = new FormAttachment(cancelButton, -5);
    // autoMapFormData.left = new FormAttachment(0, 5);

}