Example usage for com.vaadin.ui Label setStyleName

List of usage examples for com.vaadin.ui Label setStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Label setStyleName.

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:fr.univlorraine.mondossierweb.MdwFallbackTouchkitUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    Label label = new Label(applicationContext.getMessage("fallbackToMobile.message",
            new Object[] { PropertyUtils.getAppUrl() }, getLocale()), ContentMode.HTML);
    label.setStyleName(ValoTheme.LABEL_HUGE);
    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//from ww  w.j  a v  a  2s.c  o m
    content.setMargin(true);
    content.addComponent(label);
    setContent(content);

}

From source file:fr.univlorraine.mondossierweb.views.CalendrierMobileView.java

License:Apache License

public void refresh() {
    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();// www  .  j a  v a2s . com

        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        if (userController.isEnseignant()) {
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(ListeInscritsMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToListeInscrits();
                }

                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToRecherche(null);
                }
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);
        }

        //Title
        Label labelNavBar = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelNavBar.setStyleName("v-label-navbar");
        navbar.addComponent(labelNavBar);
        navbar.setComponentAlignment(labelNavBar, Alignment.MIDDLE_CENTER);

        navbar.setExpandRatio(labelNavBar, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        //globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);
        globalLayout.setStyleName("v-scrollableelement");

        if (MdwTouchkitUI.getCurrent().getEtudiant() != null
                && MdwTouchkitUI.getCurrent().getEtudiant().getCalendrier() != null
                && MdwTouchkitUI.getCurrent().getEtudiant().getCalendrier().size() > 0) {

            List<Examen> listeExam = MdwTouchkitUI.getCurrent().getEtudiant().getCalendrier();

            for (Examen exam : listeExam) {
                Panel panelCalendrier = new Panel();
                panelCalendrier.setSizeFull();
                HorizontalLayout labelExamenLayout = new HorizontalLayout();
                labelExamenLayout.setMargin(true);
                labelExamenLayout.setSpacing(true);
                labelExamenLayout.setSizeFull();

                //Dtail de l'preuve
                VerticalLayout detailLayout = new VerticalLayout();
                detailLayout.setSizeFull();
                //ajout de la date
                Label dateLabel = new Label(exam.getDatedeb());
                dateLabel.setStyleName(ValoTheme.LABEL_BOLD);
                detailLayout.addComponent(dateLabel);
                dateLabel.addStyleName("v-label-align-right");

                //ajout de l'heure
                Label heureLabel = new Label(exam.getHeure());
                detailLayout.addComponent(heureLabel);
                heureLabel.setStyleName("v-label-align-right");

                //ajout de la salle
                Label salleLabel = new Label(exam.getLibsalle());
                detailLayout.addComponent(salleLabel);
                salleLabel.setStyleName("v-label-align-right");

                //ajout du batiment
                Label batimentLabel = new Label(exam.getBatiment());
                detailLayout.addComponent(batimentLabel);
                batimentLabel.setStyleName("v-label-align-right");

                //Libelle de l'preuve
                VerticalLayout libelleLayout = new VerticalLayout();
                libelleLayout.setSizeFull();
                Label libLabel = new Label(exam.getEpreuve());
                libLabel.setSizeFull();
                libLabel.setStyleName(ValoTheme.LABEL_BOLD);
                libelleLayout.addComponent(new Label(""));
                libelleLayout.addComponent(libLabel);

                //Ajout des 2 layouts dans le layout principal 
                labelExamenLayout.addComponent(detailLayout);
                labelExamenLayout.addComponent(libelleLayout);

                //Ajout du layout principal dans le panel
                panelCalendrier.setContent(labelExamenLayout);

                //Ajout du panel  la vue
                globalLayout.addComponent(panelCalendrier);

            }

        } else {
            Panel panelCalendrier = new Panel();
            panelCalendrier.setSizeFull();
            HorizontalLayout labelExamenLayout = new HorizontalLayout();
            labelExamenLayout.setMargin(true);
            labelExamenLayout.setSizeFull();
            Label aucunExamen = new Label(
                    applicationContext.getMessage(NAME + ".examen.aucun", null, getLocale()));
            aucunExamen.setStyleName(ValoTheme.LABEL_COLORED);
            aucunExamen.addStyleName(ValoTheme.LABEL_BOLD);
            aucunExamen.setWidth("100%");
            aucunExamen.addStyleName("label-centre");
            labelExamenLayout.addComponent(aucunExamen);
            panelCalendrier.setContent(labelExamenLayout);
            globalLayout.addComponent(panelCalendrier);
        }

        addComponent(globalLayout);
        setExpandRatio(globalLayout, 1);
    }
}

From source file:fr.univlorraine.mondossierweb.views.CalendrierView.java

License:Apache License

/**
 * Initialise la vue//from  w  w  w.ja  v  a2 s . c  o m
 */
