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

The following examples show how to use org.eclipse.swt.widgets.Control#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 check out the related API usage on the sidebar.
Example 1
@Override
protected Control createButtonBar(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    final GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    layout.marginLeft = 5;
    layout.numColumns++;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    composite.setFont(parent.getFont());

    createToolbar(composite);

    final Control buttonSection = super.createButtonBar(composite);
    ((GridData) buttonSection.getLayoutData()).grabExcessHorizontalSpace = true;
    return composite;
}
 
Example 2
private void showSpecificControls(boolean show) {
      	if (fElements.size() != 1)
      		return;

      	Preference[] preferences= fElements.get(0).getSpecificPreferences();
   	if (preferences.length == 0)
   		return;

   	fRequiresRelayout= true;
   	for (int i= 0; i < preferences.length; i++) {
		Preference preference= preferences[i];
		Control control= preference.getControl();
		control.setVisible(show);
		((GridData)control.getLayoutData()).exclude= !show;
	}
}
 
Example 3
protected void adjustForNumColumns( int numColumns )
{
	Control control = getLabelControl( );
	if ( control != null )
	{
		( (GridData) control.getLayoutData( ) ).horizontalSpan = 1;
		numColumns--;
	}

	if ( hasChoice )
	{
		( (GridData) getComboBoxControl( parent ).getLayoutData( ) ).horizontalSpan = 1;
		( (GridData) getComboBoxControl( parent ).getLayoutData( ) ).widthHint = 70;
	}
	else
	{
		( (GridData) getTextControl( parent ).getLayoutData( ) ).horizontalSpan = 1;
		( (GridData) getTextControl( parent ).getLayoutData( ) ).widthHint = 85;
	}
	numColumns--;

	( (GridData) getMeasureControl( parent ).getLayoutData( ) ).horizontalSpan = numColumns;
	( (GridData) getMeasureControl( parent ).getLayoutData( ) ).widthHint = 65;

}
 
Example 4
/**
 * Sets the horizontal grabbing of a control to true. Assumes that GridData is used.
 */
public static void setHorizontalGrabbing(Control control)
{
	Object ld = control.getLayoutData();
	if (ld instanceof GridData)
	{
		((GridData) ld).grabExcessHorizontalSpace = true;
	}
}
 
Example 5
Source Project: birt   File: LayoutUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the span of a control. Assumes that GridData is used.
 */
public static void setHorizontalSpan(Control control, int span) {
	Object ld= control.getLayoutData();
	if (ld instanceof GridData) {
		((GridData)ld).horizontalSpan= span;
	} else if (span != 1) {
		GridData gd= new GridData();
		gd.horizontalSpan= span;
		control.setLayoutData(gd);
	}
}
 
Example 6
@Override
protected Control createTitleControl(Composite parent)
{
	Control control = super.createTitleControl(parent);
	Object data = control.getLayoutData();
	if (data instanceof GridData)
	{
		((GridData) data).horizontalSpan = 1;
	}
	return control;
}
 
Example 7
/**
 * Sets the horizontal indent of a control. Assumes that GridData is used.
 */
public static void setHorizontalIndent(Control control, int horizontalIndent) {
	Object ld = control.getLayoutData();
	if (ld instanceof GridData) {
		((GridData) ld).horizontalIndent = horizontalIndent;
	}
}
 
Example 8
Source Project: birt   File: LayoutUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the width hint of a control. Assumes that GridData is used.
 */
public static void setWidthHint(Control control, int widthHint) {
	Object ld= control.getLayoutData();
	if (ld instanceof GridData) {
		((GridData)ld).widthHint= widthHint;
	}
}
 
Example 9
Source Project: birt   File: WidgetUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the span of a control. Assumes that GridData is used.
 */
public static void setHorizontalSpan( Control control, int span )
{
	Object ld = control.getLayoutData( );
	if ( ld instanceof GridData )
	{
		( (GridData) ld ).horizontalSpan = span;
	}
	else if ( span != 1 )
	{
		GridData gd = new GridData( );
		gd.horizontalSpan = span;
		control.setLayoutData( gd );
	}
}
 
