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