@PostConstruct
public void init() {
    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())
            && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) {
        /* Style */
        setMargin(true);
        setSpacing(true);

        //Si on n'a pas dj essayer de rcuprer le calendrier
        if (!MainUI.getCurrent().getEtudiant().isCalendrierRecupere()) {
            etudiantController.recupererCalendrierExamens();
        }

        /* Titre */
        HorizontalLayout titleLayout = new HorizontalLayout();
        titleLayout.setWidth("100%");
        Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        titleLayout.addComponent(title);
        titleLayout.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
        //Test si on a des diplomes ou des etapes
        if (MainUI.getCurrent().getEtudiant().getCalendrier() != null
                && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) {
            Button pdfButton = new Button();
            pdfButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
            pdfButton.addStyleName("button-big-icon");
            pdfButton.addStyleName("red-button-icon");
            pdfButton.setIcon(FontAwesome.FILE_PDF_O);
            pdfButton.setDescription(
                    applicationContext.getMessage(NAME + ".btn.pdf.description", null, getLocale()));
            if (PropertyUtils.isPushEnabled()) {
                MyFileDownloader fd = new MyFileDownloader(calendrierController.exportPdf());
                fd.extend(pdfButton);
            } else {
                FileDownloader fd = new FileDownloader(calendrierController.exportPdf());
                fd.setOverrideContentType(false);
                fd.extend(pdfButton);
            }
            titleLayout.addComponent(pdfButton);
            titleLayout.setComponentAlignment(pdfButton, Alignment.MIDDLE_RIGHT);
        }
        addComponent(titleLayout);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);

        /* Message d'info */
        if (applicationContext.getMessage(NAME + ".message.info", null, getLocale()) != null) {
            Panel panelVue = new Panel();

            HorizontalLayout vueLayout = new HorizontalLayout();
            vueLayout.setMargin(true);
            vueLayout.setSpacing(true);
            vueLayout.setSizeFull();

            Label vueLabel = new Label(
                    applicationContext.getMessage(NAME + ".message.info", null, getLocale()));
            vueLabel.setContentMode(ContentMode.HTML);
            vueLabel.setStyleName(ValoTheme.LABEL_SMALL);
            vueLayout.addComponent(vueLabel);
            vueLayout.setExpandRatio(vueLabel, 1);

            panelVue.setContent(vueLayout);
            globalLayout.addComponent(panelVue);
        }

        /* Le Calendrier */
        Panel panelCalendrier = new Panel(
                applicationContext.getMessage(NAME + ".calendrier.title", null, getLocale()));
        panelCalendrier.setSizeFull();

        if (MainUI.getCurrent().getEtudiant() != null
                && MainUI.getCurrent().getEtudiant().getCalendrier() != null
                && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) {

            BeanItemContainer<Examen> bic = new BeanItemContainer<>(Examen.class,
                    MainUI.getCurrent().getEtudiant().getCalendrier());
            Table calendrierTable = new Table(null, bic);
            calendrierTable.setWidth("100%");
            String[] colonnes_to_create = CAL_FIELDS;
            if (configController.isAffNumPlaceExamen()) {
                colonnes_to_create = CAL_FIELDS_AVEC_PLACE;
            }
            for (String fieldName : colonnes_to_create) {
                calendrierTable.setColumnHeader(fieldName,
                        applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale()));
            }
            calendrierTable.addGeneratedColumn("batiment", new BatimentColumnGenerator());
            calendrierTable.addGeneratedColumn("salle", new SalleColumnGenerator());
            calendrierTable.setColumnHeader("batiment",
                    applicationContext.getMessage(NAME + ".table.batiment", null, getLocale()));
            calendrierTable.setColumnHeader("salle",
                    applicationContext.getMessage(NAME + ".table.salle", null, getLocale()));
            String[] colonnes_to_display = CAL_FIELDS_ORDER;
            if (configController.isAffNumPlaceExamen()) {
                colonnes_to_display = CAL_FIELDS_ORDER_AVEC_PLACE;
            }
            calendrierTable.setVisibleColumns((Object[]) colonnes_to_display);
            calendrierTable.setColumnCollapsingAllowed(true);
            calendrierTable.setColumnReorderingAllowed(true);
            calendrierTable.setSelectable(false);
            calendrierTable.setImmediate(true);
            calendrierTable.setStyleName("noscrollabletable");
            calendrierTable.setPageLength(calendrierTable.getItemIds().size());

            panelCalendrier.setContent(calendrierTable);
        } else {
            HorizontalLayout labelExamenLayout = new HorizontalLayout();
            labelExamenLayout.setMargin(true);
            labelExamenLayout.setSizeFull();
            Label aucunExamen = new Label(
                    applicationContext.getMessage(NAME + ".examen.aucun", null, getLocale()));
            aucunExamen.setStyleName(ValoTheme.LABEL_COLORED);
            aucunExamen.addStyleName(ValoTheme.LABEL_BOLD);
            labelExamenLayout.addComponent(aucunExamen);
            panelCalendrier.setContent(labelExamenLayout);
        }
        globalLayout.addComponent(panelCalendrier);

        addComponent(globalLayout);
    }
}

From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java

License:Apache License

private void renseignerPanelContact() {

    VerticalLayout contactLayout = new VerticalLayout();

    /* Layout pour afficher les erreurs */
    VerticalLayout erreursLayout = new VerticalLayout();
    contactLayout.addComponent(erreursLayout);
    erreursLayout.setVisible(false);/* ww w. j av  a  2s . co  m*/

    /* Layout avec les champ 'Portable' et 'Email personnel' */
    FormLayout formContactLayout = new FormLayout();
    formContactLayout.setSpacing(true);
    formContactLayout.setMargin(true);

    String captionTelPortable = applicationContext.getMessage(NAME + ".portable.title", null, getLocale());
    fieldTelPortable = new TextField(captionTelPortable, MainUI.getCurrent().getEtudiant().getTelPortable());
    formatTextField(fieldTelPortable);
    fieldTelPortable.setMaxLength(15);
    formContactLayout.addComponent(fieldTelPortable);

    if (userController.isEtudiant()) {
        String captionMailPerso = applicationContext.getMessage(NAME + ".mailperso.title", null, getLocale());
        fieldMailPerso = new TextField(captionMailPerso, MainUI.getCurrent().getEtudiant().getEmailPerso());
        formatTextField(fieldMailPerso);
        fieldMailPerso.setMaxLength(200);
        formContactLayout.addComponent(fieldMailPerso);
    }

    contactLayout.addComponent(formContactLayout);

    /* Si user tudiant , modifications autorise des coordonnes de contact
     * et si l'tudiant possde une addresse annuelle, on affiche les boutons de modification */
    if (userController.isEtudiant() && configController.isModificationCoordonneesPersoAutorisee()
            && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
        //Layout pour les boutons de modification
        HorizontalLayout btnLayout = new HorizontalLayout();
        btnLayout.setSizeFull();
        btnLayout.setSpacing(true);
        btnLayout.setMargin(true);

        //Bouton pour valider la modification
        btnValidModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.validercoordonnees", null, getLocale()));
        btnValidModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_FRIENDLY);
        btnValidModifCoordonneesPerso.setIcon(FontAwesome.CHECK);
        btnValidModifCoordonneesPerso.addClickListener(e -> {
            erreursLayout.removeAllComponents();
            List<String> retour = etudiantController.updateContact(fieldTelPortable.getValue(),
                    fieldMailPerso.getValue(), MainUI.getCurrent().getEtudiant().getCod_etu());
            //si modif ok
            if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) {
                etudiantController.recupererEtatCivil();
                renseignerPanelContact();
            } else {
                //affichage erreurs
                if (retour != null && retour.size() > 0) {
                    String errorMsg = "";
                    for (String erreur : retour) {
                        if (!errorMsg.equals(""))
                            errorMsg = errorMsg + "<br />";
                        errorMsg = errorMsg + erreur;
                    }
                    Label labelErreur = new Label(errorMsg);
                    labelErreur.setContentMode(ContentMode.HTML);
                    labelErreur.setStyleName(ValoTheme.LABEL_FAILURE);
                    erreursLayout.addComponent(labelErreur);
                }
                erreursLayout.setVisible(true);
            }
        });
        btnValidModifCoordonneesPerso.setVisible(false);
        btnLayout.addComponent(btnValidModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnValidModifCoordonneesPerso, Alignment.MIDDLE_CENTER);

        //Bouton pour annuler la modification
        btnAnnulerModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.annulercoordonnees", null, getLocale()));
        btnAnnulerModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_DANGER);
        btnAnnulerModifCoordonneesPerso.setIcon(FontAwesome.TIMES);
        btnAnnulerModifCoordonneesPerso.addClickListener(e -> {
            erreursLayout.removeAllComponents();
            fieldMailPerso.setValue(MainUI.getCurrent().getEtudiant().getEmailPerso());
            fieldMailPerso.setEnabled(false);
            fieldMailPerso.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            fieldTelPortable.setValue(MainUI.getCurrent().getEtudiant().getTelPortable());
            fieldTelPortable.setEnabled(false);
            fieldTelPortable.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            btnValidModifCoordonneesPerso.setVisible(false);
            btnAnnulerModifCoordonneesPerso.setVisible(false);
            btnModifCoordonneesPerso.setVisible(true);

        });
        btnAnnulerModifCoordonneesPerso.setVisible(false);
        btnLayout.addComponent(btnAnnulerModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnAnnulerModifCoordonneesPerso, Alignment.MIDDLE_CENTER);

        //Bouton pour activer la modification des donnes
        btnModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.modifiercoordonnees", null, getLocale()));
        btnModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_PRIMARY);
        btnModifCoordonneesPerso.setIcon(FontAwesome.EDIT);
        btnModifCoordonneesPerso.addClickListener(e -> {
            fieldMailPerso.setEnabled(true);
            fieldMailPerso.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            fieldTelPortable.setEnabled(true);
            fieldTelPortable.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            btnValidModifCoordonneesPerso.setVisible(true);
            btnAnnulerModifCoordonneesPerso.setVisible(true);
            btnModifCoordonneesPerso.setVisible(false);
        });
        btnLayout.addComponent(btnModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnModifCoordonneesPerso, Alignment.MIDDLE_CENTER);
        contactLayout.addComponent(btnLayout);
    }

    panelContact.setContent(contactLayout);

}

