/** Configures the visibility of the fields in edit mode depending on the user privileges */ public void setFieldEditAccess() { if (!AccessManager.canEditSortieLotDescription()) CDT.setVisible(false); if (!AccessManager.canEditSortieLotDescription()) lot.setVisible(false); if (!AccessManager.canEditSortieLotDescription()) quantite.setVisible(false); }
/** Sets the properties of the fields */ public void properties() { CDT.setLabel(NLS.constants().sortieLot_field_cDT()); // the value of CDT affects the value of other fields CDT.notifyChanges(requestFactory.getEventBus()); lot.setLabel(NLS.constants().sortieLot_field_lot()); quantite.setLabel(NLS.constants().sortieLot_field_quantite()); }
/** * Sets the edition mode * * @param isEdited true to enable the edition of the form */ public void setEdited(boolean isEdited) { if (isEdited) setFieldEditAccess(); else setFieldReadAccess(); CDT.setEdited(isEdited); lot.setEdited(isEdited); quantite.setEdited(isEdited); }
/** Validate fields values */ public void validateFields() { // cDT is a required field if (CDT.getValue() == null) delegate.recordError(BaseNLS.messages().error_required(), null, "cDT"); // lot is a required field if (lot.getValue() == null) delegate.recordError(BaseNLS.messages().error_required(), null, "lot"); // quantite is a required field if (quantite.getValueWithoutParseException() == null && quantite.isValid()) delegate.recordError(BaseNLS.messages().error_required(), null, "quantite"); // quantite shall be superior or equal to '0' if (quantite.getValueWithoutParseException() != null && !(quantite.getValueWithoutParseException() >= 0)) delegate.recordError( BaseNLS.messages().error_min_num(NLS.constants().sortieLot_field_quantite_min()), null, "quantite"); }
@Override public void showErrors(List<EditorError> errors) { if (errors != null && errors.size() > 0) { List<EditorError> cDTFieldErrors = new ArrayList<EditorError>(); List<EditorError> lotFieldErrors = new ArrayList<EditorError>(); List<EditorError> quantiteFieldErrors = new ArrayList<EditorError>(); for (EditorError error : errors) { Object userData = error.getUserData(); if (userData != null && userData instanceof String) { String field = (String) userData; if (field.equals("cDT")) cDTFieldErrors.add(error); if (field.equals("lot")) lotFieldErrors.add(error); if (field.equals("quantite")) quantiteFieldErrors.add(error); } } if (cDTFieldErrors.size() > 0) CDT.showErrors(cDTFieldErrors); if (lotFieldErrors.size() > 0) lot.showErrors(lotFieldErrors); if (quantiteFieldErrors.size() > 0) quantite.showErrors(quantiteFieldErrors); } }