这里是我的Eclipse RCP应用程序的我的工作的摘录:如何在Eclipse RCP应用程序中使用用户输入?
说明:在该方法中createContents(Composite)
类ContainerSelectionDialog
我打电话MyComposite
createComposite(Composite)
内,从抽象类继承AbstractCompositeProxy
:
TabFolder folder = new TabFolder((Composite) dialogArea, SWT.TOP);
Composite comp = (Composite) super.createDialogArea(folder);
TabItem tab = new TabItem(folder, SWT.NONE);
tab.setText("Header");
tab.setControl(compositeProxy
.createComposite(comp));
里面createComposite(Composite)
我创建SWT部件像org.eclipse.swt.widgets.Text
,org.eclipse.swt.widgets.Combo
等。例如:
Label label = new Label(parentComposite, SWT.NONE);
label.setText("Something");
Text text = new Text(parentComposite, SWT.BORDER);
GridData gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
text.setLayoutData(gridData);
所以我的Eclipse RCP应用程序中,用户可以打开与定义的控件元素,在那里他可以输入数据的对话框。在okPressed()
,在类ContainerSelectionDialog
我想读的值,用户投入,通过使用getSettings()
从MyComposite
:
@Override
protected void okPressed() {
List<Object> results = new ArrayList<>();
results.add(abstractCompositeProxy.getSimulationSettings());
setResult(results);
super.okPressed();
}
这不是我的设计决策。我只是想了解以下内容:如何使用okPressed()
中的getSettings()
方法获取值?
希望这是足够的信息,否则我会在评论中提供更多信息。我会appriciate任何帮助!
在对象(abstractCompositeProxy)上调用方法(getSimulationSettings)的问题究竟是什么?方法签名看起来很奇怪,但可能适合你。我希望getSimulationSettings返回一个设置实例列表,这可能会导致在结果上调用“addAll”,而不是添加。 – pimpf0r