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:com.nokia.cdt.internal.debug.launch.newwizard.ConnectToDeviceDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);/*www.j ava 2 s.c o m*/ final Composite composite = initDialogArea(parent, Messages.getString("ConnectToDeviceDialog.Title"), //$NON-NLS-1$ LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_CONNECTION); Group viewerGroup = new Group(composite, SWT.NONE); viewerGroup.setText(Messages.getString("ConnectToDeviceDialog.GroupLabel")); //$NON-NLS-1$ GridDataFactory.fillDefaults().applyTo(viewerGroup); GridLayoutFactory.swtDefaults().applyTo(viewerGroup); viewer = new ComboViewer(viewerGroup, SWT.READ_ONLY); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IConnection) return ((IConnection) element).getDisplayName(); return Messages.getString("ConnectToDeviceDialog.NoCurrentItem"); //$NON-NLS-1$ } }); viewer.setContentProvider(new ArrayContentProvider()); Combo combo = viewer.getCombo(); GridDataFactory.defaultsFor(combo).grab(true, false).applyTo(combo); viewer.getControl().setData(UID, "combo_viewer"); //$NON-NLS-1$ viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (getDialogArea() != null) connectionSelected(getConnectionFromSelection(event.getSelection())); } }); manager.addConnectionListener(this); parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { manager.removeConnectionListener(ConnectToDeviceDialog.this); if (currentServiceListener != null) currentServiceListener.removeStatusChangedListener(ConnectToDeviceDialog.this); } }); final Composite buttonGroup = new Composite(viewerGroup, SWT.NONE); int w = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_MARGIN); int h = Dialog.convertVerticalDLUsToPixels(fm, IDialogConstants.VERTICAL_MARGIN); int hs = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_SPACING); int vs = Dialog.convertVerticalDLUsToPixels(fm, IDialogConstants.VERTICAL_SPACING); GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).margins(w, h).spacing(hs, vs) .applyTo(buttonGroup); GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).applyTo(buttonGroup); buttonGroup.setFont(parent.getFont()); newButton = new Button(buttonGroup, SWT.PUSH); newButton.setText(Messages.getString("ConnectToDeviceDialog.NewLabel")); //$NON-NLS-1$ newButton.setFont(JFaceResources.getDialogFont()); int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH); Point minSize = newButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); widthHint = Math.max(widthHint, minSize.x); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.TOP).hint(widthHint, SWT.DEFAULT).applyTo(newButton); newButton.setData(UID, "newButton"); //$NON-NLS-1$ newButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SettingsWizard wizard = new SettingsWizard(null, connectionData.getService()); wizard.open(composite.getShell()); IConnection connection = wizard.getConnectionToEdit(); setViewerInput(connection); } }); editButton = new Button(buttonGroup, SWT.PUSH); editButton.setText(Messages.getString("ConnectToDeviceDialog.EditLabel")); //$NON-NLS-1$ editButton.setFont(JFaceResources.getDialogFont()); widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH); minSize = editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); widthHint = Math.max(widthHint, minSize.x); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).hint(widthHint, SWT.DEFAULT).applyTo(editButton); editButton.setData(UID, "editButton"); //$NON-NLS-1$ editButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IConnection connection = getConnectionFromSelection(viewer.getSelection()); if (connection != null) { SettingsWizard wizard = new SettingsWizard(connection, connectionData.getService()); wizard.open(composite.getShell()); } } }); descriptionLabel = new Label(composite, SWT.WRAP); GridDataFactory.defaultsFor(descriptionLabel).grab(false, true).applyTo(descriptionLabel); composite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { descriptionLabel.pack(); } }); setViewerInput(connectionData.getConnection()); return composite; }
From source file:com.nokia.s60tools.imaker.SWTFactory.java
License:Open Source License
public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(); int widthHint = converter.convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
From source file:com.nokia.tools.carbidect.cone.ui.internal.preferences.ConeFieldEditor.java
License:Open Source License
/** * Helper method to create a push button. * //from w ww . j a v a2 s. 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) { Button button = new Button(parent, SWT.PUSH); button.setText(JFaceResources.getString(key)); button.setFont(parent.getFont()); GridData data = new GridData(GridData.FILL_HORIZONTAL); // data.heightHint = convertVerticalDLUsToPixels(button, IDialogConstants.BUTTON_HEIGHT); 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:com.nokia.tools.s60.preferences.ExampleThemesPreferencePage.java
License:Open Source License
/** * /*from ww w . j a v a2 s. com*/ * @param button */ private void calculateButtonSize(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int wHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point mSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(wHint, mSize.x); button.setLayoutData(data); }
From source file:com.nokia.tools.s60.preferences.ExternalToolsPreferencePage.java
License:Open Source License
private void calculateButtonSize(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int wHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point mSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(wHint, mSize.x); button.setLayoutData(data);// w w w. jav a 2 s . c o m }
From source file:com.nokia.tools.s60.preferences.S60UICustomizationGeneralPreferencePage.java
License:Open Source License
protected void calculateButtonSize(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int wHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point mSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(wHint, mSize.x); button.setLayoutData(data);/*from w ww . j a v a2s . com*/ }
From source file:com.prodyna.bamboo.status.preferences.ProjectFieldEditor.java
License:Open Source License
private Button createPushButton(Composite parent, String key) { Button button = new Button(parent, SWT.PUSH); button.setText(JFaceResources.getString(key)); button.setFont(parent.getFont());//ww w .j av a 2 s . c o m 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(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { doLoad(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); return button; }
From source file:com.rawpixil.eclipse.launchpad.internal.ui.SWTFactory.java
License:Open Source License
/** * Returns a width hint for a button control. */// w ww . j a v a 2 s . c om 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:com.rohanclan.afae.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 www .jav a 2 s .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:com.salesforce.ide.ui.internal.utils.UIUtils.java
License:Open Source License
public static void setDefaultButtonLayoutData(Button button) { GC gc = new GC(button); try {/*from w ww . j a v a 2 s .c o m*/ gc.setFont(button.getFont()); FontMetrics fontMetrics = gc.getFontMetrics(); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); } finally { if (gc != null) { gc.dispose(); } } }