Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setExpandRatio.

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

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

License:Apache License

public void initListe() {
    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && userController.isEnseignant()) {
        // initialisation de la vue
        removeAllComponents();//from w ww  . java  2  s .  c  o m
        listeEtapes = null;
        listeGroupes = null;

        // Style 
        setMargin(true);
        setSpacing(true);
        setSizeFull();

        // Rcupration de l'objet de la SE dont on doit afficher les inscrits
        code = MainUI.getCurrent().getCodeObjListInscrits();
        typeFavori = MainUI.getCurrent().getTypeObjListInscrits();
        libelleObj = "";
        if (typeIsVet() && MainUI.getCurrent().getEtapeListeInscrits() != null) {
            libelleObj = MainUI.getCurrent().getEtapeListeInscrits().getLibelle();
        }
        if (typeIsElp() && MainUI.getCurrent().getElpListeInscrits() != null) {
            libelleObj = MainUI.getCurrent().getElpListeInscrits().getLibelle();
        }

        // Si l'objet est renseign
        if (code != null && typeFavori != null) {

            //Panel contenant les filtres d'affichage et le bouton de mise en favori
            HorizontalLayout panelLayout = new HorizontalLayout();
            panelLayout.setSizeFull();
            panelLayout.addStyleName("small-font-element");

            // Layout contenant les filtres
            FormLayout formInscritLayout = new FormLayout();
            formInscritLayout.setStyleName(ValoTheme.FORMLAYOUT_LIGHT);
            formInscritLayout.setSpacing(true);
            formInscritLayout.setMargin(true);

            panelFormInscrits = new Panel(code + " " + libelleObj);

            //Affichage d'une liste droulante contenant la liste des annes
            List<String> lannees = MainUI.getCurrent().getListeAnneeInscrits();
            if (lannees != null && lannees.size() > 0) {
                listeAnnees = new ComboBox(applicationContext.getMessage(NAME + ".annee", null, getLocale()));
                listeAnnees.setPageLength(5);
                listeAnnees.setTextInputAllowed(false);
                listeAnnees.setNullSelectionAllowed(false);
                listeAnnees.setWidth("150px");
                for (String annee : lannees) {
                    listeAnnees.addItem(annee);
                    int anneenplusun = Integer.parseInt(annee) + 1;
                    listeAnnees.setItemCaption(annee, annee + "/" + anneenplusun);
                }
                listeAnnees.setValue(MainUI.getCurrent().getAnneeInscrits());

                //Gestion de l'vnement sur le changement d'anne
                listeAnnees.addValueChangeListener(new ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        String selectedValue = (String) event.getProperty().getValue();

                        //faire le changement
                        Map<String, String> parameterMap = new HashMap<>();
                        parameterMap.put("code", code);
                        parameterMap.put("type", typeFavori);

                        //rcupration de la nouvelle liste
                        if (typeIsVet()) {
                            listeInscritsController.recupererLaListeDesInscrits(parameterMap, selectedValue,
                                    MainUI.getCurrent());
                        }
                        if (typeIsElp()) {
                            listeInscritsController.recupererLaListeDesInscritsELP(parameterMap, selectedValue,
                                    MainUI.getCurrent());
                        }

                        //update de l'affichage
                        initListe();
                    }
                });
                formInscritLayout.addComponent(listeAnnees);

            }

            //Si on affiche la liste des inscrits  un ELP
            //on doit affiche l'tape d'appartenance et ventuellement les groupes
            //Affichage d'une liste droulante contenant la liste des annes
            if (typeIsElp()) {
                List<VersionEtape> letapes = MainUI.getCurrent().getListeEtapesInscrits();
                if (letapes != null && letapes.size() > 0) {
                    listeEtapes = new ComboBox(
                            applicationContext.getMessage(NAME + ".etapes", null, getLocale()));
                    listeEtapes.setPageLength(5);
                    listeEtapes.setNullSelectionAllowed(false);
                    listeEtapes.setTextInputAllowed(false);
                    listeEtapes.setRequired(false);
                    listeEtapes.setWidth("400px");
                    listeEtapes.addItem(TOUTES_LES_ETAPES_LABEL);
                    listeEtapes.setItemCaption(TOUTES_LES_ETAPES_LABEL, TOUTES_LES_ETAPES_LABEL);
                    for (VersionEtape etape : letapes) {
                        String idEtape = etape.getId().getCod_etp() + "/" + etape.getId().getCod_vrs_vet();
                        listeEtapes.addItem(idEtape);
                        listeEtapes.setItemCaption(idEtape, "[" + idEtape + "] " + etape.getLib_web_vet());
                    }

                    if (MainUI.getCurrent().getEtapeInscrits() != null) {
                        listeEtapes.setValue(MainUI.getCurrent().getEtapeInscrits());
                    } else {

                        listeEtapes.setValue(TOUTES_LES_ETAPES_LABEL);
                    }

                    //Gestion de l'vnement sur le changement d'tape
                    listeEtapes.addValueChangeListener(new ValueChangeListener() {
                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            String vetSelectionnee = (String) event.getProperty().getValue();
                            if (vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) {
                                vetSelectionnee = null;
                            }
                            MainUI.getCurrent().setEtapeInscrits(vetSelectionnee);

                            //faire le changement
                            String groupeSelectionne = ((listeGroupes != null
                                    && listeGroupes.getValue() != null) ? (String) listeGroupes.getValue()
                                            : null);
                            if (groupeSelectionne != null && groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) {
                                groupeSelectionne = null;
                            }
                            filtrerInscrits(vetSelectionnee, groupeSelectionne);

                        }
                    });
                    formInscritLayout.addComponent(listeEtapes);

                }

                List<ElpDeCollection> lgroupes = MainUI.getCurrent().getListeGroupesInscrits();
                if (lgroupes != null && lgroupes.size() > 0) {
                    listeGroupes = new ComboBox();
                    listeGroupes.setPageLength(5);
                    listeGroupes.setNullSelectionAllowed(false);
                    listeGroupes.setTextInputAllowed(false);
                    listeGroupes.setRequired(false);
                    listeGroupes.setStyleName(ValoTheme.COMBOBOX_BORDERLESS);
                    listeGroupes.setWidth("348px");
                    listeGroupes.addItem(TOUS_LES_GROUPES_LABEL);
                    listeGroupes.setItemCaption(TOUS_LES_GROUPES_LABEL, TOUS_LES_GROUPES_LABEL);
                    for (ElpDeCollection edc : lgroupes) {
                        for (CollectionDeGroupes cdg : edc.getListeCollection()) {
                            for (Groupe groupe : cdg.getListeGroupes()) {
                                listeGroupes.addItem(groupe.getCleGroupe());
                                listeGroupes.setItemCaption(groupe.getCleGroupe(), groupe.getLibGroupe());

                            }
                        }
                    }
                    if (MainUI.getCurrent().getGroupeInscrits() != null) {
                        listeGroupes.setValue(MainUI.getCurrent().getGroupeInscrits());
                    } else {
                        listeGroupes.setValue(TOUS_LES_GROUPES_LABEL);
                    }

                    //Gestion de l'vnement sur le changement de groupe
                    listeGroupes.addValueChangeListener(new ValueChangeListener() {
                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            String grpSelectionnee = (String) event.getProperty().getValue();
                            if (grpSelectionnee.equals(TOUS_LES_GROUPES_LABEL)) {
                                grpSelectionnee = null;
                            }
                            MainUI.getCurrent().setGroupeInscrits(grpSelectionnee);

                            //faire le changement
                            String etapeSelectionnee = ((listeEtapes != null && listeEtapes.getValue() != null)
                                    ? (String) listeEtapes.getValue()
                                    : null);
                            if (etapeSelectionnee != null
                                    && etapeSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) {
                                etapeSelectionnee = null;
                            }
                            filtrerInscrits(etapeSelectionnee, grpSelectionnee);

                        }
                    });

                    HorizontalLayout gpLayout = new HorizontalLayout();
                    gpLayout.setCaption(applicationContext.getMessage(NAME + ".groupes", null, getLocale()));
                    gpLayout.setMargin(false);
                    gpLayout.setSpacing(false);
                    gpLayout.addComponent(listeGroupes);
                    Button btnDetailGpe = new Button();
                    btnDetailGpe.setWidth("52px");
                    btnDetailGpe.setHeight("32px");
                    btnDetailGpe.setStyleName(ValoTheme.BUTTON_PRIMARY);
                    btnDetailGpe.setIcon(FontAwesome.SEARCH);
                    btnDetailGpe.setDescription(
                            applicationContext.getMessage(NAME + ".detail.groupes", null, getLocale()));
                    btnDetailGpe.addClickListener(e -> {
                        String vet = null;
                        if (listeEtapes != null && listeEtapes.getValue() != null
                                && !listeEtapes.getValue().equals(TOUTES_LES_ETAPES_LABEL)) {
                            vet = listeEtapes.getItemCaption(listeEtapes.getValue());
                        }
                        DetailGroupesWindow dgw = new DetailGroupesWindow(lgroupes,
                                panelFormInscrits.getCaption(), vet, (String) listeAnnees.getValue());
                        UI.getCurrent().addWindow(dgw);
                    });
                    gpLayout.addComponent(btnDetailGpe);

                    formInscritLayout.addComponent(gpLayout);

                }
            }
            panelLayout.addComponent(formInscritLayout);
            panelLayout.setComponentAlignment(formInscritLayout, Alignment.MIDDLE_LEFT);

            //Cration du favori pour l'objet concern pas la liste des inscrits
            List<Favoris> lfav = favorisController.getFavoris();
            FavorisPK favpk = new FavorisPK();
            favpk.setLogin(userController.getCurrentUserName());
            favpk.setIdfav(code);
            favpk.setTypfav(typeFavori);
            Favoris favori = new Favoris();
            favori.setId(favpk);
            //Cration du bouton pour ajouter l'objet aux favoris
            favoriLayout = new VerticalLayout();
            favoriLayout.setSizeFull();
            favoriLayout.setMargin(true);
            favoriLayout.setSpacing(true);
            btnAjoutFavori = new Button(
                    applicationContext.getMessage(NAME + ".btn.ajoutFavori", null, getLocale()));
            btnAjoutFavori.setIcon(FontAwesome.STAR_O);
            btnAjoutFavori.addStyleName(ValoTheme.BUTTON_PRIMARY);
            btnAjoutFavori.setDescription(
                    applicationContext.getMessage(NAME + ".btn.ajoutFavori", null, getLocale()));
            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
            favoriLayout.addComponent(btnAjoutFavori);
            favoriLayout.setComponentAlignment(btnAjoutFavori, Alignment.TOP_RIGHT);
            if (typeIsElp()) {
                btnMasquerFiltre = new Button(
                        applicationContext.getMessage(NAME + ".btn.btnMasquerFiltre", null, getLocale()));
                btnMasquerFiltre.setIcon(FontAwesome.CHEVRON_CIRCLE_UP);
                btnMasquerFiltre.addStyleName(ValoTheme.BUTTON_FRIENDLY);
                btnMasquerFiltre.setDescription(
                        applicationContext.getMessage(NAME + ".btn.btnMasquerFiltre", null, getLocale()));
                btnMasquerFiltre.addClickListener(e -> {
                    panelFormInscrits.setContent(null);
                    if (btnDisplayFiltres != null) {
                        btnDisplayFiltres.setVisible(true);
                    }
                });
                favoriLayout.addComponent(btnMasquerFiltre);
                favoriLayout.setComponentAlignment(btnMasquerFiltre, Alignment.BOTTOM_RIGHT);
            }
            panelLayout.addComponent(favoriLayout);
            panelLayout.setComponentAlignment(favoriLayout, Alignment.TOP_RIGHT);

            //Si l'objet est dj en favori
            if (lfav != null && lfav.contains(favori)) {

                //On affiche pas le bouton de mise en favori
                btnAjoutFavori.setVisible(false);
            }

            panelFormInscrits.setContent(panelLayout);
            addComponent(panelFormInscrits);

            //Rcupration de la liste des inscrits
            linscrits = MainUI.getCurrent().getListeInscrits();

            refreshListeCodind(new BeanItemContainer<>(Inscrit.class, linscrits));

            //Test si la liste contient des tudiants
            if (linscrits != null && linscrits.size() > 0 && listecodind != null && listecodind.size() > 0) {
                infoLayout = new VerticalLayout();
                infoLayout.setSizeFull();

                //Layout avec le nb d'inscrit, le bouton trombinoscope et le bouton d'export
                HorizontalLayout resumeLayout = new HorizontalLayout();
                resumeLayout.setWidth("100%");
                resumeLayout.setHeight("50px");

                //Label affichant le nb d'inscrits
                infoNbInscrit = new Label(
                        applicationContext.getMessage(NAME + ".message.nbinscrit", null, getLocale()) + " : "
                                + linscrits.size());

                leftResumeLayout = new HorizontalLayout();
                leftResumeLayout.addComponent(infoNbInscrit);
                leftResumeLayout.setComponentAlignment(infoNbInscrit, Alignment.MIDDLE_LEFT);

                Button infoDescriptionButton = new Button();
                infoDescriptionButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
                infoDescriptionButton.setIcon(FontAwesome.INFO_CIRCLE);
                infoDescriptionButton.setDescription(applicationContext
                        .getMessage(NAME + ".message.info.predescription", null, getLocale()));
                infoDescriptionButton.addClickListener(e -> {
                    String message = "";
                    if (typeIsVet()) {
                        message = applicationContext.getMessage(NAME + ".message.info.vetdescription", null,
                                getLocale());
                    }
                    if (typeIsElp()) {
                        message = applicationContext.getMessage(NAME + ".message.info.elpdescription", null,
                                getLocale());
                    }

                    HelpBasicWindow hbw = new HelpBasicWindow(message,
                            applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()));
                    UI.getCurrent().addWindow(hbw);
                });
                leftResumeLayout.addComponent(infoDescriptionButton);
                leftResumeLayout.setComponentAlignment(infoDescriptionButton, Alignment.MIDDLE_LEFT);

                //Bouton export trombinoscope
                btnExportTrombi = new Button();
                btnExportTrombi.setIcon(FontAwesome.FILE_PDF_O);
                btnExportTrombi.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
                btnExportTrombi.addStyleName("button-icon");
                btnExportTrombi.addStyleName("red-button-icon");
                btnExportTrombi.setDescription(
                        applicationContext.getMessage(NAME + ".pdf.trombinoscope.link", null, getLocale()));

                //methode qui permet de generer l'export  la demande
                //Cration du nom du fichier
                String nomFichier = applicationContext.getMessage("pdf.trombinoscope.title", null,
                        Locale.getDefault()) + "_" + panelFormInscrits.getCaption() + ".pdf";
                nomFichier = nomFichier.replaceAll(" ", "_");
                StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
                    @Override
                    public InputStream getStream() {

                        //recuperation de l'anne slectionne et du libell de l'ELP
                        String annee = (String) listeAnnees.getValue();
                        String libObj = panelFormInscrits.getCaption();

                        //cration du trombi en pdf
                        return listeInscritsController.getPdfStream(linscrits, listecodind, libObj, annee);
                    }
                }, nomFichier);
                resource.setMIMEType("application/force-download;charset=UTF-8");
                resource.setCacheTime(0);

                //On ajoute le FD sur le bouton d'export
                if (PropertyUtils.isPushEnabled()) {
                    new MyFileDownloader(resource).extend(btnExportTrombi);
                } else {
                    FileDownloader fdpdf = new FileDownloader(resource);
                    fdpdf.setOverrideContentType(false);
                    fdpdf.extend(btnExportTrombi);
                }

                leftResumeLayout.addComponent(btnExportTrombi);
                leftResumeLayout.setComponentAlignment(btnExportTrombi, Alignment.MIDDLE_LEFT);
                //if(!afficherTrombinoscope){

                //On cache le bouton d'export pdf
                btnExportTrombi.setVisible(false);
                //}

                //Bouton export liste excel
                btnExportExcel = new Button();
                btnExportExcel.setIcon(FontAwesome.FILE_EXCEL_O);
                btnExportExcel.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
                btnExportExcel.addStyleName("button-icon");
                btnExportExcel
                        .setDescription(applicationContext.getMessage(NAME + ".excel.link", null, getLocale()));
                String nomFichierXls = applicationContext.getMessage("excel.listeinscrits.title", null,
                        Locale.getDefault()) + "_" + panelFormInscrits.getCaption() + ".xls";
                nomFichierXls = nomFichierXls.replaceAll(" ", "_");

                StreamResource resourceXls = new StreamResource(new StreamResource.StreamSource() {

                    @Override
                    public InputStream getStream() {

                        //recuperation de l'anne slectionne et du libell de l'ELP
                        String annee = (String) listeAnnees.getValue();
                        String libObj = panelFormInscrits.getCaption();

                        //cration du trombi en pdf
                        return listeInscritsController.getXlsStream(linscrits, listecodind, listeGroupes,
                                libObj, annee, typeFavori);
                    }
                }, nomFichierXls);
                resourceXls.setMIMEType("application/force-download;charset=UTF-8");
                resourceXls.setCacheTime(0);
                //On ajoute le FD sur le bouton d'export
                if (PropertyUtils.isPushEnabled()) {
                    new MyFileDownloader(resourceXls).extend(btnExportExcel);
                } else {
                    FileDownloader fd = new FileDownloader(resourceXls);
                    fd.setOverrideContentType(false);
                    fd.extend(btnExportExcel);
                }

                //if(!afficherTrombinoscope){
                //On change le bouton d'export pdf par le bouton export excel
                leftResumeLayout.replaceComponent(btnExportTrombi, btnExportExcel);
                //}

                resumeLayout.addComponent(leftResumeLayout);

                //Middle layout avec les bouton de collapse des colonnes
                middleResumeLayout = new HorizontalLayout();
                middleResumeLayout.setSizeFull();
                middleResumeLayout.addStyleName("small-font-element");
                middleResumeLayout.setSpacing(true);

                if (!typeIsVet()) {
                    collapseEtp = new CheckBox(
                            applicationContext.getMessage(NAME + ".collapseEtp.title", null, getLocale()));
                    collapseEtp.setValue(true);
                    collapseEtp.addValueChangeListener(e -> {
                        inscritstable.setColumnCollapsed("etape", !collapseEtp.getValue());
                    });
                    collapseEtp.setDescription(applicationContext.getMessage(NAME + ".collapseEtp.description",
                            null, getLocale()));
                    middleResumeLayout.addComponent(collapseEtp);
                    middleResumeLayout.setComponentAlignment(collapseEtp, Alignment.MIDDLE_CENTER);
                }
                collapseResultatsS1 = new CheckBox(
                        applicationContext.getMessage(NAME + ".collapseResultatsS1.title", null, getLocale()));
                collapseResultatsS1.setValue(false);
                collapseResultatsS1.addValueChangeListener(e -> {
                    inscritstable.setColumnCollapsed("notes1", !collapseResultatsS1.getValue());
                });
                collapseResultatsS1.setDescription(applicationContext
                        .getMessage(NAME + ".collapseResultatsS1.description", null, getLocale()));
                middleResumeLayout.addComponent(collapseResultatsS1);
                middleResumeLayout.setComponentAlignment(collapseResultatsS1, Alignment.MIDDLE_CENTER);

                collapseResultatsS2 = new CheckBox(
                        applicationContext.getMessage(NAME + ".collapseResultatsS2.title", null, getLocale()));
                collapseResultatsS2.setValue(false);
                collapseResultatsS2.addValueChangeListener(e -> {
                    inscritstable.setColumnCollapsed("notes2", !collapseResultatsS2.getValue());
                });
                collapseResultatsS2.setDescription(applicationContext
                        .getMessage(NAME + ".collapseResultatsS2.description", null, getLocale()));
                middleResumeLayout.addComponent(collapseResultatsS2);
                middleResumeLayout.setComponentAlignment(collapseResultatsS2, Alignment.MIDDLE_CENTER);

                resumeLayout.addComponent(middleResumeLayout);

                HorizontalLayout buttonResumeLayout = new HorizontalLayout();
                buttonResumeLayout.setSizeFull();
                buttonResumeLayout.setSpacing(true);
                //Bouton pour afficher les filtres
                btnDisplayFiltres = new Button();
                btnDisplayFiltres.setWidth("52px");
                btnDisplayFiltres.setHeight("32px");
                btnDisplayFiltres.setStyleName(ValoTheme.BUTTON_FRIENDLY);
                btnDisplayFiltres.setIcon(FontAwesome.FILTER);
                btnDisplayFiltres.setDescription(
                        applicationContext.getMessage(NAME + ".btn.displayFilters", null, getLocale()));
                btnDisplayFiltres.addClickListener(e -> {
                    panelFormInscrits.setContent(panelLayout);
                    btnDisplayFiltres.setVisible(false);
                });
                buttonResumeLayout.addComponent(btnDisplayFiltres);
                buttonResumeLayout.setComponentAlignment(btnDisplayFiltres, Alignment.MIDDLE_RIGHT);
                buttonResumeLayout.setExpandRatio(btnDisplayFiltres, 1);
                btnDisplayFiltres.setVisible(false);

                //Bouton trombinoscope
                btnTrombi = new Button(
                        applicationContext.getMessage(NAME + ".message.trombinoscope", null, getLocale()));
                if (listeInscritsController.isPhotoProviderOperationnel()) {
                    btnTrombi.setIcon(FontAwesome.GROUP);
                    buttonResumeLayout.addComponent(btnTrombi);

                    //Gestion du clic sur le bouton trombinoscope
                    btnTrombi.addClickListener(e -> {

                        //Si on doit afficher une fentre de loading pendant l'excution
                        if (PropertyUtils.isPushEnabled() && PropertyUtils.isShowLoadingIndicator()) {
                            //affichage de la pop-up de loading
                            MainUI.getCurrent().startBusyIndicator();

                            //Execution de la mthode en parallle dans un thread
                            executorService.execute(new Runnable() {
                                public void run() {
                                    MainUI.getCurrent().access(new Runnable() {
                                        @Override
                                        public void run() {
                                            executeDisplayTrombinoscope();
                                            //close de la pop-up de loading
                                            MainUI.getCurrent().stopBusyIndicator();
                                        }
                                    });
                                }
                            });

                        } else {
                            //On ne doit pas afficher de fentre de loading, on excute directement la mthode
                            executeDisplayTrombinoscope();
                        }

                    });
                    buttonResumeLayout.setComponentAlignment(btnTrombi, Alignment.MIDDLE_RIGHT);
                }

                //Bouton de retour  l'affichage de la liste
                btnRetourListe = new Button(
                        applicationContext.getMessage(NAME + ".message.retourliste", null, getLocale()));
                btnRetourListe.setIcon(FontAwesome.BARS);
                buttonResumeLayout.addComponent(btnRetourListe);
                //if(!afficherTrombinoscope){
                btnRetourListe.setVisible(false);
                //}

                //Gestion du clic sur le bouton de  retour  l'affichage de la liste
                btnRetourListe.addClickListener(e -> {
                    afficherTrombinoscope = false;
                    btnExportTrombi.setVisible(false);
                    leftResumeLayout.replaceComponent(btnExportTrombi, btnExportExcel);
                    btnTrombi.setVisible(true);
                    btnRetourListe.setVisible(false);
                    dataLayout.removeAllComponents();
                    dataLayout.addComponent(inscritstable);
                    middleResumeLayout.setVisible(true);

                });
                buttonResumeLayout.setComponentAlignment(btnRetourListe, Alignment.MIDDLE_RIGHT);

                resumeLayout.addComponent(buttonResumeLayout);

                infoLayout.addComponent(resumeLayout);

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

                //Table contenant la liste des inscrits
                inscritstable = new Table(null, new BeanItemContainer<>(Inscrit.class, linscrits));

                inscritstable.addStyleName("table-without-column-selector");
                inscritstable.setSizeFull();
                inscritstable.setVisibleColumns(new String[0]);

                String[] fields = INS_FIELDS_ELP;
                if (typeIsVet()) {
                    fields = INS_FIELDS_VET;
                }
                for (String fieldName : fields) {
                    inscritstable.setColumnHeader(fieldName,
                            applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale()));
                }

                inscritstable.addGeneratedColumn("cod_etu", new CodEtuColumnGenerator());
                inscritstable.setColumnHeader("cod_etu",
                        applicationContext.getMessage(NAME + ".table.cod_etu", null, getLocale()));
                inscritstable.addGeneratedColumn("email", new MailColumnGenerator());
                inscritstable.setColumnHeader("email",
                        applicationContext.getMessage(NAME + ".table.email", null, getLocale()));
                inscritstable.addGeneratedColumn("notes1", new Session1ColumnGenerator());
                inscritstable.setColumnHeader("notes1",
                        applicationContext.getMessage(NAME + ".table.notes1", null, getLocale()));
                inscritstable.addGeneratedColumn("notes2", new Session2ColumnGenerator());
                inscritstable.setColumnHeader("notes2",
                        applicationContext.getMessage(NAME + ".table.notes2", null, getLocale()));

                //Si on est sur un ELP
                if (typeIsElp()) {
                    //on affiche l'tape de rattachement
                    inscritstable.addGeneratedColumn("etape", new EtapeColumnGenerator());
                    inscritstable.setColumnHeader("etape",
                            applicationContext.getMessage(NAME + ".table.etape", null, getLocale()));
                }

                String[] fields_to_display = INS_FIELDS_TO_DISPLAY_ELP;
                if (typeIsVet()) {
                    fields_to_display = INS_FIELDS_TO_DISPLAY_VET;
                }

                inscritstable.setVisibleColumns((Object[]) fields_to_display);

                inscritstable.setColumnCollapsingAllowed(true);
                inscritstable.setColumnReorderingAllowed(false);

                //On masque les colonnes de notes par dfaut
                inscritstable.setColumnCollapsed("notes1", true);
                inscritstable.setColumnCollapsed("notes2", true);

                inscritstable.setSelectable(false);
                inscritstable.setImmediate(true);
                inscritstable.addStyleName("scrollabletable");
                //Si on n'a pas dj demand  afficher le trombinoscope
                //if(!afficherTrombinoscope){
                //la layout contient la table
                dataLayout.addComponent(inscritstable);
                //}

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

                //Cration du trombinoscope
                displayTrombinoscope();

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

                //Si on a demand  afficher le trombinoscope
                /*if(afficherTrombinoscope){
                   //Le layout contient le trombi  afficher
                   dataLayout.addComponent(verticalLayoutForTrombi);
                }*/
                infoLayout.addComponent(dataLayout);
                infoLayout.setExpandRatio(dataLayout, 1);
                addComponent(infoLayout);
                setExpandRatio(infoLayout, 1);

                //Si on a demand  afficher le trombinoscope
                if (afficherTrombinoscope) {
                    //On execute la procdure d'affichage du trombinoscope
                    executeDisplayTrombinoscope();
                }
            } else {
                Label infoAucuninscrit = new Label(
                        applicationContext.getMessage(NAME + ".message.aucuninscrit", null, getLocale()));
                addComponent(infoAucuninscrit);
                setComponentAlignment(infoAucuninscrit, Alignment.TOP_CENTER);
                setExpandRatio(infoAucuninscrit, 1);
            }

        }
    }
}

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

