Example usage for org.apache.wicket.markup.repeater.data DataView DataView

List of usage examples for org.apache.wicket.markup.repeater.data DataView DataView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.repeater.data DataView DataView.

Prototype

protected DataView(String id, IDataProvider<T> dataProvider) 

Source Link

Usage

From source file:com.asptt.plongee.resa.ui.web.wicket.page.consultation.ConsulterPlongees.java

@SuppressWarnings("serial")
public ConsulterPlongees() {

    setPageTitle("Consulter les plong\u00e9es");
    this.adh = getResaSession().getAdherent();
    add(new Label("message",
            new StringResourceModel(CatalogueMessages.CONSULTER_MSG_ADHERENT, this, new Model<Adherent>(adh))));

    modal2 = new ModalWindow("modal2");
    modal2.setTitle("This is modal window with panel content.");
    modal2.setCookieName("modal-adherent");
    add(modal2);/*from w  w w .  ja  v  a  2 s.c o  m*/

    try {
        List<Plongee> plongees = getResaSession().getPlongeeService().rechercherPlongeeProchainJour(adh);

        PlongeeDataProvider pDataProvider = new PlongeeDataProvider(plongees);

        add(new DataView<Plongee>("simple", pDataProvider) {
            protected void populateItem(final Item<Plongee> item) {
                final Plongee plongee = item.getModelObject();
                String nomDP = "Aucun";
                if (null != plongee.getDp()) {
                    nomDP = plongee.getDp().getNom();
                }

                item.add(new IndicatingAjaxLink("select") {
                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        if (adh.isEncadrent() || adh.getRoles().hasRole("SECRETARIAT")) {
                            replaceModalWindowEncadrant(target, item.getModel());
                        } else {
                            replaceModalWindow(target, item.getModel());
                        }
                        modal2.show(target);
                    }
                });

                // Mise en forme de la date
                Calendar cal = Calendar.getInstance();
                cal.setTime(plongee.getDate());
                String dateAffichee = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.FRANCE)
                        + " ";
                dateAffichee = dateAffichee + cal.get(Calendar.DAY_OF_MONTH) + " ";
                dateAffichee = dateAffichee + cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.FRANCE)
                        + " ";
                dateAffichee = dateAffichee + cal.get(Calendar.YEAR);

                item.add(new Label("date", dateAffichee));
                item.add(new Label("dp", nomDP));
                item.add(new Label("type", plongee.getType()));
                item.add(new Label("niveauMini", plongee.getNiveauMinimum().toString()));

                // Places restantes
                item.add(new Label("placesRestantes",
                        getResaSession().getPlongeeService().getNbPlaceRestante(plongee).toString()));

                item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                    @Override
                    public String getObject() {
                        String cssClass;
                        if (item.getIndex() % 2 == 1) {
                            cssClass = "even";
                        } else {
                            cssClass = "odd";
                        }
                        boolean isInscrit = false;
                        for (Adherent adherent : plongee.getParticipants()) {
                            if (adherent.getNumeroLicense().equals(adh.getNumeroLicense())) {
                                cssClass = cssClass + " inscrit";
                                isInscrit = true;
                            }
                        }
                        if (!plongee.isNbMiniAtteint(Parameters.getInt("nb.plongeur.mini"))) {
                            if (isInscrit) {
                                cssClass = cssClass + "MinimumPlongeur";
                            } else {
                                cssClass = cssClass + " minimumPlongeur";
                            }
                        }
                        return cssClass;
                    }
                }));
            }
        });
    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

}

From source file:com.asptt.plongee.resa.ui.web.wicket.page.consultation.ImpressionPlongee.java

