private void populateGaitGrd(GaitReEducationVoCollection voGaitColl) {
    GaitReEducationGaitAspectCollection aspColl = null;
    for (int i = 0; i < voGaitColl.size(); i++) {
      GaitReEducationVo voGait = voGaitColl.get(i);
      GenForm.gridGaitRow pRow = form.gridGait().getRows().newRow();

      // fix WDEV-2255
      if (voGait.getAuthoringDateTimeIsNotNull())
        pRow.setColDate(voGait.getAuthoringDateTime().toString());
      if (voGait.getAuthoringCPIsNotNull()) pRow.setColHCP(voGait.getAuthoringCP().toString());
      if (voGait.getDetailsIsNotNull()) pRow.setColDetails(voGait.getDetails());

      // display children
      if (voGait.getGaitAspect() != null) {
        aspColl = voGait.getGaitAspect();

        String gait = "";
        for (int z = 0; z < aspColl.size(); z++) {
          // fix WDEV-2255
          GaitReEducationGaitAspect aspect = aspColl.get(z);
          gait += aspect.toString() + "\n";
        }
        pRow.setColGait(gait);
      }

      pRow.setValue(voGait);
    }
  }
  protected void onBtnSaveClick() throws PresentationLogicException {
    GaitReEducationVo voGait = form.getLocalContext().getGaitEducation();
    if (voGait == null) voGait = new GaitReEducationVo();
    voGait.setAuthoringCP(form.qmbAuthoringCP().getValue());
    voGait.setAuthoringDateTime(form.dtimAuthoring().getValue());

    if (form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull())
      voGait.setClinicalContact(form.getGlobalContext().Core.getCurrentClinicalContact());

    voGait.setDetails(form.txtDetails().getValue());

    voGait.setGaitAspect(populateDataFromGrdAspect());

    String[] uiErrors = getUiErrors();
    String[] message = voGait.validate(uiErrors);
    if (message != null) {
      engine.showErrors("Validation errors", message);
      return;
    }

    try {
      domain.saveGaitReEducation(voGait);
    } catch (StaleObjectException e) {
      engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
      open();
      return;
    } catch (UniqueKeyViolationException e) {
      engine.showMessage("A Gait Re-Education record already exists. " + e.getMessage());
      open();
      return;
    }

    open();
  }
  private void populateControls(GaitReEducationVo voGait) {
    form.qmbAuthoringCP().newRow(voGait.getAuthoringCP(), voGait.getAuthoringCP().toString());
    form.qmbAuthoringCP().setValue(voGait.getAuthoringCP());
    form.dtimAuthoring().setValue(voGait.getAuthoringDateTime());
    form.txtDetails().setValue(voGait.getDetails());

    if (voGait.getGaitAspect() != null) populateGaitGrid(voGait.getGaitAspect());
  }
  protected void onGridGaitSelectionChanged() throws PresentationLogicException {
    populateControls(form.gridGait().getSelectedRow().getValue());
    ClinicalContactShortVo voClinicalContact =
        form.getGlobalContext().Core.getCurrentClinicalContact();
    GaitReEducationVo voGait = form.gridGait().getSelectedRow().getValue();
    if (voClinicalContact != null
        && voGait != null
        && voGait.getClinicalContactIsNotNull()
        && voGait.getClinicalContact().equals(voClinicalContact)) {
      updateContextMenu();
      form.btnUpdate().setVisible(true);
    } else {
      form.getContextMenus().getGenericGridUpdateItem().setVisible(false);
      form.getContextMenus().getGenericGridRemoveItem().setVisible(false);
      form.getContextMenus().getGenericGridMoveDownItem().setVisible(false);
      form.getContextMenus().getGenericGridMoveUpItem().setVisible(false);
      form.getContextMenus().getGenericGridViewItem().setVisible(false);

      form.btnUpdate().setVisible(false);
    }
  }
  private void isRecordCurrent() {
    ClinicalContactShortVo voCurrent = null;
    if (form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull())
      voCurrent = form.getGlobalContext().Core.getCurrentClinicalContact();

    for (int i = 0; i < form.gridGait().getRows().size(); i++) {
      GaitReEducationVo voGait = form.gridGait().getRows().get(i).getValue();
      if (voCurrent != null && voGait.getClinicalContact() != null) {
        if (voGait
            .getClinicalContact()
            .getID_ClinicalContact()
            .equals(voCurrent.getID_ClinicalContact())) {
          form.getLocalContext().setUpdateCurrentRecord(new Boolean(true));
          // set colour of current record + set it expanded
          GenForm.gridGaitRow currentRow = form.gridGait().getRows().get(i);
          currentRow.setBackColor(Color.Beige);
          currentRow.setExpanded(true);
          form.gridGait().setValue(voGait);
        }
      }
      populateControls(voGait);
    }
  }