Example usage for org.eclipse.jface.dialogs Dialog convertVerticalDLUsToPixels

List of usage examples for org.eclipse.jface.dialogs Dialog convertVerticalDLUsToPixels

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog convertVerticalDLUsToPixels.

Prototype

public static int convertVerticalDLUsToPixels(FontMetrics fontMetrics, int dlus) 

Source Link

Document

Returns the number of pixels corresponding to the given number of vertical dialog units.

Usage

From source file:org.eclipse.cdt.debug.internal.ui.PixelConverter.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
 *///  www.  j  a v a  2  s .  com
public int convertVerticalDLUsToPixels(int dlus) {
    return Dialog.convertVerticalDLUsToPixels(getFontMetrics(), dlus);
}

From source file:org.eclipse.cdt.managedbuilder.ui.properties.DiscoveryTab.java

License:Open Source License

@Override
public void createControls(Composite parent) {
    super.createControls(parent);
    wrapper = new DiscoveryPageWrapper(this.page, this);
    usercomp.setLayout(new GridLayout(1, false));

    if (page.isForProject() || page.isForPrefs()) {
        Group scopeGroup = setupGroup(usercomp, Messages.DiscoveryTab_0, 1, GridData.FILL_HORIZONTAL);
        scopeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        scopeComboBox = new Combo(scopeGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
        scopeComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        scopeComboBox.add(Messages.DiscoveryTab_1);
        scopeComboBox.add(Messages.DiscoveryTab_2);
        scopeComboBox.addSelectionListener(new SelectionAdapter() {
            @Override//from   w w  w .j a va 2 s  . c  o  m
            public void widgetSelected(SelectionEvent e) {
                if (cbi == null)
                    return;
                cbi.setPerRcTypeDiscovery(scopeComboBox.getSelectionIndex() == 0);
                updateData();
            }
        });
    }

    // Create the sash form
    sashForm = new SashForm(usercomp, SWT.NONE);
    sashForm.setOrientation(SWT.HORIZONTAL);
    sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite comp = new Composite(sashForm, SWT.NONE);
    comp.setLayout(new GridLayout(1, true));
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));

    fTableDefinition = new Label(comp, SWT.LEFT);
    fTableDefinition.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    resTable = new Table(comp, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 150;
    resTable.setLayoutData(gd);
    resTable.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleToolSelected();
        }
    });
    initializeProfilePageMap();

    Composite c = new Composite(sashForm, 0);
    c.setLayout(new GridLayout(1, false));
    c.setLayoutData(new GridData(GridData.FILL_BOTH));

    createScannerConfigControls(c);

    profileOptionsComposite = new Composite(c, SWT.NONE);
    gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = Dialog.convertVerticalDLUsToPixels(getFontMetrics(parent), DEFAULT_HEIGHT);
    profileOptionsComposite.setLayoutData(gd);
    profileOptionsComposite.setLayout(new TabFolderLayout());

    fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
    setEnablement();

    sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.IUDetailsGroup.java

License:Open Source License

/**
 * Creates the group composite that holds the details area
 * @param parent The parent composite/*from   w ww .  j  av  a2 s.  co m*/
 */
void createGroupComposite(Composite parent) {
    Group detailsComposite = new Group(parent, SWT.NONE);
    GC gc = new GC(parent);
    gc.setFont(JFaceResources.getDialogFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    detailsComposite.setText(ProvUIMessages.ProfileModificationWizardPage_DetailsLabel);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    detailsComposite.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    detailsComposite.setLayoutData(gd);

    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.verticalIndent = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);
    gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics,
            ILayoutConstants.DEFAULT_DESCRIPTION_HEIGHT);
    gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics,
            ILayoutConstants.MINIMUM_DESCRIPTION_HEIGHT);
    gd.widthHint = widthHint;
    if (scrollable)
        detailsArea = new Text(detailsComposite, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
    else
        detailsArea = new Text(detailsComposite, SWT.WRAP | SWT.READ_ONLY);
    detailsArea.setLayoutData(gd);

    gd = new GridData(SWT.END, SWT.BOTTOM, true, false);
    gd.horizontalIndent = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN);
    propLink = createLink(detailsComposite,
            new PropertyDialogAction(new SameShellProvider(parent.getShell()), selectionProvider),
            ProvUIMessages.AvailableIUsPage_GotoProperties);
    propLink.setLayoutData(gd);

    // set the initial state based on selection
    propLink.setVisible(!selectionProvider.getSelection().isEmpty());

}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.StructuredIUGroup.java

License:Open Source License

protected int convertVerticalDLUsToPixels(int dlus) {
    return Dialog.convertVerticalDLUsToPixels(fm, dlus);
}

From source file:org.eclipse.gmf.runtime.common.ui.util.WindowUtil.java

License:Open Source License

/**
 * Returns height and width data in a GridData for the button that was
 * passed in.  You can call button.setLayoutData with the returned
 * data./*from  w w w . jav a  2  s . co  m*/
 * 
 * @param button which has already been made.  We'll be making the
 * GridData for this button, so be sure that the text has already
 * been set.
 * @return GridData for this button with the suggested height and width
 */
