org.eclipse.swt.widgets.Composite#setBounds ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Composite#setBounds ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gama   文件: ParameterExpandItem.java
/**
 * 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());
	}
}
 
源代码2 项目: CogniCrypt   文件: PrimitiveQuestionnairePage.java
@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);

}
 
源代码3 项目: bonita-studio   文件: BOSSplashHandler.java
@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;
}
 
源代码4 项目: elexis-3-core   文件: SWTHelper.java
/** 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);
		}
	}
}
 
源代码5 项目: APICloud-Studio   文件: RunMobileDialog.java
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;
}
 
源代码6 项目: APICloud-Studio   文件: CustomerLoaderDialog.java
@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;
}
 
源代码7 项目: birt   文件: CustomChooserComposite.java
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( );
}