這裏是我的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