Java Code Examples for org.eclipse.swt.widgets.Label#getLayoutData()

The following examples show how to use org.eclipse.swt.widgets.Label#getLayoutData() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
public void setVisible(boolean visible, Composite parent) {
    Label labelControl = getLabelControl(parent);
    Text textControl = getTextControl(parent);
    labelControl.setVisible(visible);
    textControl.setVisible(visible);

    Object layoutData = labelControl.getLayoutData();
    if (layoutData instanceof GridData) {
        ((GridData) layoutData).exclude = !visible;
    }
    layoutData = textControl.getLayoutData();
    if (layoutData instanceof GridData) {
        ((GridData) layoutData).exclude = !visible;
    }

}
 
Example 2
public void setVisible(boolean visible, Composite parent) {
    if (!useGroup) {
        Label labelControl = getLabelControl(parent);
        labelControl.setVisible(visible);
        Object layoutData = labelControl.getLayoutData();
        if (layoutData instanceof GridData) {
            ((GridData) layoutData).exclude = !visible;
        }

        radioBox.setVisible(visible);
        layoutData = radioBox.getLayoutData();
        if (layoutData instanceof GridData) {
            ((GridData) layoutData).exclude = !visible;
        }
    } else {
        // TODO: Implement when needed.
    }

}
 
Example 3
/**
 * Creates the status and close section of the dialog.
 *
 * @param parent
 *            the parent composite
 * @return the status and close button
 */
private Composite createStatusAndCloseButton(Composite parent) {

    Composite panel = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    panel.setLayout(layout);

    fStatusLabel = new Label(panel, SWT.LEFT);
    fStatusLabel.setText(Messages.TimeGraphFindDialog_StatusWrappedLabel);
    setGridData(fStatusLabel, SWT.FILL, true, SWT.CENTER, false);
    GridData gd = (GridData) fStatusLabel.getLayoutData();
    gd.widthHint = fStatusLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    fStatusLabel.setText("");  //$NON-NLS-1$

    Composite buttonSection = new Composite(panel, SWT.NULL);
    GridLayout buttonLayout = new GridLayout();
    buttonLayout.numColumns = 2;
    buttonSection.setLayout(buttonLayout);

    String label = Messages.TimeGraphFindDialog_CloseButtonLabel;
    Button closeButton = createButton(buttonSection, 101, label, false);
    setGridData(closeButton, SWT.RIGHT, false, SWT.BOTTOM, false);

    fFindNextButton = makeButton(buttonSection, Messages.TimeGraphFindDialog_FindNextButtonLabel, 102, true, new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            performSearch(((e.stateMask & SWT.SHIFT) != 0) ^ isForwardSearch());
            updateFindHistory();
        }
    });
    setGridData(fFindNextButton, SWT.FILL, true, SWT.FILL, false);

    return panel;
}
 
Example 4
/**
 * Update the width of the label to take into account the error font. Only works for labels in a grid layout
 * 
 * @param label
 * @param errorFont
 */
public static void updateErrorLabelWidth(Label label, Font errorFont)
{
	Object layoutData = label.getLayoutData();
	if (layoutData instanceof GridData)
	{
		Font currentFont = label.getFont();
		label.setFont(errorFont);
		((GridData) layoutData).widthHint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
		label.setFont(currentFont);
	}
}
 
Example 5
public static Label createLabel(Composite parent, String text, int span, int indent, boolean bold, int fill) {
    Label label = createLabel(parent, text, span, SWT.NONE, fill);
    if (bold) {
        label.setFont(JFaceResources.getDialogFontDescriptor().withStyle(SWT.BOLD).createFont(null));
    }
    GridData gridData = (GridData) label.getLayoutData();
    gridData.horizontalIndent = indent;    

    return label;
}
 
Example 6
Source Project: birt   File: MeasureDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private int getLabelWidth( Label label )
{
    Object layout = label.getLayoutData( );
    if ( layout instanceof GridData )
    {
        if ( ( (GridData) layout ).horizontalSpan == 1 )
        {
            return label.getBounds( ).width - label.getBorderWidth( ) * 2;
        }
    }
    return 0;
}
 
Example 7
Source Project: uima-uimaj   File: AbstractDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * New error message.
 *
 * @param twoCol the two col
 * @param span the span
 */
protected void newErrorMessage(Composite twoCol, int span) {
  Label m = new Label(twoCol, SWT.WRAP);
  m.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  ((GridData) m.getLayoutData()).horizontalSpan = span;
  ((GridData) m.getLayoutData()).widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
  errorMessageUI = m;
}
 
Example 8
private void createHeader(Composite composite, boolean editable) {
	UI.filler(composite);
	if (editable) {
		UI.filler(composite);
	}
	for (int i = 1; i <= getModel().getScoreCount(); i++) {
		String scoreLabel = getModel().getScoreLabel(i);
		if (scoreLabel == null) {
			scoreLabel = Integer.toString(i);
		}
		if (editable) {
			Text labelText = createTextCell(composite, 1, 8);
			labelText.setText(scoreLabel);
			int pos = i;
			labelText.addModifyListener((e) -> {
				getModel().setScoreLabel(pos, labelText.getText());
				getEditor().setDirty(true);
			});
			scoreTexts.put(i, labelText);
			commentControl(composite, "scores[" + i + "]");
		} else {
			Label label = UI.formLabel(composite, scoreLabel);
			label.setToolTipText(scoreLabel);
			setGridData(label, 1, 8);
			((GridData) label.getLayoutData()).horizontalAlignment = SWT.CENTER;
			Text scoreText = scoreTexts.get(i);
			scoreText.addModifyListener((e) -> {
				label.setText(scoreText.getText());
				label.setToolTipText(scoreText.getText());
			});
			UI.filler(composite);
		}
	}
}
 
Example 9
public void resizeLabel(final int width) {
	final Label l = getLabel();
	if (l != null) {
		((GridData) l.getLayoutData()).widthHint = width;
	}
}
 
Example 10
/**
 * Creates a wrapping label
 * 
 * @param parent
 *            the parent composite to add this label to
 * @param text
 *            the text to be displayed in the label
 * @param hspan
 *            the horizontal span that label should take up in the parent composite
 * @param wrapwidth
 *            the width hint that the label should wrap at
 * @return a new label that wraps at a specified width
 */
public static Label createWrapLabel(Composite parent, String text, int hspan, int wrapwidth)
{
	Label l = createLabel(parent, text, 0, parent.getFont(), hspan);
	((GridData) l.getLayoutData()).widthHint = wrapwidth;

	return l;
}