【发布时间】:2012-08-20 15:06:41
【问题描述】:
我在编辑器中有两个部分,它们使用TableWrapLayout 并排排列。正如您在下面的屏幕截图中看到的,右侧部分的标题没有使用全宽。展开时,部分的标题和内容都使用全宽。当该部分再次关闭时,它会保持这种状态。所以问题只有在打开编辑器时才会出现。
那么,如何让部分部分使用全宽?
我已经将 TableWrapData 的 grabHorizontal 属性设置为 true 并在底层复合材料上使用了 GridData.FILL_HORIZONTAL。
当然,立即将该部分设置为展开可以解决问题,但我希望最初保持关闭,因为加载该部分的内容会导致后端工作繁重,因此会导致加载时间更长编辑。
编辑器代码:
public void createPartControl(Composite parent) {
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
form.setLayoutData(new GridData(GridData.FILL_BOTH));
toolkit.decorateFormHeading(form.getForm());
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
form.getBody().setLayout(layout);
createMetaInfoSection();
createUpdateDocumentSection();
}
private void createMetaInfoSection() {
Section metaInfoSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
TableWrapData twd = new TableWrapData();
twd.grabHorizontal = true;
twd.colspan = 1;
metaInfoSection.setLayoutData(twd);
// Composite
Composite composite = toolkit.createComposite(metaInfoSection);
GridLayout gridLayout = new GridLayout();
composite.setLayout(gridLayout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Content
...
metaInfoSection.setClient(composite);
}
private void createUpdateDocumentSection() {
Section updateDocumentSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
TableWrapData twd = new TableWrapData();
twd.grabHorizontal = true;
twd.colspan = 1;
updateDocumentSection.setLayoutData(twd);
// Composite
Composite composite = toolkit.createComposite(updateDocumentSection);
GridLayout gridLayout = new GridLayout();
composite.setLayout(gridLayout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Content
...
updateDocumentSection.setClient(composite);
}
【问题讨论】:
标签: java layout swt eclipse-rcp jface