Example usage for com.vaadin.ui HorizontalLayout setMargin

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

Introduction

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

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:fr.amapj.view.views.login.LoginPart.java

License:Open Source License

public void buildLoginView(ValoMenuLayout root, AmapUI ui, String loginFromUrl, String passwordFromUrl,
        String sudo) {/*  w  ww . ja v a2  s .c  om*/
    this.ui = ui;
    CssLayout loginAera = root.prepareForLoginPage();

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

    loginAera.setStyleName("login-backgroundimage");
    loginAera.addComponent(loginLayout);

    // Recuperation des parametres
    String nomAmap = new ParametresService().getParametres().nomAmap;
    ui.getPage().setTitle(nomAmap);

    // Zone de saisie login/password 
    MyLoginForm myLoginForm = new MyLoginForm(loginFromUrl, passwordFromUrl, sudo, nomAmap);
    myLoginForm.addStyleName("login-layout");
    loginLayout.addComponent(myLoginForm);
    loginLayout.setComponentAlignment(myLoginForm, Alignment.MIDDLE_CENTER);
    loginLayout.setExpandRatio(myLoginForm, 10);

    Label l1 = new Label("Application fonctionnant avec AmapJ - ");
    Link link = new Link("Plus d'infos", new ExternalResource("http://amapj.fr"));
    link.setTargetName("_blank");

    HorizontalLayout hL = new HorizontalLayout();
    hL.addComponent(l1);
    hL.setComponentAlignment(l1, Alignment.MIDDLE_CENTER);
    hL.addComponent(link);
    hL.setComponentAlignment(link, Alignment.MIDDLE_CENTER);
    hL.setMargin(true);

    loginLayout.addComponent(hL);
    loginLayout.setComponentAlignment(hL, Alignment.BOTTOM_CENTER);
    loginLayout.setExpandRatio(hL, 1);

    // Si les deux champs ont t remplis on tente une validation automatique
    if ((passwordFromUrl != null) && (loginFromUrl != null)) {
        myLoginForm.login(loginFromUrl, passwordFromUrl);
    }

}

From source file:fr.amapj.view.views.mescontrats.MesContratsView.java

License:Open Source License

public void refresh() {
    mesContratsDTO = new MesContratsService().getMesContrats(SessionManager.getUserId());

    layout = this;
    layout.removeAllComponents();//from   w  ww .ja  va  2s  .c  o  m

    // Information sur le renouvellement de l'adhsion
    adhesionPart.addAhesionInfo(layout);

    // Le titre
    addLabel(layout, "Les nouveaux contrats disponibles");

    // la liste des nouveaux contrats 
    List<ContratDTO> newContrats = mesContratsDTO.getNewContrats();
    for (ContratDTO c : newContrats) {
        Panel p = new Panel();
        p.addStyleName(PANEL_UNCONTRAT);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setMargin(true);
        hl.setSpacing(true);
        hl.setWidth("100%");

        VerticalLayout vl = new VerticalLayout();
        Label lab = new Label(c.nom);
        lab.addStyleName(LABEL_TITRECONTRAT);
        vl.addComponent(lab);

        String str = formatLibelleContrat(c, true);
        BaseUiTools.addHtmlLabel(vl, str, "libelle-contrat");

        hl.addComponent(vl);
        hl.setExpandRatio(vl, 1);

        VerticalLayout vl2 = new VerticalLayout();
        vl2.setWidth("115px");
        vl2.setSpacing(true);

        Button b = addButtonInscription("S'inscrire", c);
        b.setWidth("100%");
        b.addStyleName(BUTTON_PRINCIPAL);
        vl2.addComponent(b);

        hl.addComponent(vl2);
        hl.setComponentAlignment(vl2, Alignment.MIDDLE_CENTER);

        p.setContent(hl);

        layout.addComponent(p);

    }

    // Le titre
    addLabel(layout, "Mes contrats existants");

    // la liste des contrats existants 
    List<ContratDTO> existingContrats = mesContratsDTO.getExistingContrats();
    for (ContratDTO c : existingContrats) {
        Panel p = new Panel();
        p.addStyleName(PANEL_UNCONTRAT);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setMargin(true);
        hl.setSpacing(true);
        hl.setWidth("100%");

        VerticalLayout vl = new VerticalLayout();
        Label lab = new Label(c.nom);
        lab.addStyleName(LABEL_TITRECONTRAT);
        vl.addComponent(lab);

        String str = formatLibelleContrat(c, false);
        BaseUiTools.addHtmlLabel(vl, str, "libelle-contrat");

        hl.addComponent(vl);
        hl.setExpandRatio(vl, 1);

        VerticalLayout vl2 = new VerticalLayout();
        vl2.setWidth("115px");
        vl2.setSpacing(true);

        if (c.isModifiable) {
            Button b = addButtonInscription("Modifier", c);
            b.setWidth("100%");
            vl2.addComponent(b);
        }

        if (c.isSupprimable) {
            Button b = addButtonSupprimer("Supprimer", c);
            b.setWidth("100%");
            vl2.addComponent(b);
        }

        if (c.isJoker) {
            Button b = addButtonJoker("Grer jokers", c);
            b.setWidth("100%");
            vl2.addComponent(b);
        }

        Button v = addButtonVoir("Voir", c);
        v.addStyleName(BUTTON_PRINCIPAL);
        v.setWidth("100%");
        vl2.addComponent(v);

        hl.addComponent(vl2);
        hl.setComponentAlignment(vl2, Alignment.MIDDLE_CENTER);

        p.setContent(hl);

        layout.addComponent(p);

    }

    // Le bouton pour tlcharger les contrats
    if (existingContrats.size() > 0) {
        Button telechargerButton = new Button("Imprimer mes contrats ...");
        telechargerButton.setIcon(FontAwesome.PRINT);
        telechargerButton.addStyleName("borderless");
        telechargerButton.addStyleName("large");
        telechargerButton.addClickListener(e -> handleTelecharger());

        layout.addComponent(telechargerButton);
        layout.setComponentAlignment(telechargerButton, Alignment.MIDDLE_LEFT);

    }
}

