예제 #1
0
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    ContentPanel inforPanel = new ContentPanel();
    //		 inforPanel.setHeading(this.getCurState().getAuction().getString(IAuction.AUCTION_NAME));
    HorizontalPanel infoContent = new HorizontalPanel();
    infoContent.setSpacing(20);
    Label sk = new Label("拍卖活动名称:");
    Label sv = new Label(this.getCurState().getAuction().getString(IAuction.AUCTION_NAME));
    Label ek = new Label("拍卖商品名称:");
    Label ev = new Label(this.getCurState().getAuction().getString(IAuction.GOOD_NAME));
    infoContent.add(sk);
    infoContent.add(sv);
    infoContent.add(ek);
    infoContent.add(ev);
    inforPanel.add(infoContent);

    BasePagingLoader loader = new PagingListService().getLoader(ModelNames.AUCTIONLOG);
    loader.load(0, 10);
    store = new ListStore<BeanObject>(loader);
    toolBar = new PagingToolBar(10);
    toolBar.bind(loader);

    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    final CheckBoxSelectionModel<BeanObject> smRowSelection =
        new CheckBoxSelectionModel<BeanObject>();
    columns.add(smRowSelection.getColumn());
    columns.add(new ColumnConfig(IAuctionLog.BID_USER, "买家", 150));
    columns.add(new ColumnConfig(IAuctionLog.BID_PRICE, "出价", 150));
    columns.add(new ColumnConfig(IAuctionLog.BID_TIME, "时间", 150));
    columns.add(new ColumnConfig(IAuctionLog.LOG_ID, "状态", 150));

    ColumnModel cm = new ColumnModel(columns);
    grid = new Grid<BeanObject>(store, cm);

    //        grid.setLoadMask(true);
    //        grid.setBorders(true);
    grid.setSelectionModel(smRowSelection);
    grid.addPlugin(smRowSelection);
    grid.setHeight(250);

    ContentPanel contentPanel = new ContentPanel();
    contentPanel.setFrame(true);
    contentPanel.setCollapsible(true);
    contentPanel.setAnimCollapse(false);
    contentPanel.setButtonAlign(HorizontalAlignment.CENTER);
    contentPanel.setIconStyle("icon-table");
    contentPanel.setLayout(new FitLayout());
    contentPanel.add(grid);
    contentPanel.setBottomComponent(toolBar);

    topPanel.add(inforPanel);
    topPanel.add(contentPanel);
    add(topPanel);
  }
예제 #2
0
  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;
  }