@SuppressWarnings("serial")
public ImpressionPlongee(final Plongee plongee, final ResaSession session) {

    // Mise en forme de la date
    Calendar cal = Calendar.getInstance();
    cal.setTime(plongee.getDate());/*w  w  w  . j  a  v a  2  s . co m*/
    String dateAffichee = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.FRANCE) + " ";
    dateAffichee = dateAffichee + cal.get(Calendar.DAY_OF_MONTH) + " ";
    dateAffichee = dateAffichee + cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.FRANCE) + " ";
    dateAffichee = dateAffichee + cal.get(Calendar.YEAR);

    add(new Label("message", "Plong\u00e9e du " + dateAffichee + "    '" + plongee.getType() + "'"));
    add(new Label("nbInscrit", "Nombre de participants " + plongee.getParticipants().size() + ""));

    List<Adherent> adherentsInscrit = plongee.getParticipants();

    add(new DataView<Adherent>("participants", new InscritsPlongeeDataProvider(adherentsInscrit)) {
        protected void populateItem(final Item<Adherent> item) {
            Adherent adherent = item.getModelObject();

            item.add(new Label("nom", adherent.getNom()));
            item.add(new Label("prenom", adherent.getPrenom()));

            // Ds que le plongeur est encadrant, on affiche son niveau
            // d'encadrement
            String niveauAffiche = adherent.getPrerogative();

            // Pour les externes, le niveau est suffix par (Ext.)
            String refParrain = "";
            String noTelParrain = "";
            if (adherent.getActifInt() == 2) {
                niveauAffiche = niveauAffiche + " (Ext.)";
                Adherent parrain = session.getAdherentService()
                        .rechercherParrainParIdentifiantFilleul(adherent.getNumeroLicense(), plongee.getId());
                if (null != parrain) {
                    refParrain = parrain.getNom().concat(" " + parrain.getPrenom());
                    noTelParrain = parrain.getTelephone();
                }
            }
            item.add(new Label("niveau", niveauAffiche));
            item.add(new Label("aptitude", adherent.getAptitude()));
            item.add(new Label("telephone", adherent.getTelephone()));
            item.add(new Label("nomParrain", refParrain));
            item.add(new Label("telParrain", noTelParrain));
            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    });

    List<Adherent> adhereAttente = plongee.getParticipantsEnAttente();

    DataView<Adherent> dataView = new DataView<Adherent>("listeAttente",
            new ListeAttentePlongeeDataProvider(adhereAttente)) {
        protected void populateItem(final Item<Adherent> item) {
            Adherent adherent = item.getModelObject();

            item.add(new Label("nom", adherent.getNom()));
            item.add(new Label("prenom", adherent.getPrenom()));

            // Ds que le plongeur est encadrant, on affiche son niveau
            // d'encadrement
            String niveauAffiche = adherent.getPrerogative();

            // Pour les externes, le niveau est suffix par (Ext.)
            String refParrain = "";
            String noTelParrain = "";
            if (adherent.getActifInt() == 2) {
                niveauAffiche = niveauAffiche + " (Ext.)";
                Adherent parrain = session.getAdherentService()
                        .rechercherParrainParIdentifiantFilleul(adherent.getNumeroLicense(), plongee.getId());
                if (null != parrain) {
                    refParrain = parrain.getNom().concat(" " + parrain.getPrenom());
                    noTelParrain = parrain.getTelephone();
                }
            }

            item.add(new Label("niveau", niveauAffiche));
            item.add(new Label("aptitude", adherent.getAptitude()));
            item.add(new Label("telephone", adherent.getTelephone()));
            item.add(new Label("nomParrain", refParrain));
            item.add(new Label("telParrain", noTelParrain));
            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    add(dataView);
}

From source file:com.asptt.plongee.resa.ui.web.wicket.page.inscription.DeInscriptionPlongeePage.java

private void init() {
    try {/*from   w w  w .j av  a 2s.c om*/
        plongees = getResaSession().getPlongeeService().rechercherPlongeesAdherentInscrit(
                getResaSession().getAdherent(), Parameters.getInt("desincription.nb.heure"));
    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

    PlongeeDataProvider pDataProvider = new PlongeeDataProvider(plongees);

    add(new DataView<Plongee>("simple", pDataProvider) {

        private static final long serialVersionUID = 2877768852318892774L;

        protected void populateItem(final Item<Plongee> item) {
            final Plongee plongee = item.getModelObject();
            String nomDP = "Aucun";
            if (null != plongee.getDp()) {
                nomDP = plongee.getDp().getNom();
            }
            //preparation du message de confirmation
            IModel<Plongee> model = new Model<Plongee>(plongee);
            StringResourceModel srm = new StringResourceModel(CatalogueMessages.DESINSCRIPTION_CONFIRMATION,
                    this, model, new Object[] { new PropertyModel<Plongee>(model, "getType"),
                            ResaUtil.getDateString(plongee.getDate()) });

            item.add(new ConfirmAjaxLink("select", srm.getString()) {
                private static final long serialVersionUID = 1771547719792642196L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deInscrire(target, item.getModel());
                }
            });

            // Mise en forme de la date
            Calendar cal = Calendar.getInstance();
            cal.setTime(plongee.getDate());
            String dateAffichee = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.FRANCE) + " ";
            dateAffichee = dateAffichee + cal.get(Calendar.DAY_OF_MONTH) + " ";
            dateAffichee = dateAffichee + cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.FRANCE)
                    + " ";
            dateAffichee = dateAffichee + cal.get(Calendar.YEAR);

            item.add(new Label("date", dateAffichee));
            item.add(new Label("dp", nomDP));
            item.add(new Label("type", plongee.getType()));
            item.add(new Label("niveauMini", plongee.getNiveauMinimum().toString()));

            // Places restantes
            item.add(new Label("placesRestantes",
                    getResaSession().getPlongeeService().getNbPlaceRestante(plongee).toString()));

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                @Override
                public String getObject() {
                    String cssClass;
                    if (item.getIndex() % 2 == 1) {
                        cssClass = "even";
                    } else {
                        cssClass = "odd";
                    }
                    boolean isInscrit = false;
                    for (Adherent adherent : plongee.getParticipants()) {
                        if (adherent.getNumeroLicense().equals(adh.getNumeroLicense())) {
                            cssClass = cssClass + " inscrit";
                            isInscrit = true;
                        }
                    }
                    if (!plongee.isNbMiniAtteint(Parameters.getInt("nb.plongeur.mini"))) {
                        if (isInscrit) {
                            cssClass = cssClass + "MinimumPlongeur";
                        } else {
                            cssClass = cssClass + " minimumPlongeur";
                        }
                    }
                    return cssClass;
                }
            }));
        }
    });

}