License:Apache License

@SuppressWarnings("deprecation")
public void refresh(Etape etapeToDisplay, String codetuToDisplay) {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {

        //On repassera dans la cration que si on n'a pas dej cr la vue
        if (codetu == null || !codetuToDisplay.equals(codetu)) {
            codetu = null;/*from w ww.j a va  2 s.c o  m*/
        }
        //On repassera dans la cration que si on n'a pas dej cr la vue
        if (etape == null || !etapeToDisplay.getAnnee().equals(etape.getAnnee())
                || !etapeToDisplay.getCode().equals(etape.getCode())
                || !etapeToDisplay.getVersion().equals(etape.getVersion())) {
            etape = null;
        }
        //On repassera dans la cration que si on n'a pas dej cr la vue
        if (codetu == null || etape == null) {
            compteurElp = 0;

            removeAllComponents();

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

            //Test si user enseignant
            if (userController.isEnseignant()) {
                //On recupere les notes pour un enseignant
                etudiantController.renseigneDetailNotesEtResultatsEnseignant(etapeToDisplay);
            } else {
                //On rcupre les notes pour un tudiant
                etudiantController.renseigneDetailNotesEtResultats(etapeToDisplay);
            }

            //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(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                MdwTouchkitUI.getCurrent().navigateToResumeNotes();
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

            //Titre
            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);

            //Significations
            if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
                significationButton = new Button();
                significationButton.setIcon(FontAwesome.INFO_CIRCLE);
                significationButton.setStyleName("v-nav-button");
                significationButton.addClickListener(e -> {
                    //afficher les significations
                    SignificationsMobileWindow w = new SignificationsMobileWindow(true);
                    UI.getCurrent().addWindow(w);
                });
                navbar.addComponent(significationButton);
                navbar.setComponentAlignment(significationButton, Alignment.MIDDLE_RIGHT);
            }

            addComponent(navbar);

            layoutList = new HashMap<String, LinkedList<HorizontalLayout>>();

            etape = etapeToDisplay;
            codetu = codetuToDisplay;

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

            /* Titre */
            setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale()));

            List<ElementPedagogique> lelp = MdwTouchkitUI.getCurrent().getEtudiant().getElementsPedagogiques();

            if (lelp != null && lelp.size() > 0) {
                //Panel notesPanel = new Panel();
                //notesPanel.setSizeFull();

                VerticalLayout notesLayout = new VerticalLayout();
                //notesLayout.setSpacing(true);

                HorizontalLayout libSessionLayout = new HorizontalLayout();
                libSessionLayout.setSizeFull();
                libSessionLayout.addComponent(new Label());

                HorizontalLayout sessionLayout = new HorizontalLayout();
                sessionLayout.setSizeFull();
                Label session1 = new Label("Session1");
                session1.setStyleName("label-bold-with-bottom");
                sessionLayout.addComponent(session1);
                Label session2 = new Label("Session2");
                session2.setStyleName("label-bold-with-bottom");
                sessionLayout.addComponent(session2);

                libSessionLayout.addComponent(sessionLayout);

                notesLayout.addComponent(libSessionLayout);

                boolean blueLevel = false;

                compteurElp = 0;
                elpPere = "";

                HorizontalLayout layoutPere = null;
                int nbFils = 0;

                for (ElementPedagogique elp : lelp) {

                    compteurElp++;

                    //Si on est sur un element de niveau 1, diffrent du premier element de la liste (qui est un rappel de l'etape)
                    if (elp.getLevel() == 1 && compteurElp > 1) {
                        blueLevel = !blueLevel;
                    }
                    HorizontalLayout libElpLayout = new HorizontalLayout();

                    if (compteurElp > 1) {
                        if (elp.getLevel() == 1) {

                            //Si le pere prcdent n'avait aucun fils
                            if (layoutPere != null && nbFils == 0) {
                                layoutPere.setStyleName("layout-bottom-line-separator");
                            }

                            layoutPere = libElpLayout;
                            nbFils = 0;
                            //Sur un elp de niveau 1, il est sur fond sombre
                            libElpLayout.addStyleName("main-layout-bottom-line-separator");

                            //ajout dans la hashMap
                            layoutList.put(elp.getCode(), new LinkedList<HorizontalLayout>());
                            elpPere = elp.getCode();

                            libElpLayout.setId("layout_pere_" + elp.getCode());

                        } else {
                            nbFils++;
                            libElpLayout.addStyleName("layout-bottom-line-separator");
                            libElpLayout.setId(compteurElp + "_" + elp.getCode() + "_layout_fils_" + elpPere);
                            //ajout dans la hashMap
                            layoutList.get(elpPere).add(libElpLayout);

                        }
                    } else {
                        //on affiche la racine (qui est un rappel de l'etape) en blanc sur un fond trs sombre
                        libElpLayout.addStyleName("root-layout-bottom-line-separator");
                    }
                    libElpLayout.setSizeFull();
                    libElpLayout.setHeight("100%");

                    VerticalLayout libVerticalLayout = new VerticalLayout();

                    Label libElpLabel = new Label(elp.getLibelle());
                    if (elp.isEpreuve()) {
                        libElpLabel.setStyleName("bold-italic-label");
                    } else {
                        libElpLabel.setStyleName("bold-label");
                    }
                    libVerticalLayout.addComponent(libElpLabel);

                    //Si on n'est pas sur le premier elp de la liste (rappel de l'tape) on affiche un indicateur de niveau
                    if (compteurElp > 1) {
                        HorizontalLayout levelMainLayout = new HorizontalLayout();
                        levelMainLayout.setSizeFull();
                        levelMainLayout.setSpacing(true);
                        levelMainLayout.setStyleName("level-indicator-layout");

                        int k = 0;
                        for (int i = 0; i < elp.getLevel(); i++) {
                            //Ajout d'un level
                            k++;
                            Label libLevelLayout = new Label();
                            libLevelLayout.setSizeFull();
                            libLevelLayout.setHeight("8px");
                            if (blueLevel) {
                                libLevelLayout.setStyleName("layout-level-blue-indicator");
                            } else {
                                libLevelLayout.setStyleName("layout-level-green-indicator");
                            }
                            levelMainLayout.addComponent(libLevelLayout);
                        }
                        //On pense avoir 7 level maxi 
                        for (int j = k; j < 8; j++) {
                            Label libLevelSpaceLayout = new Label();
                            libLevelSpaceLayout.setSizeFull();
                            libLevelSpaceLayout.setHeight("8px");
                            levelMainLayout.addComponent(libLevelSpaceLayout);
                        }

                        libVerticalLayout.addComponent(levelMainLayout);
                    }
                    libElpLayout.addComponent(libVerticalLayout);

                    HorizontalLayout noteLayout = new HorizontalLayout();
                    noteLayout.setSizeFull();

                    VerticalLayout vlsession1 = new VerticalLayout();
                    Label note1 = new Label(elp.getNote1());
                    if (!StringUtils.hasText(elp.getNote2())) {
                        if (elp.isEpreuve()) {
                            note1.setStyleName("bold-italic-label");
                        } else {
                            note1.setStyleName("bold-label");
                        }
                    }
                    vlsession1.addComponent(note1);
                    if (StringUtils.hasText(elp.getRes1())) {
                        Label adm1 = new Label(elp.getRes1());
                        if (!StringUtils.hasText(elp.getRes2())) {
                            if (elp.isEpreuve()) {
                                adm1.setStyleName("bold-italic-label");
                            } else {
                                adm1.setStyleName("bold-label");
                            }
                        }
                        vlsession1.addComponent(adm1);
                    }
                    noteLayout.addComponent(vlsession1);

                    VerticalLayout vlsession2 = new VerticalLayout();
                    Label note2 = new Label(elp.getNote2());
                    if (StringUtils.hasText(elp.getNote2())) {
                        if (elp.isEpreuve()) {
                            note2.setStyleName("bold-italic-label");
                        } else {
                            note2.setStyleName("bold-label");
                        }
                    }
                    vlsession2.addComponent(note2);
                    if (StringUtils.hasText(elp.getRes2())) {
                        Label adm2 = new Label(elp.getRes2());
                        if (StringUtils.hasText(elp.getRes2())) {
                            if (elp.isEpreuve()) {
                                adm2.setStyleName("bold-italic-label");
                            } else {
                                adm2.setStyleName("bold-label");
                            }
                        }
                        vlsession2.addComponent(adm2);
                    }
                    noteLayout.addComponent(vlsession2);

                    libElpLayout.addComponent(noteLayout);

                    notesLayout.addComponent(libElpLayout);

                    //Au dpart, on cache les lments de niveau suprieur  1
                    if (compteurElp > 1 && elp.getLevel() > 1) {
                        //libElpLayout.setVisible(false);
                        Page.getCurrent().getJavaScript().execute("document.getElementById('"
                                + libElpLayout.getId() + "').style.display=\"none\";");

                    }
                }

                //Cas o le dernier lment tait un lment le pere qui n'avait aucun fils
                if (layoutPere != null && nbFils == 0) {
                    layoutPere.setStyleName("layout-bottom-line-separator");
                }

                //Ajout du javascript
                for (Entry<String, LinkedList<HorizontalLayout>> entry : layoutList.entrySet()) {
                    String pere = entry.getKey();
                    LinkedList<HorizontalLayout> listeLayoutFils = entry.getValue();
                    // traitements
                    if (listeLayoutFils != null && listeLayoutFils.size() > 0) {
                        String affichagejavascriptfils = "";
                        for (HorizontalLayout hl : listeLayoutFils) {
                            affichagejavascriptfils += "if(document.getElementById('" + hl.getId()
                                    + "').style.display==\"none\"){document.getElementById('" + hl.getId()
                                    + "').style.display = \"block\";}else{document.getElementById('"
                                    + hl.getId() + "').style.display = \"none\";}";
                        }
                        //sur le clic du layout pere, on affiche les fils
                        Page.getCurrent().getJavaScript().execute("document.getElementById('" + "layout_pere_"
                                + pere + "').onclick=function(){ " + affichagejavascriptfils + "};");
                    }
                }

                layout.addComponent(notesLayout);
                layout.setExpandRatio(notesLayout, 1);

            } else {
                setHeight(30, Unit.PERCENTAGE);
                HorizontalLayout messageLayout = new HorizontalLayout();
                messageLayout.setSpacing(true);
                messageLayout.setMargin(true);
                Label labelAucunResultat = new Label(
                        applicationContext.getMessage(NAME + ".message.aucuneresultat", null, getLocale()));
                labelAucunResultat.setStyleName(ValoTheme.LABEL_BOLD);
                messageLayout.addComponent(labelAucunResultat);
                layout.addComponent(messageLayout);

            }

            addComponent(layout);

            setExpandRatio(layout, 1);

        } else {
            refreshJavascript();
        }
    }
}

