Example usage for com.vaadin.ui HorizontalLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:fr.amapj.view.views.producteur.contrats.ProducteurContratListPart.java

License:Open Source License

@Override
public void enterIn(ViewChangeEvent event) {

    //// w w  w . j  av a  2 s  .  c  om
    producteurSelector = new ProducteurSelectorPart(this);

    // Lecture dans la base de donnes
    mcInfos = new BeanItemContainer<ModeleContratSummaryDTO>(ModeleContratSummaryDTO.class);

    // Bind it to a component
    cdesTable = createTable(mcInfos);

    // Titre des colonnes
    cdesTable.setVisibleColumns(new String[] { "etat", "nom", "finInscription", "dateDebut", "dateFin",
            "nbLivraison", "nbProduit" });
    cdesTable.setColumnHeader("etat", "Etat");
    cdesTable.setColumnHeader("nom", "Nom");
    cdesTable.setColumnHeader("nomProducteur", "Producteur");
    cdesTable.setColumnHeader("finInscription", "Fin inscription");
    cdesTable.setColumnHeader("dateDebut", "Premire livraison");
    cdesTable.setColumnHeader("dateFin", "Dernire livraison");
    cdesTable.setColumnHeader("nbLivraison", "Nb de livraisons");
    cdesTable.setColumnHeader("nbProduit", "Nb de produits");

    //
    cdesTable.setConverter("finInscription", new DateToStringConverter());
    cdesTable.setConverter("dateDebut", new DateToStringConverter());
    cdesTable.setConverter("dateFin", new DateToStringConverter());

    cdesTable.setSelectable(true);
    cdesTable.setImmediate(true);

    // Activation au desactivation des boutons delete et edit
    cdesTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            setModificationsEnabled(event.getProperty().getValue() != null);
        }

        private void setModificationsEnabled(boolean b) {
            enableButtonBar(b);
        }
    });

    cdesTable.setSizeFull();

    cdesTable.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                cdesTable.select(event.getItemId());
            }
        }
    });

    Label title2 = new Label("Liste des contrats d'un producteur");
    title2.setSizeUndefined();
    title2.addStyleName("stdlistpart-text-title");

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("stdlistpart-hlayout-button");

    testButton = new Button("Tester");
    testButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleTester();

        }
    });

    telechargerButton = new Button("Tlcharger ...");
    telechargerButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleTelecharger();
        }
    });

    searchField = new TextField();
    searchField.setInputPrompt("Rechercher par nom");
    searchField.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            textFilter = event.getText();
            updateFilters();
        }
    });

    toolbar.addComponent(testButton);
    toolbar.addComponent(telechargerButton);

    toolbar.addComponent(searchField);
    toolbar.setWidth("100%");
    toolbar.setExpandRatio(searchField, 1);
    toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT);

    addComponent(producteurSelector.getChoixProducteurComponent());
    addComponent(title2);
    addComponent(toolbar);
    addComponent(cdesTable);
    setExpandRatio(cdesTable, 1);

    refreshTable();

}

From source file:fr.amapj.view.views.producteur.ProducteurSelectorPart.java

License:Open Source License

public HorizontalLayout getChoixProducteurComponent() {
    // Partie choix du producteur
    HorizontalLayout toolbar1 = new HorizontalLayout();
    toolbar1.addStyleName("producteur-selectorpart");

    if (allowedProducteurs.size() > 1) {
        constructMultipleProducteur(toolbar1);
    } else {/*  w  w w  . j ava  2  s.  co m*/
        constructOneProducteur(toolbar1);
    }

    toolbar1.setSpacing(true);
    toolbar1.setWidth("100%");

    return toolbar1;
}

From source file:fr.amapj.view.views.saisiepermanence.SaisiePermanenceListPart.java

License:Open Source License

