I'm trying to fill a composite horizontally from data coming from a TreeViewer, without success. If you have any suggestions, I would me most thankful.
Here's the code I'm using:
private Composite composite;
private ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
composite = new Composite(scrolledComposite, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
composite.setLayout(createNoMarginLayout(1, false));
scrolledComposite.setContent(composite);
compositeNdal = new Composite(composite, SWT.NONE);
compositeNdal.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
compositeNdal.setLayout(createNoMarginLayout(1, true));
compositeNdal.setVisible(true);
treeViewerNdalEditor = new TreeViewer(compositeNdal,SWT.BORDER|SWT.FILL);
/* (computing the tree part goes here) */
public static GridLayout createNoMarginLayout(int numColumns, boolean makeColumnsEqualWidth) {
GridLayout layout = new GridLayout(numColumns, makeColumnsEqualWidth);
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
layout.marginTop = 0;
layout.marginBottom = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
return layout;
}
You have to set layout data on the tree to tell the parent composite layout how to handle the tree:
treeViewerNdalEditor.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));