private void changeState(String type) {
    if (type == null) {
      type = "def";
    }

    MaskedTextBox widget = this.getDateInput();
    Widget button = this.getButton();

    widget.removeStyleName("warn");
    button.removeStyleName("warn");

    widget.setStyleName(type, true);
    button.setStyleName(type, true);
  }
Exemple #2
0
  private void init() {
    widget.setStyleName("color-off");

    addMouseOverHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {
            widget.setStyleName("color-on");
          }
        });

    addMouseOutHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            if (!isSelected) widget.setStyleName("color-off");
          }
        });
  }
  /**
   * Opens an HTML popup info window at the given screen coordinates (within the plot bounds)
   *
   * <p>It sets the same font family, size, color and bgcolor defined for markers, if you wanted
   * override them use the css selector div.chrono-infoWindow-content.
   *
   * <p>FIXME: (MCM) this should be a unique instance of popup: ask Shawn
   */
  public InfoWindow createInfoWindow(String html, double x, double y) {
    final PopupPanel pp = new DecoratedPopupPanel(true);
    pp.addStyleName("chrono-infoWindow");
    Widget content = new HTML(html);
    content.setStyleName("chrono-infoWindow-content");
    pp.setWidget(content);
    pp.setPopupPosition(
        getElement().getAbsoluteLeft() + (int) x, getElement().getAbsoluteTop() + (int) y);

    GssProperties markerProperties = gssContext.getPropertiesBySelector("marker");
    if (markerProperties != null) {
      pp.getElement().getStyle().setBackgroundColor(markerProperties.bgColor.toString());
      pp.getElement().getStyle().setColor(markerProperties.color.toString());
      pp.getElement().getStyle().setProperty("fontFamily", markerProperties.fontFamily.toString());
      pp.getElement().getStyle().setProperty("fontSize", markerProperties.fontSize.toString());
      pp.getElement().getStyle().setPadding(5, Unit.PX);
    }
    pp.getElement().getStyle().setZIndex(9999);
    pp.show();

    return new BrowserInfoWindow(this, pp);
  }
Exemple #4
0
  public void setSelected(boolean isSelected) {
    this.isSelected = isSelected;

    if (isSelected) widget.setStyleName("color-on");
    else widget.setStyleName("color-off");
  }
  public void setResponse(SurveyResponse surveyResponse, ElementHandlerCallback callback) {
    date.setText(surveyResponse.getResponseDate().toString());
    campaign.setText(surveyResponse.getCampaignName());
    survey.setText(surveyResponse.getSurveyName());
    username.setText(surveyResponse.getUserName());
    NumberFormat locationFormat = NumberFormat.getFormat("####.000");
    String latString = locationFormat.format(surveyResponse.getLatitude());
    String longString = locationFormat.format(surveyResponse.getLongitude());
    location.setText(latString + ", " + longString);

    for (PromptResponse promptResponse : surveyResponse.getPromptResponses()) {
      Widget responseDisplayWidget = null;
      switch (promptResponse.getPromptType()) {
        case PHOTO:
          String raw = promptResponse.getResponseRaw();
          if (raw.equals("SKIPPED") || raw.equals("NOT_DISPLAYED")) {
            responseDisplayWidget = new HTML(raw);
          } else {
            // generate urls for thumbnail and full sized photo and pass to widget
            String thumbUrl =
                AwUrlBasedResourceUtils.getImageUrl(
                    promptResponse.getResponseRaw(),
                    surveyResponse.getUserName(),
                    surveyResponse.getCampaignId(),
                    AwUrlBasedResourceUtils.ImageSize.SMALL);
            final String fullSizedImageUrl =
                AwUrlBasedResourceUtils.getImageUrl(
                    promptResponse.getResponseRaw(),
                    surveyResponse.getUserName(),
                    surveyResponse.getCampaignId(),
                    AwUrlBasedResourceUtils.ImageSize.ORIGINAL);
            Image img = new Image(thumbUrl);
            img.setStyleName(style.promptImage());

            // Locking in the width and height here stops the Image from resizing on image
            // load which causes the InfoWindow to refresh and flicker
            img.setPixelSize(AwConstants.MAPS_THUMBNAIL_WIDTH, AwConstants.MAPS_THUMBNAIL_HEIGHT);

            // Let's the calling code do whatever with the image, specifically used to avoid
            // dependencies
            // on the google maps API
            if (callback != null) {
              callback.addingElement(img.getElement(), fullSizedImageUrl);
            }

            FlowPanel panel = new FlowPanel();
            panel.add(img);
            responseDisplayWidget = panel;
          }
          break;
          // TODO: special case timestamp?
        default:
          // anything other than a photo, just copy it verbatim
          responseDisplayWidget = new HTML(promptResponse.getResponsePrepared());
          break;
      }

      // set up and style question
      HTML question = new HTML(promptResponse.getText());
      question.setStyleName(style.promptQuestion());

      // add style to response
      responseDisplayWidget.setStyleName(style.promptResponse());

      // add question and response to styled div
      FlowPanel panel = new FlowPanel();
      panel.setStyleName(style.prompt());
      panel.add(question);
      panel.add(responseDisplayWidget);

      // add the whole thing to prompt list
      prompts.add(panel);
    }
  }