Search in sources :

Example 1 with PixelConverter

use of org.eclipse.xtext.ui.util.PixelConverter in project xtext-eclipse by eclipse.

the class ResetPromptDialogSettingsField method createField.

protected ResetPromptDialogSettingsField createField(Composite parent, int colums) {
    if (dontAskGroup == null) {
        GridLayout layout = new GridLayout(2, false);
        dontAskGroup = new Group(parent, SWT.NONE);
        dontAskGroup.setLayout(layout);
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = colums;
        dontAskGroup.setLayoutData(gridData);
        dontAskGroup.setText(languageInfo.getShortName() + Messages.ResetPromptDialogSettingsField_0);
        Label label = new Label(dontAskGroup, SWT.WRAP);
        label.setText(Messages.ResetPromptDialogSettingsField_1);
        label.setFont(parent.getFont());
        GridData data = new GridData(GridData.FILL, GridData.CENTER, true, false);
        data.widthHint = new PixelConverter(parent).convertHorizontalDLUsToPixels(40);
        label.setLayoutData(data);
        Button clearButton = new Button(dontAskGroup, SWT.PUSH);
        // $NON-NLS-1$
        clearButton.setText("&Clear");
        GridData layoutData = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
        clearButton.setLayoutData(layoutData);
        clearButton.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                unhideAllDialogs();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                unhideAllDialogs();
            }
        });
        layoutData.widthHint = SWTUtil.getButtonWidthHint(clearButton);
    }
    return this;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) PixelConverter(org.eclipse.xtext.ui.util.PixelConverter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with PixelConverter

use of org.eclipse.xtext.ui.util.PixelConverter in project xtext-eclipse by eclipse.

the class ListDialogField method doFillIntoGrid.

// ------ layout helpers
/*
	 * @see DialogField#doFillIntoGrid
	 */
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
    PixelConverter converter = new PixelConverter(parent);
    assertEnoughColumns(nColumns);
    Label label = getLabelControl(parent);
    GridData gd = gridDataForLabel(1);
    gd.verticalAlignment = GridData.BEGINNING;
    label.setLayoutData(gd);
    Control list = getListControl(parent);
    gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = false;
    gd.verticalAlignment = GridData.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = nColumns - 2;
    gd.widthHint = converter.convertWidthInCharsToPixels(50);
    gd.heightHint = converter.convertHeightInCharsToPixels(6);
    list.setLayoutData(gd);
    Composite buttons = getButtonBox(parent);
    gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = false;
    gd.verticalAlignment = GridData.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = 1;
    buttons.setLayoutData(gd);
    return new Control[] { label, list, buttons };
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) PixelConverter(org.eclipse.xtext.ui.util.PixelConverter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 3 with PixelConverter

use of org.eclipse.xtext.ui.util.PixelConverter in project xtext-eclipse by eclipse.

the class AbstractValidatorConfigurationBlock method doCreateContents.

@Override
public Control doCreateContents(Composite parent) {
    fPixelConverter = new PixelConverter(parent);
    setShell(parent.getShell());
    Composite mainComp = new Composite(parent, SWT.NONE);
    mainComp.setFont(parent.getFont());
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    mainComp.setLayout(layout);
    Composite commonComposite = createStyleTabContent(mainComp);
    GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
    gridData.heightHint = fPixelConverter.convertHeightInCharsToPixels(20);
    commonComposite.setLayoutData(gridData);
    validateSettings(null, null, null);
    return mainComp;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) PixelConverter(org.eclipse.xtext.ui.util.PixelConverter) GridData(org.eclipse.swt.layout.GridData)

Aggregations

GridData (org.eclipse.swt.layout.GridData)3 PixelConverter (org.eclipse.xtext.ui.util.PixelConverter)3 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 Button (org.eclipse.swt.widgets.Button)1 Control (org.eclipse.swt.widgets.Control)1 Group (org.eclipse.swt.widgets.Group)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1