0
我有一個對話框,它擴展了TrayDialog
以從用戶收集一些數據。我想將收集的值傳遞給另一個類而不關閉對話框。如果我重寫okPressed()
方法,數據將被傳回,但窗口將被關閉。保持TrayDialog打開並提交數據
public class MyDialog extends TrayDialog {
public MyDialog(final Shell shell, final MyData mydata) {
super(shell);
this.shell = shell;
this.mydata = mydata;
}
@Override
protected void okPressed() {
if (!validateData()) {
return;
}
super.okPressed();
}
//rest of the code for text box, buttons in the dialog
}
final MyDialog myDialog = new MyDialog(new Shell(), this.mydata);
if (myDialog.open() == Window.CANCEL) {
return null;
}
//here get the data that user has entered in the dialog after they press ok