Example usage for com.google.gwt.user.client.ui CheckBox CheckBox

List of usage examples for com.google.gwt.user.client.ui CheckBox CheckBox

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui CheckBox CheckBox.

Prototype

public CheckBox() 

Source Link

Document

Creates a check box with no label.

Usage

From source file:com.square.client.gwt.client.view.personne.physique.creation.PopupCreationPersonneDoublonViewImpl.java

License:Open Source License

/**
 * Construit le tableau de recherche.//from  w  w  w .  j av  a  2s  .c om
 * @param listeDoublons la liste des doublons.
 */
private void construireTableauRecherche(List<PersonneDoublonModel> listeDoublons) {
    final List<CheckBox> listeCBSelection = new ArrayList<CheckBox>();
    final HeaderFlexTable<PersonneDoublonModel> ftDoublons = new HeaderFlexTable<PersonneDoublonModel>() {
        @Override
        public Widget[] setHeader() {
            return new Widget[] { new Label(viewConstants.enTeteColonneNom()),
                    new Label(viewConstants.enTeteColonnePrenom()),
                    new Label(viewConstants.enTeteColonneDateNaissance()),
                    new Label(viewConstants.enTeteColonneAdresse()),
                    new Label(viewConstants.enTeteColonneCodePostal()),
                    new Label(viewConstants.enTeteColonneVille()),
                    new Label(viewConstants.enTeteColonneCompoFamiliale()),
                    new Label(viewConstants.enTeteSelection()) };
        }

        @Override
        public void setRow(final PersonneDoublonModel doublon) {
            setWidget(0, new Label(doublon.getNom()));
            setWidget(1, new Label(doublon.getPrenom()));
            setWidget(2, new Label(doublon.getDateNaissance()));
            setWidget(3, new Label(doublon.getAdresse()));
            setWidget(4, new Label(doublon.getCodePostal()));
            setWidget(5, new Label(doublon.getCommune()));
            setWidget(6, new Label(doublon.getCompoFamiliale()));
            final CheckBox cb = new CheckBox();
            cb.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    if (cb.getValue()) {
                        for (CheckBox checkBox : listeCBSelection) {
                            if (!cb.equals(checkBox)) {
                                checkBox.setEnabled(false);
                            }
                        }
                        idPersonneSelectionnee = doublon.getId();
                        btnRattacher.setEnabled(true);
                    } else {
                        for (CheckBox checkBox : listeCBSelection) {
                            checkBox.setEnabled(true);
                        }
                        idPersonneSelectionnee = null;
                        btnRattacher.setEnabled(false);
                    }
                }
            });
            listeCBSelection.add(cb);
            setWidget(7, cb);
            setCellHorizontalAlignment(7, HasAlignment.ALIGN_CENTER);
        }
    };
    //        ftDoublons.addStyleName(SquareResources.INSTANCE.css().popupTableDoublons());
    //        ftDoublons.getCellFormatter().addStyleName(0, 0, SquareResources.INSTANCE.css().titreColonneTableDoublon());
    //        styleLigne = SquareResources.INSTANCE.css().celluleSombreTableDoublon();
    //        styleLigne = SquareResources.INSTANCE.css().celluleClaireTableDoublon();
    ftDoublons.setWidth(AppControllerConstants.POURCENT_100);
    ftDoublons.setListeObjets(listeDoublons);

    scrollPanel.add(ftDoublons);
}

From source file:com.square.composant.contrat.square.client.view.ContratGarantieViewImpl.java

License:Open Source License

