以下是我正在开发的 Eclipse RCP 应用程序的摘录:
描述:在ContainerSelectionDialog
类内的createContents(Composite)
方法中,我在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
类中,我想通过使用 MyComposite
中的 getSettings()
读取用户输入的值:
@Override
protected void okPressed() {
List<Object> results = new ArrayList<>();
results.add(abstractCompositeProxy.getSimulationSettings());
setResult(results);
super.okPressed();
}
这不是我的设计决定。我只是想了解以下内容:如何使用 okPressed()
中的 getSettings()
方法来获取值?
希望这是足够的信息,否则我将在评论中提供更多信息。我会感谢任何帮助!
最佳答案
从 okPressed()
访问 compositeProxy
的方式与在 createContents()
中的操作方式相同。
关于java - 如何在 Eclipse RCP 应用程序中使用用户输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32454167/