From source file:fr.univlorraine.mondossierweb.views.FavorisMobileView.java

License:Apache License

/**
 * Initialise la vue//from w ww .ja v  a  2 s.c  o m
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        removeAllComponents();

        /* Style */
        setSizeFull();

        liste_types_inscrits = new LinkedList<String>();
        liste_types_inscrits.add("ELP");
        liste_types_inscrits.add("VET");

        liste_type_arbo = new LinkedList<String>();
        liste_type_arbo.add("CMP");
        liste_type_arbo.add("VET");

        List<Favoris> lfav = favorisController.getFavoris();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton info
        infoButton = new Button();
        infoButton.setIcon(FontAwesome.INFO);
        infoButton.setStyleName("v-nav-button");
        infoButton.addClickListener(e -> {
            /**
             * NOUVELLE VERSION
             */
            Notification note = new Notification(
                    applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()), "",
                    Notification.TYPE_TRAY_NOTIFICATION, true);
            note.setPosition(Position.MIDDLE_CENTER);
            note.setDelayMsec(6000);
            note.show(UI.getCurrent().getPage());
            /**
             * ANCIENNE VERSION
             */
            /*
            //afficher message
            HelpMobileWindow hbw = new HelpMobileWindow(applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()),applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()),false);
                    
            UI.getCurrent().addWindow(hbw);
            */
        });
        navbar.addComponent(infoButton);
        navbar.setComponentAlignment(infoButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelFav = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelFav.setStyleName("v-label-navbar");
        navbar.addComponent(labelFav);
        navbar.setComponentAlignment(labelFav, Alignment.MIDDLE_CENTER);

        //Bouton Search
        Button searchButton = new Button();
        searchButton.setIcon(FontAwesome.SEARCH);
        searchButton.setStyleName("v-nav-button");
        navbar.addComponent(searchButton);
        navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);
        searchButton.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });
        navbar.setExpandRatio(labelFav, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);

        FormLayout labelLayout = new FormLayout();
        labelLayout.setSizeFull();
        labelLayout.setMargin(false);
        labelLayout.setSpacing(false);

        Label infoLabel = new Label(applicationContext.getMessage(NAME + ".info.label", null, getLocale()));
        infoLabel.setStyleName(ValoTheme.LABEL_SMALL);
        infoLabel.setIcon(FontAwesome.INFO_CIRCLE);
        infoLabel.setWidth("100%");

        labelLayout.addComponent(infoLabel);
        globalLayout.addComponent(labelLayout);

        if (lfav != null && lfav.size() > 0) {
            if (favorisContientVet(lfav)) {

                Panel vetPanel = new Panel(
                        applicationContext.getMessage(NAME + ".vetpanel.title", null, getLocale()));
                vetPanel.setStyleName("centertitle-panel");
                vetPanel.addStyleName("v-colored-panel-caption");
                vetPanel.setSizeFull();

                VerticalLayout vetLayout = new VerticalLayout();
                vetLayout.setSizeFull();
                vetLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.VET)) {
                        i++;

                        HorizontalLayout favVetLayout = new HorizontalLayout();
                        favVetLayout.setSizeFull();
                        favVetLayout.setMargin(true);
                        favVetLayout.setSpacing(true);
                        favVetLayout.setStyleName("v-layout-multiline");
                        favVetLayout.setWidth("100%");
                        favVetLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        codeButton.setCaption(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favVetLayout.addComponent(codeButton);
                        //favVetLayout.setComponentAlignment(codeButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.addComponent(libButton);
                        favVetLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.setExpandRatio(libButton, 1);
                        vetLayout.addComponent(favVetLayout);
                        if (i > 1) {
                            favVetLayout.addStyleName("line-separator");
                        }
                    }
                }
                vetPanel.setContent(vetLayout);
                globalLayout.addComponent(vetPanel);

            }

            if (favorisContientElp(lfav)) {
                Panel elpPanel = new Panel(
                        applicationContext.getMessage(NAME + ".elppanel.title", null, getLocale()));
                elpPanel.setStyleName("centertitle-panel");
                elpPanel.addStyleName("v-colored-panel-caption");
                elpPanel.setSizeFull();

                VerticalLayout elpLayout = new VerticalLayout();
                elpLayout.setSizeFull();
                elpLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.ELP)) {
                        i++;
                        HorizontalLayout favElpLayout = new HorizontalLayout();
                        favElpLayout.setSizeFull();
                        favElpLayout.setMargin(true);
                        favElpLayout.setSpacing(true);
                        favElpLayout.setStyleName("v-layout-multiline");
                        favElpLayout.setWidth("100%");
                        favElpLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favElpLayout.addComponent(codeButton);
                        favElpLayout.addComponent(libButton);
                        favElpLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favElpLayout.setExpandRatio(libButton, 1);
                        elpLayout.addComponent(favElpLayout);
                        if (i > 1) {
                            favElpLayout.addStyleName("line-separator");
                        }
                    }
                }
                elpPanel.setContent(elpLayout);
                globalLayout.addComponent(elpPanel);
            }

        }

        labelAucunFavoriLayout = new HorizontalLayout();
        labelAucunFavoriLayout.setMargin(true);
        labelAucunFavoriLayout.setSizeFull();
        Button aucunFavoris = new Button(
                applicationContext.getMessage(NAME + ".favoris.aucun", null, getLocale()));
        aucunFavoris.setStyleName("v-nav-button");
        aucunFavoris.addStyleName(ValoTheme.BUTTON_LINK);
        aucunFavoris.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });

        labelAucunFavoriLayout.addComponent(aucunFavoris);
        labelAucunFavoriLayout.setVisible(false);
        globalLayout.addComponent(labelAucunFavoriLayout);

        if (lfav == null || lfav.size() == 0) {
            labelAucunFavoriLayout.setVisible(true);
        }

        //addComponent(globalLayout);
        contentLayout.setStyleName("v-scrollableelement");
        contentLayout.addComponent(globalLayout);
        addComponent(contentLayout);
        setExpandRatio(contentLayout, 1);

    }
}

