Problem with Gridlayout [message #669213] |
Mon, 09 May 2011 13:55 |
arthurembo Simo 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 |
|
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
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03487 seconds