From source file:fr.amapj.view.views.mescontrats.MesContratsViewAdhesionPart.java

License:Open Source License

public void addAhesionInfo(VerticalLayout layout) {
    MesContratsDTO mesContratsDTO = view.mesContratsDTO;

    // Cas classique de renouvellement de l'adhsion
    if (mesContratsDTO.adhesionDTO.displayAdhesionTop()) {

        Label lab = new Label("Renouvellement de votre adhsion  l'AMAP");
        lab.addStyleName(MesContratsView.LABEL_RUBRIQUE);
        layout.addComponent(lab);/*from   ww w.  j  a  va 2 s .c  om*/

        Panel p = new Panel();
        p.addStyleName(MesContratsView.PANEL_UNCONTRAT);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setMargin(true);
        hl.setSpacing(true);
        hl.setWidth("100%");

        VerticalLayout vl = new VerticalLayout();
        Label lab1 = new Label("Adhsion pour " + mesContratsDTO.adhesionDTO.periodeCotisationDTO.nom);
        lab1.addStyleName(MesContratsView.LABEL_TITRECONTRAT);
        vl.addComponent(lab1);

        String str = formatLibelleAdhesion(mesContratsDTO.adhesionDTO);
        BaseUiTools.addHtmlLabel(vl, str, "libelle-contrat");

        addLinkImpressionBulletin(mesContratsDTO.adhesionDTO, vl);

        hl.addComponent(vl);
        hl.setExpandRatio(vl, 1);

        VerticalLayout vl2 = new VerticalLayout();
        vl2.setWidth("115px");
        vl2.setSpacing(true);

        hl.addComponent(vl2);
        hl.setComponentAlignment(vl2, Alignment.MIDDLE_CENTER);

        if (mesContratsDTO.adhesionDTO.isCotisant()) {
            Button b = addButtonAdhesionAdherer("Modifier");
            b.setWidth("100%");
            vl2.addComponent(b);

            b = addButtonAdhesionSupprimer("Supprimer");
            b.setWidth("100%");
            vl2.addComponent(b);

            Button v = addButtonAdhesionVoir("Voir");
            v.setWidth("100%");
            v.addStyleName(MesContratsView.BUTTON_PRINCIPAL);
            vl2.addComponent(v);

        } else {
            Button b = addButtonAdhesionAdherer("Adhrer");
            b.addStyleName(MesContratsView.BUTTON_PRINCIPAL);
            b.setWidth("100%");
            vl2.addComponent(b);
        }

        p.setContent(hl);
        layout.addComponent(p);

    }

    // Cas d'affichage uniquement, pendant 30 jours apres la fin des inscriptions  
    if (mesContratsDTO.adhesionDTO.affichageOnly != null) {
        AffichageOnly aff = mesContratsDTO.adhesionDTO.affichageOnly;

        Label lab = new Label("Votre adhsion  l'AMAP");
        lab.addStyleName(MesContratsView.LABEL_RUBRIQUE);
        layout.addComponent(lab);

        Panel p = new Panel();
        p.addStyleName(MesContratsView.PANEL_UNCONTRAT);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setMargin(true);
        hl.setSpacing(true);
        hl.setWidth("100%");

        VerticalLayout vl = new VerticalLayout();
        Label lab1 = new Label("Adhsion pour " + aff.nomPeriode);
        lab1.addStyleName(MesContratsView.LABEL_TITRECONTRAT);
        vl.addComponent(lab1);

        String str = "Vous avez renouvel votre adhsion  l'AMAP. Montant : "
                + new CurrencyTextFieldConverter().convertToString(aff.montantAdhesion) + " ";
        BaseUiTools.addHtmlLabel(vl, str, "libelle-contrat");

        if (shouldDisplayLinkBulletinInAffichageOnly(aff)) {
            Link l = LinkCreator
                    .createLink(new PGBulletinAdhesion(aff.idPeriode, aff.idPeriodeUtilisateur, null));
            l.setCaption("Imprimer mon bulletin d'adhsion");
            l.setStyleName("adhesion");

            vl.addComponent(l);
        }

        hl.addComponent(vl);
        hl.setExpandRatio(vl, 1);

        VerticalLayout vl2 = new VerticalLayout();
        vl2.setWidth("115px");
        vl2.setSpacing(true);

        hl.addComponent(vl2);
        hl.setComponentAlignment(vl2, Alignment.MIDDLE_CENTER);

        p.setContent(hl);
        layout.addComponent(p);

    }
}

