Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem with Gridlayout
Problem with Gridlayout [message #669213] Mon, 09 May 2011 13:55 Go to next message
arthurembo Simo is currently offline arthurembo SimoFriend
Messages: 16
Registered: May 2011
Location: Germany
Junior Member
Hi,

I have a simple use case, but I don't understand it don't work. I have a view and I want to add a Gridlayout to my view. It's look like that:

@Override
	public void createPartControl(Composite parent) {
		Layout l = parent.getLayout();
		Composite composite = new Composite(parent, SWT.NULL);
        GridLayout gridLayout = new GridLayout(1, false);
        composite.setLayout(gridLayout);
        GridData data = new GridData(GridData.FILL_BOTH);
        composite.setLayoutData(data);
        composite.layout();
        
        // add row to show the number of results
        Label resultInfos = new Label(composite, SWT.NONE); 
        
        // add treeviewer
		resultTreeViewer = new TreeViewer(composite);
		resultTreeViewer.setContentProvider(new CSResultTreeContentProvider());
		resultTreeViewer.setLabelProvider(new CSResultTreeLabelProvider());
		Object result = Activator.getDefault().getComponentsSearchResult();
		if (result instanceof Set<?>){
			Set<?> input = (Set<?>) result;
			// set the number of results
			resultInfos.setText(input.size() + " Manöver found!");
			TreeNode rootNode = new TreeNode("root", null);
			boolean isNotNode = false;
			for(Object node:input){
				if (node instanceof Node){
					try {
						String nodeName = DomReader.getTextContent((Node) node, "MANEUVERNAME");
						TreeNode child = new TreeNode(nodeName, node);
						rootNode.addChild(child);
					} catch (XPathExpressionException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					
					
				}else{
					isNotNode = true;
					break;
				}
			}
			
			if (!isNotNode){
				resultTreeViewer.setInput(rootNode);
			}
		}
	}



The result is in the attached file.

I want that the treeviewer fill horizontaly my view and scroll vertically, when the number of results big is.

Thanks for your help

Best regards

Re: Problem with Gridlayout [message #669240 is a reply to message #669213] Mon, 09 May 2011 15:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 05/09/2011 09:55 AM, arthurembo wrote:
> Hi,
>
> I have a simple use case, but I don't understand it don't
> work. I have a view and I want to add a Gridlayout to my
> view. It's look like that:
>
>
> @Override
> public void createPartControl(Composite parent) {
> Layout l = parent.getLayout();
> Composite composite = new Composite(parent, SWT.NULL);
> GridLayout gridLayout = new GridLayout(1, false);
> composite.setLayout(gridLayout);
> GridData data = new GridData(GridData.FILL_BOTH);
> composite.setLayoutData(data);

Uh, you cannot set GridData on your composite (the layout data goes with
the parent layout, and the parent Composite is probably a FillLayout).

> composite.layout();

Don't do this ^^^^


>
> // add row to show the number of results
> Label resultInfos = new Label(composite, SWT.NONE);
>
>
> // add treeviewer
> resultTreeViewer = new TreeViewer(composite);

If you need to set layout data, you should set them on your label and
tree viewer controls.

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Problem with Gridlayout [message #669254 is a reply to message #669213] Mon, 09 May 2011 15:23 Go to previous messageGo to next message
arthurembo Simo is currently offline arthurembo SimoFriend
Messages: 16
Registered: May 2011
Location: Germany
Junior Member
Hi Paul,

thanks, it works fine now. I'm new in SWT and I don't really understand the layout mechanism. But now I learned really somethings.

Best regards
Re: Problem with Gridlayout [message #669272 is a reply to message #669254] Mon, 09 May 2011 16:46 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 05/09/2011 11:23 AM, arthurembo wrote:
> Hi Paul,
>
> thanks, it works fine now. I'm new in SWT and I don't really
> understand the layout mechanism. But now I learned really
> somethings.

You can also see
http://www.eclipse.org/articles/article.php?file=Article-Und erstanding-Layouts/index.html

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Converting points using 'toControl' and 'toDisplay' gives wrong location on ubuntu10.10
Next Topic:swt awt browser
Goto Forum:
  


Current Time: Thu Apr 18 14:54:52 GMT 2024

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

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

Back to the top