Example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

Introduction

In this page you can find the example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel.

Prototype

AbstractReadOnlyModel

Source Link

Usage

From source file:com.asptt.plongee.resa.ui.web.wicket.page.admin.GererAdherents.java

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

    setPageTitle("Gerer les adherents");
    setOutputMarkupId(true);//from   w  w  w  .  j av a 2s  .c  om
    modal2 = new ModalWindow("modal2");
    modal2.setTitle("This is modal window with panel content.");
    modal2.setCookieName("modal-adherent");
    add(modal2);

    modalSupp = new ModalWindow("modalSupp");
    modalSupp.setTitle("Confirmation");
    modalSupp.setResizable(false);
    modalSupp.setInitialWidth(30);
    modalSupp.setInitialHeight(15);
    modalSupp.setWidthUnit("em");
    modalSupp.setHeightUnit("em");
    modalSupp.setCssClassName(ModalWindow.CSS_CLASS_BLUE);
    add(modalSupp);

    modalPwd = new ModalWindow("modalPwd");
    modalPwd.setTitle("Confirmation");
    modalPwd.setResizable(false);
    modalPwd.setInitialWidth(30);
    modalPwd.setInitialHeight(15);
    modalPwd.setWidthUnit("em");
    modalPwd.setHeightUnit("em");
    modalPwd.setCssClassName(ModalWindow.CSS_CLASS_BLUE);
    add(modalPwd);

    List<Adherent> adherents = getResaSession().getAdherentService().rechercherAdherentsTous();

    // On construit la liste des adhrents (avec pagination)
    DataView adherentsView = new DataView<Adherent>("simple", new AdherentDataProvider(adherents), 10) {
        protected void populateItem(final Item<Adherent> item) {
            final Adherent adherent = item.getModelObject();

            item.add(new IndicatingAjaxLink("select") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    replaceModalWindow(target, item.getModel());
                    modal2.show(target);
                }
            });

            item.add(new IndicatingAjaxLink("suppAdh") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    replaceModalWindowSupp(target, item.getModel());
                    modalSupp.show(target);
                }
            });

            item.add(new IndicatingAjaxLink("pwdAdh") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    replaceModalWindowPwd(target, item.getModel());
                    modalPwd.show(target);
                }
            });

            item.add(new Label("license", adherent.getNumeroLicense()));
            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();
            item.add(new Label("niveau", niveauAffiche));
            item.add(new Label("aptitude", adherent.getAptitude()));
            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";
                    }
                    if (!adherent.isActif()) {
                        cssClass = cssClass + " inactif";
                    }
                    return cssClass;
                }
            }));
        }
    };
    adherentsView.setOutputMarkupId(true);
    add(adherentsView);
    add(new PagingNavigator("navigator", adherentsView));

    add(new AdherentForm("form"));

}

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  ww .  j av a  2  s.  com*/

    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());/* www  .  j ava 2  s .c o  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.consultation.InfoAdherent.java

private void init() {

    //      private static final long serialVersionUID = 5374674730458593314L;

    Adherent adherent = getResaSession().getAdherentService()
            .rechercherAdherentParIdentifiant(getResaSession().getAdherent().getNumeroLicense());

    add(new Label("nom", adherent.getNom()));
    add(new Label("prenom", adherent.getPrenom()));
    add(new Label("numeroLicense", adherent.getNumeroLicense()));
    add(new Label("telephone", adherent.getTelephone()));
    add(new Label("mail", adherent.getMail()));
    add(new Label("niveau", adherent.getNiveau()));
    add(new Label("aptitude", adherent.getAptitude()));

    // Ajout de la checkbox pilote
    if (adherent.isPilote()) {
        add(new Label("pilote", "oui"));
    } else {/*from   w  ww. ja  va2s  .  c  om*/
        add(new Label("pilote", "non"));
    }
    // Ajout de la liste des niveaux d'encadrement
    add(new Label("encadrement", adherent.getEncadrement()));
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    add(new Label("dateCM", sdf.format(adherent.getDateCM())));

    List<ContactUrgent> contactUrgents = adherent.getContacts();
    DataView cuView = new DataView<ContactUrgent>("cuView", new ContactUrgentDataProvider(contactUrgents), 20) {
        @Override
        protected void populateItem(final Item<ContactUrgent> item) {
            final ContactUrgent contact = (ContactUrgent) item.getModelObject();

            item.add(new Label("titre", contact.getTitre()));
            item.add(new Label("nom", contact.getNom()));
            item.add(new Label("prenom", contact.getPrenom()));
            item.add(new Label("telephone", contact.getTelephone()));
            item.add(new Label("telephtwo", contact.getTelephtwo()));

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 5259097512265622750L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };
    cuView.setOutputMarkupId(true);
    add(cuView);

}

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

private void init() {
    try {// www. j  a  va  2 s  . co m
        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 .  j a v a 2s.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);
    ///*  ww w  . ja  v  a  2 s  . c o  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 www . ja  va2 s. c  o 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.consultation.InfoAdherent.java

private void init() {

    final Adherent adherent = ResaSession.get().getAdherentService()
            .rechercherAdherentParIdentifiant(ResaSession.get().getAdherent().getNumeroLicense());

    add(new Label("nom", adherent.getNom()));
    add(new Label("prenom", adherent.getPrenom()));
    add(new Label("numeroLicense", adherent.getNumeroLicense()));
    add(new Label("telephone", adherent.getTelephone()));
    add(new Label("mail", adherent.getMail()));
    add(new Label("niveau", adherent.getNiveau().getText()));
    add(new Label("aptitude", adherent.getAptitude().getText()));

    // Ajout de la checkbox pilote
    if (adherent.isPilote()) {
        add(new Label("pilote", "oui"));
    } else {// w  w w. j  av a2  s  .com
        add(new Label("pilote", "non"));
    }
    // Ajout de la liste des niveaux d'encadrement
    add(new Label("encadrement", adherent.getEncadrement().getText()));
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    add(new Label("dateCM", sdf.format(adherent.getDateCM())));

    List<ContactUrgent> contactUrgents = adherent.getContacts();
    DataView cuView = new DataView<ContactUrgent>("cuView", new ContactUrgentDataProvider(contactUrgents), 20) {
        @Override
        protected void populateItem(final Item<ContactUrgent> item) {
            final ContactUrgent contact = (ContactUrgent) item.getModelObject();

            item.add(new Label("titre", contact.getTitre()));
            item.add(new Label("nom", contact.getNom()));
            item.add(new Label("prenom", contact.getPrenom()));
            item.add(new Label("telephone", contact.getTelephone()));
            item.add(new Label("telephtwo", contact.getTelephtwo()));

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 5259097512265622750L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };
    cuView.setOutputMarkupId(true);
    add(cuView);

    //add openPdf resouceLink with webResource pdf for visu FS
    add(new UtilsFSpdf().createWebResourcePdf(adherent, null));

}

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

private void init() {
    try {/*from   w  w w.  ja v a 2  s  .  c  o m*/
        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;
                }
            }));
        }
    });

}