From source file:fr.univlorraine.mondossierweb.views.NotesMobileView.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   w w 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();
                }

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

        //Titre
        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);

        //Significations
        if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
            significationButton = new Button();
            significationButton.setIcon(FontAwesome.INFO_CIRCLE);
            significationButton.setStyleName("v-nav-button");
            significationButton.addClickListener(e -> {
                //afficher les significations
                SignificationsMobileWindow w = new SignificationsMobileWindow(false);
                UI.getCurrent().addWindow(w);
            });
            navbar.addComponent(significationButton);
            navbar.setComponentAlignment(significationButton, Alignment.MIDDLE_RIGHT);
        }

        addComponent(navbar);

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

        List<Diplome> ldiplomes = MdwTouchkitUI.getCurrent().getEtudiant().getDiplomes();
        if (ldiplomes != null && ldiplomes.size() > 0) {
            Panel diplomesPanel = new Panel(
                    applicationContext.getMessage(NAME + ".table.diplomes", null, getLocale()));
            diplomesPanel.setStyleName("centertitle-panel");
            diplomesPanel.addStyleName("v-colored-panel-caption");
            VerticalLayout diplomesLayout = new VerticalLayout();
            for (Diplome diplome : ldiplomes) {
                Panel panelEnCours = null;

                panelEnCours = new Panel(diplome.getAnnee());
                panelEnCours.setStyleName("v-panel-caption-centertitle-panel");

                HorizontalLayout noteLayout = new HorizontalLayout();
                noteLayout.setSizeFull();
                noteLayout.setSpacing(true);

                VerticalLayout libelleLayout = new VerticalLayout();
                libelleLayout.setSizeFull();

                Label libelleButton = new Label(diplome.getLib_web_vdi());
                libelleButton.setHeight("100%");
                libelleButton.setWidth("100%");
                libelleButton.addStyleName("label-centre");

                //Appel de la window contenant le dtail des notes
                if (diplome.getResultats() != null && diplome.getResultats().size() > 0) {
                    libelleLayout.addComponent(new Label(""));
                }
                libelleLayout.addComponent(libelleButton);
                libelleLayout.setComponentAlignment(libelleButton, Alignment.MIDDLE_CENTER);

                HorizontalLayout notesessionLayout = new HorizontalLayout();
                notesessionLayout.setSizeFull();
                notesessionLayout.setSpacing(true);

                if (diplome.getResultats() != null && diplome.getResultats().size() > 0) {
                    int i = 0;
                    for (Resultat r : diplome.getResultats()) {
                        i++;
                        VerticalLayout resultatLayout = new VerticalLayout();
                        resultatLayout.setSizeFull();
                        Label session = new Label(r.getSession());
                        session.setStyleName("label-bold-with-bottom");
                        resultatLayout.addComponent(session);
                        Label note = new Label(r.getNote());
                        resultatLayout.addComponent(note);
                        Label resultat = new Label(r.getAdmission());
                        resultatLayout.addComponent(resultat);
                        //Si c'est la dernire session
                        if (i == diplome.getResultats().size()) {
                            //On affiche les infos en gras
                            note.setStyleName(ValoTheme.LABEL_BOLD);
                            resultat.setStyleName(ValoTheme.LABEL_BOLD);
                        }
                        notesessionLayout.addComponent(resultatLayout);
                    }
                } else {
                    Label resultat = new Label("Aucun rsultat");
                    resultat.setStyleName(ValoTheme.LABEL_SMALL);
                    notesessionLayout.addComponent(resultat);
                }

                noteLayout.addComponent(libelleLayout);

                noteLayout.addComponent(notesessionLayout);

                panelEnCours.setContent(noteLayout);
                diplomesLayout.addComponent(panelEnCours);
            }
            diplomesPanel.setContent(diplomesLayout);
            globalLayout.addComponent(diplomesPanel);
        }

        List<Etape> letapes = MdwTouchkitUI.getCurrent().getEtudiant().getEtapes();

        if (letapes != null && letapes.size() > 0) {
            Panel elpsPanel = new Panel(
                    applicationContext.getMessage(NAME + ".table.etapes", null, getLocale()));
            elpsPanel.setStyleName("centertitle-panel");
            elpsPanel.addStyleName("v-colored-panel-caption");
            VerticalLayout elpsLayout = new VerticalLayout();

            for (Etape etape : letapes) {
                Panel panelEnCours = null;

                panelEnCours = new Panel(etape.getAnnee());
                panelEnCours.setStyleName("v-panel-caption-centertitle-panel");

                HorizontalLayout noteLayout = new HorizontalLayout();
                noteLayout.setSizeFull();
                noteLayout.setSpacing(true);

                VerticalLayout libelleLayout = new VerticalLayout();
                libelleLayout.setSizeFull();

                Button libelleButton = new Button(etape.getLibelle());
                Utils.setButtonStyle(libelleButton);
                libelleButton.setHeight("100%");
                libelleButton.setWidth("100%");

                //Appel de la window contenant le dtail des notes
                prepareBoutonAppelDetailDesNotes(libelleButton, etape);
                if (etape.getResultats() != null && etape.getResultats().size() > 0) {
                    libelleLayout.addComponent(new Label(""));
                }
                libelleLayout.addComponent(libelleButton);
                libelleLayout.setComponentAlignment(libelleButton, Alignment.MIDDLE_CENTER);

                HorizontalLayout notesessionLayout = new HorizontalLayout();
                notesessionLayout.setSizeFull();
                notesessionLayout.setSpacing(true);

                if (etape.getResultats() != null && etape.getResultats().size() > 0) {
                    int i = 0;
                    for (Resultat r : etape.getResultats()) {
                        i++;
                        VerticalLayout resultatLayout = new VerticalLayout();
                        resultatLayout.setSizeFull();
                        Label session = new Label(r.getSession());
                        session.setStyleName("label-bold-with-bottom");
                        resultatLayout.addComponent(session);
                        Label note = new Label(r.getNote());
                        resultatLayout.addComponent(note);
                        Label resultat = new Label(r.getAdmission());
                        resultatLayout.addComponent(resultat);
                        //Si c'est la dernire session
                        if (i == etape.getResultats().size()) {
                            //On affiche les infos en gras
                            note.setStyleName(ValoTheme.LABEL_BOLD);
                            resultat.setStyleName(ValoTheme.LABEL_BOLD);
                        }
                        notesessionLayout.addComponent(resultatLayout);
                    }
                } else {
                    Label resultat = new Label("Aucun rsultat");
                    resultat.setStyleName(ValoTheme.LABEL_SMALL);
                    notesessionLayout.addComponent(resultat);
                }

                noteLayout.addComponent(libelleLayout);

                noteLayout.addComponent(notesessionLayout);

                panelEnCours.setContent(noteLayout);
                elpsLayout.addComponent(panelEnCours);
            }
            elpsPanel.setContent(elpsLayout);
            globalLayout.addComponent(elpsPanel);

        }

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

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

