Java Code Examples for org.eclipse.swt.widgets.Composite#setBounds()

The following examples show how to use org.eclipse.swt.widgets.Composite#setBounds() . 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: ParameterExpandItem.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the control that is shown when the item is expanded.
 *
 * @param control
 *            the new control (or null)
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
 *                <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 *                </ul>
 */
public void setControl(final Composite control) {
	if (control != null) {
		if (control.isDisposed()) {
			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
		}
		if (control.getParent() != parent) {
			SWT.error(SWT.ERROR_INVALID_PARENT);
		}
	}
	this.control = control;
	if (control != null) {
		control.setVisible(expanded);
		final int headerHeight = parent.bandHeight;
		control.setBounds(x + BORDER, y + headerHeight, Math.max(0, width - 2 * BORDER),
				Math.max(0, height + BORDER));
		control.setBackground(IGamaColors.PARAMETERS_BACKGROUND.color());
	}
}
 
Example 2
Source File: PrimitiveQuestionnairePage.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
	final Composite container = new Composite(parent, SWT.NULL);
	container.setBounds(10, 10, 200, 300);
	// Updated the number of columns to order the questions vertically.
	final GridLayout layout = new GridLayout(1, false);
	container.setLayout(layout);
	// If legacy JSON files are in effect.

	for (final Question question : this.page.getContent()) {
		createQuestionControl(container, question);
	}
	setControl(container);

}
 
Example 3
Source File: BOSSplashHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IProgressMonitor getBundleProgressMonitor() {
    if (monitor == null) {
        if(getSplash() == null){
            return null ;
        }
        final Composite parent = new Composite(getSplash(), Window.getDefaultOrientation());
        final Point size = getSplash().getSize();
        parent.setBounds(new Rectangle(0,0,size.x,size.y));
        monitor = new CustomAbsolutePositionProgressMonitorPart(parent);
        monitor.setSize(size);
        if (progressRect != null) {
            monitor.getProgressIndicator().setBounds(progressRect);
        } else {
            monitor.getProgressIndicator().setVisible(false);
        }

        if (messageRect != null) {
            monitor.getProgressText().setBounds(messageRect);
        } else {
            monitor.getProgressText().setVisible(false);
        }


        monitor.getProgressText().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
        monitor.setBackgroundMode(SWT.INHERIT_FORCE);
        monitor.setBackgroundImage(getSplash().getShell()
                .getBackgroundImage());
    }
    return monitor;
}
 
Example 4
Source File: SWTHelper.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/** Ein Objekt innerhalb des parents zentrieren */
public static void center(final Shell parent, final Composite child){
	if (parent != null && child != null) {
		Rectangle par = parent.getBounds();
		Rectangle ch = child.getBounds();
		if (par != null && ch != null) {
			int xOff = (par.width - ch.width) / 2;
			int yOff = (par.height - ch.height) / 2;
			child.setBounds(par.x + xOff, par.y + yOff, ch.width, ch.height);
		}
	}
}
 
Example 5
Source File: RunMobileDialog.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected Control createDialogArea(Composite parent) {
	Composite comp = (Composite) super.createDialogArea(parent);
	comp.setLayout(new GridLayout(1, false));

	Composite composite = new Composite(comp, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
			1));
	formToolkit.adapt(composite);
	formToolkit.paintBordersFor(composite);

	Composite composite_1 = new Composite(composite, SWT.NONE);
	composite_1.setLayout(new GridLayout(1, false));
	composite_1.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true,
			false, 1, 1));
	formToolkit.adapt(composite_1);
	formToolkit.paintBordersFor(composite_1);

	Composite composite_6 = new Composite(composite_1, SWT.NONE);
	composite_6.setLayout(new GridLayout(2, false));
	composite_6.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false,
			false, 1, 1));
	composite_6.setBounds(0, 0, 64, 64);
	formToolkit.adapt(composite_6);
	formToolkit.paintBordersFor(composite_6);
	
	Label lblNewLabel_project = new Label(composite_6, SWT.NONE);
	lblNewLabel_project.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
			false, 1, 1));
	formToolkit.adapt(lblNewLabel_project, true, true);
	lblNewLabel_project.setText(Messages.RunSimulatorDialog_PROJECT_NAME);

	
	this.list = new ComboViewer(composite_6, SWT.READ_ONLY);
	GridData gd_text1 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
	gd_text1.widthHint = 181;
	this.list.getCombo().setLayoutData(gd_text1);
	this.list.setLabelProvider(new ProjectLabelProvider());
	this.list.setContentProvider(new ArrayContentProvider());
	this.list.setInput(projects);
	this.list.getCombo().select(0);
	formToolkit.adapt(list.getCombo(), true, true);

	return parent;
}
 