Example 10
Source Project: birt   File: WidgetUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the width hint of a control. Assumes that GridData is used.
 */
public static void setWidthHint( Control control, int widthHint )
{
	Object ld = control.getLayoutData( );
	if ( ld instanceof GridData )
	{
		( (GridData) ld ).widthHint = widthHint;
	}
}
 
Example 11
/**
 * Sets the span of a control. Assumes that GridData is used.
 */
private static void setHorizontalSpan(Control control, int span)
{
	Object ld = control.getLayoutData();
	if (ld instanceof GridData)
	{
		((GridData) ld).horizontalSpan = span;
	}
	else if (span != 1)
	{
		GridData gd = new GridData();
		gd.horizontalSpan = span;
		control.setLayoutData(gd);
	}
}
 
Example 12
/**
 * Sets the visibility of a control. Includes setting of the include property of the layoutData (if available)
 * 
 * @param visible
 */
public static void setVisiblity(Control control, boolean visible)
{
	if (control == null)
	{
		return;
	}

	control.setVisible(visible);
	Object layoutData = control.getLayoutData();
	if (layoutData instanceof GridData)
	{
		((GridData) layoutData).exclude = !visible;
	}
}
 
Example 13
Source Project: typescript.java   File: LayoutUtil.java    License: MIT License 5 votes vote down vote up
/**
 * Sets the width hint of a control. Assumes that GridData is used.
 */
public static void setWidthHint(Control control, int widthHint) {
	Object ld= control.getLayoutData();
	if (ld instanceof GridData) {
		((GridData)ld).widthHint= widthHint;
	}
}
 
Example 14
private void setVisible(Control control, boolean visible) {
    control.setVisible(visible);
    Object layoutData = control.getLayoutData();
    if (layoutData instanceof GridData) {
        ((GridData) layoutData).exclude = !visible;
    }
}
 
Example 15
Source Project: birt   File: WidgetUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the heightHint hint of a control. Assumes that GridData is used.
 */
public static void setHeightHint( Control control, int heightHint )
{
	Object ld = control.getLayoutData( );
	if ( ld instanceof GridData )
	{
		( (GridData) ld ).heightHint = heightHint;
	}
}
 
Example 16
Source Project: typescript.java   File: LayoutUtil.java    License: MIT License 5 votes vote down vote up
/**
 * Sets the horizontal grabbing of a control to true. Assumes that GridData is used.
 */
public static void setHorizontalGrabbing(Control control) {
	Object ld= control.getLayoutData();
	if (ld instanceof GridData) {
		((GridData)ld).grabExcessHorizontalSpace= true;
	}
}
 
Example 17
Source Project: birt   File: LayoutUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the heightHint hint of a control. Assumes that GridData is used.
 */
public static void setHeightHint(Control control, int heightHint) {
	Object ld= control.getLayoutData();
	if (ld instanceof GridData) {
		((GridData)ld).heightHint= heightHint;
	}
}
 
Example 18
Source Project: cppcheclipse   File: CheckedTreeEditor.java    License: Apache License 2.0 5 votes vote down vote up
protected void adjustForNumColumns(int numColumns) {
	Control control = getLabelControl();
	if (control != null) {
		((GridData) control.getLayoutData()).horizontalSpan = numColumns;
		((GridData) getTreeControl().getLayoutData()).horizontalSpan = numColumns;
	} else {
		((GridData) getTreeControl().getLayoutData()).horizontalSpan = numColumns;
	}
}
 
Example 19
private static void setHorizontalGrabbing(Control control)
{
	Object ld = control.getLayoutData();
	if (ld instanceof GridData)
	{
		((GridData) ld).grabExcessHorizontalSpace = true;
	}
}
 
Example 20
Source Project: depan   File: Widgets.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * When you need to tweak a layout.
 */
public static GridData getLayoutData(Control control) {
  return (GridData) control.getLayoutData();
}