License:Apache License

/**
 * Initialise la vue/*from  w  w w.  j a  va2s. com*/
 */
@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) {

        LOG.debug(userController.getCurrentUserName() + " NotesView");

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

        //Test si user enseignant et en vue Enseignant
        if (userController.isEnseignant() && MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
            //On recupere les notes pour un enseignant
            etudiantController.renseigneNotesEtResultatsVueEnseignant(MainUI.getCurrent().getEtudiant());
        } else {
            //On rcupre les notes pour un tudiant
            etudiantController.renseigneNotesEtResultats(MainUI.getCurrent().getEtudiant());
        }

        /* 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().getDiplomes() != null
                && MainUI.getCurrent().getEtudiant().getDiplomes().size() > 0)
                || (MainUI.getCurrent().getEtudiant().getEtapes() != null
                        && MainUI.getCurrent().getEtudiant().getEtapes().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(noteController.exportPdfResume());
                fd.extend(pdfButton);
            } else {
                FileDownloader fd = new FileDownloader(noteController.exportPdfResume());
                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);

        //Test si user enseignant
        if (userController.isEnseignant()) {
            Panel panelVue = new Panel();

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

            Button changerVueButton = new Button(
                    applicationContext.getMessage(NAME + ".button.vueEnseignant", null, getLocale()));
            changerVueButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                changerVueButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
                changerVueButton.setCaption(
                        applicationContext.getMessage(NAME + ".button.vueEtudiant", null, getLocale()));
            }
            //On change la variable vueEnseignantNotesEtResultats et on recr la vue en cours
            changerVueButton.addClickListener(e -> {
                etudiantController.changerVueNotesEtResultats();
                init();
            });

            Label vueLabel = new Label(
                    applicationContext.getMessage(NAME + ".label.vueEtudiant", null, getLocale()));
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                vueLabel.setValue(
                        applicationContext.getMessage(NAME + ".label.vueEnseignant", null, getLocale()));
            }
            vueLabel.setContentMode(ContentMode.HTML);
            vueLabel.setStyleName(ValoTheme.LABEL_SMALL);

            vueLayout.addComponent(changerVueButton);
            vueLayout.setComponentAlignment(changerVueButton, Alignment.MIDDLE_CENTER);
            vueLayout.addComponent(vueLabel);
            vueLayout.setExpandRatio(vueLabel, 1);

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

        Panel panelNotesDiplomes = new Panel(
                applicationContext.getMessage(NAME + ".table.diplomes", null, getLocale()));
        //panelNotesDiplomes.addStyleName("small-font-element");

        Table notesDiplomesTable = new Table(null,
                new BeanItemContainer<>(Diplome.class, MainUI.getCurrent().getEtudiant().getDiplomes()));
        notesDiplomesTable.setWidth("100%");
        notesDiplomesTable.setVisibleColumns((Object[]) DIPLOMES_FIELDS_ORDER);
        for (String fieldName : DIPLOMES_FIELDS_ORDER) {
            notesDiplomesTable.setColumnHeader(fieldName,
                    applicationContext.getMessage(NAME + ".table.diplomes." + fieldName, null, getLocale()));
        }
        notesDiplomesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.diplomes.session", null, getLocale()),
                new SessionColumnGenerator());
        notesDiplomesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.diplomes.note", null, getLocale()),
                new NoteColumnGenerator());
        notesDiplomesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.diplomes.resultat", null, getLocale()),
                new ResultatColumnGenerator());

        if (MainUI.getCurrent().getEtudiant().isAfficherRang()) {
            notesDiplomesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.diplomes.mention", null, getLocale()),
                    new MentionColumnGenerator());
        }
        if (configController.isAffMentionEtudiant()) {
            notesDiplomesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.diplomes.rang", null, getLocale()),
                    new RangColumnGenerator());
        }

        notesDiplomesTable.setColumnCollapsingAllowed(true);
        notesDiplomesTable.setColumnReorderingAllowed(false);
        notesDiplomesTable.setSelectable(false);
        notesDiplomesTable.setImmediate(true);
        notesDiplomesTable.setStyleName("noscrollabletable");
        notesDiplomesTable.setPageLength(notesDiplomesTable.getItemIds().size());
        panelNotesDiplomes.setContent(notesDiplomesTable);
        globalLayout.addComponent(panelNotesDiplomes);

        Panel panelNotesEtapes = new Panel(
                applicationContext.getMessage(NAME + ".table.etapes", null, getLocale()));
        //panelNotesEtapes.addStyleName("small-font-element");

        Table notesEtapesTable = new Table(null,
                new BeanItemContainer<>(Etape.class, MainUI.getCurrent().getEtudiant().getEtapes()));
        notesEtapesTable.setWidth("100%");
        notesEtapesTable.setVisibleColumns((Object[]) ETAPES_FIELDS_ORDER);
        for (String fieldName : ETAPES_FIELDS_ORDER) {
            notesEtapesTable.setColumnHeader(fieldName,
                    applicationContext.getMessage(NAME + ".table.etapes." + fieldName, null, getLocale()));
        }
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.codevers", null, getLocale()),
                new CodeEtapeColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.libelle", null, getLocale()),
                new LibelleEtapeColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.session", null, getLocale()),
                new SessionColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.note", null, getLocale()),
                new NoteColumnGenerator());
        notesEtapesTable.addGeneratedColumn(
                applicationContext.getMessage(NAME + ".table.etapes.resultat", null, getLocale()),
                new ResultatColumnGenerator());

        if (MainUI.getCurrent().getEtudiant().isAfficherRang()) {
            notesEtapesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.etapes.mention", null, getLocale()),
                    new MentionColumnGenerator());
        }
        if (configController.isAffMentionEtudiant()) {
            notesEtapesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.etapes.rang", null, getLocale()),
                    new RangColumnGenerator());
        }

        notesEtapesTable.setColumnCollapsingAllowed(true);
        notesEtapesTable.setColumnReorderingAllowed(false);
        notesEtapesTable.setSelectable(false);
        notesEtapesTable.setImmediate(true);
        notesEtapesTable.setStyleName("noscrollabletable");
        notesEtapesTable.setPageLength(notesEtapesTable.getItemIds().size());
        panelNotesEtapes.setContent(notesEtapesTable);
        globalLayout.addComponent(panelNotesEtapes);

        if (MainUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
            Panel panelSignificationResultats = new Panel(
                    applicationContext.getMessage(NAME + ".info.significations.resultats", null, getLocale()));

            panelSignificationResultats.addStyleName("significationpanel");
            panelSignificationResultats.setIcon(FontAwesome.INFO_CIRCLE);

            VerticalLayout significationLayout = new VerticalLayout();
            significationLayout.setMargin(true);
            significationLayout.setSpacing(true);

            String grilleSignficationResultats = "";
            //grilleSignficationResultats = significationResultats.toString().substring(1,significationResultats.toString().length()-1);
            Set<String> ss = MainUI.getCurrent().getEtudiant().getSignificationResultats().keySet();
            for (String k : ss) {
                if (k != null && !k.equals("") && !k.equals(" ")) {
                    grilleSignficationResultats = grilleSignficationResultats + "<b>" + k + "</b>&#160;:&#160;"
                            + MainUI.getCurrent().getEtudiant().getSignificationResultats().get(k);
                    grilleSignficationResultats = grilleSignficationResultats + "&#160;&#160;&#160;";
                }
            }
            Label mapSignificationLabel = new Label(grilleSignficationResultats);
            mapSignificationLabel.setContentMode(ContentMode.HTML);
            mapSignificationLabel.setStyleName(ValoTheme.LABEL_SMALL);
            significationLayout.addComponent(mapSignificationLabel);

            panelSignificationResultats.setContent(significationLayout);
            globalLayout.addComponent(panelSignificationResultats);
        }

        addComponent(globalLayout);
    }
}

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

License:Apache License

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

    //On vrifie le droit d'accder  la vue
    if (userController.isEnseignant()) {
        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        if (listeBoutonFavoris != null) {
            listeBoutonFavoris.clear();
        } else {
            listeBoutonFavoris = new LinkedList<ReferencedButton>();
        }

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

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

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

        recuperationDesfavoris();

        HorizontalLayout btnLayout = new HorizontalLayout();
        btnLayout.setMargin(false);
        btnLayout.setSpacing(false);
        btnLayout.setWidth("100%");

        comboBoxAnneeUniv = new ComboBox(applicationContext.getMessage(NAME + ".anneeuniv", null, getLocale()));
        comboBoxAnneeUniv.setPageLength(5);
        comboBoxAnneeUniv.setTextInputAllowed(false);
        comboBoxAnneeUniv.setNullSelectionAllowed(false);
        //Initialisation de la liste des annes
        List<String> lanneeUniv = rechercheArborescenteController.recupererLesDernieresAnneeUniversitaire();
        if (lanneeUniv != null && lanneeUniv.size() > 0) {
            for (String anneeUniv : lanneeUniv) {
                comboBoxAnneeUniv.addItem(anneeUniv);
                int anneenplusun = Integer.parseInt(anneeUniv) + 1;
                comboBoxAnneeUniv.setItemCaption(anneeUniv, anneeUniv + "/" + anneenplusun);
            }
            if (annee == null) {
                annee = etudiantController.getAnneeUnivEnCours(MainUI.getCurrent());
                //annee = lanneeUniv.get(0);
            }
        }
        comboBoxAnneeUniv.setValue(annee);
        comboBoxAnneeUniv.setStyleName(ValoTheme.COMBOBOX_SMALL);
        comboBoxAnneeUniv.addValueChangeListener(e -> changerAnnee((String) comboBoxAnneeUniv.getValue()));

        reinitButton = new Button();
        reinitButton.setDescription(
                applicationContext.getMessage(NAME + ".reinitbutton.description", null, getLocale()));
        reinitButton.addClickListener(e -> {
            initFromScratch();
        });
        reinitButton.setStyleName(ValoTheme.BUTTON_DANGER);
        reinitButton.setIcon(FontAwesome.TIMES);
        if (!StringUtils.hasText(code)) {
            reinitButton.setVisible(false);
        }
        labelLigneSelectionneeLabel = new Label();
        labelLigneSelectionneeLabel
                .setValue(applicationContext.getMessage(NAME + ".ligneselectionnee", null, getLocale()));
        labelLigneSelectionneeLabel.addStyleName("label-align-right");
        labelLigneSelectionneeLabel.setVisible(false);

        HorizontalLayout btnLeftLayout = new HorizontalLayout();
        btnLeftLayout.setWidth("100%");
        btnLeftLayout.setMargin(true);
        btnLeftLayout.addComponent(comboBoxAnneeUniv);
        btnLeftLayout.setComponentAlignment(comboBoxAnneeUniv, Alignment.MIDDLE_LEFT);
        /*btnLeftLayout.addComponent(reinitButton);
        btnLeftLayout.setComponentAlignment(reinitButton, Alignment.BOTTOM_RIGHT);*/
        btnLeftLayout.addComponent(labelLigneSelectionneeLabel);
        btnLeftLayout.setComponentAlignment(labelLigneSelectionneeLabel, Alignment.MIDDLE_CENTER);
        btnLayout.addComponent(btnLeftLayout);

        ligneSelectionneeLabel = new Label();
        //ligneSelectionneeLabel.setCaption(applicationContext.getMessage(NAME+".ligneselectionnee", null, getLocale()));
        ligneSelectionneeLabel.setVisible(false);
        elpLayout = new FormLayout();
        elpLayout.setMargin(false);
        vetElpSelectionneLabel = new Label();
        vetElpSelectionneLabel.setVisible(false);
        elpLayout.addComponent(vetElpSelectionneLabel);
        elpLayout.setVisible(false);
        VerticalLayout ligneLayout = new VerticalLayout();
        ligneLayout.addComponent(ligneSelectionneeLabel);
        ligneLayout.addComponent(elpLayout);

        HorizontalLayout rightLayout = new HorizontalLayout();
        rightLayout.setSizeFull();
        rightLayout.setSpacing(true);
        rightLayout.setMargin(true);
        rightLayout.addComponent(ligneLayout);
        rightLayout.setComponentAlignment(ligneLayout, Alignment.MIDDLE_LEFT);
        rightLayout.addComponent(reinitButton);
        rightLayout.setComponentAlignment(reinitButton, Alignment.MIDDLE_RIGHT);
        rightLayout.setExpandRatio(ligneLayout, 1);
        btnLayout.addComponent(rightLayout);
        btnLayout.setComponentAlignment(rightLayout, Alignment.MIDDLE_LEFT);

        addComponent(btnLayout);

        if (code != null && type != null) {
            Label elementRecherche = new Label(code + " " + type);
            elementRecherche.addStyleName(ValoTheme.LABEL_H1);
            //addComponent(elementRecherche);

        }

        table = new TreeTable();
        table.setSizeFull();
        table.setStyleName("scrollabletable");
        table.setSelectable(true);

        initComposantes();

        //gestion du style pour les lignes en favori
        table.setCellStyleGenerator(new CellStyleGenerator() {
            @Override
            public String getStyle(final Table source, final Object itemId, final Object propertyId) {
                String style = null;
                if (propertyId == null && markedRows.contains(itemId)) {
                    style = "marked";
                }
                return style;
            }
        });

        table.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                selectionnerLigne(event.getItemId());
            }

        });

        //gestion du clic sur la fleche pour dplier une entre
        table.addExpandListener(new ExpandListener() {
            private static final long serialVersionUID = 8532342540008245348L;

            @Override
            public void nodeExpand(ExpandEvent event) {
                if (event != null && event.getItemId() != null && hc != null
                        && hc.getItem(event.getItemId()) != null
                        && hc.getItem(event.getItemId()).getItemProperty(TYPE_PROPERTY) != null) {
                    selectionnerLigne(event.getItemId());
                    deplierNoeud((String) event.getItemId(), true);
                }
            }
        });

        VerticalLayout tableVerticalLayout = new VerticalLayout();
        tableVerticalLayout.setMargin(new MarginInfo(false, true, true, true));
        tableVerticalLayout.setSizeFull();
        tableVerticalLayout.addComponent(table);
        tableVerticalLayout.setExpandRatio(table, 1);
        addComponent(tableVerticalLayout);
        setExpandRatio(tableVerticalLayout, 1);

    }
}

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

