private HtmlMenuOption createOtherOption(HtmlMenu menu) {
    String title = RenderUtils.getResourceString("renderers.menu.other.title");
    HtmlMenuOption otherOption = menu.createOption(title);
    otherOption.setValue(OPTION_KEY);

    return otherOption;
  }
  @Override
  protected HtmlComponent renderComponent(Layout layout, Object object, Class type) {
    String value = (String) object;
    MetaSlot slot = (MetaSlot) getInputContext().getMetaObject();

    HtmlMenu menu = (HtmlMenu) super.renderComponent(layout, object, type);
    HtmlMenuOption otherOption = createOtherOption(menu);

    HtmlHiddenField field = new HtmlHiddenField();

    HtmlTextInput other = new HtmlTextInput();
    other.setSize(getOtherSize());

    boolean otherSelected = true;
    for (HtmlMenuEntry entry : menu.getEntries()) {
      if (entry.isSelected()) {
        other.setStyle("display: none;");
        otherSelected = false;
        break;
      }
    }

    if (otherSelected) {
      otherOption.setSelected(true);
      other.setValue(value);
    }

    field.setValue(value);
    field.bind(slot);
    field.setController(new CopyController(menu, other));

    menu.setTargetSlot(null);
    menu.setName(getLocalName(slot, "menu"));
    other.setName(getLocalName(slot, "other"));

    HtmlContainer container = new HtmlBlockContainer();

    container.addChild(createSwitchScript(field, menu, other));
    container.addChild(field);
    container.addChild(menu);
    container.addChild(other);

    return container;
  }
  private void createResultsGroup(CurricularCourseResumeResult courseResumeResult, HtmlMenu menu) {
    HtmlMenuGroup resultsGroup =
        menu.createGroup(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.results"));
    HtmlMenuOption optionUC = resultsGroup.createOption();
    optionUC.setText(
        RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.ucResults"));
    String resultsParameters = buildParametersForResults(courseResumeResult);
    HtmlLink link = new HtmlLink();
    link.setModule("/publico");
    link.setUrl("/viewCourseResults.do?" + resultsParameters);
    link.setEscapeAmpersand(false);
    String calculatedUrl = link.calculateUrl();
    optionUC.setValue(
        calculatedUrl
            + "&_request_checksum_="
            + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));

    for (TeacherShiftTypeResultsBean teacherShiftTypeResultsBean :
        courseResumeResult.getTeachersResults()) {
      String teacherResultsParameters =
          buildParametersForTeacherResults(teacherShiftTypeResultsBean);
      HtmlLink teacherLink = new HtmlLink();
      teacherLink.setEscapeAmpersand(false);
      teacherLink.setModule("/publico");
      teacherLink.setUrl("/viewTeacherResults.do?" + teacherResultsParameters);
      calculatedUrl = teacherLink.calculateUrl();

      HtmlMenuOption optionTeacher = resultsGroup.createOption();
      optionTeacher.setText(
          teacherShiftTypeResultsBean.getShiftType().getFullNameTipoAula()
              + " - "
              + teacherShiftTypeResultsBean.getProfessorship().getPerson().getName());
      optionTeacher.setValue(
          calculatedUrl
              + "&_request_checksum_="
              + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
    }
  }
  private void createReportsGroup(CurricularCourseResumeResult courseResumeResult, HtmlMenu menu) {
    String calculatedUrl;
    HtmlMenuGroup reportsGroup =
        menu.createGroup(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.reports"));
    for (InquiryDelegateAnswer inquiryDelegateAnswer :
        courseResumeResult.getExecutionCourse().getInquiryDelegatesAnswersSet()) {
      if (inquiryDelegateAnswer.getExecutionDegree() == courseResumeResult.getExecutionDegree()) {
        String delegateInquiryParameters = buildParametersForDelegateInquiry(inquiryDelegateAnswer);
        HtmlLink delegateLink = new HtmlLink();
        delegateLink.setEscapeAmpersand(false);
        delegateLink.setModule("/publico");
        delegateLink.setUrl("/viewQUCInquiryAnswers.do?" + delegateInquiryParameters);
        calculatedUrl = delegateLink.calculateUrl();

        HtmlMenuOption optionDelegate = reportsGroup.createOption();
        optionDelegate.setText(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.delegate"));
        optionDelegate.setValue(
            calculatedUrl
                + "&_request_checksum_="
                + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
      }
    }

    for (Professorship professorship :
        courseResumeResult.getExecutionCourse().getProfessorshipsSet()) {
      if (professorship.getInquiryTeacherAnswer() != null) {
        HtmlLink teacherLink = new HtmlLink();
        teacherLink.setEscapeAmpersand(false);
        teacherLink.setModule("/publico");
        teacherLink.setUrl(
            "/viewQUCInquiryAnswers.do?method=showTeacherInquiry&professorshipOID="
                + professorship.getExternalId());
        calculatedUrl = teacherLink.calculateUrl();
        HtmlMenuOption optionTeacher = reportsGroup.createOption();
        optionTeacher.setText(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.teacher")
                + " ("
                + professorship.getPerson().getName()
                + ")");
        optionTeacher.setValue(
            calculatedUrl
                + "&_request_checksum_="
                + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
      }
    }

    for (Professorship professorship :
        courseResumeResult.getExecutionCourse().getProfessorshipsSet()) {
      if (professorship.getInquiryRegentAnswer() != null) {
        HtmlLink regentLink = new HtmlLink();
        regentLink.setEscapeAmpersand(false);
        regentLink.setModule("/publico");
        regentLink.setUrl(
            "/viewQUCInquiryAnswers.do?method=showRegentInquiry&professorshipOID="
                + professorship.getExternalId());
        calculatedUrl = regentLink.calculateUrl();
        HtmlMenuOption optionRegent = reportsGroup.createOption();
        optionRegent.setText(
            RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.regent")
                + " ("
                + professorship.getPerson().getName()
                + ")");
        optionRegent.setValue(
            calculatedUrl
                + "&_request_checksum_="
                + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession()));
      }
    }
  }