From source file:fr.univlorraine.mondossierweb.views.FavorisView.java

License:Apache License

/**
 * Initialise la vue/*from  w w  w .  j  a  v a 2s .com*/
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && userController.isEnseignant()) {

        removeAllComponents();
        /* Style */
        setMargin(true);
        setSpacing(true);

        liste_types_inscrits = new LinkedList<String>();
        liste_types_inscrits.add(Utils.ELP);
        liste_types_inscrits.add(Utils.VET);

        liste_type_arbo = new LinkedList<String>();
        liste_type_arbo.add(Utils.CMP);
        liste_type_arbo.add(Utils.VET);

        lfav = favorisController.getFavoris();

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);

        if (lfav != null && lfav.size() > 0) {
            bic = new BeanItemContainer<>(Favoris.class, lfav);
            bic.addNestedContainerProperty("id.typfav");
            bic.addNestedContainerProperty("id.idfav");
            favorisTable = new Table(null, bic);
            favorisTable.setWidth("100%");

            favorisTable.addGeneratedColumn("Type", new DisplayTypeColumnGenerator());
            favorisTable.setColumnHeader("Type",
                    applicationContext.getMessage(NAME + ".table.id.typfav", null, getLocale()));

            favorisTable.addGeneratedColumn("id", new DisplayIdColumnGenerator());
            favorisTable.setColumnHeader("id",
                    applicationContext.getMessage(NAME + ".table.id.idfav", null, getLocale()));

            favorisTable.addGeneratedColumn("Libelle", new MyLibelleColumnGenerator());
            favorisTable.addGeneratedColumn("Actions", new MyActionsColumnGenerator());

            favorisTable.setVisibleColumns((Object[]) FAV_FIELDS_ORDER);
            favorisTable.setColumnCollapsingAllowed(true);
            favorisTable.setColumnReorderingAllowed(true);
            favorisTable.setSelectable(true);
            favorisTable.setImmediate(true);
            favorisTable.addStyleName("noscrollabletable");
            favorisTable.setPageLength(favorisTable.getItemIds().size());
            globalLayout.addComponent(favorisTable);

        }

        labelAucunFavoriLayout = new HorizontalLayout();
        labelAucunFavoriLayout.setMargin(true);
        labelAucunFavoriLayout.setSizeFull();
        Label aucunFavoris = new Label(
                applicationContext.getMessage(NAME + ".favoris.aucun", null, getLocale()));
        aucunFavoris.setStyleName(ValoTheme.LABEL_COLORED);
        aucunFavoris.addStyleName(ValoTheme.LABEL_BOLD);
        labelAucunFavoriLayout.addComponent(aucunFavoris);
        labelAucunFavoriLayout.setVisible(false);
        globalLayout.addComponent(labelAucunFavoriLayout);

        if (lfav == null || lfav.size() == 0) {
            labelAucunFavoriLayout.setVisible(true);
        }

        addComponent(globalLayout);

    }
}

From source file:fr.univlorraine.mondossierweb.views.InformationsAnnuellesMobileView.java

License:Apache License