License:Apache License

/**
 * Initialise la vue/*w w  w  .  j  a  v a  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");

        //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 -> {
            MdwTouchkitUI.getCurrent().backFromSearch();
        });
        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);

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

        //BOUTON DE RECHERCHE
        btnRecherche = new Button();
        btnRecherche.setIcon(FontAwesome.SEARCH);
        btnRecherche.setStyleName(ValoTheme.BUTTON_PRIMARY);
        btnRecherche.addStyleName("v-popover-button");
        btnRecherche.addStyleName("v-button-without-padding");
        btnRecherche.setEnabled(true);
        btnRecherche.addClickListener(e -> search(false));

        //CHAMP DE RECHERCHE
        champRechercheLayout = new HorizontalLayout();
        champRechercheLayout.setWidth("100%");
        mainVerticalLayout = new VerticalLayout();
        mainVerticalLayout.setImmediate(true);
        mainVerticalLayout.setSizeFull();

        //Init connexion  ES, pour gain perf au premiere lettre tapes
        if (ElasticSearchService.initConnexion(true)) {

            //Cration du champ autoComplete
            champRecherche = new AutoComplete();
            champRecherche.setWidth(100, Unit.PERCENTAGE);
            champRecherche.setEnabled(true);
            champRecherche.setImmediate(true);
            champRecherche.focus();
            champRecherche.setTextChangeEventMode(TextChangeEventMode.EAGER);
            champRecherche.addTextChangeListener(new TextChangeListener() {
                @Override
                public void textChange(TextChangeEvent event) {
                    /*if(event.getText()!=null){
                    resetButton.setIcon(FontAwesome.TIMES);
                    }*/

                    champRecherche.showChoices(quickSearch(event.getText()), mainVerticalLayout, btnRecherche,
                            true);

                }
            });
            champRecherche.setImmediate(true);
            champRecherche.addShortcutListener(
                    new ShortcutListener("Enter Shortcut", ShortcutAction.KeyCode.ENTER, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                //Si on tait sur une ligne propose sous le champ de recherche
                                if (champRecherche.getSelectedItem() > 0) {
                                    //On remplie d'abord le champ avec la ligne slectionne
                                    champRecherche.setValue(champRecherche.getChoices()
                                            .getItem(champRecherche.getSelectedItem()).getItemProperty("lib")
                                            .getValue().toString());
                                }
                                search(false);
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Bottom Arrow", ShortcutAction.KeyCode.ARROW_DOWN, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    champRecherche.getChoices().setValue(champRecherche.getNextItem());

                                }
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Top Arrow", ShortcutAction.KeyCode.ARROW_UP, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    Integer champSelectionne = champRecherche.getPreviousItem();
                                    if (champSelectionne > 0) {
                                        champRecherche.getChoices().setValue(champSelectionne);
                                    } else {
                                        champRecherche.getChoices().setValue(null);
                                    }

                                }
                            }
                        }
                    });

            champRechercheLayout.addComponent(champRecherche);
            champRechercheLayout.setComponentAlignment(champRecherche, Alignment.MIDDLE_LEFT);

            //BOUTON RESET
            champRecherche.addStyleName("textfield-resetable");
            resetButton = new Button();
            resetButton.setIcon(FontAwesome.TIMES);
            resetButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
            resetButton.addStyleName("v-popover-button");
            resetButton.addStyleName("v-button-without-padding");
            resetButton.addStyleName("btn-reset");
            resetButton.addClickListener(e -> {
                champRecherche.setValue("");
                //search1.setValue("");
                resetButton.setIcon(FontAwesome.TIMES);
                champRecherche.focus();
            });
            champRechercheLayout.addComponent(resetButton);
            champRechercheLayout.setComponentAlignment(resetButton, Alignment.MIDDLE_LEFT);

            //Ajout du bouton de recherche au layout
            champRechercheLayout.addComponent(btnRecherche);
            mainVerticalLayout.addComponent(champRechercheLayout);
            mainVerticalLayout.setComponentAlignment(champRechercheLayout, Alignment.MIDDLE_LEFT);
            champRechercheLayout.setMargin(true);
            champRechercheLayout.setExpandRatio(champRecherche, 1);

            HorizontalLayout checkBoxVetLayout = new HorizontalLayout();
            Label etapeLabel = new Label(
                    applicationContext.getMessage(NAME + ".etapes.checkbox", null, getLocale()));
            etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxVetLayout.addComponent(etapeLabel);

            HorizontalLayout checkBoxElpLayout = new HorizontalLayout();
            Label elpLabel = new Label(
                    applicationContext.getMessage(NAME + ".elps.checkbox", null, getLocale()));
            elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxElpLayout.addComponent(elpLabel);

            HorizontalLayout checkBoxEtuLayout = new HorizontalLayout();
            Label etuLabel = new Label(
                    applicationContext.getMessage(NAME + ".etudiants.checkbox", null, getLocale()));
            etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxEtuLayout.addComponent(etuLabel);

            checkBoxVetLayout.setSizeFull();
            checkBoxElpLayout.setSizeFull();
            checkBoxEtuLayout.setSizeFull();

            if (casesAcocherVet) {
                checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                etapeLabel.addStyleName("label-line-through");
            }

            if (casesAcocherElp) {
                checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                elpLabel.addStyleName("label-line-through");
            }

            if (casesAcocherEtudiant) {
                checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                etuLabel.addStyleName("label-line-through");
            }

            checkBoxVetLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherVet) {
                        casesAcocherVet = false;
                        checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                        etapeLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherVet = true;
                        checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                        etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxElpLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherElp) {
                        casesAcocherElp = false;
                        checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                        elpLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherElp = true;
                        checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                        elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxEtuLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherEtudiant) {
                        casesAcocherEtudiant = false;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                        etuLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherEtudiant = true;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                        etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            HorizontalLayout checkBoxLayout = new HorizontalLayout();
            checkBoxLayout.setWidth("100%");
            checkBoxLayout.setHeight("50px");
            checkBoxLayout.setMargin(true);
            checkBoxLayout.setSpacing(true);
            checkBoxLayout.addComponent(checkBoxVetLayout);
            checkBoxLayout.addComponent(checkBoxElpLayout);
            checkBoxLayout.addComponent(checkBoxEtuLayout);

            mainVerticalLayout.addComponent(checkBoxLayout);

            //TABLE DE RESULTATS
            rrContainer = new HierarchicalContainer();
            rrContainer.addContainerProperty("lib", String.class, "");
            rrContainer.addContainerProperty("code", String.class, "");
            rrContainer.addContainerProperty("type", String.class, "");
            tableResultats = new TreeTable();
            tableResultats.setWidth("100%");
            tableResultats.setSelectable(false);
            tableResultats.setMultiSelect(false);
            tableResultats.setImmediate(true);
            columnHeaders = new String[FIELDS_ORDER.length];
            for (int fieldIndex = 0; fieldIndex < FIELDS_ORDER.length; fieldIndex++) {
                columnHeaders[fieldIndex] = applicationContext
                        .getMessage("result.table." + FIELDS_ORDER[fieldIndex], null, Locale.getDefault());
            }

            tableResultats.addGeneratedColumn("type", new DisplayTypeColumnGenerator());
            tableResultats.addGeneratedColumn("lib", new DisplayNameColumnGenerator());
            tableResultats.setContainerDataSource(rrContainer);
            tableResultats.setVisibleColumns(FIELDS_ORDER);
            tableResultats.setStyleName("nohscrollabletable");
            tableResultats.setColumnHeaders(columnHeaders);
            tableResultats.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
            tableResultats.setColumnWidth("type", 100);

            /*mainVerticalLayout.addComponent(searchBoxFilter);
            mainVerticalLayout.setComponentAlignment(searchBoxFilter, Alignment.MIDDLE_RIGHT);*/
            VerticalLayout tableVerticalLayout = new VerticalLayout();
            tableVerticalLayout.setMargin(true);
            tableVerticalLayout.setSizeFull();
            tableVerticalLayout.addComponent(tableResultats);
            mainVerticalLayout.addComponent(tableVerticalLayout);
            mainVerticalLayout.setExpandRatio(tableVerticalLayout, 1);
            tableResultats.setVisible(false);

            addComponent(mainVerticalLayout);
            setExpandRatio(mainVerticalLayout, 1);
        } else {
            //Message fonctionnalit indisponible
            addComponent(
                    new Label(applicationContext.getMessage(NAME + ".indisponible.message", null, getLocale()),
                            ContentMode.HTML));
        }
    }
}

