我有一个RCP应用程序,其中upen delete,MessageDialog用于确认删除操作。您可以在下面的代码中看到的其中一个按钮是“预览”按钮,如果单击该按钮,将弹出另一个对话框以显示有关预期操作结果的更多信息。这个“预览”按钮默认以某种方式关闭我的主MessageDialog。我该怎么办才能使它不关闭主对话框?
MessageDialog dialog =
new MessageDialog(null, "Dangerous Activity", null,
"Are you sure you want to delete?", MessageDialog.CONFIRM,
new String[]{"Preview>", "Delete", "Cancel"}, 0);
int dialogResult = dialog.open();
// if preview button is selected
if (dialogResult == 0) {
// open another dialog for a second more informative warning
// but DO NOT CLOSE THE CURRENT MAIN ONE..HOW TO?
}
我感谢任何帮助!
谢谢,
答案 0 :(得分:3)
尝试覆盖MessageDialog上的buttonPressed方法:
MessageDialog dialog =
new MessageDialog(null, "Dangerous Activity", null,
"Are you sure you want to delete?", MessageDialog.CONFIRM,
new String[]{"Preview>", "Delete", "Cancel"}, 0)
{
protected void buttonPressed(int buttonId) {
setReturnCode(buttonId);
// close(); Call close for Delete or Cancel?
}};