/** * Constructeur. * * @param constantesApp constantes de l'application * @param ressources les ressources. * @param garantie la garantie. */ public ContratGarantiePersonneMoraleViewImpl( ConstantesModel constantesApp, ComposantContratPersonneMoraleResources ressources, GarantiePersonneMoraleModel garantie) { this.viewConstants = (ContratGarantiePMViewImplConstants) GWT.create(ContratGarantiePMViewImplConstants.class); numberFormat = NumberFormat.getFormat("#,##0.00 " + viewConstants.symboleMonnaie()); this.constantesApp = constantesApp; this.ressources = ressources; construireBlocContenu(garantie); final CaptionPanel captionPanel = new CaptionPanel(garantie.getLibelle()); captionPanel.setStylePrimaryName(this.ressources.css().panelGarantieContrat()); captionPanel.add(conteneurGlobal); initWidget(captionPanel); }
/** Construit le tableau de la garantie. */ private void construireTableauGarantie(GarantiePersonneMoraleModel garantie) { if (garantie.getListeInfosGarantie() != null && garantie.getListeInfosGarantie().size() > 0) { // On regarde s'il y a des montants souscrits pour afficher la colonne ou non. boolean hasMontantSouscrit = false; for (InfosGarantiePersonneMoraleModel infosGarantie : garantie.getListeInfosGarantie()) { if (infosGarantie.getMontantSouscrit() != null && infosGarantie.getMontantSouscrit() > 0.0d) { hasMontantSouscrit = true; break; } } // Construction du tableau final FlexTable tableInfosGarantie = new FlexTable(); tableInfosGarantie.setWidth(ComposantContratPersonneMoraleConstants.POURCENT_100); tableInfosGarantie.setCellPadding(6); tableInfosGarantie.setStylePrimaryName(ressources.css().tableau()); tableInfosGarantie.getRowFormatter().setStyleName(0, ressources.css().ligneEnteteColonne()); tableInfosGarantie.setWidget(0, 0, new Label(viewConstants.labelCodeTarif())); tableInfosGarantie.setWidget(0, 1, new Label(viewConstants.labelGarantieGestion())); tableInfosGarantie.setWidget(0, 2, new Label(viewConstants.labelPopulation())); if (hasMontantSouscrit) { tableInfosGarantie.setWidget(0, 3, new Label(viewConstants.labelCapital())); } // Remplissage des lignes int ligne = 1; for (InfosGarantiePersonneMoraleModel infosGarantie : garantie.getListeInfosGarantie()) { tableInfosGarantie.setWidget(ligne, 0, new Label(infosGarantie.getCodeTarif())); tableInfosGarantie.setWidget( ligne, 1, new Label(infosGarantie.getLibelleGarantieGestion())); tableInfosGarantie.setWidget(ligne, 2, new Label(infosGarantie.getLibellePopulation())); if (hasMontantSouscrit && infosGarantie.getMontantSouscrit() != null) { tableInfosGarantie.setWidget( ligne, 3, new Label(numberFormat.format(infosGarantie.getMontantSouscrit()))); } final Long idStatut = infosGarantie.getStatut().getIdentifiant(); if (constantesApp.getIdStatutGarantieEnCours().equals(idStatut)) { tableInfosGarantie .getRowFormatter() .addStyleName(ligne, this.ressources.css().couleurFondGarantieEnCours()); } else if (constantesApp.getIdStatutGarantieResiliee().equals(idStatut)) { tableInfosGarantie .getRowFormatter() .addStyleName(ligne, this.ressources.css().couleurFondGarantieResiliee()); } ligne++; } if (hasMontantSouscrit) { tableInfosGarantie.getColumnFormatter().setWidth(0, "15%"); tableInfosGarantie.getColumnFormatter().setWidth(1, "45%"); tableInfosGarantie.getColumnFormatter().setWidth(2, "25%"); tableInfosGarantie.getColumnFormatter().setWidth(3, "15%"); } else { tableInfosGarantie.getColumnFormatter().setWidth(0, "20%"); tableInfosGarantie.getColumnFormatter().setWidth(1, "50%"); tableInfosGarantie.getColumnFormatter().setWidth(2, "30%"); } conteneurGlobal.add(tableInfosGarantie); } }