public void refresh() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();/*from  ww  w  . jav a 2 s .co m*/

        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        if (userController.isEnseignant()) {
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(ListeInscritsMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToListeInscrits();
                } else {

                    if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                            .getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                        MdwTouchkitUI.getCurrent().navigateToRecherche(null);
                    }
                }
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);
        }

        //Title
        Label labelTrombi = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        if (userController.isEnseignant()) {
            //Si on ne peut pas dj revenir sur la recherche via le bouton 'retour'
            if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() == null
                    || !MdwTouchkitUI.getCurrent().getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                //Bouton Search
                Button searchButton = new Button();
                searchButton.setIcon(FontAwesome.SEARCH);
                searchButton.setStyleName("v-nav-button");
                navbar.addComponent(searchButton);
                navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);
                searchButton.addClickListener(e -> {
                    ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
                });
            }
        }

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        //globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);
        globalLayout.setStyleName("v-scrollableelement");

        VerticalLayout slimLayout = new VerticalLayout();
        slimLayout.setSpacing(false);
        slimLayout.setMargin(false);
        //slimLayout.setStyleName("v-scrollableelement");

        String mail = MdwTouchkitUI.getCurrent().getEtudiant().getEmail();
        if (StringUtils.hasText(mail)) {
            Panel mailPanel = new Panel();
            mailPanel.setStyleName("panel-without-bottom-line-separator");
            HorizontalLayout mailLayout = new HorizontalLayout();
            mailLayout.setSizeFull();
            mailLayout.setHeight("25px");
            Label mailLabel = new Label();

            mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>";
            mailLabel.setValue(mail);
            mailLabel.setContentMode(ContentMode.HTML);

            mailLabel.setSizeFull();
            mailLabel.addStyleName("label-centre");
            mailLayout.addComponent(mailLabel);
            mailLayout.setComponentAlignment(mailLabel, Alignment.MIDDLE_CENTER);
            mailPanel.setContent(mailLayout);
            slimLayout.addComponent(mailPanel);
            slimLayout.setComponentAlignment(mailPanel, Alignment.MIDDLE_CENTER);
        }

        Panel etuPanel = new Panel();
        HorizontalLayout photoLayout = new HorizontalLayout();
        photoLayout.setId(MdwTouchkitUI.getCurrent().getEtudiant().getCod_ind());
        photoLayout.setSizeFull();
        if (MdwTouchkitUI.getCurrent().getEtudiant().getPhoto() != null) {
            Image fotoEtudiant = new Image(null,
                    new ExternalResource(MdwTouchkitUI.getCurrent().getEtudiant().getPhoto()));
            fotoEtudiant.setWidth("120px");
            fotoEtudiant.setStyleName(ValoTheme.BUTTON_LINK);
            photoLayout.addComponent(fotoEtudiant);

        }
        VerticalLayout nomCodeLayout = new VerticalLayout();
        //nomCodeLayout.setSizeFull();
        nomCodeLayout.setSpacing(false);

        Label labelNomEtudiant = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelNomEtudiant.setSizeFull();
        labelNomEtudiant.setStyleName(ValoTheme.LABEL_BOLD);
        labelNomEtudiant.addStyleName("label-centre");
        nomCodeLayout.addComponent(labelNomEtudiant);
        nomCodeLayout.setComponentAlignment(labelNomEtudiant, Alignment.MIDDLE_CENTER);
        //nomCodeLayout.setExpandRatio(labelNomEtudiant, 1);

        Label codetuLabel = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getCod_etu());
        codetuLabel.setSizeFull();
        codetuLabel.setStyleName(ValoTheme.LABEL_TINY);
        codetuLabel.addStyleName("label-centre");
        nomCodeLayout.addComponent(codetuLabel);
        nomCodeLayout.setComponentAlignment(codetuLabel, Alignment.MIDDLE_CENTER);

        photoLayout.addComponent(nomCodeLayout);
        photoLayout.setComponentAlignment(nomCodeLayout, Alignment.MIDDLE_CENTER);
        photoLayout.setExpandRatio(nomCodeLayout, 1);

        etuPanel.setContent(photoLayout);

        slimLayout.addComponent(etuPanel);
        slimLayout.setComponentAlignment(etuPanel, Alignment.MIDDLE_CENTER);

        globalLayout.addComponent(slimLayout);

        Panel panelInfos = new Panel(applicationContext.getMessage(NAME + ".infos.title", null, getLocale())
                + " " + Utils.getAnneeUniversitaireEnCours(
                        etudiantController.getAnneeUnivEnCours(MdwTouchkitUI.getCurrent())));
        panelInfos.setStyleName("centertitle-panel");
        panelInfos.addStyleName("v-colored-panel-caption");

        //Si l'tudiant est inscrit pour l'anne en cours
        if (MdwTouchkitUI.getCurrent().getEtudiant().isInscritPourAnneeEnCours()) {

            FormLayout formInfosLayout = new FormLayout();
            formInfosLayout.setSpacing(true);
            formInfosLayout.setMargin(true);

            //Numro Anonymat visible que si l'utilisateur est tudiant
            List<Anonymat> lano = null;
            if (!userController.isEnseignant() && userController.isEtudiant()) {
                lano = MdwTouchkitUI.getCurrent().getEtudiant().getNumerosAnonymat();
                if (lano != null) {
                    //Si l'tudiant n'a qu'un seul numro d'anonymat
                    if (lano.size() == 1) {
                        String captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymat.title",
                                null, getLocale());
                        TextField fieldNumAnonymat = new TextField(captionNumAnonymat, MdwTouchkitUI
                                .getCurrent().getEtudiant().getNumerosAnonymat().get(0).getCod_etu_ano());
                        formatTextField(fieldNumAnonymat);
                        //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE);
                        //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale()));
                        formInfosLayout.addComponent(fieldNumAnonymat);
                    }
                    //Si l'tudiant a plusieurs numros d'anonymat
                    if (lano.size() > 1) {
                        int i = 0;
                        for (Anonymat ano : lano) {
                            String captionNumAnonymat = "";
                            if (i == 0) {
                                //Pour le premier numro affich on affiche le libell du champ
                                captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymats.title",
                                        null, getLocale());
                            }
                            TextField fieldNumAnonymat = new TextField(captionNumAnonymat,
                                    ano.getCod_etu_ano() + " (" + ano.getLib_man() + ")");
                            formatTextField(fieldNumAnonymat);
                            if (i == 0) {
                                //Pour le premier numro affich on affiche l'info bulle
                                //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE);
                                //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale()));
                            }
                            formInfosLayout.addComponent(fieldNumAnonymat);
                            i++;
                        }
                    }
                }
            }

            String captionBousier = applicationContext.getMessage(NAME + ".boursier.title", null, getLocale());
            TextField fieldNumBoursier = new TextField(captionBousier,
                    MdwTouchkitUI.getCurrent().getEtudiant().isBoursier()
                            ? applicationContext.getMessage(NAME + ".boursier.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".boursier.non", null, getLocale()));
            formatTextField(fieldNumBoursier);
            formInfosLayout.addComponent(fieldNumBoursier);

            String captionSalarie = applicationContext.getMessage(NAME + ".salarie.title", null, getLocale());
            TextField fieldSalarie = new TextField(captionSalarie,
                    MdwTouchkitUI.getCurrent().getEtudiant().isTemSalarie() == true
                            ? applicationContext.getMessage(NAME + ".salarie.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".salarie.non", null, getLocale()));
            formatTextField(fieldSalarie);
            formInfosLayout.addComponent(fieldSalarie);

            String captionAmenagementEtude = applicationContext.getMessage(NAME + ".amenagementetude.title",
                    null, getLocale());
            TextField fieldAmenagementEtude = new TextField(captionAmenagementEtude,
                    MdwTouchkitUI.getCurrent().getEtudiant().isTemAmenagementEtude() == true
                            ? applicationContext.getMessage(NAME + ".amenagementetude.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".amenagementetude.non", null, getLocale()));
            formatTextField(fieldAmenagementEtude);
            formInfosLayout.addComponent(fieldAmenagementEtude);

            panelInfos.setContent(formInfosLayout);
        } else {

            HorizontalLayout labelNonInscritLayout = new HorizontalLayout();
            labelNonInscritLayout.setMargin(true);
            labelNonInscritLayout.setSizeFull();
            Label labelNonInscrit = new Label(
                    applicationContext.getMessage(NAME + ".inscrit.non", null, getLocale()));
            labelNonInscrit.setStyleName(ValoTheme.LABEL_COLORED);
            labelNonInscrit.addStyleName(ValoTheme.LABEL_BOLD);
            labelNonInscrit.setWidth("100%");
            labelNonInscrit.addStyleName("label-centre");
            labelNonInscritLayout.addComponent(labelNonInscrit);
            panelInfos.setContent(labelNonInscritLayout);

        }
        globalLayout.addComponent(panelInfos);

        addComponent(globalLayout);
        setExpandRatio(globalLayout, 1);

    }
}

From source file:fr.univlorraine.mondossierweb.views.InscriptionsView.java

License:Apache License

/**
 * Initialise la vue//  w  ww .  j a  va2s.  c  om
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())
            && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) {
        /* Style */
        setMargin(true);
        setSpacing(true);

        /* Titre */
        Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        addComponent(title);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);

        //Si les informations sur les inscriptions n'ont pas dj t rcupres, on les rcupre
        if (MainUI.getCurrent().getEtudiant().getLibEtablissement() == null) {
            etudiantController.recupererInscriptions();
        }

        //Test si la rcupration des inscriptions via le WS s'est bien passe
        if (MainUI.getCurrent().isRecuperationWsInscriptionsOk()) {

            //Tout c'est bien pass lors de la rcupration des infos via le WS
            Panel panelInscription = new Panel(MainUI.getCurrent().getEtudiant().getLibEtablissement());

            Table inscriptionsTable = new Table(null, new BeanItemContainer<>(Inscription.class,
                    MainUI.getCurrent().getEtudiant().getLinsciae()));
            inscriptionsTable.setWidth("100%");
            String[] colonnes = IA_FIELDS_ORDER;
            if (userController.isEtudiant()) {
                colonnes = IA_FIELDS_ORDER_ETU;
            }
            inscriptionsTable.setVisibleColumns((Object[]) colonnes);
            for (String fieldName : colonnes) {
                inscriptionsTable.setColumnHeader(fieldName,
                        applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale()));
            }
            inscriptionsTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.lib_etp", null, getLocale()),
                    new LibelleInscriptionColumnGenerator());

            //inscriptionsTable.setSortContainerPropertyId("cod_anu");
            inscriptionsTable.setColumnCollapsingAllowed(true);
            inscriptionsTable.setColumnReorderingAllowed(false);
            inscriptionsTable.setSelectable(false);
            inscriptionsTable.setImmediate(true);
            inscriptionsTable.setStyleName("noscrollabletable");
            inscriptionsTable.setPageLength(inscriptionsTable.getItemIds().size());
            panelInscription.setContent(inscriptionsTable);
            globalLayout.addComponent(panelInscription);

            //DAC
            Panel panelDAC = new Panel(applicationContext.getMessage(NAME + ".dac.title", null, getLocale()));

            if (MainUI.getCurrent().getEtudiant().getLinscdac() != null
                    && MainUI.getCurrent().getEtudiant().getLinscdac().size() > 0) {
                Table inscriptionsDAC = new Table(null, new BeanItemContainer<>(Inscription.class,
                        MainUI.getCurrent().getEtudiant().getLinscdac()));
                inscriptionsDAC.setWidth("100%");
                inscriptionsDAC.setVisibleColumns((Object[]) DAC_FIELDS_ORDER);
                for (String fieldName : DAC_FIELDS_ORDER) {
                    inscriptionsDAC.setColumnHeader(fieldName,
                            applicationContext.getMessage(NAME + ".tabledac." + fieldName, null, getLocale()));
                }
                inscriptionsDAC.setColumnCollapsingAllowed(true);
                inscriptionsDAC.setColumnReorderingAllowed(false);
                inscriptionsDAC.setSelectable(false);
                inscriptionsDAC.setImmediate(true);
                inscriptionsDAC.setStyleName("noscrollabletable");
                inscriptionsDAC.setPageLength(inscriptionsDAC.getItemIds().size());
                panelDAC.setContent(inscriptionsDAC);
            } else {
                HorizontalLayout labelDacLayout = new HorizontalLayout();
                labelDacLayout.setMargin(true);
                labelDacLayout.setSizeFull();
                Label aucuneDAC = new Label(
                        applicationContext.getMessage(NAME + ".dac.aucune", null, getLocale()) + " "
                                + MainUI.getCurrent().getEtudiant().getLibEtablissement());
                aucuneDAC.setStyleName(ValoTheme.LABEL_COLORED);
                aucuneDAC.addStyleName(ValoTheme.LABEL_BOLD);
                labelDacLayout.addComponent(aucuneDAC);
                panelDAC.setContent(labelDacLayout);
            }
            globalLayout.addComponent(panelDAC);

            Panel panelPremInscription = new Panel(
                    applicationContext.getMessage(NAME + ".premiereinsc.title", null, getLocale()));
            FormLayout formPremInscription = new FormLayout();
            formPremInscription.setSpacing(true);
            formPremInscription.setMargin(true);

            String captionAnneePremInscription = applicationContext.getMessage(NAME + ".premiereinsc.annee",
                    null, getLocale());
            TextField fieldAnneePremInscription = new TextField(captionAnneePremInscription,
                    MainUI.getCurrent().getEtudiant().getAnneePremiereInscrip());
            formatTextField(fieldAnneePremInscription);
            formPremInscription.addComponent(fieldAnneePremInscription);

            String captionEtbPremInscription = applicationContext.getMessage(NAME + ".premiereinsc.etb", null,
                    getLocale());
            TextField fieldEtbPremInscription = new TextField(captionEtbPremInscription,
                    MainUI.getCurrent().getEtudiant().getEtbPremiereInscrip());
            formatTextField(fieldEtbPremInscription);
            formPremInscription.addComponent(fieldEtbPremInscription);

            panelPremInscription.setContent(formPremInscription);
            globalLayout.addComponent(panelPremInscription);

            addComponent(globalLayout);
        } else {
            //Il y a eu un soucis lors de la rcupration des infos via le WS
            Panel panelErreurInscription = new Panel();
            Label labelMsgErreur = new Label(
                    applicationContext.getMessage("AllView.erreur.message", null, getLocale()));
            panelErreurInscription.setContent(labelMsgErreur);
            addComponent(panelErreurInscription);

        }
    }

}