/** Construit le contenu. */
private void construireBlocContenu(GarantieModel garantie) {
    conteneurGlobal = new FlexTable();
    conteneurGlobal.setWidth(ContratsViewImplConstants.POURCENT_100);
    conteneurGlobal.setCellPadding(2);//from  ww w  . j  ava  2  s.  c  o m

    // Code tarif
    if (garantie.getCodeTarif() != null) {
        final Label lCodeTarif = new Label(viewConstants.libelleCodeTarif(), false);
        final Label labelCodeTarif = new Label(garantie.getCodeTarif(), false);
        conteneurGlobal.setWidget(0, 0, lCodeTarif);
        conteneurGlobal.setWidget(0, 1, labelCodeTarif);
    }

    // Code gnration
    if (garantie.getCodeGeneration() != null) {
        final Label lCodeGeneration = new Label(viewConstants.libelleCodeGeneration(), false);
        final Label labelCodeGeneration = new Label(garantie.getCodeGeneration(), false);
        conteneurGlobal.setWidget(0, 2, lCodeGeneration);
        conteneurGlobal.setWidget(0, 3, labelCodeGeneration);
    }

    // Garantie Gestion
    if (garantie.getLibelleGarantieGestion() != null) {
        final Label lGarantieGestion = new Label(viewConstants.libelleGarantieGestion(), false);
        final Label labelGarantieGestion = new Label(garantie.getLibelleGarantieGestion(), false);
        conteneurGlobal.setWidget(0, 4, lGarantieGestion);
        conteneurGlobal.setWidget(0, 5, labelGarantieGestion);
    }

    // Produit Gestion
    if (garantie.getLibelleProduitGestion() != null) {
        final Label lProduitGestion = new Label(viewConstants.libelleProduitGestion(), false);
        final Label labelProduitGestion = new Label(garantie.getLibelleProduitGestion(), false);
        conteneurGlobal.setWidget(0, 6, lProduitGestion);
        conteneurGlobal.setWidget(0, 7, labelProduitGestion);
    }

    // Loi Madelin
    final Label lLoiMadelin = new Label(viewConstants.libelleLoiMadelin(), false);
    final CheckBox cbLoiMadelin = new CheckBox();
    cbLoiMadelin.setEnabled(false);
    cbLoiMadelin.setValue(garantie.getLoiMadelin());
    conteneurGlobal.setWidget(1, 0, lLoiMadelin);
    conteneurGlobal.setWidget(1, 1, cbLoiMadelin);

    // Montant souscrit
    if (garantie.getMontantSouscrit() != null) {
        final Label lMontantSouscrit = new Label(viewConstants.libelleMontantSouscrit(), false);
        final Label labelMontantSouscrit = new Label(numberFormat.format(garantie.getMontantSouscrit()), false);
        conteneurGlobal.setWidget(1, 2, lMontantSouscrit);
        conteneurGlobal.setWidget(1, 3, labelMontantSouscrit);
    }

    conteneurGlobal.getColumnFormatter().setWidth(0, "14%");
    conteneurGlobal.getColumnFormatter().setWidth(1, "8%");
    conteneurGlobal.getColumnFormatter().setWidth(2, "12%");
    conteneurGlobal.getColumnFormatter().setWidth(3, "5%");
    conteneurGlobal.getColumnFormatter().setWidth(4, "12%");
    conteneurGlobal.getColumnFormatter().setWidth(5, "24%");
    conteneurGlobal.getColumnFormatter().setWidth(6, "12%");
    conteneurGlobal.getColumnFormatter().setWidth(7, "13%");
}

From source file:com.square.composant.fusion.square.client.composants.BlocChampsPersonneFusion.java

License:Open Source License

/**
 * Ajoute un champ de la source dans le bloc des proprits  fusionner.
 * @param row la ligne o ajouter le champ.
 * @param label le label du champ.//from  w  ww .j  a v a2  s  .  c  om
 * @param lChamp la valeur du champ.
 * @param champ le champ.
 * @param styleLigne le style de la ligne.
 * @return le style de la ligne
 */
private String ajouterChampSourceBlocFusion(int row, Label label, Label lChamp,
        final ProprieteFusionnableModel champ, String styleLigne) {
    String style = styleLigne;
    ftProprietes.setWidget(row, 0, label);
    ftProprietes.setWidget(row, 1, lChamp);

    if (champ.getIsSelectionnable() != null && champ.getIsSelectionnable()) {
        final CheckBox cb = new CheckBox();
        cb.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                if (cb.getValue() != null && cb.getValue()) {
                    champ.setAFusionner(true);
                    nbChampsSelectionnesPourFusion++;
                    if (nbChampsSelectionnesPourFusion == nbChampsFusionnables) {
                        btnSelection.setText(composantConstants.btnRienSelectionner());
                    }
                } else {
                    champ.setAFusionner(false);
                    nbChampsSelectionnesPourFusion--;
                    if (nbChampsSelectionnesPourFusion != nbChampsFusionnables) {
                        btnSelection.setText(composantConstants.btnToutSelectionner());
                    }
                }
            }
        });
        ftProprietes.setWidget(row, 2, cb);
        ftProprietes.getFlexCellFormatter().setHorizontalAlignment(row, 2, ALIGN_CENTER);
    }

    // Dfinition du style pour alterner ligne sombre et ligne claire
    if (ComposantFusionPresenter.RESOURCES.css().cellClair().equals(style)) {
        style = ComposantFusionPresenter.RESOURCES.css().cellClair();
    } else {
        style = ComposantFusionPresenter.RESOURCES.css().cellSombre();
    }
    ftProprietes.getCellFormatter().addStyleName(row, 0, style);
    ftProprietes.getCellFormatter().addStyleName(row, 1, style);
    ftProprietes.getCellFormatter().addStyleName(row, 2, style);

    ftProprietes.getCellFormatter().setHeight(row, 0,
            BlocChampsPersonneFusionConstants.HAUTEUR_LIGNES_PROPRIETES);
    ftProprietes.getCellFormatter().setHeight(row, 1,
            BlocChampsPersonneFusionConstants.HAUTEUR_LIGNES_PROPRIETES);
    ftProprietes.getCellFormatter().setHeight(row, 2,
            BlocChampsPersonneFusionConstants.HAUTEUR_LIGNES_PROPRIETES);
    nbChampsFusionnables++;
    return style;
}

