/**
   * Display the current instance of TransfertReference in editor
   *
   * @param entity the TransfertReferenceProxy to be displayed
   */
  private void viewTransfertReference(TransfertReferenceProxy entity) {

    /* display instance information */
    setTitle(
        NLS.constants().transfertReference_name()
            + ": "
            + EpicamRenderer.get().getDisplayValue(entity));
    setMetaData((ImogBeanProxy) entity);

    /* push the instance to the editor in view mode */
    request = requestFactory.transfertReferenceRequest();
    current = request.edit(entity);

    editor.setEditedValue(current);

    /* set request context for list editor operations */
    editor.setRequestContextForListEditors(request);

    editorDriver.edit(current, request);
    editor.setEdited(false);

    /* update field widgets in editor */
    editor.computeVisibility(null, true);

    /* display edit button */
    if (AccessManager.canEditTransfertReference()) setModifiable(true);

    showGlassPanel = false;
    EpicamEntryPoint.GP.hide();
  }
  /** Create a new instance of TransfertReference */
  private void createNewTransfertReference() {

    request = requestFactory.transfertReferenceRequest();

    /* create a new intance of TransfertReference */
    TransfertReferenceProxy newTransfertReference = request.create(TransfertReferenceProxy.class);
    newTransfertReference.setId(ImogKeyGenerator.generateKeyId("TRANS_REF"));

    /* push the instance to the editor */
    current = newTransfertReference;
    editorDriver.edit(current, request);

    /* set request context for list editor operations */
    editor.setRequestContextForListEditors(request);

    /* update field widgets in editor */
    editor.computeVisibility(null, true);
    // Field districtSante depends on the value of field region
    editor.getDistrictSanteFilteredByRegion(null);
    // Field cDTDepart depends on the value of field districtSante
    editor.getCDTDepartFilteredByDistrictSante(null);
    // Field districtSanteArrivee depends on the value of field regionArrivee
    editor.getDistrictSanteArriveeFilteredByRegionArrivee(null);
    // Field cDTArrivee depends on the value of field districtSanteArrivee
    editor.getCDTArriveeFilteredByDistrictSanteArrivee(null);
    editor.getPatientFilteredByCDTDepart(null);
    editor.setEdited(true);
  }
  /** Persist the current instance of TransfertReference */
  @Override
  protected void save() {

    editor.validateFields();

    editorDriver.flush();

    // Check for errors on the client side
    if (editorDriver.hasErrors()) {
      // Window.alert("TransfertReference form not validated locally");
      return;
    }

    Request<Void> saveRequest = request.save(current, isNew);
    saveRequest.to(
        new Receiver<Void>() {
          @Override
          public void onSuccess(Void response) {
            requestFactory
                .getEventBus()
                .fireEvent(new SaveTransfertReferenceEvent(current, initField));
            closeForm();
          }

          @Override
          public void onConstraintViolation(Set<ConstraintViolation<?>> errors) {
            // Window.alert("TransfertReference form not validated on server");

            // TODO manage errors on client side when made available by GWT
            if (errors != null && errors.size() > 0) {
              // convert ConstraintViolation to get localized messages
              EpicamRenderer renderer = EpicamRenderer.get();
              Set<ConstraintViolation<?>> imogErrors = new HashSet<ConstraintViolation<?>>();
              for (ConstraintViolation<?> error : errors) {
                ImogConstraintViolation violation = new ImogConstraintViolation();
                violation.setLeafBean((BaseProxy) error.getLeafBean());
                violation.setPropertyPath(error.getPropertyPath());
                violation.setRootBean((BaseProxy) error.getRootBean());
                violation.setMessage(renderer.getI18nErrorMessage(error.getMessage()));
                imogErrors.add(violation);
              }
              editorDriver.setConstraintViolations(imogErrors);
            }
          }

          @Override
          public void onFailure(ServerFailure error) {
            Window.alert("Error updating the TransfertReference");
            super.onFailure(error);
          }
        });

    request.fire();
  }
  /** Edit the current instance of TransfertReference in editor */
  @Override
  protected void edit() {

    /* set the instance in edit mode in the editor */
    editor.setEdited(true);

    /* update field widgets in editor */
    // Field districtSante depends on the value of field region
    editor.getDistrictSanteFilteredByRegion(current.getRegion());
    // Field cDTDepart depends on the value of field districtSante
    editor.getCDTDepartFilteredByDistrictSante(current.getDistrictSante());
    // Field districtSanteArrivee depends on the value of field regionArrivee
    editor.getDistrictSanteArriveeFilteredByRegionArrivee(current.getRegionArrivee());
    // Field cDTArrivee depends on the value of field districtSanteArrivee
    editor.getCDTArriveeFilteredByDistrictSanteArrivee(current.getDistrictSanteArrivee());
    editor.getPatientFilteredByCDTDepart(current.getCDTDepart());
  }
 /**
  * Setter to inject a CentreDiagTrait value
  *
  * @param value the value to be injected
  * @param isLocked true if relation field shall be locked (non editable)
  */
 public void setCDTArrivee(CentreDiagTraitProxy value, boolean isLocked) {
   editor.setCDTArrivee(value, isLocked);
 }
 /**
  * Setter to inject a DistrictSante value
  *
  * @param value the value to be injected
  * @param isLocked true if relation field shall be locked (non editable)
  */
 public void setDistrictSanteArrivee(DistrictSanteProxy value, boolean isLocked) {
   editor.setDistrictSanteArrivee(value, isLocked);
 }
 /**
  * Setter to inject a Region value
  *
  * @param value the value to be injected
  * @param isLocked true if relation field shall be locked (non editable)
  */
 public void setRegionArrivee(RegionProxy value, boolean isLocked) {
   editor.setRegionArrivee(value, isLocked);
 }
 /**
  * Setter to inject a Patient value
  *
  * @param value the value to be injected
  * @param isLocked true if relation field shall be locked (non editable)
  */
 public void setPatient(PatientProxy value, boolean isLocked) {
   editor.setPatient(value, isLocked);
 }
 /**
  * Setter to inject a CentreDiagTrait value
  *
  * @param value the value to be injected
  * @param isLocked true if relation field shall be locked (non editable)
  */
 public void setCDTDepart(CentreDiagTraitProxy value, boolean isLocked) {
   editor.setCDTDepart(value, isLocked);
 }