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.eclipse.wb.internal.core.utils.ui.dialogs.image.pages.FileImagePage.java

License:Open Source License

public FileImagePage(Composite parent, int style, AbstractImageDialog imageDialog) {
    super(parent, style, imageDialog);
    GridLayoutFactory.create(this).columns(2);
    // add dispose listener
    addListener(SWT.Dispose, new Listener() {
        public void handleEvent(Event event) {
            for (ImageInfo imageInfo : m_pathToImageInfo.values()) {
                imageInfo.getImage().dispose();
            }/*www. j a v a  2 s. co  m*/
        }
    });
    // path
    {
        m_pathText = new Text(this, SWT.BORDER);
        GridDataFactory.create(m_pathText).grabH().hintHC(50).fillH();
        // add listener
        m_pathText.addListener(SWT.Modify, new Listener() {
            public void handleEvent(Event event) {
                updateImageInfo();
            }
        });
    }
    // "Browse" button
    {
        Button button = new Button(this, SWT.NONE);
        GridDataFactory.create(button).hintHU(IDialogConstants.BUTTON_WIDTH).fill();
        button.setText(Messages.FileImagePage_browseButton);
        button.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {
                FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
                fileDialog.setFilterPath(m_pathText.getText());
                String newPath = fileDialog.open();
                if (newPath != null) {
                    m_pathText.setText(newPath);
                }
            }
        });
    }
}

From source file:org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage.java

License:Open Source License

public void createControl(Composite parent) {
    super.createControl(parent);
    Button defaultButton = getDefaultsButton();
    defaultButton.setText(Messages.Revert);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    Object layoutData = defaultButton.getLayoutData();
    if (layoutData instanceof GridData) {
        GridData data = (GridData) defaultButton.getLayoutData();
        Point minButtonSize = defaultButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        data.widthHint = Math.max(widthHint, minButtonSize.x);
        defaultButton.setLayoutData(data);
    }/*from  www .  j  a  v a2s.c  om*/
}

From source file:org.eclipse.wst.common.frameworks.internal.ui.NewProjectGroup.java

License:Open Source License

private void createUserSpecifiedProjectLocationGroup(Composite projectGroup) {
    Font font = projectGroup.getFont();
    // location label
    final Label locationLabel = new Label(projectGroup, SWT.NONE);
    locationLabel.setFont(font);//from  w  w  w.j av a 2 s .  c om
    locationLabel.setText(InternalCommonWorkbenchMessages.WizardNewProjectCreationPage_locationLabel);

    // project location entry field
    locationPathField = new Text(projectGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    locationPathField.setLayoutData(data);
    locationPathField.setFont(font);
    BidiUtils.applyBidiProcessing(locationPathField, StructuredTextTypeHandlerFactory.FILE);

    // browse button
    browseButton = new Button(projectGroup, SWT.PUSH);
    GridDataFactory.defaultsFor(browseButton).applyTo(browseButton);
    browseButton.setFont(font);
    browseButton.setText(defBrowseButtonLabel);
    GC gc = new GC(projectGroup);
    gc.setFont(projectGroup.getFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    Object layoutData = browseButton.getLayoutData();
    //This if statement fixes the truncated value of the browse button text
    if (layoutData instanceof GridData) {
        GridData dataForBrowseButton = (GridData) layoutData;
        Point minButtonSize = browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);

        dataForBrowseButton.widthHint = Math.max(widthHint, minButtonSize.x);
        dataForBrowseButton.heightHint = Math.max(dataForBrowseButton.heightHint, minButtonSize.y);

        browseButton.setLayoutData(dataForBrowseButton);
    }
    browseButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            handleLocationBrowseButtonPressed();
        }
    });

    final IDataModel localModel = model;

    class LocationListener implements ModifyListener, IDataModelListener {
        private boolean typing = false;

        public void modifyText(ModifyEvent e) {
            if (!localModel.getBooleanProperty(USE_DEFAULT_LOCATION)) {
                try {
                    typing = true;
                    localModel.setProperty(USER_DEFINED_LOCATION, locationPathField.getText());
                } finally {
                    typing = false;
                }
            }
        }

        public void propertyChanged(DataModelEvent event) {
            boolean useDefault = localModel.getBooleanProperty(USE_DEFAULT_LOCATION);
            if (USE_DEFAULT_LOCATION.equals(event.getPropertyName())) {
                locationLabel.setEnabled(!useDefault);
                locationPathField.setEnabled(!useDefault);
                browseButton.setEnabled(!useDefault);
                if (useDefault) {
                    locationPathField.setText(localModel.getStringProperty(DEFAULT_LOCATION));
                } else {
                    locationPathField.setText(localModel.getStringProperty(USER_DEFINED_LOCATION));
                }
            } else if (!typing) {
                if ((useDefault && DEFAULT_LOCATION.equals(event.getPropertyName()))
                        || (!useDefault && USER_DEFINED_LOCATION.equals(event.getPropertyName()))) {
                    locationPathField.setText((String) event.getProperty());
                }
            }
        }
    }

    LocationListener listener = new LocationListener();

    listener.propertyChanged(new DataModelEvent(model, USE_DEFAULT_LOCATION, IDataModel.VALUE_CHG));

    locationPathField.addModifyListener(listener);
    model.addListener(listener);
}

