private DialogBox createDialogBox(final BeanObject bean) {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.ensureDebugId("cwDialogBox");
    dialogBox.setText("插入邮件队列");
    // Create a panel to layout the content
    ColumnPanel contentPanel = new ColumnPanel();
    final ListBox list = new ListBox();
    list.addItem("普通");
    list.addItem("高");
    contentPanel.createPanel(IEmailSendList.PRIORITY, "选择优先级", list);
    // add a button to commit
    com.google.gwt.user.client.ui.Button commitButton =
        new com.google.gwt.user.client.ui.Button(
            "确定",
            new ClickListener() {
              public void onClick(Widget sender) {
                // update the mail template
                final Map<String, Object> emails = bean.getProperties();
                emails.remove(IMailTemplate.LASTSEND);
                Date currentTime = new Date();
                final Timestamp nowTime = new Timestamp(currentTime.getTime());
                emails.put(IMailTemplate.LASTSEND, nowTime);
                BeanObject emailBean = new BeanObject(ModelNames.MAILTEMPLATE, emails);
                new UpdateService()
                    .updateBean(
                        (Long) emails.get(IMailTemplate.ID),
                        emailBean,
                        new UpdateService.Listener() {

                          @Override
                          public void onSuccess(Boolean success) {}
                        });

                new EmailSettings()
                    .getSettingsInfo(
                        new EmailSettings.Listener() {
                          public void onSuccess(HashMap<String, String> result) {
                            // create new mail send list
                            int index = list.getSelectedIndex();
                            Map<String, Object> sendlist = new HashMap<String, Object>();
                            sendlist.put(IEmailSendList.EMAIL, result.get("account"));
                            sendlist.put(IEmailSendList.TEMPLATEID, emails.get(IMailTemplate.ID));
                            sendlist.put(
                                IEmailSendList.EMAILCONTENT, emails.get(IMailTemplate.CONTENT));
                            sendlist.put(IEmailSendList.ERROR, 0);
                            sendlist.put(IEmailSendList.LASTSEND, nowTime);
                            sendlist.put(IEmailSendList.PRIORITY, index);
                            // new bean object of send list
                            BeanObject listBean =
                                new BeanObject(ModelNames.EMAILSENDLIST, sendlist);
                            new CreateService()
                                .createBean(
                                    listBean,
                                    new CreateService.Listener() {
                                      public void onSuccess(String id) {}
                                    });
                            dialogBox.hide();
                            toolBar.refresh();

                            // 采用BFS算法的原理,处理邮件队列中的邮件。
                            new ListService()
                                .listBeans(
                                    ModelNames.EMAILLIST,
                                    new ListService.Listener() {

                                      @Override
                                      public void onSuccess(List<BeanObject> beans) {
                                        // 取出所有订阅者的订阅地址,构造发送列表
                                        StringBuffer sendTo = new StringBuffer();
                                        for (BeanObject bean : beans) {
                                          Boolean isConfirm = bean.get(IEmailList.CONFIRM);
                                          if (isConfirm.booleanValue()) {
                                            sendTo.append(";" + bean.getString(IEmailList.EMAIL));
                                          }
                                        }
                                        HashMap<String, String> subscribe =
                                            new HashMap<String, String>();
                                        subscribe.put("sendTo", sendTo.substring(1));
                                        subscribe.put(
                                            "subject", (String) emails.get(IMailTemplate.SUBJECT));
                                        subscribe.put(
                                            "content", (String) emails.get(IMailTemplate.CONTENT));
                                        new EmailSettings()
                                            .sendEmailAndGetState(
                                                subscribe,
                                                new EmailSettings.Listener() {
                                                  public void onSuccess(Boolean result) {}

                                                  public void onFailure(Throwable caught) {}
                                                });
                                      }
                                    });
                          }
                        });
              }
            });
    // Add a close button at the bottom of the dialog
    com.google.gwt.user.client.ui.Button closeButton =
        new com.google.gwt.user.client.ui.Button(
            "Close",
            new ClickListener() {
              public void onClick(Widget sender) {
                dialogBox.hide();
              }
            });

    contentPanel.add(closeButton);
    contentPanel.add(commitButton);
    dialogBox.setWidget(contentPanel);
    return dialogBox;
  }