我想将scrolledComposite添加到Eclipse插件的向导页面中。在我实现scrolledComposite的FirstPage上一切正常。问题是,后面要显示的SecondPage是空白的。
FirstPage的初始化代码:
public void createControl(Composite parent) {
ScrolledComposite scroll = new ScrolledComposite(parent, SWT.NULL | SWT.V_SCROLL);
scroll.setLayoutData(new GridData(GridData.FILL_VERTICAL));
scroll.setAlwaysShowScrollBars(false);
scroll.setExpandVertical(true);
scroll.setExpandHorizontal(true);
scroll.setMinHeight(500);
scroll.setLayout(new GridLayout(1, false));
Composite container = new Composite(scroll, SWT.NULL);
GridLayout layout = new GridLayout();
container.setLayout(layout);
scroll.setContent(container);
setControl(container);
setPageComplete(false);
}SecondPage createControl代码是标准的,但我也尝试过定位一个父对象,这将是一个滚动-我认为这应该是“嵌套”ScrolledComposite的问题-就像这样:
ScrolledComposite scroll = null;
if(parent.getChildren() != null && parent.getChildren().length > 1 && parent.getChildren()[1] instanceof ScrolledComposite) {
scroll = (ScrolledComposite)parent.getChildren()[1];
}
scroll.setLayoutData(new GridData(GridData.FILL_VERTICAL));
Composite container = new Composite(scroll, SWT.NULL);
scroll.setContent(container);
scroll.setAlwaysShowScrollBars(false);
scroll.setExpandVertical(true);
scroll.setExpandHorizontal(true);
scroll.setMinHeight(500);
scroll.setLayout(new GridLayout(1, false));
GridLayout layout = new GridLayout();
container.setLayout(layout);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));但这样的方法行不通。
有没有人有与ScrolledComposites和多页JFace向导集成的经验?
发布于 2017-11-30 19:43:10
我找到了解决方案,但是--我必须承认--这是一个非常愚蠢的错误。将setControl(container);更改为setControl(scroll);就足够了。现在,每个页面都正确显示了。请以后注意这些事情:)
发布于 2017-11-29 18:02:00
如果您看到类层次结构IDialogPage --> DialogPage --> WizardPage --> YourCustomPage。因此,对于每个页面,您需要在父组合下创建自定义内容,该组合由向导在整个WizardPages中共享。
但是您在这个根组合之上添加了ScollableComposite,在本例中它是content元素,特定于第一个页面,并且不应该共享给第二个向导页面。
因此,您需要为第二个页面创建一个新的ScollableComposite并单独添加您的内容。如果您尝试在第二页中更新相同ScollableComposite的内容,那么当您单击back按钮时,您的内容不会更新到第一页。因为在调用getPreviousPage()时不会调用createContent()。
https://stackoverflow.com/questions/47532245
复制相似问题