From source file:com.asptt.plongee.resa.ui.web.wicket.page.inscription.DesinscriptionFilleulPage.java

private void init() {
    try {//from w ww  .ja  v  a2 s. co  m
        plongeesDesFilleuls = getResaSession().getPlongeeService().rechercherPlongeesFilleulInscrit(parrain,
                Parameters.getInt("desincription.nb.heure"));
    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

    PlongeeFilleulDataProvider pDataProvider = new PlongeeFilleulDataProvider(plongeesDesFilleuls);

    add(new DataView<InscriptionFilleul>("simple", pDataProvider) {

        private static final long serialVersionUID = 2877768852318892774L;

        protected void populateItem(final Item<InscriptionFilleul> item) {
            final InscriptionFilleul inscription = item.getModelObject();
            final Plongee plongee = inscription.getPlongeeInscrit();
            final Adherent filleul = inscription.getFilleul();
            String nomDP = "Aucun";
            if (null != plongee.getDp()) {
                nomDP = plongee.getDp().getNom();
            }
            //preparation du message de confirmation
            IModel<Plongee> model = new Model<Plongee>(plongee);
            StringResourceModel srm = new StringResourceModel(
                    CatalogueMessages.DESINSCRIPTION_FILLEUL_CONFIRMATION, this, model,
                    new Object[] { new PropertyModel<Plongee>(model, "getType"),
                            ResaUtil.getDateString(plongee.getDate()), filleul.getNom(), filleul.getPrenom() });

            item.add(new ConfirmAjaxLink("select", srm.getString()) {
                private static final long serialVersionUID = 1771547719792642196L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    desinscrire(target, plongee, filleul);
                }
            });

            String nomFilleul = filleul.getNom();
            String prenomFilleul = filleul.getPrenom();

            // Mise en forme de la date
            Calendar cal = Calendar.getInstance();
            cal.setTime(plongee.getDate());
            String dateAffichee = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.FRANCE) + " ";
            dateAffichee = dateAffichee + cal.get(Calendar.DAY_OF_MONTH) + " ";
            dateAffichee = dateAffichee + cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.FRANCE)
                    + " ";
            dateAffichee = dateAffichee + cal.get(Calendar.YEAR);

            item.add(new Label("nom", nomFilleul));
            item.add(new Label("prenom", prenomFilleul));
            item.add(new Label("date", dateAffichee));
            item.add(new Label("type", plongee.getType()));

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                @Override
                public String getObject() {
                    String cssClass;
                    if (item.getIndex() % 2 == 1) {
                        cssClass = "even";
                    } else {
                        cssClass = "odd";
                    }
                    boolean isInscrit = false;
                    for (Adherent adherent : plongee.getParticipants()) {
                        if (adherent.getNumeroLicense().equals(parrain.getNumeroLicense())) {
                            cssClass = cssClass + " inscrit";
                            isInscrit = true;
                        }
                    }
                    if (!plongee.isNbMiniAtteint(Parameters.getInt("nb.plongeur.mini"))) {
                        if (isInscrit) {
                            cssClass = cssClass + "MinimumPlongeur";
                        } else {
                            cssClass = cssClass + " minimumPlongeur";
                        }
                    }
                    return cssClass;
                }
            }));
        }
    });

}

