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 Levin
Messages: 88
Registered: July 2009
Member
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);
        composite.setLayout(layout);
        
        Label labelImage = new Label(composite, SWT.RIGHT);
        labelImage.setImage(image);
        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;		
	}
	
	@Override
	public boolean isDynamic() {
		return true;
	}

Thanks
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 Levin
Messages: 88
Registered: July 2009
Member
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;
text.setLayoutData(data);

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: Fri Oct 24 16:59:10 GMT 2014

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

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