From source file:fr.univlorraine.mondossierweb.views.windows.DetailNotesWindow.java

License:Apache License

private void init() {

    //On vrifie le droit d'accder  la vue
    if ((userController.isEnseignant() || userController.isEtudiant()) && MainUI.getCurrent() != null
            && MainUI.getCurrent().getEtudiant() != null) {

        /* Style */
        setWidth(80, Unit.PERCENTAGE);// w w  w.j  a  va 2  s  .  c om
        setHeight(95, Unit.PERCENTAGE);
        setModal(true);
        setResizable(false);

        //Test si user enseignant et en vue Enseignant
        if (userController.isEnseignant() && MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
            //On recupere les notes pour un enseignant
            etudiantController.renseigneDetailNotesEtResultatsEnseignant(etape);
        } else {
            //On rcupre les notes pour un tudiant
            etudiantController.renseigneDetailNotesEtResultats(etape);
        }

        /* Layout */
        VerticalLayout layout = new VerticalLayout();
        layout.setSizeFull();
        layout.setMargin(true);
        layout.setSpacing(true);

        /* Titre */
        setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale()));

        List<ElementPedagogique> lelp = MainUI.getCurrent().getEtudiant().getElementsPedagogiques();

        //Sous titre avec l'anne
        HorizontalLayout titleLayout = new HorizontalLayout();
        titleLayout.setSizeFull();
        titleLayout.setHeight("20px");
        Label messageLabel = new Label(
                applicationContext.getMessage(NAME + ".label.messageinfo", null, getLocale()));
        messageLabel.setContentMode(ContentMode.HTML);
        messageLabel.setStyleName(ValoTheme.LABEL_SMALL);
        titleLayout.addComponent(messageLabel);
        titleLayout.setExpandRatio(messageLabel, 1);
        titleLayout.setComponentAlignment(messageLabel, Alignment.MIDDLE_LEFT);

        //Test si user enseignant
        if (userController.isEnseignant() && lelp != null && lelp.size() > 0) {
            //Bouton pour afficher les filtres
            btnDisplayFiltres = new Button();
            btnDisplayFiltres.setWidth("52px");
            btnDisplayFiltres.setHeight("32px");
            btnDisplayFiltres.setStyleName(ValoTheme.BUTTON_PRIMARY);
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                btnDisplayFiltres.setStyleName(ValoTheme.BUTTON_FRIENDLY);
            }
            btnDisplayFiltres.setIcon(FontAwesome.FILTER);
            btnDisplayFiltres.setDescription(
                    applicationContext.getMessage(NAME + ".btn.displayFilters", null, getLocale()));
            btnDisplayFiltres.addClickListener(e -> {
                btnDisplayFiltres.setVisible(false);
                panelVue.setVisible(true);
            });
            titleLayout.addComponent(btnDisplayFiltres);
            titleLayout.setComponentAlignment(btnDisplayFiltres, Alignment.MIDDLE_RIGHT);
            //titleLayout.setExpandRatio(btnDisplayFiltres, 1);
            btnDisplayFiltres.setVisible(true);
        }

        if (lelp != null && lelp.size() > 0 && configController.isPdfNotesActive()) {
            Button pdfButton = new Button();
            pdfButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
            pdfButton.addStyleName("button-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(noteController.exportPdfDetail(etape));
                fd.extend(pdfButton);
            } else {
                FileDownloader fd = new FileDownloader(noteController.exportPdfDetail(etape));
                fd.extend(pdfButton);
            }

            titleLayout.addComponent(pdfButton);
            titleLayout.setComponentAlignment(pdfButton, Alignment.MIDDLE_RIGHT);
        }
        layout.addComponent(titleLayout);

        //Test si user enseignant
        if (userController.isEnseignant() && lelp != null && lelp.size() > 0) {
            panelVue = new Panel();

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

            Button changerVueButton = new Button(
                    applicationContext.getMessage(NAME + ".button.vueEnseignant", null, getLocale()));
            changerVueButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                changerVueButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
                changerVueButton.setCaption(
                        applicationContext.getMessage(NAME + ".button.vueEtudiant", null, getLocale()));
            }
            //On change la variable vueEnseignantNotesEtResultats et on recr la vue en cours
            changerVueButton.addClickListener(e -> {
                etudiantController.changerVueNotesEtResultats();
                init();
            });

            Label vueLabel = new Label(
                    applicationContext.getMessage(NAME + ".label.vueEtudiant", null, getLocale()));
            if (MainUI.getCurrent().isVueEnseignantNotesEtResultats()) {
                vueLabel.setValue(
                        applicationContext.getMessage(NAME + ".label.vueEnseignant", null, getLocale()));
            }
            vueLabel.setContentMode(ContentMode.HTML);
            vueLabel.setStyleName(ValoTheme.LABEL_SMALL);

            vueLayout.addComponent(changerVueButton);
            vueLayout.setComponentAlignment(changerVueButton, Alignment.MIDDLE_CENTER);
            vueLayout.addComponent(vueLabel);
            vueLayout.setExpandRatio(vueLabel, 1);

            panelVue.setContent(vueLayout);
            layout.addComponent(panelVue);
            panelVue.setVisible(false);
        }

        Panel panelDetailNotes = new Panel(etape.getLibelle() + " - "
                + applicationContext.getMessage(NAME + ".label.anneeuniv", null, getLocale()) + " "
                + etape.getAnnee());
        panelDetailNotes.addStyleName("small-font-element");
        panelDetailNotes.setSizeFull();

        if (lelp != null && lelp.size() > 0) {
            Table detailNotesTable = new Table(null, new BeanItemContainer<>(ElementPedagogique.class, lelp));
            detailNotesTable.setSizeFull();
            detailNotesTable.setVisibleColumns(new String[0]);
            if (contientElpObtenusPrecedemment(lelp)) {
                detailNotesTable.addGeneratedColumn(
                        applicationContext.getMessage(NAME + ".table.elp.annee", null, getLocale()),
                        new AnneeColumnGenerator());
            }
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.code", null, getLocale()),
                    new CodeElpColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.libelle", null, getLocale()),
                    new LibelleElpColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.notesession1", null, getLocale()),
                    new Session1ColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.resultatsession1", null, getLocale()),
                    new ResultatSession1ColumnGenerator());
            detailNotesTable.addGeneratedColumn(
                    applicationContext.getMessage(NAME + ".table.elp.notesession2", null, getLocale()),
                    new Session2ColumnGenerator());
            detailNotesTable.addGeneratedColumn("resultatsession2", new ResultatSession2ColumnGenerator());
            detailNotesTable.setColumnHeader("resultatsession2",
                    applicationContext.getMessage(NAME + ".table.elp.resultatsession2", null, getLocale()));
            if (configController.isAffRangEtudiant() || etudiantController.isAfficherRangElpEpr()) {
                detailNotesTable.addGeneratedColumn(
                        applicationContext.getMessage(NAME + ".table.elp.rang", null, getLocale()),
                        new RangColumnGenerator());
            }
            if (configController.isAffECTSEtudiant()) {
                detailNotesTable.addGeneratedColumn(
                        applicationContext.getMessage(NAME + ".table.elp.ects", null, getLocale()),
                        new ECTSColumnGenerator());
            }
            detailNotesTable.setColumnCollapsingAllowed(true);
            detailNotesTable.setColumnReorderingAllowed(false);
            detailNotesTable.setSelectable(false);
            detailNotesTable.setImmediate(true);
            detailNotesTable.addStyleName("scrollabletable");
            panelDetailNotes.setContent(detailNotesTable);
        } else {
            setHeight(30, Unit.PERCENTAGE);
            HorizontalLayout messageLayout = new HorizontalLayout();
            messageLayout.setSpacing(true);
            messageLayout.setMargin(true);
            Label labelAucunResultat = new Label(
                    applicationContext.getMessage(NAME + ".message.aucuneresultat", null, getLocale()));
            labelAucunResultat.setStyleName(ValoTheme.LABEL_BOLD);
            messageLayout.addComponent(labelAucunResultat);
            panelDetailNotes.setContent(messageLayout);

        }
        layout.addComponent(panelDetailNotes);

        if (lelp != null && lelp.size() > 0
                && MainUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
            Panel panelSignificationResultats = new Panel(
                    applicationContext.getMessage(NAME + ".info.significations.resultats", null, getLocale()));

            panelSignificationResultats.addStyleName("significationpanel");
            panelSignificationResultats.addStyleName("small-font-element");
            panelSignificationResultats.setIcon(FontAwesome.INFO_CIRCLE);

            VerticalLayout significationLayout = new VerticalLayout();
            significationLayout.setMargin(true);
            significationLayout.setSpacing(true);

            String grilleSignficationResultats = "";
            //grilleSignficationResultats = significationResultats.toString().substring(1,significationResultats.toString().length()-1);
            Set<String> ss = MainUI.getCurrent().getEtudiant().getSignificationResultats().keySet();
            for (String k : ss) {
                if (k != null && !k.equals("") && !k.equals(" ")) {
                    grilleSignficationResultats = grilleSignficationResultats + "<b>" + k + "</b>&#160;:&#160;"
                            + MainUI.getCurrent().getEtudiant().getSignificationResultats().get(k);
                    grilleSignficationResultats = grilleSignficationResultats + "&#160;&#160;&#160;";
                }
            }
            Label mapSignificationLabel = new Label(grilleSignficationResultats);
            mapSignificationLabel.setStyleName(ValoTheme.LABEL_SMALL);
            mapSignificationLabel.setContentMode(ContentMode.HTML);
            significationLayout.addComponent(mapSignificationLabel);

            panelSignificationResultats.setContent(significationLayout);
            layout.addComponent(panelSignificationResultats);

        }

        layout.setExpandRatio(panelDetailNotes, 1);

        setContent(layout);

        /* Centre la fentre */
        center();

    }

}