From source file:com.asptt.plongee.resa.wicket.page.AccueilPage.java

public AccueilPage() {

    //        // add the clock component
    //        Clock clock = new Clock("clock", TimeZone.getTimeZone("Europe/Paris"));
    //        add(clock);
    ///*w w w . j  av  a  2s  . co m*/
    //        // add the ajax behavior which will keep updating the component every 5
    //        // seconds
    //        clock.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(20)));

    setPageTitle("Accueil");
    Adherent adh = ResaSession.get().getAdherent();

    // Si l'adhrent est identifi mais qu'il n'a pas chang son password (password = licence)
    if (ResaSession.get().getAdherent().getNumeroLicense()
            .equalsIgnoreCase(ResaSession.get().getAdherent().getPassword())) {
        setResponsePage(ModifPasswordPage.class);
    }

    IModel<Adherent> model = new Model<Adherent>(adh);
    add(new Label("hello", new StringResourceModel(CatalogueMessages.ACCUEIL_BIENVENUE, this, model,
            new Object[] { new PropertyModel<Adherent>(model, "prenom"), calculerDateCourante() })));

    try {
        List<Message> messages = ResaSession.get().getAdherentService().rechercherMessage();
        List<Message> msgSepares = new ArrayList();
        Message ligne = new Message();
        ligne.setLibelle(" ");

        if (!messages.isEmpty()) {
            for (Message msg : messages) {
                msgSepares.add(msg);
                msgSepares.add(ligne);
            }
            int ledernier = msgSepares.size();
            msgSepares.remove(ledernier - 1);
        }

        MessageDataProvider pDataProvider = new MessageDataProvider(msgSepares);

        add(new DataView<Message>("listmessages", pDataProvider) {
            @Override
            protected void populateItem(final Item<Message> item) {
                final Message message = item.getModelObject();
                item.add(new Label("libelle", message.getLibelle()));

                item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                    @Override
                    public String getObject() {
                        String cssClass;
                        if (item.getIndex() % 2 == 1) {
                            cssClass = "even";
                        } else {
                            cssClass = "odd";
                        }
                        return cssClass;
                    }
                }));
            }
        });
        //gestion du message pour le certificat medical perim
        String msgCertificat = "";
        try {
            ResaSession.get().getCheckCM(null);
        } catch (ResaException e) {
            boolean continuer = true;
            if (continuer && e.getKey().equalsIgnoreCase(CatalogueMessages.CM_PERIME)) {
                StringResourceModel srm = new StringResourceModel(CatalogueMessages.CM_PERIME, this, null);
                msgCertificat = srm.getString();
                continuer = false;
            }
            if (continuer && e.getKey().substring(0, 13).equalsIgnoreCase(CatalogueMessages.CM_A_RENOUVELER)) {
                String nbJour = e.getKey().substring(14);
                StringResourceModel srm = new StringResourceModel(CatalogueMessages.CM_A_RENOUVELER, this,
                        model, new Object[] { new PropertyModel<Adherent>(model, "prenom"), nbJour });
                msgCertificat = srm.getString();
                continuer = false;
            }
            if (continuer && e.getKey().equalsIgnoreCase(CatalogueMessages.ADHERENT_NULL)) {
                StringResourceModel srm = new StringResourceModel(CatalogueMessages.ADHERENT_NULL, this, null);
                msgCertificat = srm.getString();
            }
        }
        add(new Label("certificat", msgCertificat));

        //gestion du message pour le cotisation non renouvelle
        try {
            ResaSession.get().getAdherentService().checkAnneeCotisation(ResaSession.get().getAdherent());
        } catch (ResaException e) {
            PageParameters pp = new PageParameters();
            StringResourceModel msgCotisation = new StringResourceModel(
                    CatalogueMessages.ACCUEIL_COTISATION_PERIME, this, new Model<Adherent>(adh));
            pp.add("cotisation", msgCotisation.getString());
            setResponsePage(new LoginPage(pp));
        }

    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

}

