Пример #1
0
  /** Sets the inner HTML according to an icon */
  public void setMarkHTML() {

    // Starts with an empty HTML
    String html = "";
    String iconhtml = "";

    // Create the icon string if any
    if (this.iconType != null) {
      Icon icon = new Icon(this.iconType);
      iconhtml = icon.toString();
    } else if (this.iconOnly && this instanceof CustomMark) {
      CustomMark cmark = (CustomMark) this;
      iconhtml = cmark.getTitle();
    }

    String markername =
        EMarkingConfiguration.isMarkerAnonymous()
            ? MarkingInterface.messages.MarkerDetails(MarkingInterface.messages.Anonymous())
            : MarkingInterface.messages.MarkerDetails(this.getMarkername());
    String styleColor = "";

    // If the mark has a color, we use the background to color it
    if (this.criterionid > 0 && this.iconOnly) {
      styleColor = "style=\"color:" + Color.getCSSHueColor(criterionid) + "\"";
    }

    html +=
        "<div class=\""
            + Resources.INSTANCE.css().markicon()
            + "\" title=\""
            + markername
            + "\" "
            + styleColor
            + ">"
            + iconhtml
            + "</div>";
    // If the mark is an icon
    if (!this.iconOnly && this.getRawtext().trim().length() > 0) {
      html +=
          "<div class=\""
              + Resources.INSTANCE.css().markrawtext()
              + "\">"
              + SafeHtmlUtils.htmlEscape(this.getRawtext())
              + "</div>";
      // Show the marker's name if the marking process is not anonymous
      if (!EMarkingConfiguration.isMarkerAnonymous()) {
        html +=
            "<div class=\""
                + Resources.INSTANCE.css().markmarkername()
                + "\">"
                + markername
                + "</div>";
      }
    }

    this.setHTML(html);
  }
Пример #2
0
  public CriterionHeader(int idx, int cid, String cdesc, float b, int regrid, int regraccepted) {
    this.mainPanel = new VerticalPanel();
    this.mainPanel.addStyleName(Resources.INSTANCE.css().criterionrow());
    this.criterionId = cid;
    this.criterionDescription = cdesc;
    this.index = idx;

    Label lbl = new Label(cdesc);
    lbl.addStyleName(Resources.INSTANCE.css().criterionheader());
    lbl.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            if (commentId > 0 && commentPage > 0)
              EMarkingWeb.markingInterface
                  .getMarkingPagesInterface()
                  .highlightRubricMark(commentId, commentPage);
          }
        });
    mainPanel.add(lbl);

    HorizontalPanel horizontal = new HorizontalPanel();
    horizontal.addStyleName(Resources.INSTANCE.css().colorsquaretable());

    // the square with the color
    if (EMarkingConfiguration.isColoredRubric()) {
      Label lbl2 = new Label("");
      Color.setWidgetBackgroundHueColor(cid, lbl2);
      lbl2.addStyleName(Resources.INSTANCE.css().colorsquare());
      lbl2.setTitle(String.valueOf(idx));
      // lbl2.addStyleName(MarkingInterface.getMapCss().get("colorsquare"));

      // HTML rectangle = new HTML();
      // rectangle.setHTML("<div data-index='"+idx+"' style='width:20px;	height:20px;border:1px
      // solid #000;' class='"+ MarkingInterface.getMapCss().get("color"+idx) +"
      // "+MarkingInterface.getMapCss().get("colorsquare") + "' ></div>");
      lbl2.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              Label rectangle = (Label) event.getSource();
              int index = Integer.parseInt(rectangle.getTitle());
              EMarkingWeb.markingInterface
                  .getToolbar()
                  .getMarkingButtons()
                  .changeCriterionList(index);
            }
          });
      horizontal.add(lbl2);
    }

    HTML separation = new HTML();
    separation.setHTML("<div style='width:20px;height:20px;'></div>");
    horizontal.add(separation);

    mainPanel.add(horizontal);

    bonusHtml = new HTML();
    setBonus(b);

    mainPanel.add(bonusHtml);

    regradeHtml = new HTML();
    regradeHtml.setVisible(false);

    mainPanel.add(regradeHtml);

    this.setRegradeData(regrid, regraccepted);

    loadingIcon = new HTML();
    loadingIcon.setVisible(false);
    Icon iconloading = new Icon(IconType.COG);
    loadingIcon.setHTML(iconloading.toString());
    loadingIcon.addStyleName(Resources.INSTANCE.css().loadingicon());
    loadingIcon.addStyleName("icon-spin");

    mainPanel.add(loadingIcon);
    mainPanel.setCellHorizontalAlignment(loadingIcon, HasHorizontalAlignment.ALIGN_CENTER);

    initWidget(mainPanel);
  }