From source file:com.square.composant.fusion.square.client.view.selection.doublon.SelectionDoublonViewImpl.java

License:Open Source License

/** Construit le tableau de slection de doublons. */
private void construireTableauSelectionDoublon() {
    remotePagingTableDoublons = new RemotePagingTable<RechercheDoublonResultatModel, RechercheDoublonCritereModel>(
            SelectionDoublonViewImplConstants.NB_ELEMENT_PAR_PAGE, true) {

        @Override/*w  ww .j a  v a  2  s.  co m*/
        public void setDataProvider(RemotePagingCriteriasGwt<RechercheDoublonCritereModel> params,
                AsyncCallback<RemotePagingResultsGwt<RechercheDoublonResultatModel>> callback) {
            remotePagingHandlerManager.fireEvent(
                    new SetDataProviderEvent<RechercheDoublonCritereModel, RechercheDoublonResultatModel>(
                            params, callback));
        }

        @Override
        public int setDefaultSortAsc() {
            return RemotePagingSortGwt.REMOTE_PAGING_SORT_ASC;
        }

        @Override
        public String setDefaultSortField() {
            return constantes.getProprietePersonneNom();
        }

        @Override
        public Column[] setHeader() {
            return new Column[] {
                    new Column(viewConstants.headerNumClient(), constantes.getProprietePersonneNumeroClient()),
                    new Column(viewConstants.headerDateCreation(),
                            constantes.getProprietePersonneDateCreation()),
                    new Column(viewConstants.headerNom(), constantes.getProprietePersonneNom()),
                    new Column(viewConstants.headerPrenom(), constantes.getProprietePersonnePrenom()),
                    new Column(viewConstants.headerDateNaissance(),
                            constantes.getProprietePersonneDateNaissance()),
                    new Column(viewConstants.headerNature(), constantes.getProprietePersonneNature()),
                    new Column(viewConstants.headerCodePostal(), constantes.getProprietePersonneCodePostal()),
                    new Column(viewConstants.headerCommune(), constantes.getProprietePersonneCommune()),
                    new Column(viewConstants.headerSelectionne()) };
        }

        @Override
        public void setRow(int row, final RechercheDoublonResultatModel doublon) {
            setWidget(row, 0, new Label(doublon.getNumeroClient()));
            setWidget(row, 1, new Label(doublon.getDateCreation()));
            setWidget(row, 2, new Label(doublon.getNom()));
            setWidget(row, 3, new Label(doublon.getPrenom()));
            setWidget(row, 4, new Label(doublon.getDateNaissance()));
            setWidget(row, 5, new Label(doublon.getNature()));
            setWidget(row, 6, new Label(doublon.getCodePostal()));
            setWidget(row, 7, new Label(doublon.getCommune()));
            final CheckBox cb = new CheckBox();
            cb.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    if (cb.getValue()) {
                        mapCBSelectionnees.put(doublon.getId(), cb);
                    } else {
                        mapCBSelectionnees.remove(doublon.getId());
                    }

                    // Mise  jour de l'autorisation sur les CheckBoxs
                    majCBTableau();

                    // Mise  jour de l'tat des boutons
                    mAJEtatsBtnsSelection();
                }
            });
            if (doublon.getId().equals(idPersonneSelectionnee)) {
                // On pr-selectionne la ligne correspondant  l'identifiant de la personne spficie
                cb.setValue(true);
                mapCBSelectionnees.put(doublon.getId(), cb);
            }
            setWidget(row, 8, cb);

            getFlexCellFormatter().setHorizontalAlignment(row, 8, HasAlignment.ALIGN_CENTER);
        }

        @Override
        public void setCellClicked(RechercheDoublonResultatModel doublon) {
        }
    };
    remotePagingHandlerManager = new HandlerManager(remotePagingTableDoublons);
    remotePagingTableDoublons.setWidth(ComposantFusionPresenterConstants.POURCENT_100);
    conteneur.add(remotePagingTableDoublons);
}