Example 6
Source File: CustomerLoaderDialog.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite comp = (Composite) super.createDialogArea(parent);
	comp.setLayout(new GridLayout(1, false));

	Composite composite = new Composite(comp, SWT.NONE);
	composite.setLayout(new GridLayout(1, false));
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
			1));
	formToolkit.adapt(composite);
	formToolkit.paintBordersFor(composite);

	Composite composite_1 = new Composite(composite, SWT.NONE);
	composite_1.setLayout(new GridLayout(1, false));
	composite_1.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true,
			false, 1, 1));
	formToolkit.adapt(composite_1);
	formToolkit.paintBordersFor(composite_1);

	Composite composite_6 = new Composite(composite_1, SWT.NONE);
	composite_6.setLayout(new GridLayout(2, false));
	composite_6.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false,
			false, 1, 1));
	composite_6.setBounds(0, 0, 64, 64);
	formToolkit.adapt(composite_6);
	formToolkit.paintBordersFor(composite_6);

	Label lblNewLabel_project = new Label(composite_6, SWT.NONE);
	lblNewLabel_project.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
			false, false, 1, 1));
	formToolkit.adapt(lblNewLabel_project, true, true);
	lblNewLabel_project.setText(Messages.RunSimulatorDialog_PROJECT_NAME);

	this.list = new ComboViewer(composite_6, SWT.READ_ONLY);
	GridData gd_text1 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1,
			1);
	gd_text1.widthHint = 181;
	this.list.getCombo().setLayoutData(gd_text1);
	this.list.setLabelProvider(new ProjectLabelProvider());
	this.list.setContentProvider(new ArrayContentProvider());
	this.list.setInput(projects);
	this.list.getCombo().select(0);
	formToolkit.adapt(list.getCombo(), true, true);

	return parent;
}
 
Example 7
Source File: CustomChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void createDropDownComponent( int iXLoc, int iYLoc )
{
	if ( !bEnabled )
	{
		return;
	}

	int shellWidth = this.getSize( ).x;
	Shell shell = new Shell( this.getShell( ), SWT.NONE );
	shell.setLayout( new FillLayout( SWT.FILL ) );
	if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 )
	{
		iXLoc -= shellWidth;
	}
	shell.setLocation( iXLoc, iYLoc );

	container = new ScrolledComposite( shell, SWT.V_SCROLL );
	container.setAlwaysShowScrollBars( false );
	container.setExpandHorizontal( true );

	cmpDropDown = new Composite( container, SWT.NONE );
	GridLayout gl = new GridLayout( );
	gl.horizontalSpacing = 0;
	gl.verticalSpacing = 0;
	gl.marginHeight = 0;
	gl.marginWidth = 0;
	cmpDropDown.setLayout( gl );

	Listener listenerCmpDropDown = new Listener( ) {

		public void handleEvent( Event event )
		{
			handleEventCmpDropDown( event );
		}
	};

	cmpDropDown.addListener( SWT.KeyDown, listenerCmpDropDown );
	cmpDropDown.addListener( SWT.FocusOut, listenerCmpDropDown );

	popupCanvases = new ICustomChoice[this.items.length];

	for ( int iC = 0; iC < items.length; iC++ )
	{
		ICustomChoice cnv = createChoice( cmpDropDown, items[iC] );
		GridData gd = new GridData( GridData.FILL_HORIZONTAL );
		cnv.setLayoutData( gd );
		cnv.addListener( SWT.MouseDown, canvasListener );
		cnv.addListener( SWT.MouseEnter, canvasListener );
		cnv.addListener( SWT.KeyDown, canvasListener );

		popupCanvases[iC] = cnv;
		if ( cnvSelection.getValue( ).equals( cnv.getValue( ) ) )
		{
			cnv.notifyListeners( SWT.FocusIn, new Event( ) );
			popupSelection = cnv;
		}
	}

	int width = 0;
	int height = 0;

	int maxWidth = 0;
	Control[] children = container.getChildren( );
	for ( int i = 0; i < children.length; i++ )
	{
		Point point = children[i].computeSize( SWT.DEFAULT, SWT.DEFAULT );
		maxWidth = point.x > maxWidth ? point.x : maxWidth;
		height += point.y;
	}
	
	width = getSize( ).x > maxWidth ? getSize( ).x : maxWidth;
	height = 18 > height ? 18 : height;

	cmpDropDown.setBounds( 0, 0, width, height );

	container.setContent( cmpDropDown );

	if ( height >= 298 )
	{
		int containerWidth = maxWidth
				+ container.getVerticalBar( ).getSize( ).x;
		width = width > containerWidth ? getSize( ).x : containerWidth;
	}

	shell.setSize( width, height < 298 ? height + 2 : 300 );

	shell.layout( );
	shell.open( );
}