我试图从来自 TreeViewer 的数据水平填充复合材料,但没有成功。如果您有任何建议,我将不胜感激。
这是我正在使用的代码:
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;
}