From source file:fr.univlorraine.mondossierweb.views.ListeInscritsMobileView.java

License:Apache License

/**
 * Initialise la vue/*w  w w.j  a  va  2  s . c om*/
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        // On rinitialise la vue
        removeAllComponents();

        // Style
        setSizeFull();
        addStyleName("v-noscrollableelement");

        // On rcupre le favori  afficher
        typeFavori = MdwTouchkitUI.getCurrent().getTypeObjListInscrits();
        libelleObj = "";
        if (typeIsVet() && MdwTouchkitUI.getCurrent().getEtapeListeInscrits() != null) {
            libelleObj = MdwTouchkitUI.getCurrent().getEtapeListeInscrits().getLibelle();
        }
        if (typeIsElp() && MdwTouchkitUI.getCurrent().getElpListeInscrits() != null) {
            libelleObj = MdwTouchkitUI.getCurrent().getElpListeInscrits().getLibelle();
        }

        //Rcupration de la liste des inscrits
        List<Inscrit> linscrits = MdwTouchkitUI.getCurrent().getListeInscrits();

        //Rcupration du nombre d'inscrit par page
        nbEtuParPage = configController.getTrombiMobileNbEtuParPage();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        returnButton = new Button();
        returnButton.setIcon(FontAwesome.ARROW_LEFT);
        returnButton.setStyleName("v-nav-button");
        returnButton.addClickListener(e -> {
            if (MdwTouchkitUI.getCurrent().getTrombinoscopeFromView() != null
                    && MdwTouchkitUI.getCurrent().getTrombinoscopeFromView().equals(FavorisMobileView.NAME)) {
                MdwTouchkitUI.getCurrent().navigateTofavoris();
            }
            if (MdwTouchkitUI.getCurrent().getTrombinoscopeFromView() != null
                    && MdwTouchkitUI.getCurrent().getTrombinoscopeFromView().equals(RechercheMobileView.NAME)) {
                MdwTouchkitUI.getCurrent().navigateToRecherche(null);
            }
        });
        navbar.addComponent(returnButton);
        navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelTrombi = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        // bouton pour ajouter en favori si ce n'est pas dj le cas
        List<Favoris> lfav = favorisController.getFavoris();
        FavorisPK favpk = new FavorisPK();
        favpk.setLogin(userController.getCurrentUserName());
        favpk.setIdfav(MdwTouchkitUI.getCurrent().getCodeObjListInscrits());
        favpk.setTypfav(typeFavori);
        Favoris favori = new Favoris();
        favori.setId(favpk);
        //Si l'objet n'est pas dj en favori
        if (lfav != null && !lfav.contains(favori)) {
            //Cration du bouton pour ajouter l'objet aux favoris
            Button btnAjoutFavori = new Button("+");
            btnAjoutFavori.setIcon(FontAwesome.STAR_O);
            btnAjoutFavori.setStyleName("v-nav-button");
            btnAjoutFavori.addClickListener(e -> {

                //creation du favori en base sur le clic du bouton
                favorisController.saveFavori(favori);

                //On cache le bouton de mise en favori
                btnAjoutFavori.setVisible(false);

                //Affichage d'un message de confirmation
                Notification.show(
                        applicationContext.getMessage(NAME + ".message.favoriAjoute", null, getLocale()),
                        Type.TRAY_NOTIFICATION);
            });

            //Ajout du bouton  l'interface
            navbar.addComponent(btnAjoutFavori);
        }

        //Bouton Filtre
        //On a la possibilit de filtrer le trombinoscope que si on est positionn sur un ELP
        if (typeIsElp()) {
            FiltreInscritsMobileWindow w = new FiltreInscritsMobileWindow();
            //Si on a des lments  afficher dans la popup filtre
            if ((w.getListeEtapes() != null && w.getListeEtapes().size() > 0)
                    || (w.getListeGroupes() != null && w.getListeGroupes().size() > 0)) {
                filterButton = new Button();
                filterButton.setIcon(FontAwesome.ELLIPSIS_V);
                filterButton.setStyleName("v-nav-button");

                filterButton.addClickListener(e -> {
                    w.addCloseListener(f -> {
                        //Si la personne a ferm la popup en appuyant sur le bouton FILTRER
                        if (w.isDemandeFiltrage()) {
                            vetSelectionnee = w.getVetSelectionnee();
                            groupeSelectionne = w.getGroupeSelectionne();
                            displayTrombinoscope(false);
                        }
                    });
                    UI.getCurrent().addWindow(w);

                });
                navbar.addComponent(filterButton);
                navbar.setComponentAlignment(filterButton, Alignment.MIDDLE_RIGHT);
            }
        }

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        //Test si la liste contient des tudiants
        if (linscrits != null && linscrits.size() > 0) {

            pageEnCours = 1;
            //Calcul du nombre maxi de page
            if (nbEtuParPage > 0 && linscrits.size() > nbEtuParPage) {
                pageMax = (linscrits.size() / nbEtuParPage) + 1;
            } else {
                //On affiche tous les inscrits sur une seule page
                pageMax = 1;
            }

            infoLayout = new VerticalLayout();
            infoLayout.setSizeFull();
            infoLayout.setMargin(true);
            infoLayout.setSpacing(true);
            infoLayout.addStyleName("v-scrollableelement");

            //Layout avec le Libelle
            HorizontalLayout resumeLayout = new HorizontalLayout();
            resumeLayout.setWidth("100%");
            resumeLayout.setHeight("20px");
            //Label affichant le nb d'inscrits
            infoLibelleObj = new Label(libelleObj);
            infoLibelleObj.setStyleName(ValoTheme.LABEL_SMALL);
            infoLibelleObj.setSizeFull();
            resumeLayout.addComponent(infoLibelleObj);
            resumeLayout.setComponentAlignment(infoLibelleObj, Alignment.TOP_CENTER);
            infoLayout.addComponent(resumeLayout);

            //Layout qui contient la liste des inscrits et le trombinoscope
            dataLayout = new VerticalLayout();
            dataLayout.setSizeFull();

            //Layout contenant le gridLayout correspondant au trombinoscope
            verticalLayoutForTrombi = new VerticalLayout();
            verticalLayoutForTrombi.setSizeFull();
            verticalLayoutForTrombi.addStyleName("v-scrollablepanel");

            //Cration du trombinoscope
            displayTrombinoscope(false);

            verticalLayoutForTrombi.addComponent(trombiLayout);
            verticalLayoutForTrombi.setSizeFull();
            verticalLayoutForTrombi.setHeight(null);

            if (pageMax > 1) {
                HorizontalLayout layoutPagination = new HorizontalLayout();
                layoutPagination.setWidth("100%");
                layoutPagination.setMargin(true);
                if (pageEnCours < pageMax) {
                    Button btnNext = new Button(
                            applicationContext.getMessage(NAME + ".btn.affichersuite", null, getLocale()));
                    btnNext.setStyleName(ValoTheme.BUTTON_PRIMARY);
                    btnNext.addStyleName("v-popover-button");
                    btnNext.addClickListener(e -> {
                        pageEnCours++;
                        displayTrombinoscope(true);
                        if (pageEnCours >= pageMax) {
                            btnNext.setVisible(false);
                        }
                    });
                    layoutPagination.addComponent(btnNext);
                    layoutPagination.setComponentAlignment(btnNext, Alignment.MIDDLE_CENTER);
                    layoutPagination.setExpandRatio(btnNext, 1);
                }
                verticalLayoutForTrombi.addComponent(layoutPagination);

            }

            //Le layout contient le trombi  afficher
            dataLayout.addComponent(verticalLayoutForTrombi);

            infoLayout.addComponent(dataLayout);
            infoLayout.setExpandRatio(dataLayout, 1);

            addComponent(infoLayout);

            setExpandRatio(infoLayout, 1);
        } else {
            // Layout contenant le label du message indiquant aucun inscrit
            infoLayout = new VerticalLayout();
            infoLayout.setMargin(true);
            infoLayout.setSpacing(true);

            // Label du message indiquant aucun inscrit
            Label infoAucuninscrit = new Label(
                    applicationContext.getMessage(NAME + ".message.aucuninscrit", null, getLocale()));
            infoAucuninscrit.setSizeFull();

            // Ajout du label au layout
            infoLayout.addComponent(infoAucuninscrit);
            addComponent(infoLayout);
            setExpandRatio(infoLayout, 1);
        }

    }

}

