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.webcat.eclipse.importer.SWTUtil.java
License:Open Source License
/** * Returns a width hint for a button control. * /*from www . j a va 2 s .c o m*/ * @param button the button * @return a width hint */ 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.whole.lang.ui.util.UIUtils.java
License:Open Source License
public static int getButtonWidthHint(Composite composite) { GC gc = new GC(composite); gc.setFont(composite.getFont());/* w ww . j a v a 2s . com*/ FontMetrics fFontMetrics = gc.getFontMetrics(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH); gc.dispose(); return widthHint; }
From source file:org.xmind.ui.internal.print.multipage.MultipageSetupDialog.java
License:Open Source License
@Override protected void setButtonLayoutData(Button button) { if (((Integer) button.getData()) == HIDE_DETAIL_ID) { GridData data = new GridData(SWT.LEFT, SWT.CENTER, true, false); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); org.eclipse.swt.graphics.Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data);//from w ww. ja va2 s. com } else { super.setButtonLayoutData(button); } }
From source file:org.zend.php.zendserver.deployment.ui.editors.ResourceListSection.java
License:Open Source License
private Button createButton(FormToolkit toolkit, Composite buttons, String message) { Button button = toolkit.createButton(buttons, message, SWT.NONE); GridData gd = new GridData(SWT.FILL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.TOP, true, false); button.setLayoutData(gd);//from w w w. j a va2 s . c o m // Set the default button size button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return button; }
From source file:raptor.pref.fields.ListEditor.java
License:Open Source License
/** * Helper method to create a push button. * //from ww w .j a v a2s. c o m * @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, String keyOverride) { Button button = new Button(parent, SWT.PUSH); button.setText(key != null ? JFaceResources.getString(key) : keyOverride); 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:si.gos.eclipse.parts.ActionPart.java
License:Open Source License
protected Button createButton(Composite parent, String label, int index, IWidgetFactory factory) { boolean visible = getAction(index).isVisible(); final Button button = factory.createButton(parent, label, SWT.PUSH); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.exclude = !visible;/*from ww w. j a v a 2s .c o m*/ button.setLayoutData(gd); button.setData(new Integer(index)); button.setVisible(visible); // add property change listener PartAction action = getAction(index); action.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String prop = event.getProperty(); if (prop.equals("enabled")) { button.setEnabled((Boolean) event.getNewValue()); } else if (prop.equals("visible")) { GridData gd = (GridData) button.getLayoutData(); gd.exclude = !(Boolean) event.getNewValue(); button.setLayoutData(gd); button.setVisible((Boolean) event.getNewValue()); button.getParent().layout(true, true); } else if (prop.equals("text")) { button.setText((String) event.getNewValue()); } } }); button.setData(ACTION_KEY, action); // Set the default button size button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return button; }