From source file:com.asptt.plongee.resa.wicket.page.consultation.ConsulterPlongees.java

@SuppressWarnings("serial")
public ConsulterPlongees() {

    setPageTitle("Consulter les plong\u00e9es");
    this.adh = ResaSession.get().getAdherent();
    add(new Label("message",
            new StringResourceModel(CatalogueMessages.CONSULTER_MSG_ADHERENT, this, new Model<Adherent>(adh))));

    modal2 = new ModalWindow("modal2");
    modal2.setTitle("This is modal window with panel content.");
    modal2.setCookieName("modal-adherent");
    add(modal2);/*from w ww.j  a v  a 2 s  .  co  m*/

    try {
        List<Plongee> plongees = ResaSession.get().getPlongeeService().rechercherPlongeeProchainJour(adh,
                ActionRecherche.CONSULTATION);

        PlongeeDataProvider pDataProvider = new PlongeeDataProvider(plongees);

        add(new DataView<Plongee>("simple", pDataProvider) {
            @Override
            protected void populateItem(final Item<Plongee> item) {
                final Plongee plongee = item.getModelObject();
                String nomDP = "Aucun";
                if (null != plongee.getDp()) {
                    nomDP = plongee.getDp().getNom();
                }
                item.add(new IndicatingAjaxLink("select") {
                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        if (adh.isEncadrent() || adh.getRoles().hasRole("SECRETARIAT")) {
                            replaceModalWindowEncadrant(target, item.getModel());
                        } else {
                            replaceModalWindow(target, item.getModel());
                        }
                        modal2.show(target);
                    }
                });
                item.add(new Label("date", ResaUtil.getJourDatePlongee(plongee.getDatePlongee())));
                item.add(new Label("heure", ResaUtil.getHeurePlongee(plongee.getDatePlongee())));
                item.add(new Label("typePlongee", plongee.getTypePlongee().getText()));
                item.add(new Label("dp", nomDP));
                item.add(new Label("niveauMini", plongee.getNiveauMinimum()));
                // Places restantes
                item.add(new Label("placesRestantes",
                        ResaSession.get().getPlongeeService().getNbPlaceRestante(plongee).toString()));

                item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                    @Override
                    public String getObject() {
                        String cssClass;
                        if (item.getIndex() % 2 == 1) {
                            cssClass = "even";
                        } else {
                            cssClass = "odd";
                        }
                        boolean isInscrit = false;
                        for (Adherent adherent : plongee.getParticipants()) {
                            if (adherent.getNumeroLicense().equals(adh.getNumeroLicense())) {
                                cssClass = cssClass + " inscrit";
                                isInscrit = true;
                            }
                        }
                        if (!plongee.isNbMiniAtteint(Parameters.getInt("nb.plongeur.mini"))) {
                            if (isInscrit) {
                                cssClass = cssClass + "MinimumPlongeur";
                            } else {
                                cssClass = cssClass + " minimumPlongeur";
                            }
                        }
                        return cssClass;
                    }
                }));
            }
        });
    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

}

From source file:com.asptt.plongee.resa.wicket.page.inscription.DeInscriptionPlongeePage.java