From source file:org.eclipse.wst.html.ui.internal.preferences.ui.HTMLSourcePreferencePage.java

License:Open Source License

private void createContentsForFormattingGroup(Composite parent) {
    Group formattingGroup = createGroup(parent, 2);
    formattingGroup.setText(HTMLUIMessages.Formatting_UI_);

    createLabel(formattingGroup, HTMLUIMessages.Line_width__UI_);
    fLineWidthText = new Text(formattingGroup, SWT.SINGLE | SWT.BORDER);
    GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.BEGINNING);
    gData.widthHint = 25;//from   www .j a v a  2s  . c o m
    fLineWidthText.setLayoutData(gData);
    fLineWidthText.addModifyListener(this);

    fSplitMultiAttrs = createCheckBox(formattingGroup, HTMLUIMessages.Split_multiple_attributes);
    ((GridData) fSplitMultiAttrs.getLayoutData()).horizontalSpan = 2;
    fAlignEndBracket = createCheckBox(formattingGroup, HTMLUIMessages.Align_final_bracket);
    ((GridData) fAlignEndBracket.getLayoutData()).horizontalSpan = 2;
    fClearAllBlankLines = createCheckBox(formattingGroup, HTMLUIMessages.Clear_all_blank_lines_UI_);
    ((GridData) fClearAllBlankLines.getLayoutData()).horizontalSpan = 2;

    // [269224] - Place the indent controls in their own composite for proper tab ordering
    Composite indentComposite = createComposite(formattingGroup, 1);
    ((GridData) indentComposite.getLayoutData()).horizontalSpan = 2;
    ((GridLayout) indentComposite.getLayout()).marginWidth = 0;
    ((GridLayout) indentComposite.getLayout()).marginHeight = 0;

    fIndentUsingTabs = createRadioButton(indentComposite, HTMLUIMessages.Indent_using_tabs);
    ((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 1;

    fIndentUsingSpaces = createRadioButton(indentComposite, HTMLUIMessages.Indent_using_spaces);
    ((GridData) fIndentUsingSpaces.getLayoutData()).horizontalSpan = 1;

    createLabel(formattingGroup, HTMLUIMessages.Indentation_size);
    fIndentationSize = new Spinner(formattingGroup, SWT.READ_ONLY | SWT.BORDER);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    fIndentationSize.setLayoutData(gd);
    fIndentationSize.setToolTipText(HTMLUIMessages.Indentation_size_tip);
    fIndentationSize.setMinimum(MIN_INDENTATION_SIZE);
    fIndentationSize.setMaximum(MAX_INDENTATION_SIZE);
    fIndentationSize.setIncrement(1);
    fIndentationSize.setPageIncrement(4);
    fIndentationSize.addModifyListener(this);

    GridData data;

    Composite inlineGroup = new Composite(formattingGroup, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    inlineGroup.setLayout(layout);

    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    inlineGroup.setLayoutData(data);

    Label label = createLabel(inlineGroup, HTMLUIMessages.Inline_elements_table_label);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    final TableViewer viewer = new TableViewer(inlineGroup,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 1;
    data.verticalAlignment = SWT.BEGINNING;
    data.heightHint = convertHeightInCharsToPixels(10);
    viewer.getTable().setLayoutData(data);

    Composite buttonContainer = new Composite(inlineGroup, SWT.NONE);
    data = new GridData(GridData.FILL_VERTICAL);
    buttonContainer.setLayoutData(data);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonContainer.setLayout(layout);

    fAddButton = new Button(buttonContainer, SWT.PUSH);
    fAddButton.setText(HTMLUIMessages.Add_inline);
    fAddButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            HTMLElementDialog dialog = new HTMLElementDialog(getShell());
            dialog.setMessage(HTMLUIMessages.Elements_Dialog_message);
            dialog.setTitle(HTMLUIMessages.Elements_Dialog_title);
            dialog.setMultipleSelection(true);
            dialog.setAllowDuplicates(false);
            dialog.open();
            Object[] result = dialog.getResult();
            if (result != null) {
                for (int i = 0; i < result.length; i++) {
                    fContentProvider.addElement(result[i].toString());
                }
                fViewer.refresh();
            }
        }
    });
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, fAddButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    data.horizontalSpan = 1;
    fAddButton.setLayoutData(data);

    fRemoveButton = new Button(buttonContainer, SWT.PUSH);
    fRemoveButton.setText(HTMLUIMessages.Remove_inline);
    fRemoveButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            ISelection selection = viewer.getSelection();
            if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) {
                Object[] remove = ((StructuredSelection) selection).toArray();
                for (int i = 0; i < remove.length; i++) {
                    fContentProvider.removeElement(remove[i].toString());
                }
                if (remove.length > 0) {
                    fViewer.refresh();
                }
            }
        }
    });
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    data.horizontalSpan = 1;
    fRemoveButton.setLayoutData(data);

    fViewer = viewer;
    fContentProvider = new ContentProvider();
    viewer.setContentProvider(fContentProvider);
    viewer.setInput(this);
    viewer.setComparator(new ViewerComparator(Collator.getInstance()));
}