From source file:fr.univlorraine.mondossierweb.views.ListeInscritsMobileView.java

License:Apache License

/**
 * Affichage du trombinoscope/*w  w w  .j a v a 2 s. com*/
 */
private void displayTrombinoscope(boolean completion) {
    // Rcupration de la liste des inscrits
    List<Inscrit> linscrits = MdwTouchkitUI.getCurrent().getListeInscrits();

    // On rinitialise le layout contenant le trombinoscope
    if (trombiLayout != null) {
        //On n'a pas fait 'afficher suivant'
        if (!completion) {
            trombiLayout.removeAllComponents();
        }
    } else {
        trombiLayout = new VerticalLayout();
        trombiLayout.setSizeFull();
        trombiLayout.setSpacing(true);
    }

    int compteurEtu = 0;
    //Pour chaque inscrit
    for (Inscrit inscrit : linscrits) {

        compteurEtu++;
        //Si on affiche tout sur une page ou si l'tudiant doit tre affich sur cette page
        if (pageMax == 1 || ((((pageEnCours - 1) * nbEtuParPage) < compteurEtu)
                && (compteurEtu <= ((pageEnCours) * nbEtuParPage)))) {

            boolean afficherEtudiant = true;

            //Si l'tudiant n'est pas dans la VET slectionne, on ne l'affiche pas
            if (StringUtils.hasText(vetSelectionnee)
                    && (inscrit.getId_etp() == null || !inscrit.getId_etp().contains(vetSelectionnee))) {
                afficherEtudiant = false;

            }

            // Si l'tudiant n'est pas dans le groupe slectionn, on ne l'affiche pas
            if (StringUtils.hasText(groupeSelectionne) && (inscrit.getCodes_groupes() == null
                    || !inscrit.getCodes_groupes().contains(groupeSelectionne))) {
                afficherEtudiant = false;
            }

            // Si l'tudiant doit tre affich
            if (afficherEtudiant) {

                // Panel contenant l'tudiant
                Panel etuPanel = new Panel();

                // Layout du Panel contenant l'tudiant
                HorizontalLayout photoLayout = new HorizontalLayout();
                // Ajout d'un id sur le layout
                photoLayout.setId(inscrit.getCod_ind());
                photoLayout.setSizeFull();

                // Si on a une url renseigne vers la photo de l'tudiant
                if (inscrit.getUrlphoto() != null) {

                    // Image contenant la photo de l'tudiant
                    Image fotoEtudiant = new Image(null, new ExternalResource(inscrit.getUrlphoto()));
                    fotoEtudiant.setWidth("120px");
                    fotoEtudiant.setStyleName(ValoTheme.BUTTON_LINK);
                    // Gestion du clic sur la photo
                    fotoEtudiant.addClickListener(e -> {
                        // Au clic sur la photo on redirige vers le contenu du dossier de l'tudiant dont la photo a t clique
                        rechercheController.accessToMobileDetail(inscrit.getCod_etu().toString(),
                                Utils.TYPE_ETU, false);
                    });
                    // Ajout de la photo au layout
                    photoLayout.addComponent(fotoEtudiant);

                }

                // Layout contenant le nom, prnom et le codetu
                VerticalLayout nomCodeLayout = new VerticalLayout();
                //nomCodeLayout.setSizeFull();
                nomCodeLayout.setSpacing(false);

                // Bouton contenant le nom/prnom
                Button btnNomEtudiant = new Button(inscrit.getPrenom() + " " + inscrit.getNom());
                Utils.setButtonStyle(btnNomEtudiant);

                // Ajout du bouton au layout
                nomCodeLayout.addComponent(btnNomEtudiant);
                //Gestion du clic sur le bouton
                btnNomEtudiant.addClickListener(e -> {
                    // Au clic sur le bouton on redirige vers le contenu du dossier de l'tudiant dont le nom a t cliqu
                    rechercheController.accessToMobileDetail(inscrit.getCod_etu().toString(), Utils.TYPE_ETU,
                            false);
                });
                nomCodeLayout.setComponentAlignment(btnNomEtudiant, Alignment.MIDDLE_CENTER);
                //nomCodeLayout.setExpandRatio(btnNomEtudiant, 1);

                // Label contenant le codetu
                Label codetuLabel = new Label(inscrit.getCod_etu());
                codetuLabel.setSizeFull();
                codetuLabel.setStyleName(ValoTheme.LABEL_TINY);
                codetuLabel.addStyleName("label-centre");

                // Ajout du label au layout
                nomCodeLayout.addComponent(codetuLabel);
                nomCodeLayout.setComponentAlignment(codetuLabel, Alignment.MIDDLE_CENTER);

                // Ajout du layout contenant nom, prnom et codetu au layout de la photo
                photoLayout.addComponent(nomCodeLayout);
                photoLayout.setComponentAlignment(nomCodeLayout, Alignment.MIDDLE_CENTER);
                photoLayout.setExpandRatio(nomCodeLayout, 1);

                // Ajout du layout de la photo comme contenu du panel
                etuPanel.setContent(photoLayout);
                trombiLayout.addComponent(etuPanel);
                trombiLayout.setComponentAlignment(etuPanel, Alignment.MIDDLE_CENTER);
            }
        }
    }

}