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

The following examples show how to use org.eclipse.swt.widgets.Control#getLayoutData() . 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: AbstractDefinitionWizardDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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
Source File: LineWrappingTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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
Source File: ComboBoxMeasureFieldEditor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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
Source File: PropertyAndPreferenceFieldEditorPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private static void setHorizontalGrabbing(Control control)
{
	Object ld = control.getLayoutData();
	if (ld instanceof GridData)
	{
		((GridData) ld).grabExcessHorizontalSpace = true;
	}
}
 
Example 5
Source File: LayoutUtil.java    From APICloud-Studio with GNU General Public License v3.0 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 6
Source File: CheckedTreeEditor.java    From cppcheclipse with 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 7
Source File: LayoutUtil.java    From birt with 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 8
Source File: LayoutUtil.java    From typescript.java with 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 9
Source File: WidgetUtil.java    From birt with 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 10
Source File: FileFieldEditorCustom.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void setVisible(Control control, boolean visible) {
    control.setVisible(visible);
    Object layoutData = control.getLayoutData();
    if (layoutData instanceof GridData) {
        ((GridData) layoutData).exclude = !visible;
    }
}
 
Example 11
Source File: LayoutUtil.java    From typescript.java with 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 12
Source File: SWTUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 File: PropertyAndPreferenceFieldEditorPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 14
Source File: WidgetUtil.java    From birt with 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 15
Source File: WidgetUtil.java    From birt with 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 16
Source File: LayoutUtil.java    From birt with 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 17
Source File: LayoutUtil.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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 18
Source File: GenericInfoPopupDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@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 19
Source File: LayoutUtil.java    From birt with 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 20
Source File: Widgets.java    From depan with 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();
}