From source file:org.eclipse.wst.xquery.set.internal.ui.preferences.SETSausalitoPropertyPage.java

License:Open Source License

private void createProjectConfigControls(final Composite composite) {
    Composite configBlock = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;/*from   ww w  .j ava  2s.c o m*/
    layout.marginWidth = 0;
    configBlock.setLayout(layout);
    configBlock.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label label = new Label(configBlock, SWT.NONE);
    label.setText("Project logical URI:");

    fUriLabel = new Label(configBlock, SWT.NONE);
    fUriLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    label = new Label(configBlock, SWT.NONE);
    label.setText("Version:");

    fVersionLabel = new Label(configBlock, SWT.NONE);
    fVersionLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    label = new Label(configBlock, SWT.NONE);
    label.setText("Start page:");

    fStartPageLabel = new Label(configBlock, SWT.NONE);
    fStartPageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    //        fStartPageLink.addSelectionListener(new SelectionAdapter() {
    //            @Override
    //            public void widgetSelected(SelectionEvent e) {
    //                String startPage = SETEditProjectConfigDialog.getHandlerFunctionStartPage(fProject, getShell());
    //                fStartPageLink.setText(startPage);
    //                fConfig.setStartPage(startPage);
    //            }
    //        });

    label = new Label(configBlock, SWT.NONE);
    label.setText("API Version:");

    fApiVersionLabel = new Label(configBlock, SWT.NONE);
    fApiVersionLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    updateConfigControls();

    createSeparator(configBlock);

    Composite buttonBar = new Composite(configBlock, SWT.NONE);
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonBar.setLayout(layout);

    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    buttonBar.setLayoutData(gd);

    Button changeButton = new Button(buttonBar, SWT.PUSH);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    Point minButtonSize = changeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd.widthHint = Math.max(widthHint, minButtonSize.x);
    changeButton.setLayoutData(gd);
    changeButton.setText("&Change...");
    changeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Shell shell = composite.getShell();
            SETEditProjectConfigDialog dialog = new SETEditProjectConfigDialog(shell, fProject, fConfig);
            if (dialog.open() == Window.OK) {
                fConfig = dialog.getProjectConfig();
                updateConfigControls();
            }
        }
    });
}

