List of usage examples for org.eclipse.jface.dialogs IDialogConstants BUTTON_WIDTH
int BUTTON_WIDTH
To view the source code for org.eclipse.jface.dialogs IDialogConstants BUTTON_WIDTH.
Click Source Link
From source file:org.eclipse.acceleo.ui.interpreter.internal.view.wizards.NewVariableWizardPage.java
License:Open Source License
/** * Returns a width hint for a button control. * /*w ww . j a v a 2s . co m*/ * @param button * the button * @return the width hint */ public static int getButtonWidthHint(Button button) { Font font = JFaceResources.getDialogFont(); button.setFont(font); GC gc = new GC(font.getDevice()); gc.setFont(font); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:org.eclipse.actf.ai.voice.preferences.util.ComboButtonFieldEditor.java
License:Open Source License
protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns - 1); testButton = getButtonControl(parent); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(testButton, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, testButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); testButton.setLayoutData(gd);// ww w. j ava2 s. c o m }
From source file:org.eclipse.ant.internal.ui.preferences.AddPropertyDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite comp = (Composite) super.createDialogArea(parent); ((GridLayout) comp.getLayout()).numColumns = 2; fNameLabel = new Label(comp, SWT.NONE); fNameLabel.setText(AntPreferencesMessages.AddPropertyDialog__Name__1); fNameLabel.setFont(comp.getFont());//from w w w .ja v a2 s .co m fNameText = new Text(comp, SWT.BORDER | SWT.SINGLE); 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() { @Override public void modifyText(ModifyEvent e) { updateButtons(); } }); fValueLabel = new Label(comp, SWT.NONE); fValueLabel.setText(AntPreferencesMessages.AddPropertyDialog__Value__2); fValueLabel.setFont(comp.getFont()); fValueText = new Text(comp, SWT.BORDER | SWT.SINGLE); fValueText.setText(fInitialValues[1]); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = 300; fValueText.setLayoutData(gd); fValueText.setFont(comp.getFont()); fValueText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { updateButtons(); } }); Button variablesButton = new Button(comp, SWT.PUSH); variablesButton.setText(AntPreferencesMessages.AddPropertyDialog_2); 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() { @Override public void widgetSelected(SelectionEvent se) { getVariable(); } }); return comp; }
From source file:org.eclipse.b3.aggregator.presentation.VersionRangeEditorDialog.java
License:Open Source License
protected Control createPageArea(Composite parent) { final String[] inclusiveExclusive = new String[] { getString("_UI_VersionRangeEditor_inclusiveChoice"), getString("_UI_VersionRangeEditor_exclusiveChoice") }; topComposite = new Composite(parent, SWT.NONE); topComposite.setFont(parent.getFont()); topComposite.setLayout(new GridLayout(3, false)); topComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); new Label(topComposite, SWT.NONE).setText(getString("_UI_VersionRangeEditor_minimumVersionLabel")); minVersionText = new Text(topComposite, SWT.BORDER); minVersionText/*from w w w . j av a2 s . com*/ .setText(versionRange.getMinimum().getOriginal() != null ? versionRange.getMinimum().getOriginal() : versionRange.getMinimum().toString()); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = VERSION_TEXT_WIDTH_HINT; minVersionText.setLayoutData(gridData); minVersionInclusiveCombo = new Combo(topComposite, SWT.READ_ONLY); minVersionInclusiveCombo.setItems(inclusiveExclusive); minVersionInclusiveCombo.select(versionRange.getIncludeMinimum() ? 0 : 1); Label label = new Label(topComposite, SWT.NONE); label.setText(getString("_UI_VersionRangeEditor_maximumVersionLabel")); labelWidth = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x; maxVersionText = new Text(topComposite, SWT.BORDER); Version maxVersion = versionRange.getMaximum(); maxVersionText.setText((Version.MAX_VERSION.equals(maxVersion) || OSGi_versionMax.equals(maxVersion)) ? "" : maxVersion.getOriginal() != null ? maxVersion.getOriginal() : maxVersion.toString()); maxVersionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); maxVersionInclusiveCombo = new Combo(topComposite, SWT.READ_ONLY); maxVersionInclusiveCombo.setItems(inclusiveExclusive); maxVersionInclusiveCombo.select(versionRange.getIncludeMaximum() ? 0 : 1); ModifyListener modifyListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { okButton.setEnabled(isOKEnabled()); } }; minVersionText.addModifyListener(modifyListener); minVersionInclusiveCombo.addModifyListener(modifyListener); maxVersionText.addModifyListener(modifyListener); maxVersionInclusiveCombo.addModifyListener(modifyListener); statusLabel = new Label(topComposite, SWT.LEFT); GridData layoutData = new GridData(GridData.FILL, GridData.CENTER, true, false); layoutData.horizontalSpan = 3; statusLabel.setLayoutData(layoutData); if (feature != null) { Label setToAvailableVersionLabel = new Label(topComposite, SWT.NONE); setToAvailableVersionLabel.setText(B3Messages.VersionRangeDialog_AvailableVersions); if (feature.getAvailableVersions() != null && !feature.getAvailableVersions().isEmpty()) { Link versions = new Link(topComposite, SWT.NONE); versions.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1)); StringBuilder versionString = new StringBuilder(); String separator = ", "; //$NON-NLS-1$ for (AvailableVersion version : feature.getAvailableVersions()) { versionString.append("<A>"); //$NON-NLS-1$ versionString.append(version.getVersion().toString()); versionString.append("</A>"); //$NON-NLS-1$ versionString.append(separator); } versionString.delete(versionString.length() - 2, versionString.length()); versions.setText(versionString.toString()); versions.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String version = e.text; minVersionText.setText(version); maxVersionText.setText(version); okButton.setEnabled(isOKEnabled()); } }); } else { Label errorLabel = new Label(topComposite, SWT.NONE); errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1)); errorLabel.setText(NLS.bind(B3Messages.VersionRangeDialog_NoVersionFound, this.feature.getName())); errorLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED)); } } advancedComposite = new Composite(topComposite, SWT.NONE); advancedComposite.setFont(topComposite.getFont()); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 3; advancedComposite.setLayoutData(layoutData); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; advancedComposite.setLayout(layout); advancedButton = new Button(advancedComposite, SWT.PUSH); advancedButton.setFont(advancedComposite.getFont()); advancedButton.setText(IDEWorkbenchMessages.showAdvanced); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = IDialogConstants.BUTTON_WIDTH; Point minSize = advancedButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); data.horizontalAlignment = GridData.BEGINNING; advancedButton.setLayoutData(data); advancedButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAdvancedButtonSelect(); } }); return topComposite; }
From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.BaseStylePreferencePage.java
License:Open Source License
public void createControl(Composite parent) { GridData gd;//from www. j a va 2 s . c o m Composite content = new Composite(parent, SWT.NONE); setControl(content); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; content.setLayout(layout); // Apply the font on creation for backward compatibility applyDialogFont(content); // initialize the dialog units initializeDialogUnits(content); descriptionLabel = createDescriptionLabel(content); if (descriptionLabel != null) { descriptionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } body = createContents(content); if (body != null) { // null is not a valid return value but support graceful failure body.setLayoutData(new GridData(GridData.FILL_BOTH)); } Composite buttonBar = new Composite(content, SWT.NONE); layout = new GridLayout(); layout.numColumns = 0; layout.marginHeight = 0; layout.marginWidth = 0; layout.makeColumnsEqualWidth = false; buttonBar.setLayout(layout); gd = new GridData(GridData.HORIZONTAL_ALIGN_END); buttonBar.setLayoutData(gd); contributeButtons(buttonBar); if (createDefaultButton) { layout.numColumns = layout.numColumns + 1; String[] labels = JFaceResources.getStrings(new String[] { "defaults", "apply" }); //$NON-NLS-2$//$NON-NLS-1$ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); defaultsButton = new Button(buttonBar, SWT.PUSH); defaultsButton.setText(labels[0]); Dialog.applyDialogFont(defaultsButton); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); Point minButtonSize = defaultsButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minButtonSize.x); defaultsButton.setLayoutData(data); defaultsButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { performDefaults(); } }); applyDialogFont(buttonBar); } else { /* * Check if there are any other buttons on the button bar. If not, * throw away the button bar composite. Otherwise there is an * unusually large button bar. */ if (buttonBar.getChildren().length < 1) { buttonBar.dispose(); } } }
From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.WizardDialog.java
License:Open Source License
/** * Sets the layout data of the button to a GridData with appropriate heights * and widths./*from w w w . ja v a 2 s. c o m*/ * <p> * The <code>WizardDialog</code> override the method in order to make Help * button split with other buttons. * * @param button * the button to be set layout data to */ protected void setButtonLayoutData(Button button) { GridData data; if (button.getText().equals(IDialogConstants.HELP_LABEL)) { data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER); data.grabExcessHorizontalSpace = true; } else { data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); } data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); }
From source file:org.eclipse.birt.report.designer.internal.ui.preferences.TreeListDialogField.java
License:Open Source License
public 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:org.eclipse.birt.report.designer.ui.dialogs.ExpressionBuilder.java
License:Open Source License
/** * Sets the layout data of the button to a GridData with appropriate heights * and widths./*w w w. ja v a2 s . com*/ * <p> * The <code>BaseDialog</code> override the method in order to make Help * button split with other buttons. * * @param button * the button to be set layout data to */ protected void setButtonLayoutData(Button button) { GridData gridData; if (button.getText().equals(IDialogConstants.HELP_LABEL)) { gridData = new GridData(GridData.VERTICAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_CENTER); gridData.grabExcessVerticalSpace = true; } else { gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); } int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gridData.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(gridData); }
From source file:org.eclipse.birt.report.designer.ui.preferences.PreviewPreferencePage.java
License:Open Source License
/** * Create UI section for custom browser. * //www. jav a 2 s .co m * @param mainComposite */ private void createCustomBrowserPathPart(Composite mainComposite) { Font font = mainComposite.getFont(); // vertical space new Label(mainComposite, SWT.NULL); Composite bPathComposite = new Composite(mainComposite, SWT.NULL); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 3; bPathComposite.setLayout(layout); bPathComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); customBrowserPathLabel = new Label(bPathComposite, SWT.LEFT); customBrowserPathLabel.setFont(font); customBrowserPathLabel.setText(Messages.getString("designer.preview.preference.browser.program")); //$NON-NLS-1$ // Browser path text customBrowserPath = new Text(bPathComposite, SWT.BORDER); customBrowserPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); customBrowserPath.setFont(font); customBrowserPath.setText( ViewerPlugin.getDefault().getPluginPreferences().getString(CustomBrowser.CUSTOM_BROWSER_PATH_KEY)); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalAlignment = GridData.FILL; data.widthHint = convertWidthInCharsToPixels(10); customBrowserPath.setLayoutData(data); // Custom browser button customBrowserBrowse = new Button(bPathComposite, SWT.NONE); customBrowserBrowse.setFont(font); customBrowserBrowse.setText(Messages.getString("designer.preview.preference.browser.browse")); //$NON-NLS-1$ data = new GridData(); data.horizontalAlignment = GridData.FILL; data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, customBrowserBrowse.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); customBrowserBrowse.setLayoutData(data); customBrowserBrowse.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent event) { } public void widgetSelected(SelectionEvent event) { FileDialog d = new FileDialog(getShell()); d.setText(Messages.getString("designer.preview.preference.browser.details")); //$NON-NLS-1$ String file = d.open(); if (file != null) { customBrowserPath.setText("\"" + file + "\" %1"); //$NON-NLS-1$ //$NON-NLS-2$ } } }); // Toggle custom browser enabled or not setCustomBrowserPathEnabled(); }
From source file:org.eclipse.birt.report.designer.ui.preferences.SelectionButtonDialogField.java
License:Open Source License
public Control[] doFillIntoGrid(Composite parent, int nColumns) { assertEnoughColumns(nColumns);//from w w w .j a v a 2 s. c o m Button button = getSelectionButton(parent); GridData gd = new GridData(); gd.horizontalSpan = nColumns; gd.horizontalAlignment = GridData.FILL; if (fButtonStyle == SWT.PUSH) { GC gc = new GC(button.getFont().getDevice()); gc.setFont(button.getFont()); FontMetrics fFontMetrics = gc.getFontMetrics(); gc.dispose(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); } button.setLayoutData(gd); return new Control[] { button }; }