示例#1
0
  public void onClick(ClickEvent event) {
    Object sender = event.getSource();

    if (sender == rootHTML) {
      JSONRequest request = new JSONRequest();
      request.doFetchURL(AoAPI.SURVEY_INPUT + survey.getId() + "/", this);
    } else if (promptMap.containsKey(sender)) {
      tree.setSelectedItem(null);
      TreeItem leaf = leaves.get(sender);
      leaf.getTree().setSelectedItem(leaf);
      Prompt p = promptMap.get(sender);
      Messages.get().displaySurveyInput(p, 0);
    }
  }
示例#2
0
  public SurveyWidget(Survey s, Images images, Composite parent) {
    this.survey = s;
    this.images = images;
    this.parent = parent;

    tree = new Tree(images);
    String title = s.getName() + " ";
    SurveyStatus status = survey.getStatus();
    switch (status) {
      case ACTIVE:
        title += "<span style='color:green'>(Active)</span>";
        break;
      case CANCELLED:
        title += "<span style='color:red'>(Cancelled)</span>";
        break;
      case EXPIRED:
        title += "(Expired)";
    }
    rootHTML = imageItemHTML(images.inbox(), title);
    root = new TreeItem(rootHTML);
    tree.addItem(root);

    tree.addSelectionHandler(
        new SelectionHandler<TreeItem>() {

          public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();

            if (promptMap.containsKey(item)) {
              Prompt p = promptMap.get(item);
              Messages.get().displaySurveyInput(p, 0);
            }
          }
        });

    detailsHTML = imageItemHTML(images.drafts(), "Details");
    detailsHTML.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            if (detailsModel == null) {
              JSONRequest request = new JSONRequest();
              request.doFetchURL(
                  AoAPI.SURVEY_DETAILS + survey.getId() + "/", new SurveyDetailsRequester());
            } else {
              DetailsDialog details = new DetailsDialog(detailsModel);
              details.show();
              details.center();
            }
          }
        });

    TreeItem details = new TreeItem(detailsHTML);
    root.addItem(details);

    if (status == SurveyStatus.ACTIVE) {
      cancelHTML = imageItemHTML(images.reject_sm(), "Cancel");
      cancelHTML.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              confirm =
                  new AreYouSureDialog(
                      "Are you sure you want to cancel all future calls for this broadcast?");
              confirm.show();
              confirm.center();

              confirm.addCloseHandler(
                  new CloseHandler<PopupPanel>() {
                    public void onClose(CloseEvent<PopupPanel> event) {
                      if (confirm.isConfirmed()) {
                        JSONRequest request = new JSONRequest();
                        request.doFetchURL(
                            AoAPI.CANCEL_SURVEY + survey.getId() + "/",
                            new CancelSurveyRequester());
                      }
                    }
                  });
            }
          });

      TreeItem cancel = new TreeItem(cancelHTML);
      root.addItem(cancel);
    }
  }