private void init() {
    try {//from  w ww  .j ava  2s .  c om
        plongees = ResaSession.get().getPlongeeService().rechercherPlongeesAdherentInscrit(
                ResaSession.get().getAdherent(), Parameters.getInt("desincription.nb.heure"));
    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

    PlongeeDataProvider pDataProvider = new PlongeeDataProvider(plongees);

    add(new DataView<Plongee>("simple", pDataProvider) {

        private static final long serialVersionUID = 2877768852318892774L;

        @Override
        protected void populateItem(final Item<Plongee> item) {
            final Plongee plongee = item.getModelObject();
            String nomDP = "Aucun";
            if (null != plongee.getDp()) {
                nomDP = plongee.getDp().getNom();
            }

            item.add(new IndicatingAjaxLink("select") {
                private static final long serialVersionUID = 1771547719792642196L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deInscrire(target, item.getModel(), adh);
                }
            });

            item.add(new Label("date", ResaUtil.getJourDatePlongee(plongee.getDatePlongee())));
            item.add(new Label("heure", ResaUtil.getHeurePlongee(plongee.getDatePlongee())));
            item.add(new Label("typePlongee", plongee.getTypePlongee().getText()));
            item.add(new Label("dp", nomDP));
            item.add(new Label("niveauMini", plongee.getNiveauMinimum()));
            // Places restantes
            item.add(new Label("placesRestantes",
                    ResaSession.get().getPlongeeService().getNbPlaceRestante(plongee).toString()));

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                @Override
                public String getObject() {
                    String cssClass;
                    if (item.getIndex() % 2 == 1) {
                        cssClass = "even";
                    } else {
                        cssClass = "odd";
                    }
                    boolean isInscrit = false;
                    for (Adherent adherent : plongee.getParticipants()) {
                        if (adherent.getNumeroLicense().equals(adh.getNumeroLicense())) {
                            cssClass = cssClass + " inscrit";
                            isInscrit = true;
                        }
                    }
                    if (!plongee.isNbMiniAtteint(Parameters.getInt("nb.plongeur.mini"))) {
                        if (isInscrit) {
                            cssClass = cssClass + "MinimumPlongeur";
                        } else {
                            cssClass = cssClass + " minimumPlongeur";
                        }
                    }
                    return cssClass;
                }
            }));
        }
    });

}

From source file:com.asptt.plongee.resa.wicket.page.inscription.DesinscriptionFilleulPage.java

private void init() {
    try {//from ww w.j  a va  2s  .c  o  m
        plongeesDesFilleuls = ResaSession.get().getPlongeeService().rechercherPlongeesFilleulInscrit(parrain,
                Parameters.getInt("desincription.nb.heure"));
    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

    PlongeeFilleulDataProvider pDataProvider = new PlongeeFilleulDataProvider(plongeesDesFilleuls);

    add(new DataView<InscriptionFilleul>("simple", pDataProvider) {

        private static final long serialVersionUID = 2877768852318892774L;

        @Override
        protected void populateItem(final Item<InscriptionFilleul> item) {
            final InscriptionFilleul inscription = item.getModelObject();
            final Plongee plongee = inscription.getPlongeeInscrit();
            final Adherent filleul = inscription.getFilleul();
            String nomDP = "Aucun";
            if (null != plongee.getDp()) {
                nomDP = plongee.getDp().getNom();
            }
            //preparation du message de confirmation
            IModel<Plongee> model = new Model<Plongee>(plongee);
            StringResourceModel srm = new StringResourceModel(
                    CatalogueMessages.DESINSCRIPTION_FILLEUL_CONFIRMATION, this, model,
                    new Object[] { ResaUtil.getHeurePlongee(plongee.getDatePlongee()),
                            ResaUtil.getDateString(plongee.getDatePlongee()), filleul.getNom(),
                            filleul.getPrenom() });

            item.add(new ConfirmAjaxLink("select", srm.getString()) {
                private static final long serialVersionUID = 1771547719792642196L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    desinscrire(target, plongee, filleul);
                }
            });

            String nomFilleul = filleul.getNom();
            String prenomFilleul = filleul.getPrenom();

            item.add(new Label("nom", nomFilleul));
            item.add(new Label("prenom", prenomFilleul));
            item.add(new Label("date", ResaUtil.getJourDatePlongee(plongee.getDatePlongee())));
            item.add(new Label("heure", ResaUtil.getHeurePlongee(plongee.getDatePlongee())));
            item.add(new Label("typePlongee", plongee.getTypePlongee().getText()));

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                @Override
                public String getObject() {
                    String cssClass;
                    if (item.getIndex() % 2 == 1) {
                        cssClass = "even";
                    } else {
                        cssClass = "odd";
                    }
                    boolean isInscrit = false;
                    for (Adherent adherent : plongee.getParticipants()) {
                        if (adherent.getNumeroLicense().equals(parrain.getNumeroLicense())) {
                            cssClass = cssClass + " inscrit";
                            isInscrit = true;
                        }
                    }
                    if (!plongee.isNbMiniAtteint(Parameters.getInt("nb.plongeur.mini"))) {
                        if (isInscrit) {
                            cssClass = cssClass + "MinimumPlongeur";
                        } else {
                            cssClass = cssClass + " minimumPlongeur";
                        }
                    }
                    return cssClass;
                }
            }));
        }
    });

}