From source file:fr.univlorraine.mondossierweb.views.windows.HelpMobileWindow.java

License:Apache License

/**
 * Cre une fentre de confirmation//from   www.  java2s . com
 * @param message
 * @param titre
 */
public HelpMobileWindow(String message, String titre, boolean displayCheckBox) {
    // Style 
    setWidth("90%");
    setModal(true);
    setResizable(false);
    setClosable(false);

    // Layout 
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    // Titre 
    if (titre == null) {
        titre = applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale());
    }
    setCaption(titre);

    // Texte 
    Label textLabel = new Label(message, ContentMode.HTML);
    layout.addComponent(textLabel);

    // Boutons
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    if (displayCheckBox) {
        // Checkbox "ne plus afficher ce message"
        checkBox.setCaption(
                applicationContext.getMessage("helpWindow.checkBox.mobile.message", null, getLocale()));
        buttonsLayout.addComponent(checkBox);
        buttonsLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_RIGHT);
    }
    // Bouton "Fermer"
    btnFermer.setIcon(FontAwesome.CHECK);
    btnFermer.setStyleName(ValoTheme.BUTTON_PRIMARY);
    btnFermer.addStyleName("v-popover-button");
    btnFermer.addClickListener(e -> close());
    buttonsLayout.addComponent(btnFermer);
    buttonsLayout.setComponentAlignment(btnFermer, Alignment.MIDDLE_RIGHT);
    if (displayCheckBox) {
        buttonsLayout.setExpandRatio(checkBox, 1);
    }

    // Centre la fentre 
    center();
}