From source file:com.square.composant.tarificateur.square.client.composant.CheckBoxAssureSelecteur.java

License:Open Source License

/**
 * Constructeur.//w w  w  . j  a v a2  s  .  c  o m
 * @param objSelecteur objet du selecteur  mettre a jour
 */
public CheckBoxAssureSelecteur(final AssureSelecteurModel objSelecteur) {
    this.objSelecteur = objSelecteur;
    this.checkBox = new CheckBox();

    // slection de la valeur si elle existe
    if (objSelecteur != null && (Boolean) objSelecteur.getIsSelection() != null) {
        this.checkBox.setValue(objSelecteur.getIsSelection());
    }
    // sinon on met a jour la valeur
    else {
        setValeur();
    }

    this.checkBox.addClickHandler(this);

    initWidget(checkBox);
}

From source file:com.square.composant.tarificateur.square.client.composant.CheckBoxSelecteur.java

License:Open Source License

/**
 * Constructeur./*w w w. j a  va2  s.  c o m*/
 * @param objSelecteur objet du selecteur  mettre a jour
 */
public CheckBoxSelecteur(SelecteurProduitEventMapper<Boolean> objSelecteur) {
    this.objSelecteur = objSelecteur;
    this.checkBox = new CheckBox();
    this.obsGenerique = new ObservableGenerique();

    // slection de la valeur si elle existe
    if (objSelecteur != null && objSelecteur.getValeurMapper() != null) {
        checkBox.setValue(objSelecteur.getValeurMapper());
    }
    // sinon on met a jour la valeur
    else {
        setValeur();
    }

    checkBox.addClickHandler(this);

    initWidget(checkBox);
}

From source file:com.square.composant.tarificateur.square.client.view.adhesion.BlocInfoSanteCompleteViewImpl.java

License:Open Source License

/**
 * Ajoute un panel contenant les informations d'un enfant.
 * @param enfant//from   w w w .  ja  v  a 2s .c o m
 */