@Override
public void enterIn(ViewChangeEvent event) {

    // Lecture dans la base de donnes
    mcInfos = new BeanItemContainer<PermanenceDTO>(PermanenceDTO.class);

    // Bind it to a component
    cdesTable = createTable(mcInfos);//w w w  . j  a v  a 2  s.  c  o  m

    // Titre des colonnes
    cdesTable.setVisibleColumns(new String[] { "datePermanence", "utilisateurs", "numeroSession" });
    cdesTable.setColumnHeader("datePermanence", "Date");
    cdesTable.setColumnHeader("utilisateurs", "Personnes de permanence");
    cdesTable.setColumnHeader("numeroSession", "Numro de la session");

    cdesTable.setConverter("datePermanence", new DateToStringConverter());

    cdesTable.setSelectable(true);
    cdesTable.setImmediate(true);

    // Activation au desactivation des boutons delete et edit
    cdesTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            setModificationsEnabled(event.getProperty().getValue() != null);
        }

        private void setModificationsEnabled(boolean b) {
            enableButtonBar(b);
        }
    });

    cdesTable.setSizeFull();

    cdesTable.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                cdesTable.select(event.getItemId());
            }
        }
    });

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("stdlistpart-hlayout-button");

    Label title2 = new Label("Planning des permanences");
    title2.setSizeUndefined();
    title2.addStyleName("stdlistpart-text-title");

    newButton = new Button("Crer une nouvelle permanence");
    newButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleAjouter();
        }
    });

    editButton = new Button("Modifier");
    editButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleEditer();

        }
    });

    deleteButton = new Button("Supprimer");
    deleteButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleSupprimer();

        }
    });

    planifButton = new Button("Planifier");
    planifButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handlePlanification();
        }
    });

    rappelButton = new Button("Envoyer un rappel");
    rappelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleRappel();
        }
    });

    deleteListButton = new Button("Supprimer plusieurs permanences");
    deleteListButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleDeleteList();
        }
    });

    searchField = new TextField();
    searchField.setInputPrompt("Rechercher par nom");
    searchField.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            textFilter = event.getText();
            updateFilters();
        }
    });

    toolbar.addComponent(newButton);
    toolbar.addComponent(editButton);
    toolbar.addComponent(deleteButton);
    toolbar.addComponent(planifButton);
    toolbar.addComponent(rappelButton);
    toolbar.addComponent(deleteListButton);

    toolbar.addComponent(searchField);
    toolbar.setWidth("100%");
    toolbar.setExpandRatio(searchField, 1);
    toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT);

    addComponent(title2);
    addComponent(toolbar);
    addComponent(LinkCreator.createLink(new EGPlanningPermanence(new Date())));
    addComponent(cdesTable);
    setExpandRatio(cdesTable, 1);
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    refreshTable();

}

From source file:fr.amapj.view.views.suiviacces.SuiviAccesView.java

License:Open Source License

/**
 * /*w ww . j ava2  s  .  c  o m*/
 */
@Override
public void enterIn(ViewChangeEvent event) {
    listPartContainer = new BeanItemContainer<>(ConnectedUserDTO.class);

    // on trie par nom puis prenom
    listPartContainer.sort(new String[] { "nom", "prenom" }, new boolean[] { true, true });

    // Bind it to a component
    beanTable = createTable(listPartContainer);

    // Gestion de la liste des colonnes visibles
    beanTable.setVisibleColumns("nom", "prenom", "email", "date", "agent", "dbName");

    beanTable.setColumnHeader("nom", "Nom");
    beanTable.setColumnHeader("prenom", "Prnom");
    beanTable.setColumnHeader("email", "E mail");
    beanTable.setColumnHeader("date", "Date connexion");
    beanTable.setColumnHeader("agent", "Browser");
    beanTable.setColumnHeader("dbName", "Nom de la base");

    beanTable.setConverter("date", new DateTimeToStringConverter());

    beanTable.setSelectable(true);
    beanTable.setImmediate(true);

    beanTable.setSizeFull();

    beanTable.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                beanTable.select(event.getItemId());
            }
        }
    });

    HorizontalLayout toolbar = new HorizontalLayout();

    Button sendMsg = new Button("Envoyer un message  tous");
    sendMsg.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            FormPopup.open(new PopupSaisieMessage());
        }
    });

    Button resfresh = new Button("Rafraichir");
    resfresh.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            refresh();
        }
    });

    toolbar.addComponent(sendMsg);
    toolbar.addComponent(resfresh);

    Label title = new Label("Liste des personnes connectes");
    title.setSizeUndefined();
    title.addStyleName("stdlistpart-text-title");

    searchField = new TextField();
    searchField.setInputPrompt("Rechercher par le nom ou l'email");
    searchField.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            textFilter = event.getText();
            updateFilters();
        }
    });
    searchField.addStyleName(ChameleonTheme.TEXTFIELD_BIG);
    searchField.setWidth("50%");

    toolbar.addComponent(searchField);
    toolbar.setWidth("100%");
    toolbar.setExpandRatio(searchField, 1);
    toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT);

    addComponent(title);
    addComponent(toolbar);
    addComponent(beanTable);
    setExpandRatio(beanTable, 1);

    refresh();

}

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

License:Apache License

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

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

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

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

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

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

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

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

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

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

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

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

        addComponent(globalLayout);
    }
}

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

License:Apache License

/**
 * Initialise la vue/*  w ww  . jav a2  s .co  m*/
 */
@PostConstruct
public void init() {

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

        /* Style */
        setSizeFull();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            }

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

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

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

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

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

        }

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

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

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

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

    }
}

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

License:Apache License

/**
 * Initialise la vue/*from   www .j  ava  2s  .  c o m*/
 */
@PostConstruct
public void init() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            //Cration du trombinoscope
            displayTrombinoscope(false);

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

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

            }

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

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

            addComponent(infoLayout);

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

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

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

    }

}

From source file:fr.univlorraine.mondossierweb.views.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 w  w .  jav  a2 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.NotesView.java

License:Apache License

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

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

        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//from  www . java 2s .c  o  m
 */
@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);

    }
}