From source file:fr.amapj.view.views.permanence.mespermanences.MesPermanencesView.java

License:Open Source License

public void refresh() {
    mesContratsDTO = new MesPermanencesService().getMesPermanenceDTO(SessionManager.getUserId());

    layout = this;
    layout.removeAllComponents();/*  w w  w  .  ja  v a2  s.c  om*/

    if (mesContratsDTO.mesPeriodesPermanences.size() > 0) {

        // Le titre
        addLabel(layout, "S'inscrire aux permanences");

        // la liste des inscriptions possibles
        for (UnePeriodePermanenceDTO c : mesContratsDTO.mesPeriodesPermanences) {
            Panel p = new Panel();
            p.addStyleName(PANEL_UNCONTRAT);

            HorizontalLayout hl = new HorizontalLayout();
            hl.setMargin(true);
            hl.setSpacing(true);
            hl.setWidth("100%");

            VerticalLayout vl = new VerticalLayout();
            Label lab = new Label(c.nom);
            lab.addStyleName(LABEL_TITRECONTRAT);
            vl.addComponent(lab);

            String str = formatLibelleContrat(c, true);
            BaseUiTools.addHtmlLabel(vl, str, "libelle-contrat");

            hl.addComponent(vl);
            hl.setExpandRatio(vl, 1);

            VerticalLayout vl2 = new VerticalLayout();
            vl2.setWidth("115px");
            vl2.setSpacing(true);

            String libButton = getLibButton(c);
            Button b = addButtonInscription(libButton, c);
            b.setWidth("100%");
            b.addStyleName(BUTTON_PRINCIPAL);
            vl2.addComponent(b);

            hl.addComponent(vl2);
            hl.setComponentAlignment(vl2, Alignment.MIDDLE_CENTER);

            p.setContent(hl);

            layout.addComponent(p);

        }
    }

    //
    addLabel(layout, "Les dates de mes permanences");

    VerticalLayout vl1 = BaseUiTools.addPanel(this, "mes-permanences");
    String mesPermanences = getLibMesPermanences();
    BaseUiTools.addHtmlLabel(vl1, mesPermanences, "ligne");

    addLabel(layout, "Consulter les plannings de permanence");

    VerticalLayout vl2 = BaseUiTools.addPanel(this, "mes-permanences");

    // Le bouton pour visualiser les permanences en ligne 
    Button onLineButton = new Button("Visualiser les plannings de permanence ...");
    onLineButton.setIcon(FontAwesome.EYE);
    onLineButton.addStyleName("borderless");
    onLineButton.addStyleName("large");
    onLineButton.addClickListener(e -> handleVisualiser());

    vl2.addComponent(onLineButton);
    vl2.setComponentAlignment(onLineButton, Alignment.MIDDLE_LEFT);

    // Le bouton pour tlcharger les permanences 
    Button telechargerButton = new Button("Tlcharger les plannings de permanence au format tableur ...");
    telechargerButton.setIcon(FontAwesome.PRINT);
    telechargerButton.addStyleName("borderless");
    telechargerButton.addStyleName("large");
    telechargerButton.addClickListener(e -> handleTelecharger());

    vl2.addComponent(telechargerButton);
    vl2.setComponentAlignment(telechargerButton, Alignment.MIDDLE_LEFT);

}