From source file:fr.univlorraine.mondossierweb.views.windows.HelpWindow.java

License:Apache License

/**
 * Cre une fentre de confirmation//from   w w  w . j  a  v  a  2  s  . c  o  m
 * @param message
 * @param titre
 */
public HelpWindow(String message, String titre, boolean displayCheckBox) {
    /* Style */
    setWidth(900, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

    /* Layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    /* Titre */
    if (titre == null) {
        titre = applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale());
    }
    setCaption(titre);

    /* Texte */
    Label textLabel = new Label(message, ContentMode.HTML);
    layout.addComponent(textLabel);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    if (displayCheckBox) {
        checkBox.setCaption(applicationContext.getMessage("helpWindow.checkBox.message", null, getLocale()));
        buttonsLayout.addComponent(checkBox);
        buttonsLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_RIGHT);
    }

    btnFermer.setCaption(applicationContext.getMessage("helpWindow.btnFermer", null, getLocale()));
    btnFermer.setIcon(FontAwesome.TIMES);
    btnFermer.addClickListener(e -> close());
    buttonsLayout.addComponent(btnFermer);
    buttonsLayout.setComponentAlignment(btnFermer, Alignment.MIDDLE_RIGHT);
    if (displayCheckBox) {
        buttonsLayout.setExpandRatio(checkBox, 1);
    }

    /* Centre la fentre */
    center();
}

From source file:info.magnolia.security.app.dialog.field.WebAccessFieldFactory.java

License:Open Source License

private Component createRuleRow(final AbstractOrderedLayout parentContainer,
        final AbstractJcrNodeAdapter ruleItem, final Label emptyLabel) {

    final HorizontalLayout ruleLayout = new HorizontalLayout();
    ruleLayout.setSpacing(true);/* ww  w.j ava2s  .  com*/
    ruleLayout.setWidth("100%");

    NativeSelect accessRights = new NativeSelect();
    accessRights.addItem(Permission.ALL);
    accessRights.setItemCaption(Permission.ALL, i18n.translate("security.web.field.getPost"));
    accessRights.addItem(Permission.READ);
    accessRights.setItemCaption(Permission.READ, i18n.translate("security.web.field.get"));
    accessRights.addItem(Permission.NONE);
    accessRights.setItemCaption(Permission.NONE, i18n.translate("security.web.field.deny"));
    accessRights.setNullSelectionAllowed(false);
    accessRights.setImmediate(true);
    accessRights.setInvalidAllowed(false);
    accessRights.setNewItemsAllowed(false);
    Property permissionsProperty = ruleItem.getItemProperty(PERMISSIONS_PROPERTY_NAME);
    if (permissionsProperty == null) {
        permissionsProperty = new DefaultProperty<Long>(Long.class, Permission.ALL);
        ruleItem.addItemProperty(PERMISSIONS_PROPERTY_NAME, permissionsProperty);
    }
    accessRights.setPropertyDataSource(permissionsProperty);
    ruleLayout.addComponent(accessRights);

    TextField path = new TextField();
    path.setWidth("100%");
    Property pathProperty = ruleItem.getItemProperty(PATH_PROPERTY_NAME);
    if (pathProperty == null) {
        pathProperty = new DefaultProperty<String>(String.class, "/*");
        ruleItem.addItemProperty(PATH_PROPERTY_NAME, pathProperty);
    }
    path.setPropertyDataSource(pathProperty);
    ruleLayout.addComponent(path);
    ruleLayout.setExpandRatio(path, 1.0f);

    final Button deleteButton = new Button();
    deleteButton.setHtmlContentAllowed(true);
    deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>");
    deleteButton.addStyleName("inline");
    deleteButton.setDescription(i18n.translate("security.web.field.delete"));
    deleteButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            parentContainer.removeComponent(ruleLayout);
            ruleItem.getParent().removeChild(ruleItem);
            if (parentContainer.getComponentCount() == 1) {
                parentContainer.addComponent(emptyLabel, 0);
            }
        }
    });
    ruleLayout.addComponent(deleteButton);

    return ruleLayout;
}