From source file:org.eclipsetrader.ui.internal.markets.HolidaysPage.java

License:Open Source License

protected void createButtons(Composite parent) {
    Composite content = new Composite(parent, SWT.NONE);
    content.setLayout(new GridLayout(1, false));
    ((GridLayout) content.getLayout()).marginWidth = 0;
    ((GridLayout) content.getLayout()).marginHeight = 0;
    content.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));

    add = new Button(content, SWT.PUSH);
    add.setText(Messages.HolidaysPage_Add);
    add.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    ((GridData) add.getLayoutData()).widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    add.addSelectionListener(new SelectionAdapter() {

        @Override/*w  w w.  ja va2s  . c  o  m*/
        public void widgetSelected(SelectionEvent e) {
            HolidayDialog dlg = new HolidayDialog(add.getShell(), null);
            if (dlg.open() == Window.OK) {
                input.add(dlg.getElement());
                viewer.refresh();
            }
        }
    });

    edit = new Button(content, SWT.PUSH);
    edit.setText(Messages.HolidaysPage_Edit);
    edit.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    ((GridData) edit.getLayoutData()).widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    edit.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            if (!selection.isEmpty()) {
                MarketHolidayElement element = (MarketHolidayElement) selection.getFirstElement();
                HolidayDialog dlg = new HolidayDialog(edit.getShell(), element);
                if (dlg.open() == Window.OK) {
                    viewer.refresh();
                }
            }
        }
    });

    remove = new Button(content, SWT.PUSH);
    remove.setText(Messages.HolidaysPage_Remove);
    remove.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    remove.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            if (!selection.isEmpty()) {
                input.removeAll(selection.toList());
                viewer.refresh();
            }
        }
    });
}

From source file:org.entirej.applicationframework.tmt.pages.EJTMTScreenPage.java

License:Apache License

protected void 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);/*ww w .  j a v  a  2 s. c om*/
}

From source file:org.entirej.applicationframework.tmt.pages.EJTMTScreenPage.java

License:Apache License

protected void setButtonLayoutFormData(Button button) {
    FormData data = new FormData();
    int widthHint = (IDialogConstants.BUTTON_WIDTH);
    Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.width = Math.max(widthHint, minSize.x);
    button.setLayoutData(data);//  www  .ja  va  2  s. com
}

From source file:org.erlide.ui.util.SWTUtil.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 *//*from   w  ww .j  av a2  s.c o m*/
public static int getButtonWidthHint(final Button button) {
    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:org.fusesource.ide.camel.editor.preferences.PreferredLabelEditor.java

License:Open Source License

/**
 * Helper method to create a push button.
 *
 * @param parent/*from   w  w  w  . j a  v a 2 s  .co  m*/
 *            the parent control
 * @param label
 *            the resource name used to supply the button's label text
 * @return Button
 */
private Button createPushButton(Composite parent, String label) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(label);
    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;
}