Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » size of WorkbenchWindowControlContribution (how to set size of text field contributed to toolbar)
size of WorkbenchWindowControlContribution [message #537179] Tue, 01 June 2010 14:53 Go to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Hi, I defined Text field and image contribution to toolbar as follows. I want it to be like a line with link in a browser. The text value may change, but it should have constant width, much larger than it is created now. text.setSize and composite.setSize doesn't help.
public class ContextField extends WorkbenchWindowControlContribution {
	protected Control createControl(Composite parent) {		      
		Composite composite = new Composite(parent, SWT.NULL);
        GridLayout layout = new GridLayout(3, false);
        Label labelImage = new Label(composite, SWT.RIGHT);
        labelImage.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));   
		text = new Text(composite, SWT.SINGLE | SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		Point p = text.getSize();
		composite.setSize(320, p.y); // try 1 - doesn't help
		p = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		System.out.println("text width=" + p.x + " height=" + p.y);
		p = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                composite.setSize(350, p.y); // try 2 - doesn't help
		System.out.println("Composite width=" + p.x + " height=" + p.y);
		return composite;		
	public boolean isDynamic() {
		return true;

Re: size of WorkbenchWindowControlContribution [message #538219 is a reply to message #537179] Sun, 06 June 2010 16:55 Go to previous message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Found the solution: the widthHint of GridData, here is the example:
text = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.widthHint = 350;

Best regards, Stella
Previous Topic:SubMonitor : mixing undefined ticks with known ticks
Next Topic:How to set title in RCP application's View?
Goto Forum:

Current Time: Wed Jun 20 15:44:39 GMT 2018

Powered by FUDForum. Page generated in 0.02105 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top