From source file:com.cubeia.backoffice.web.operator.OperatorList.java

License:Open Source License

public OperatorList() {
    final List<OperatorDTO> operators = operatorServiceClient.getOperators();
    final DataView<OperatorDTO> operatorList = new DataView<OperatorDTO>("operatorList",
            new ListDataProvider<OperatorDTO>(operators)) {

        private static final long serialVersionUID = 1L;

        @Override//from  w w w . j  ava  2s .  c  om
        protected void populateItem(Item<OperatorDTO> item) {
            OperatorDTO operator = item.getModelObject();
            item.add(new Label("id", "" + operator.getId()));
            item.add(new Label("name", operator.getName()));
            item.add(new Label("enabled", operator.isEnabled() ? "Enabled" : "Disabled"));
            String status = operator.getAccountStatus() == null ? "" : operator.getAccountStatus().toString();
            item.add(new Label("accountStatus", status));
            PageParameters parameters = new PageParameters();
            parameters.add("id", operator.getId());
            item.add(new BookmarkablePageLink<Void>("editLink", EditOperator.class, parameters));
        }
    };
    add(operatorList);
}

From source file:com.cubeia.games.poker.admin.wicket.pages.history.ShowHand.java

License:Open Source License

private void addPlayerList(final HistoricHand hand) {
    DataView<Player> players = new DataView<Player>("players", new ListDataProvider<Player>(hand.getSeats())) {

        private static final long serialVersionUID = 1908334758912501993L;

        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override/*from   w ww.j  av a  2  s.c o m*/
        protected void populateItem(Item<Player> item) {
            Player player = item.getModelObject();
            Results results = hand.getResults();
            HandResult resultsForPlayer = results.getResults().get(player.getPlayerId());

            BookmarkablePageLink<String> link = new BookmarkablePageLink<>("playerNameLink", UserSummary.class,
                    createParam("userId", player.getPlayerId()));
            link.add(new Label("playerName", player.getName()));
            item.add(link);
            item.add(new Label("playerId", String.valueOf(player.getPlayerId())));
            if (resultsForPlayer == null) {
                item.add(new Label("seat", String.valueOf(player.getSeatId()) + " (waiting)"));
                item.add(new Label("bet", ""));
                item.add(new Label("net", ""));
                item.add(new Label("initialBalance", formatAmount(player.getInitialBalance())));
                item.add(new Label("finalBalance", formatAmount(player.getInitialBalance())));
            } else {
                item.add(new Label("seat", String.valueOf(player.getSeatId())));
                item.add(new Label("bet", formatAmount(resultsForPlayer.getTotalBet())));
                String net = formatAmount(resultsForPlayer.getNetWin());
                if (resultsForPlayer.getTransactionId() != null) {
                    item.add(new WebMarkupContainer("net"));
                    BookmarkablePageLink<String> netLink = new BookmarkablePageLink("netLink",
                            TransactionInfo.class,
                            createParam("transactionId", resultsForPlayer.getTransactionId()));
                    netLink.add(new Label("netText", net));
                    item.add(netLink);
                } else {
                    item.add(new WebMarkupContainer("netLink").add(new WebMarkupContainer("netText")));
                    item.add(new Label("net", net));
                }
                item.add(new Label("initialBalance", formatAmount(player.getInitialBalance())));
                item.add(new Label("finalBalance",
                        formatAmount(player.getInitialBalance().add(resultsForPlayer.getNetWin()))));
            }
        }

    };
    add(players);
}