public static GridData makeButtonData(Button button) {
    GC gc = new GC(button);
    gc.setFont(button.getFont());

    GridData data = new GridData();
    data.heightHint = Dialog.convertVerticalDLUsToPixels(gc.getFontMetrics(), 14);
    data.widthHint = Math.max(
            Dialog.convertHorizontalDLUsToPixels(gc.getFontMetrics(), IDialogConstants.BUTTON_WIDTH),
            button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

    gc.dispose();

    return data;
}

From source file:org.eclipse.gmf.runtime.common.ui.util.WindowUtil.java

License:Open Source License

/**
 * Makes the GridData for a button to be a fixed size, regardless of
 * the contents of the button// w  w  w . java 2  s.com
 * @param button the button control that we'll make the GridData for.
 * @return GridData the new GridData for the button control.
 */
public static GridData makeFixedButtonData(Button button) {
    GC gc = new GC(button);
    gc.setFont(button.getFont());

    GridData gridData = new GridData();

    gridData.widthHint = Dialog.convertHorizontalDLUsToPixels(gc.getFontMetrics(),
            IDialogConstants.BUTTON_WIDTH);

    gridData.heightHint = Dialog.convertVerticalDLUsToPixels(gc.getFontMetrics(), 14);

    gc.dispose();

    return gridData;
}

From source file:org.eclipse.gmt.modisco.jm2t.internal.ui.util.SWTUtil.java

License:Open Source License

/**
 * Convert DLUs to pixels.// www  . jav  a  2  s .c  om
 * 
 * @param comp a component
 * @param y pixels
 * @return dlus
 */
public static int convertVerticalDLUsToPixels(Composite comp, int y) {
    if (fontMetrics == null)
        initializeDialogUnits(comp);
    return Dialog.convertVerticalDLUsToPixels(fontMetrics, y);
}

From source file:org.eclipse.jst.jsf.ui.internal.validation.PixelConverter.java

License:Open Source License

int convertVerticalDLUsToPixels(int dlus) {
    return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
}

From source file:org.eclipse.team.internal.ui.dialogs.DialogArea.java

License:Open Source License

protected int convertVerticalDLUsToPixels(int dlus) {
    return Dialog.convertVerticalDLUsToPixels(fontMetrics, dlus);
}

From source file:org.eclipse.team.internal.ui.synchronize.ConfigureSynchronizeScheduleComposite.java

License:Open Source License

protected void createMainDialogArea(Composite parent) {
    GC gc = new GC(parent);
    gc.setFont(JFaceResources.getDialogFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();/*from   ww  w .  j  av  a  2  s.  c  om*/
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.HORIZONTAL_SPACING);
    gridLayout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics,
            IDialogConstants.VERTICAL_SPACING);
    setLayout(gridLayout);
    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    Composite area = this;

    createWrappingLabel(area,
            NLS.bind(TeamUIMessages.ConfigureRefreshScheduleDialog_1, new String[] {
                    Utils.shortenText(SynchronizeView.MAX_NAME_LENGTH, schedule.getParticipant().getName()) }),
            0, 3);

    enableBackgroundRefresh = new Button(area, SWT.CHECK);
    GridData gridData = new GridData();
    gridData.horizontalSpan = 3;
    enableBackgroundRefresh.setLayoutData(gridData);
    enableBackgroundRefresh.setText(TeamUIMessages.ConfigureRefreshScheduleDialog_3);
    enableBackgroundRefresh.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            updateEnablements();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    synchronizeAt = createIndentedLabel(area, TeamUIMessages.ConfigureRefreshScheduleDialog_3a, 20);

    startTime = new DateTime(area, SWT.TIME | SWT.BORDER);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    startTime.setLayoutData(gridData);

    repeatEvery = createIndentedButton(area, TeamUIMessages.ConfigureRefreshScheduleDialog_4, 20);
    repeatEvery.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            updateEnablements();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    timeInterval = new Text(area, SWT.BORDER | SWT.RIGHT);
    gridData = new GridData();
    gridData.widthHint = 35;
    timeInterval.setLayoutData(gridData);
    timeInterval.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updateEnablements();
        }
    });
    timeInterval.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            String string = e.text;
            char[] chars = new char[string.length()];
            string.getChars(0, chars.length, chars, 0);
            for (int i = 0; i < chars.length; i++) {
                if (!('0' <= chars[i] && chars[i] <= '9')) {
                    e.doit = false;
                    return;
                }
            }
        }
    });

    hoursOrMinutes = new Combo(area, SWT.READ_ONLY);
    hoursOrMinutes.setItems(new String[] { TeamUIMessages.ConfigureRefreshScheduleDialog_5,
            TeamUIMessages.ConfigureRefreshScheduleDialog_6 }); // 
    hoursOrMinutes.setLayoutData(new GridData());

    final Label label = new Label(area, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    label.setLayoutData(gridData);
    label.setText(NLS.bind(TeamUIMessages.ConfigureRefreshScheduleDialog_2,
            new String[] { SubscriberRefreshSchedule.refreshEventAsString(schedule.getLastRefreshEvent()) }));

    initializeValues();
    updateEnablements();
}