private void construirePanel(String suffix) {
    final Label lNumSs = new Label(viewConstants.lNumSs());
    lRelation = new Label(viewConstants.relation());
    final Label lRegime = new Label(viewConstants.lRegime());
    final Label lCaisse = new Label(viewConstants.lCaisse());
    final Label lTns = new Label(viewConstants.lTns(), false);
    final Label lLoiMadelin = new Label(viewConstants.lLoiMadelin(), false);
    final Label lcouvertNow = new Label(viewConstants.lcouvertNow(), false);
    final Label lcouvert6DerniersMois = new Label(viewConstants.lcouvert6DerniersMois(), false);

    final SuggestListBoxSingleProperties<IdentifiantLibelleGwt> slbIdentifiantLibelleProperties = new SuggestListBoxSingleProperties<IdentifiantLibelleGwt>() {
        @Override
        public String getSelectSuggestRenderer(IdentifiantLibelleGwt row) {
            return row == null ? "" : row.getLibelle();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(IdentifiantLibelleGwt row) {
            return new String[] { row == null ? "" : row.getLibelle() };
        }
    };

    final SuggestListBoxSingleProperties<IdentifiantEidLibelleModel> slbIdentifiantEidLibelleProperties = new SuggestListBoxSingleProperties<IdentifiantEidLibelleModel>() {
        @Override
        public String getSelectSuggestRenderer(IdentifiantEidLibelleModel row) {
            return row == null ? "" : row.getLibelle();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(IdentifiantEidLibelleModel row) {
            return new String[] { row == null ? "" : row.getLibelle() };
        }
    };

    final SuggestListBoxSingleProperties<CaisseSimpleModel> slbCaisseProperties = new SuggestListBoxSingleProperties<CaisseSimpleModel>() {
        @Override
        public String getSelectSuggestRenderer(CaisseSimpleModel row) {
            return row == null ? "" : row.getCode() + "." + row.getCentre() + "." + row.getNom();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(CaisseSimpleModel row) {
            return new String[] {
                    row == null ? "" : row.getCode() + "." + row.getCentre() + "." + row.getNom() };
        }
    };
    final SuggestListBoxSingleProperties<IdentifiantLibelleGwt> propertiesRelation = new SuggestListBoxSingleProperties<IdentifiantLibelleGwt>() {
        @Override
        public String getSelectSuggestRenderer(IdentifiantLibelleGwt row) {
            return row == null ? "" : row.getLibelle();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(IdentifiantLibelleGwt row) {
            return new String[] { row == null ? "" : row.getLibelle() };
        }
    };

    lbSsReferents = new DecoratedSuggestListBoxSingle<IdentifiantEidLibelleModel>(
            slbIdentifiantEidLibelleProperties);
    tbNumSs = new DecoratedTextBox();
    tbNumSs.setMaxLength(InfosAdhesionViewImplConstants.LONGUEUR_NUM_SECURITE_SOCIALE);
    tbCleSs = new DecoratedTextBox();
    tbCleSs.setMaxLength(InfosAdhesionViewImplConstants.LONGUEUR_CLE_SECURITE_SOCIALE);
    tbCleSs.setWidth(InfosAdhesionViewImplConstants.LARGEUR_TB_CLE_SS);
    slbRelation = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(propertiesRelation);
    setRelationVisible(false);
    lbRegime = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(slbIdentifiantLibelleProperties);
    lbCaisse = new DecoratedSuggestListBoxSingle<CaisseSimpleModel>(slbCaisseProperties);
    cbTns = new CheckBox();
    cbLoiMadelin = new CheckBox();
    cbCouvertNow = new CheckBox();
    cbCouvert6DerniersMois = new CheckBox();

    final HorizontalPanel hpSecuSociale = new HorizontalPanel();
    hpSecuSociale.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hpSecuSociale.add(lbSsReferents);
    hpSecuSociale.add(new HTML("&nbsp;"));
    hpSecuSociale.add(tbNumSs);
    hpSecuSociale.add(new HTML("&nbsp;"));
    hpSecuSociale.add(construireBlocIcone(tbCleSs, "PersonneDto.numSecuriteSocial" + suffix));

    final FlexTable flexTable = new FlexTable();
    flexTable.setWidth(ComposantTarificateurConstants.POURCENT_100);
    flexTable.setCellSpacing(3);
    flexTable.setWidget(0, 0, lNumSs);
    flexTable.setWidget(0, 1, hpSecuSociale);
    flexTable.setWidget(1, 0, lRegime);
    flexTable.setWidget(1, 1, construireBlocIcone(lbRegime, "PersonneDto.eidRegime" + suffix));
    flexTable.setWidget(1, 2, lCaisse);
    flexTable.setWidget(1, 3, construireBlocIcone(lbCaisse, "PersonneDto.eidCaisse" + suffix));
    flexTable.setWidget(2, 0, lTns);
    flexTable.setWidget(2, 1, cbTns);
    flexTable.setWidget(2, 2, lLoiMadelin);
    flexTable.setWidget(2, 3, cbLoiMadelin);
    flexTable.setWidget(3, 0, lcouvertNow);
    flexTable.setWidget(3, 1, cbCouvertNow);
    flexTable.setWidget(3, 2, lcouvert6DerniersMois);
    flexTable.setWidget(3, 3, cbCouvert6DerniersMois);
    flexTable.setWidget(4, 0, lRelation);
    flexTable.setWidget(4, 1, construireBlocIcone(slbRelation, "RelationDto.type" + suffix));
    flexTable.getFlexCellFormatter().setColSpan(0, 1, 3);
    flexTable.getColumnFormatter().setWidth(0, InfosAdhesionViewImplConstants.LARGEUR_COL_LIBELLE_0);
    flexTable.getColumnFormatter().setWidth(1, InfosAdhesionViewImplConstants.LARGEUR_COL_CHAMP_1);
    flexTable.getColumnFormatter().setWidth(2, InfosAdhesionViewImplConstants.LARGEUR_COL_LIBELLE_2);
    flexTable.getColumnFormatter().setWidth(3, InfosAdhesionViewImplConstants.LARGEUR_COL_CHAMP_3);

    panel = new CaptionPanel();
    panel.add(flexTable);
    container.add(panel);
}

From source file:com.square.composant.tarificateur.square.client.view.adhesion.InfosAdhesionViewImpl.java

License:Open Source License

private void construirePanelOptions() {
    final Label lTeletransmission = new Label(viewConstants.lTeletransmission(), false);
    cbTeletransmission = new CheckBox();
    cbTeletransmission.setTitle(viewConstants.lTitreTeletransmission());

    final FlexTable ftOptions = new FlexTable();
    ftOptions.setWidth(ComposantTarificateurConstants.POURCENT_100);
    ftOptions.setCellSpacing(3);/*from  w ww  .  java 2 s  . c  o  m*/
    ftOptions.setWidget(0, 0, lTeletransmission);
    ftOptions.setWidget(0, 1, cbTeletransmission);
    ftOptions.getColumnFormatter().setWidth(0, InfosAdhesionViewImplConstants.LARGEUR_COL_LIBELLE_0);
    ftOptions.getColumnFormatter().setWidth(1, InfosAdhesionViewImplConstants.LARGEUR_COL_CHAMP_1);
    ftOptions.getColumnFormatter().setWidth(2, InfosAdhesionViewImplConstants.LARGEUR_COL_LIBELLE_2);
    ftOptions.getColumnFormatter().setWidth(3, InfosAdhesionViewImplConstants.LARGEUR_COL_CHAMP_3);

    final CaptionPanel panelOptions = new CaptionPanel(viewConstants.captionPanelOptions());
    panelOptions.add(ftOptions);
    container.add(panelOptions);
    // On incrmente le nombre de panel supplmentaires
    nbPanelSupplementaires++;
}

From source file:com.square.composant.tarificateur.square.client.view.ligne.devis.LigneDevisViewImpl.java

License:Open Source License

/**
 * Cre l'en-tte d'une ligne de devis principale.
 *//*  ww w.  j  a v  a  2s . c o m*/
private void creerEnteteLigneDevisPrincipale() {
    ftEnteteDevis = new FlexTable();
    ftEnteteDevis.setWidth(ComposantTarificateurConstants.POURCENT_100);
    ftEnteteDevis.setStylePrimaryName(ComposantTarificateur.RESOURCES.css().enteteLignePrincipale());

    // Case  cocher pour le transfert de la proposition
    cbTransfertLigne = new CheckBox();
    cbTransfertLigne.setTitle(viewConstants.titreCheckboxTransfertSelection());

    lDateCreation = new Label();
    final HorizontalPanel pDateCreation = creerBlocLibelleValeur(viewConstants.labelDateCreation(),
            lDateCreation);
    lCreateur = new Label();
    final HorizontalPanel pCreateur = creerBlocLibelleValeur(viewConstants.labelCreateur(), lCreateur);
    lProvenance = new Label();
    final HorizontalPanel pProvenance = creerBlocLibelleValeur(viewConstants.labelProvenance(), lProvenance);

    btnVisuGrille = new DecoratedButton(viewConstants.libelleBoutonVisualiser());
    btnVisuGrille.setTitle(viewConstants.titreBoutonVisualiser());
    btnModifierLigne = new DecoratedButton(viewConstants.libelleBoutonModifier());
    btnModifierLigne.setTitle(viewConstants.titreBoutonModifier());
    final FlexTable ftBoutons = new FlexTable();
    ftBoutons.setCellSpacing(4);
    ftBoutons.setWidget(0, 0, btnVisuGrille);
    ftBoutons.setWidget(0, 1, btnModifierLigne);

    ftEnteteDevis.setWidget(0, 0, cbTransfertLigne);
    ftEnteteDevis.setWidget(0, 1, pDateCreation);
    ftEnteteDevis.setWidget(0, 2, pCreateur);
    ftEnteteDevis.setWidget(0, 3, pProvenance);
    ftEnteteDevis.setWidget(0, 4, ftBoutons);
    ftEnteteDevis.getCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_RIGHT);

    ftEnteteDevis.getColumnFormatter().setWidth(0, "2%");
    ftEnteteDevis.getColumnFormatter().setWidth(1, "24%");
    ftEnteteDevis.getColumnFormatter().setWidth(2, "32%");
    ftEnteteDevis.getColumnFormatter().setWidth(3, "32%");
    ftEnteteDevis.getColumnFormatter().setWidth(4, "10%");
}

From source file:com.square.composant.tarificateur.square.client.view.ligne.devis.LigneDevisViewImpl.java

License:Open Source License

/**
 * Affiche les informations d'une ligne de devis.
 *///from w  w w  .  j a  va  2 s  .com
private void afficherInfosLigneDevis(LigneDevisModel ligneDevis, final boolean ligneLiee,
        boolean isLectureSeule, int numLigne) {
    // on rcupre la finalit
    final Long idFinalite = ligneDevis.getFinalite().getIdentifiant() != null
            ? ligneDevis.getFinalite().getIdentifiant()
            : constantesApp.getIdFinaliteEnCours();

    // on rcupre le critre optionnel ou pas du produit
    boolean isProduitOptionnel = true;
    if (ligneLiee && ligneDevis.getProduitOptionnel() != null) {
        isProduitOptionnel = ligneDevis.getProduitOptionnel().booleanValue();
    }

    // calcul du montant mensuel
    final float montantLigneMensuel = calculMontantMensuelLigne(ligneDevis.getMontantTtc().floatValue(),
            ligneDevis.getIdentifiantModePaiement());
    float montantLigneMensuelRemise = 0f;
    if (ligneDevis.getMontantRemise() != null) {
        montantLigneMensuelRemise = calculMontantMensuelLigne(ligneDevis.getMontantRemise().floatValue(),
                ligneDevis.getIdentifiantModePaiement());
    }

    // ajout du montant de la ligne au total sauf si ligne lie obligatoire
    if ((!ligneLiee || isProduitOptionnel) && montantLigneMensuelRemise != montantLigneMensuel) {
        montantTotalLignesGroupees += montantLigneMensuel;
        montantTotalLignesGroupeesRemise += montantLigneMensuelRemise;
    }

    final RadioButton rbLigneAdhesion = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    final RadioButton rbLigneRefus = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    final RadioButton rbLigneEnCours = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    final RadioButton rbLigneCorbeille = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    rbLigneAdhesion.setTitle(viewConstants.titreRadioAccepte());
    rbLigneRefus.setTitle(viewConstants.titreRadioRefuse());
    rbLigneEnCours.setTitle(viewConstants.titreRadioEnCours());
    rbLigneCorbeille.setTitle(viewConstants.titreRadioCorbeille());
    rbLigneAdhesion.setEnabled(!isLectureSeule);
    rbLigneRefus.setEnabled(!isLectureSeule);
    rbLigneEnCours.setEnabled(!isLectureSeule);
    rbLigneCorbeille.setEnabled(!isLectureSeule);

    // on coche la finalite suivant le cas
    if (idFinalite.equals(constantesApp.getIdFinaliteAcceptee())) {
        rbLigneAdhesion.setValue(Boolean.TRUE);
    } else if (idFinalite.equals(constantesApp.getIdFinaliteRefusee())) {
        rbLigneRefus.setValue(Boolean.TRUE);
    } else if (idFinalite.equals(constantesApp.getIdFinaliteEnCours())) {
        rbLigneEnCours.setValue(Boolean.TRUE);
    } else if (idFinalite.equals(constantesApp.getIdFinaliteCorbeille())) {
        rbLigneCorbeille.setValue(Boolean.TRUE);
    }

    final CheckBox cbImprimerLigne = new CheckBox();
    cbImprimerLigne.setTitle(viewConstants.titreCheckboxSelection());

    mapRbLigneAdhesion.put(ligneDevis.getIdentifiant(), rbLigneAdhesion);
    mapRbLigneRefus.put(ligneDevis.getIdentifiant(), rbLigneRefus);
    mapRbLigneEnAttente.put(ligneDevis.getIdentifiant(), rbLigneEnCours);
    mapRbLigneCorbeille.put(ligneDevis.getIdentifiant(), rbLigneCorbeille);
    mapCbImprimerLigne.put(ligneDevis.getIdentifiant(), cbImprimerLigne);

    if (ligneLiee && !isProduitOptionnel) {
        // produit obligatoire non coch et non dcochable (non affich de toute faon)
        cbImprimerLigne.setValue(Boolean.FALSE);
        cbImprimerLigne.setEnabled(Boolean.FALSE);
    } else if (ligneLiee && isProduitOptionnel) {
        // On slectionne pour impression les produits bonus
        if (ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus1())
                || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus2())) {
            cbImprimerLigne.setValue(Boolean.TRUE);
        } else {
            // produit optionnel dcochable
            cbImprimerLigne.setValue(ligneDevis.getSelectionnePourImpression() != null
                    ? ligneDevis.getSelectionnePourImpression()
                    : Boolean.FALSE);
        }
        cbImprimerLigne.setEnabled(Boolean.TRUE);
    } else if (!ligneLiee) {
        // produit principal dcochable
        cbImprimerLigne.setValue(ligneDevis.getSelectionnePourImpression() != null
                && ligneDevis.getSelectionnePourImpression().booleanValue());
        cbImprimerLigne.setEnabled(Boolean.TRUE);
    }

    String libelleMontant = "";
    if (montantLigneMensuelRemise != montantLigneMensuel) {
        libelleMontant = numberFormat.format((double) montantLigneMensuel)
                + ComposantTarificateurConstants.ESPACE + viewConstants.symboleMonnaie();
    } else if (montantLigneMensuel != 0f
            && (ligneDevis.getNAAucunTarif() == null || !ligneDevis.getNAAucunTarif())) {
        libelleMontant = viewConstants.libelleOffert();
    }

    final Label lProduit = new Label();
    final Label lPrenomNomBeneficiaire = new Label();
    final HTML lCriteresProduit = new HTML();
    final Label lDateEffet = new Label();
    final Label lMontant = new Label();
    lDateEffet.setWordWrap(false);
    lMontant.setWordWrap(false);

    final String libelleProduit = ligneDevis.getLibelleProduit();

    lProduit.setText(libelleProduit);

    //limite le nombre de caractres
    final String nomPrenom = ligneDevis.getPrenomNomBeneficiaire();
    String nomPrenomLimite = nomPrenom;
    if (nomPrenom.length() > viewConstants.nbMaxCaracteresNomPrenom()) { //limite si superieur a la constante
        nomPrenomLimite = nomPrenomLimite.substring(0, viewConstants.nbMaxCaracteresNomPrenom()) + "...";
    }
    lPrenomNomBeneficiaire.setText(nomPrenomLimite);
    lPrenomNomBeneficiaire.setTitle(nomPrenom);

    lCriteresProduit.setHTML(getLibelleCriteresProduit(ligneDevis));
    lDateEffet.setText(ligneDevis.getDateEffet());
    lMontant.setText(libelleMontant);

    tableauLignesDevis.setWidget(numLigne, 0, lProduit);
    tableauLignesDevis.setWidget(numLigne, 1, lPrenomNomBeneficiaire);
    tableauLignesDevis.setWidget(numLigne, 2, lCriteresProduit);
    tableauLignesDevis.setWidget(numLigne, 3, lDateEffet);
    tableauLignesDevis.setWidget(numLigne, 4, lMontant);
    tableauLignesDevis.setWidget(numLigne, 5, rbLigneAdhesion);
    tableauLignesDevis.setWidget(numLigne, 6, rbLigneRefus);
    tableauLignesDevis.setWidget(numLigne, 7, rbLigneCorbeille);
    tableauLignesDevis.setWidget(numLigne, 8, rbLigneEnCours);
    tableauLignesDevis.setWidget(numLigne, 9, cbImprimerLigne);

    // mise en forme du tableau
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 0, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 1, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 2, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 3, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 4, HasAlignment.ALIGN_RIGHT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 5, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 6, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 7, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 8, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 9, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getRowFormatter().setVerticalAlign(numLigne, HasAlignment.ALIGN_TOP);
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 0,
            ComposantTarificateur.RESOURCES.css().important());
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 1,
            ComposantTarificateur.RESOURCES.css().important());
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 3,
            ComposantTarificateur.RESOURCES.css().important());
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 4,
            ComposantTarificateur.RESOURCES.css().important());

    // Mise en forme spciale pour les lignes associes  des produits sans tarifs
    if (ligneDevis.getNAAucunTarif() != null && ligneDevis.getNAAucunTarif().booleanValue()) {
        tableauLignesDevis.getRowFormatter().addStyleName(numLigne,
                ComposantTarificateur.RESOURCES.css().produitSansTarif());
    }

    // si c'est une ligne liee dont le produit est obligatoire, ou si il s'agit d'un produit bonus
    if ((ligneLiee && !isProduitOptionnel)
            || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus1())
            || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus2())) {
        rbLigneAdhesion.setEnabled(false);
        rbLigneRefus.setEnabled(false);
        rbLigneEnCours.setEnabled(false);
        rbLigneCorbeille.setEnabled(false);
        // on cache la ligne
        tableauLignesDevis.getRowFormatter().setVisible(numLigne, false);
    }
}