Java Code Examples for org.eclipse.jface.layout.PixelConverter#convertHorizontalDLUsToPixels()

The following examples show how to use org.eclipse.jface.layout.PixelConverter#convertHorizontalDLUsToPixels() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ButtonFactory.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public static Button newPushButton(Composite parent, String label) {
  Button button = new Button(parent, SWT.PUSH);
  button.setText(label);

  PixelConverter converter = new PixelConverter(button);
  int width = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);

  GridData buttonGridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
  buttonGridData.widthHint =
      Math.max(width, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

  button.setLayoutData(buttonGridData);
  return button;
}
 
Example 2
Source File: SWTFactory.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 */
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);
}
 
Example 3
Source File: SWTUtil.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 */
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);
}
 
Example 4
Source File: SelectionButtonDialogField.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 */
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);
}
 
Example 5
Source File: AddRemoveList.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the <code>GridData</code> on the specified button to be one that is spaced for the current dialog page
 * units. The method <code>initializeDialogUnits</code> must be called once before calling this method for the first
 * time.
 * 
 * @param button
 *            the button to set the <code>GridData</code>
 * @return the <code>GridData</code> set on the specified button
 */
protected GridData setButtonLayoutData(Button button)
{
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	data.widthHint = Math.max(widthHint, minSize.x);
	button.setLayoutData(data);
	return data;
}
 
Example 6
Source File: SWTUtil.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 */
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);
}
 
Example 7
Source File: SWTFactory.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 */
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);
}
 
Example 8
Source File: SWTUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 * @param button the button
 * @return the 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);
}
 
Example 9
Source File: EssentialsPage.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private Label createFormFieldLabel(final Composite composite, final String labelText) {
	Label label = formToolkit.createLabel(composite, labelText, SWT.NONE);
	PixelConverter converter = new PixelConverter(label);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	widthHint = Math.max(widthHint, label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
	GridDataFactory.swtDefaults().hint(widthHint, SWT.DEFAULT).applyTo(label);
	return label;
}
 
Example 10
Source File: PropertiesPage.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private Button createButton(Composite parent, String label) {
	Button button = formToolkit.createButton( parent, label, SWT.NULL);
	button.setFont(JFaceResources.getDialogFont());
	
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
	GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).hint(widthHint, SWT.DEFAULT).applyTo(button);

	return button;
}
 
Example 11
Source File: SWTUtil.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 * @param button the button
 * @return the 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);
}
 
Example 12
Source File: SWTFactory.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns a width hint for a button control.
 */
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);
}
 
Example 13
Source File: SWTFactory.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public static int getButtonWidthHint(Button button) {
	PixelConverter converter= new PixelConverter(button);
	int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
 
Example 14
Source File: TreeListDialogField.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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);
}
 
Example 15
Source File: SWTFactory.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public static int getButtonWidthHint(Button button) {
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}