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:hydrograph.ui.help.aboutDialog.HydrographInstallationDialog.java
License:Apache License
private void tabSelected(CTabItem item) { if (item.getData() instanceof IConfigurationElement) { final IConfigurationElement element = (IConfigurationElement) item.getData(); Composite pageComposite = (Composite) item.getControl(); try {//from www .j av a 2s.co m final InstallationPage page = (InstallationPage) element .createExecutableExtension(IWorkbenchRegistryConstants.ATT_CLASS); page.createControl(pageComposite); // new controls created since the dialog font was applied, so // apply again. Dialog.applyDialogFont(pageComposite); page.setPageContainer(this); // Must be done before creating the buttons because the control // button creation methods // use this map. pageToId.put(page, element.getAttribute(IWorkbenchRegistryConstants.ATT_ID)); createButtons(page); item.setData(page); item.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { page.dispose(); } }); pageComposite.layout(true, true); } catch (CoreException e1) { Label label = new Label(pageComposite, SWT.NONE); label.setText(e1.getMessage()); item.setData(null); } } String id = (String) item.getData(ID); rememberSelectedTab(id); buttonManager.update(id); Button button = createButton(buttonManager.getParent(), IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); GridData gd = (GridData) button.getLayoutData(); gd.horizontalAlignment = SWT.BEGINNING; gd.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH) / 2; // Layout the button bar's parent and all of its children. We must // cascade through all children because the buttons have changed and // because tray dialog inserts an extra composite in the button bar // hierarchy. getButtonBar().getParent().layout(true, true); }
From source file:ilg.gnumcueclipse.core.ui.XpackDirectoryNotStrictFieldEditor.java
License:Open Source License
protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns - 1); fXpackButton = new Button(parent, SWT.PUSH); fXpackButton.setText("xPack..."); fXpackButton.setFont(parent.getFont()); fXpackButton.addSelectionListener(new SelectionAdapter() { @Override//from www . jav a2s . c o m public void widgetSelected(SelectionEvent event) { buttonPressed(event); } }); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(fXpackButton, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, fXpackButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fXpackButton.setLayoutData(gd); fXpackButton.setEnabled(false); }
From source file:io.usethesource.impulse.preferences.fields.FontFieldEditor.java
License:Open Source License
protected void doFillIntoGrid(Composite parent, int numColumns) { getLabelControl(parent);/*w w w .j a va 2s. c o m*/ valueControl = getValueControl(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gd.horizontalSpan = numColumns - getNumberOfControls() + 1; valueControl.setLayoutData(gd); if (previewText != null) { previewer = new DefaultPreviewer(previewText, parent); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = previewer.getPreferredHeight(); gd.widthHint = previewer.getPreferredWidth(); previewer.getControl().setLayoutData(gd); } changeFontButton = getChangeControl(); gd = new GridData(); int widthHint = convertHorizontalDLUsToPixels(changeFontButton, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, changeFontButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); changeFontButton.setLayoutData(gd); }
From source file:io.usethesource.impulse.preferences.fields.StringButtonFieldEditor.java
License:Open Source License
protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns - 1); changeButton = getChangeControl(parent); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(changeButton, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, changeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); changeButton.setLayoutData(gd);/*from www .j a va 2 s.c o m*/ }
From source file:it.albertus.eqbulletin.gui.AboutDialog.java
private void createContents(final Shell shell) { GridLayoutFactory.swtDefaults().applyTo(shell); final LinkSelectionListener linkSelectionListener = new LinkSelectionListener(); final Link info = new Link(shell, SWT.WRAP); final FontRegistry fontRegistry = JFaceResources.getFontRegistry(); if (!fontRegistry.hasValueFor(SYM_NAME_FONT_DEFAULT)) { fontRegistry.put(SYM_NAME_FONT_DEFAULT, info.getFont().getFontData()); }//from ww w. ja v a 2 s.co m info.setFont(fontRegistry.getBold(SYM_NAME_FONT_DEFAULT)); final Version version = Version.getInstance(); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(info); Date versionDate; try { versionDate = version.getDate(); } catch (final Exception e) { logger.log(Level.WARNING, e.toString(), e); versionDate = new Date(); } info.setText(buildAnchor(Messages.get("url"), Messages.get("msg.application.name")) + ' ' + Messages.get("msg.version", version.getNumber(), DateFormat.getDateInstance(DateFormat.MEDIUM, Messages.getLanguage().getLocale()) .format(versionDate))); info.addSelectionListener(linkSelectionListener); final Link acknowledgementsLocations = new Link(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false) .applyTo(acknowledgementsLocations); acknowledgementsLocations.setText(Messages.get("lbl.about.acknowledgements.locations", buildAnchor(Messages.get("url.geofon"), Messages.get("lbl.geofon")), buildAnchor(Messages.get("url.gfz"), Messages.get("lbl.gfz")), buildAnchor(Messages.get("url.gevn"), Messages.get("lbl.gevn")))); acknowledgementsLocations.addSelectionListener(linkSelectionListener); final Label acknowledgementsData = new Label(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(acknowledgementsData); acknowledgementsData.setText(Messages.get("lbl.about.acknowledgements.data", Messages.get("lbl.geofon"), Messages.get("lbl.gfz"))); final Link linkLicense = new Link(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(linkLicense); linkLicense.setText( Messages.get("lbl.about.license", buildAnchor(Messages.get("url.gpl"), Messages.get("lbl.gpl")))); linkLicense.addSelectionListener(linkSelectionListener); final Text appLicense = new Text(shell, SWT.BORDER | SWT.V_SCROLL); appLicense.setText(loadTextResource("/META-INF/LICENSE.txt")); appLicense.setEditable(false); appLicense.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER) .hint(SWT.DEFAULT, SwtUtils.convertVerticalDLUsToPixels(appLicense, 80)).applyTo(appLicense); final Link linkEclipseLicense = new Link(shell, SWT.WRAP); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(linkEclipseLicense); linkEclipseLicense.setText(Messages.get("lbl.about.license.thirdparty", buildAnchor(Messages.get("url.epl"), Messages.get("lbl.epl")))); linkEclipseLicense.addSelectionListener(linkSelectionListener); final Button okButton = new Button(shell, SWT.PUSH); okButton.setText(Messages.get("lbl.button.ok")); final int buttonWidth = SwtUtils.convertHorizontalDLUsToPixels(okButton, IDialogConstants.BUTTON_WIDTH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false) .minSize(buttonWidth, SWT.DEFAULT).applyTo(okButton); okButton.setFocus(); okButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { shell.close(); } }); shell.setDefaultButton(okButton); }
From source file:mt.com.southedge.jclockwork.plugin.preferences.fieldeditors.collections.StringListFieldEditor.java
License:Open Source License
/** * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid (Composite, int) *//*from w w w .j a va 2s . com*/ protected void doFillIntoGrid(Composite parent, int numColumns) { top = parent; GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = numColumns; top.setLayoutData(gd); Label label = getLabelControl(top); GridData labelData = new GridData(); labelData.horizontalSpan = numColumns; label.setLayoutData(labelData); list = new List(top, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); GridData listData = new GridData(GridData.FILL_HORIZONTAL); listData.heightHint = convertVerticalDLUsToPixels(list, LIST_HEIGHT_IN_DLUS); listData.horizontalSpan = numColumns - 1; list.setLayoutData(listData); list.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectionChanged(); } }); // Create the remove button. remove = new Button(top, SWT.TOP); remove.setEnabled(false); remove.setText(DEFAULT_REMOVE_LABEL); remove.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { list.remove(list.getSelectionIndex()); selectionChanged(); } }); GridData removeData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); remove.setLayoutData(removeData); // Create the text field. textField = new Text(top, SWT.BORDER); GridData textData = new GridData(GridData.FILL_HORIZONTAL); textData.horizontalSpan = numColumns - 1; textData.verticalAlignment = GridData.BEGINNING; textField.setLayoutData(textData); textField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleChange(); } }); // Create the add button. add = new Button(top, SWT.NONE); add.setEnabled(false); add.setText(DEFAULT_ADD_LABEL); add.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { add(); } }); GridData addData = new GridData(GridData.FILL); addData.widthHint = convertHorizontalDLUsToPixels(add, IDialogConstants.BUTTON_WIDTH); add.setLayoutData(addData); }
From source file:net.bpelunit.framework.client.eclipse.dialog.Field.java
License:Open Source License
protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = getDialog().convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data);//from w w w.j a v a 2 s. com }
From source file:net.bpelunit.framework.client.eclipse.preferences.OptionTableFieldEditor.java
License:Open Source License
/** * Helper method to create a push button. * //from www. j av a2 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(Composite parent, String key) { Button button = new Button(parent, SWT.PUSH); button.setText(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:net.bpelunit.toolsupport.editors.wizards.fields.DialogField.java
License:Open Source License
/** * Returns a width hint for a button control. *//*from w ww. j a v a2 s. c om*/ public 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:net.rim.ejde.internal.ui.launchers.BBJRETab.java
License:Open Source License
/** * Sets the layout of the given <code>button</code>. * * @param button/*from w ww. j a va 2s. co m*/ */ public static void setDialogConfirmButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(IDialogConstants.BUTTON_WIDTH, minSize.x); button.setLayoutData(data); }