From source file:fr.amapj.view.views.permanence.PeriodePermanenceSelectorPart.java

License:Open Source License

public HorizontalLayout getChoixPeriodeComponent() {
    // Partie choix 
    HorizontalLayout toolbar1 = new HorizontalLayout();
    toolbar1.addStyleName("periode-permanence-selectorpart");

    Label pLabel = new Label("Priode de permanence");
    pLabel.addStyleName("periode-permanence");
    pLabel.setSizeUndefined();//from   w w w . j ava 2s  .  c  o m

    toolbar1.addComponent(pLabel);

    constructMultiplePeriode(toolbar1);

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

    return toolbar1;
}

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

License:Apache License

/**
 * Construction du menu tudiant/*w  w  w. j  a  va 2  s . com*/
 */
private void buildMainMenuEtudiant() {

    //Si l'tudiant dont on affiche le dossier est renseign
    if (etudiant != null) {

        //Ajout du style au menu
        mainMenu.setPrimaryStyleName(ValoTheme.MENU_PART);
        //On fixe la largeur du menu
        mainMenu.setWidth("233px");

        //Si on a une url pour la photo de l'tudiant
        if (etudiant.getPhoto() != null) {
            //Layout contenant la photo
            HorizontalLayout photoLayout = new HorizontalLayout();

            //Ajout du style au layout
            photoLayout.addStyleName(ValoTheme.MENU_SUBTITLE);
            //On fixe la largeur du layout
            photoLayout.setWidth(213, Unit.PIXELS);
            //La layout a des marges
            photoLayout.setMargin(true);

            //Bouton qui indique, en fonction de l'icone, si l'tudiant est inscrit pour l'anne en cours. Par dfaut, icone indiquant que l'tudiant est inscrit
            Button etuInscritBtn = new Button("", FontAwesome.CHECK_CIRCLE);
            //Ajout du style au bouton
            etuInscritBtn.setPrimaryStyleName(ValoTheme.BUTTON_BORDERLESS);

            //Si l'tudiant est inscrit pour l'anne en cours
            if (etudiant.isInscritPourAnneeEnCours()) {
                //On fixe la description du bouton
                etuInscritBtn.setDescription("Inscrit pour l'anne universitaire "
                        + Utils.getAnneeUniversitaireEnCours(etudiantController.getAnneeUnivEnCours(this)));
            } else {
                //On change l'icone du bouton pour indiquer que l'tudiant n'est pas inscrit
                etuInscritBtn.setIcon(FontAwesome.EXCLAMATION_CIRCLE);
                //On fixe la description du bouton
                etuInscritBtn.setDescription("Non Inscrit pour l'anne universitaire "
                        + Utils.getAnneeUniversitaireEnCours(etudiantController.getAnneeUnivEnCours(this)));
            }

            //Ajout d'un lment vide dans le layout
            photoLayout.addComponent(new HorizontalLayout());

            //Cration de l'image contenant la photo
            Image fotoEtudiant = new Image(null, new ExternalResource(etudiant.getPhoto()));
            fotoEtudiant.setWidth("120px");
            //Ajout de la photo au layout
            photoLayout.addComponent(fotoEtudiant);
            //Alignement de la photo
            photoLayout.setComponentAlignment(fotoEtudiant, Alignment.MIDDLE_CENTER);
            //La photo prend toute la place disponible dans son layout
            photoLayout.setExpandRatio(fotoEtudiant, 1);

            //Ajout au layout du bouton, qui indique, en fonction de l'icone, si l'tudiant est inscrit pour l'anne en cours
            photoLayout.addComponent(etuInscritBtn);

            //Ajout du layout de la photo au menu
            mainMenu.addComponent(photoLayout);
        }

        //Ajout du Prnom/Nom et codetu de l'tudiant dans le menu
        Label usernameLabel = new Label(etudiant.getNom() + "<br />" + etudiant.getCod_etu(), ContentMode.HTML);
        usernameLabel.addStyleName(ValoTheme.MENU_SUBTITLE);
        usernameLabel.addStyleName("retourALaLigneAutomatique");
        usernameLabel.setSizeUndefined();
        mainMenu.addComponent(usernameLabel);

        /* Etat Civil */
        addItemMenu("Etat-civil", EtatCivilView.NAME, FontAwesome.USER);

        //info annuelles visibles que si tudiant inscrit pour l'anne en cours
        if (etudiant.isInscritPourAnneeEnCours()) {
            addItemMenu("Informations annuelles", InformationsAnnuellesView.NAME, FontAwesome.INFO_CIRCLE);
        }

        /* Adresses */
        addItemMenu(applicationContext.getMessage(AdressesView.NAME + ".title", null, getLocale()),
                AdressesView.NAME, FontAwesome.HOME);

        /* Inscriptions */
        addItemMenu("Inscriptions", InscriptionsView.NAME, FontAwesome.FILE_TEXT);

        /* Calendrier */
        addItemMenu("Calendrier des preuves", CalendrierView.NAME, FontAwesome.CALENDAR);

        /* Notes et Rsultats */
        addItemMenu(applicationContext.getMessage(NotesView.NAME + ".title", null, getLocale()), NotesView.NAME,
                FontAwesome.LIST);

        /* Sparation avant Bouton "Aide" */
        CssLayout bottomMainMenu1 = new CssLayout();
        bottomMainMenu1.setStyleName(ValoTheme.MENU_SUBTITLE);
        bottomMainMenu1.setSizeUndefined();
        mainMenu.addComponent(bottomMainMenu1);

        /* Aide */
        Button helpBtn = new Button(applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()),
                FontAwesome.SUPPORT);
        helpBtn.setPrimaryStyleName(ValoTheme.MENU_ITEM);
        helpBtn.addClickListener(e -> {
            UI.getCurrent()
                    .addWindow(new HelpBasicWindow(
                            applicationContext.getMessage("helpWindow.text.etudiant", null, getLocale()),
                            applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()), true));
        });
        mainMenu.addComponent(helpBtn);

        /* Deconnexion */
        //Voir si on peut accder  l'appli hors ENT, le dtecter, et afficher le bouton dconnexion
        if (configController.isLogoutCasPropose() && userController.isEtudiant()) {
            Button decoBtn = new Button("Dconnexion", FontAwesome.SIGN_OUT);
            decoBtn.setPrimaryStyleName(ValoTheme.MENU_ITEM);
            decoBtn.addClickListener(e -> {
                getUI().getPage().setLocation("j_spring_security_logout");
            });
            mainMenu.addComponent(decoBtn);
        }
        /* Sparation */
        CssLayout bottomMainMenu = new CssLayout();
        bottomMainMenu.setStyleName(ValoTheme.MENU_SUBTITLE);
        bottomMainMenu.setSizeUndefined();
        mainMenu.addComponent(bottomMainMenu);

    }
}

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

License:Apache License

public void refresh() {
    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();//from   ww w.ja  v  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);
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            }

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

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

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

License:Apache License

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

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

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

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

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

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

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

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

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

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

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

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

        addComponent(globalLayout);
    }
}

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

License:Apache License

private void renseignerPanelContact() {

    VerticalLayout contactLayout = new VerticalLayout();

    /* Layout pour afficher les erreurs */
    VerticalLayout erreursLayout = new VerticalLayout();
    contactLayout.addComponent(erreursLayout);
    erreursLayout.setVisible(false);//from   www .ja  v  a 2  s. c  o  m

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

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

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

    contactLayout.addComponent(formContactLayout);

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

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

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

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

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

    panelContact.setContent(contactLayout);

}

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

License:Apache License

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

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

        /* Style */
        setSizeFull();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            }

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

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

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

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

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

        }

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

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

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

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

    }
}