Example usage for com.vaadin.ui HorizontalLayout setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPage2.java

License:Open Source License

@SuppressWarnings("serial")
public void initGuiTL() {
    ActionPlan actPln = ActionPlan.getTL(apId);
    User me = Mmowgli2UI.getGlobals().getUserTL();
    addStyleName("m-cssleft-45");

    setWidth("1089px");
    setHeight("1821px");
    Label sp;//  ww  w.  j  a v  a2s  .  c  om

    VerticalLayout mainVL = new VerticalLayout();
    addComponent(mainVL, "top:0px;left:0px");
    mainVL.addStyleName("m-overflow-visible");
    mainVL.setWidth("1089px");
    mainVL.setHeight(null);
    mainVL.setSpacing(false);
    mainVL.setMargin(false);

    VerticalLayout mainVLayout = new VerticalLayout();

    mainVLayout.setSpacing(false);
    mainVLayout.setMargin(false);
    mainVLayout.addStyleName("m-actionplan-background2");
    mainVLayout.setWidth("1089px");
    mainVLayout.setHeight(null); //"1821px");
    mainVL.addComponent(mainVLayout);

    mainVLayout.addComponent(makeIdField(actPln));

    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("5px");

    VerticalLayout leftTopVL = new VerticalLayout();
    leftTopVL.setWidth("820px");
    leftTopVL.setSpacing(false);
    leftTopVL.setMargin(false);
    mainVLayout.addComponent(leftTopVL);

    HorizontalLayout titleAndThumbsHL = new HorizontalLayout();
    titleAndThumbsHL.setSpacing(false);
    titleAndThumbsHL.setMargin(false);
    titleAndThumbsHL.setHeight("115px");
    titleAndThumbsHL.addStyleName("m-actionplan-header-container");
    leftTopVL.addComponent(titleAndThumbsHL);

    titleAndThumbsHL.addComponent(sp = new Label());
    sp.setWidth("55px");

    VerticalLayout vl = new VerticalLayout();
    vl.addComponent(titleUnion); //titleTA);
    titleUnion.initGui();

    titleHistoryButt = new NativeButton();
    titleHistoryButt.setCaption("history");
    titleHistoryButt.setStyleName(BaseTheme.BUTTON_LINK);
    titleHistoryButt.addStyleName("borderless");
    titleHistoryButt.addStyleName("m-actionplan-history-button");
    titleHistoryButt.addClickListener(new TitleHistoryListener());
    titleHistoryButt.setEnabled(!readonly);
    vl.addComponent(titleHistoryButt);
    vl.setComponentAlignment(titleHistoryButt, Alignment.TOP_RIGHT);
    titleAndThumbsHL.addComponent(vl); //titleTA);

    titleUnion.setWidth(ACTIONPLAN_TITLE_W);
    titleUnion.setValueTL(actPln.getTitle() == null ? "" : actPln.getTitle());

    titleUnion.addStyleName("m-lightgrey-border");
    // titleUnion.addStyleName("m-opacity-75");
    titleUnion.setHeight("95px"); // 120 px); must make it this way for alignment of r/o vs rw

    addComponent(saveCanPan, "top:0px;left:395px");
    saveCanPan.setVisible(false);

    titleAndThumbsHL.addComponent(sp = new Label());
    sp.setWidth("50px");

    VerticalLayout thumbVL = new VerticalLayout();
    titleAndThumbsHL.addComponent(thumbVL);
    thumbVL.addComponent(sp = new Label());
    sp.setHeight("50px");

    thumbPanel = new ThumbPanel();
    Map<User, Integer> map = actPln.getUserThumbs();
    Integer t = map.get(me);
    /*  if(t == null) {
        map.put(me, 0);
        ActionPlan.update(actPln);
        GameEventLogger.logActionPlanUpdate(actPln, "thumbs changed",me.getUserName());
        t = 0;
      } */
    thumbPanel.setNumUserThumbs(t == null ? 0 : t);
    thumbVL.addComponent(thumbPanel);

    HorizontalLayout commentAndViewChainHL = new HorizontalLayout();
    leftTopVL.addComponent(commentAndViewChainHL);
    commentAndViewChainHL.setSpacing(false);
    commentAndViewChainHL.setMargin(false);
    commentAndViewChainHL.addComponent(sp = new Label());
    sp.setWidth("55px");

    VerticalLayout commLeftVL = new VerticalLayout();
    commentAndViewChainHL.addComponent(commLeftVL);
    commLeftVL.setWidth("95px");
    commLeftVL.addComponent(commentsButt);
    commentsButt.setStyleName(BaseTheme.BUTTON_LINK);
    commentsButt.addStyleName("borderless");
    commentsButt.addStyleName("m-actionplan-comments-button");

    ClickListener commLis;
    commentsButt.addClickListener(commLis = new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().setScrollTop(1250); //commentsButt.getWindow().setScrollTop(1250);
        }
    });
    commLeftVL.addComponent(sp = new Label());
    sp.setHeight("65px"); //"50px");

    commLeftVL.addComponent(envelopeButt);
    envelopeButt.addStyleName("m-actionplan-envelope-button");
    envelopeButt.addClickListener(commLis); // same as the link button above

    commentAndViewChainHL.addComponent(sp = new Label());
    sp.setWidth("5px");

    VerticalLayout commMidVL = new VerticalLayout();
    commentAndViewChainHL.addComponent(commMidVL);
    commMidVL.setWidth("535px");
    commMidVL.addComponent(addCommentButt);
    addCommentButt.setCaption("Add Comment");
    addCommentButt.setStyleName(BaseTheme.BUTTON_LINK);
    addCommentButt.addStyleName("borderless");
    addCommentButt.addStyleName("m-actionplan-comments-button");
    addCommentButt.setId(ACTIONPLAN_ADD_COMMENT_LINK_BUTTON_TOP);

    addCommentButt.addClickListener(addCommentListener = new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().setScrollTop(1250); //addCommentButt.getWindow().setScrollTop(1250);
            commentPanel.AddCommentClicked(event);
        }
    });

    commMidVL.addComponent(sp = new Label());
    sp.setHeight("5px");

    commMidVL.addComponent(lastCommentLabel = new HtmlLabel());
    lastCommentLabel.setWidth("100%");
    lastCommentLabel.setHeight("94px");
    lastCommentLabel.addStyleName("m-actionplan-textentry");
    lastCommentLabel.addStyleName("m-opacity-75");

    addComponent(viewChainButt, "left:690px;top:140px");
    viewChainButt.setStyleName("m-viewCardChainButton");
    viewChainButt.addClickListener(new ViewCardChainHandler());
    viewChainButt.setId(ACTIONPLAN_VIEW_CARD_CHAIN_BUTTON);
    // This guy sits on the bottom naw, gets covered
    // author list and rfe
    VerticalLayout rightVL = new VerticalLayout();
    this.addComponent(rightVL, "left:830px;top:0px");
    rightVL.setSpacing(false);
    rightVL.setMargin(false);
    rightVL.setWidth(null);

    VerticalLayout listVL = new VerticalLayout();
    listVL.setSpacing(false);
    listVL.addStyleName("m-actionPlanAddAuthorList");
    listVL.addStyleName("m-actionplan-header-container");
    listVL.setHeight(null);
    listVL.setWidth("190px");

    listVL.addComponent(sp = new Label());
    sp.setHeight("35px");
    sp.setDescription("List of current authors and (invited authors)");

    Label subTitle;
    listVL.addComponent(subTitle = new Label("(invited in parentheses)"));
    subTitle.setWidth(null); // keep it from being 100% wide
    subTitle.setDescription("List of current authors and (invited authors)");
    subTitle.addStyleName("m-actionplan-authorlist-sublabel");
    listVL.setComponentAlignment(subTitle, Alignment.MIDDLE_CENTER);

    rightVL.addComponent(listVL);

    TreeSet<User> ts = new TreeSet<User>(new User.AlphabeticalComparator());
    ts.addAll(actPln.getAuthors());
    TreeSet<User> greyTs = new TreeSet<User>(new User.AlphabeticalComparator());
    greyTs.addAll(actPln.getInvitees());
    authorList = new UserList(null, ts, greyTs);

    listVL.addComponent(authorList);
    authorList.addStyleName("m-greyborder");
    listVL.setComponentAlignment(authorList, Alignment.TOP_CENTER);
    authorList.setWidth("150px");
    authorList.setHeight("95px");
    listVL.addComponent(sp = new Label());
    sp.setHeight("5px");
    listVL.addComponent(addAuthButton);
    listVL.setComponentAlignment(addAuthButton, Alignment.TOP_CENTER);
    addAuthButton.setStyleName("m-actionPlanAddAuthorButt");
    addAuthButton.addClickListener(new AddAuthorHandler());
    addAuthButton.setDescription("Invite players to be authors of this action plan");

    rightVL.addComponent(sp = new Label());
    sp.setHeight("5px");
    rightVL.addComponent(rfeButt);
    rightVL.setComponentAlignment(rfeButt, Alignment.TOP_CENTER);
    // done in handleDisabledments() rfeButt.setStyleName("m-rfeButton");

    // end authorList and rfe

    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("5px");
    sp.setWidth("20px");
    // Tabs:
    AbsoluteLayout absL = new AbsoluteLayout();
    mainVLayout.addComponent(absL);
    absL.setHeight("60px");
    absL.setWidth("830px");
    HorizontalLayout tabsHL = new HorizontalLayout();
    tabsHL.setStyleName("m-actionPlanBlackTabs");
    tabsHL.setSpacing(false);

    absL.addComponent(tabsHL, "left:40px;top:0px");

    NewTabClickHandler ntabHndlr = new NewTabClickHandler();

    tabsHL.addComponent(sp = new Label());
    sp.setWidth("19px");
    thePlanTabButt.setStyleName("m-actionPlanThePlanTab");
    thePlanTabButt.addStyleName(ACTIONPLAN_TAB_THEPLAN); // debug
    thePlanTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(thePlanTabButt);

    talkTabButt.setStyleName("m-actionPlanTalkItOverTab");
    //talkTabButt.addStyleName(ACTIONPLAN_TAB_TALK);
    talkTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(talkTabButt);
    talkTabButt.addStyleName("m-transparent-background"); // initially

    imagesTabButt.setStyleName("m-actionPlanImagesTab");
    imagesTabButt.addStyleName(ACTIONPLAN_TAB_IMAGES);
    imagesTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(imagesTabButt);
    imagesTabButt.addStyleName("m-transparent-background"); // initially

    videosTabButt.setStyleName("m-actionPlanVideosTab");
    videosTabButt.addStyleName(ACTIONPLAN_TAB_VIDEO);
    videosTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(videosTabButt);
    videosTabButt.addStyleName("m-transparent-background"); // initially

    mapTabButt.setStyleName("m-actionPlanMapTab");
    mapTabButt.addStyleName(ACTIONPLAN_TAB_MAP);
    mapTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(mapTabButt);
    mapTabButt.addStyleName("m-transparent-background"); // initially

    newChatLab.setStyleName("m-newChatLabel");
    absL.addComponent(newChatLab, "left:340px;top:15px");
    newChatLab.setVisible(false);

    // stack the pages
    HorizontalLayout hsp = new HorizontalLayout();
    hsp.setHeight("742px"); // allows for differing ghost box heights
    mainVLayout.addComponent(hsp);

    hsp.addComponent(sp = new Label());
    sp.setWidth("45px");

    hsp.addComponent(thePlanTab);
    thePlanTab.initGui();

    hsp.addComponent(talkTab);
    talkTab.initGui();
    talkTab.setVisible(false);

    hsp.addComponent(imagesTab);
    imagesTab.initGui();
    imagesTab.setVisible(false);

    hsp.addComponent(videosTab);
    videosTab.initGui();
    videosTab.setVisible(false);

    hsp.addComponent(mapTab);
    mapTab.initGui();
    mapTab.setVisible(false);

    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("90px");

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.addStyleName("m-marginleft-60");
    mainVLayout.addComponent(buttLay);
    buttLay.setWidth(ActionPlanPageCommentPanel2.COMMENT_PANEL_WIDTH);
    addCommentButtBottom.setCaption("Add Comment");
    addCommentButtBottom.setStyleName(BaseTheme.BUTTON_LINK);
    addCommentButtBottom.addStyleName("borderless");
    addCommentButtBottom.addStyleName("m-actionplan-comments-button");
    addCommentButtBottom.setId(ACTIONPLAN_ADD_COMMENT_LINK_BUTTON_BOTTOM);
    addCommentButtBottom.addClickListener(addCommentListener);
    buttLay.addComponent(addCommentButtBottom);

    if (me.isAdministrator() || me.isGameMaster()) {

        buttLay.addComponent(sp = new Label());
        sp.setWidth("1px"); // "810px");
        buttLay.setExpandRatio(sp, 1.0f);
        ToggleLinkButton tlb = new ToggleLinkButton("View all", "View unhidden only",
                "m-actionplan-comment-text");
        tlb.setToolTips("Temporarily show all messages, including those marked \"hidden\" (gm)",
                "Temporarily hide messages marked \"hidden\" (gm)");
        tlb.addStyleName("m-actionplan-comments-button");
        tlb.addOnListener(new ViewAllListener());
        tlb.addOffListener(new ViewUnhiddenOnlyListener());
        buttLay.addComponent(tlb);
        buttLay.addComponent(sp = new Label());
        sp.setWidth("5px");
    }
    // And the comments
    hsp = new HorizontalLayout();
    mainVLayout.addComponent(hsp);
    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("5px");
    hsp.addComponent(sp = new Label());
    sp.setWidth("56px");

    hsp.addComponent(commentPanel);
    commentPanel.initGui();

    // Set thumbs
    double thumbs = actPln.getAverageThumb();
    long round = Math.round(thumbs);
    int numApThumbs = (int) (Math.min(round, 3));
    thumbPanel.setNumApThumbs(numApThumbs);

    Integer myRating = actPln.getUserThumbs().get(me);
    if (myRating == null)
        myRating = 0;
    thumbPanel.setNumUserThumbs(myRating);

    helpWantedListener = new HelpWantedListener();
    interestedListener = new InterestedListener();

    handleDisablementsTL();
}

From source file:edu.nps.moves.mmowgli.modules.cards.IdeaDashboard.java

License:Open Source License

private void styleBlackTabs(String gameTitleLC, HorizontalLayout tabHL) {
    if (gameTitleLC.contains("energy"))
        tabHL.setStyleName("m-ideaDashboardBlackTabsEfficiencyConsumption");
    else if (gameTitleLC.contains("innovate"))
        tabHL.setStyleName("m-ideaDashboardBlackTabs");
    else/*from  w  w  w .  j  ava2  s .  c  om*/
        tabHL.setStyleName("m-ideaDashboardEmptyBlackTabs");
}

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

License:Apache License

/**
 * Initialise la vue//from ww  w  .j  av a  2s.  co 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) {
        removeAllComponents();

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

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

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

        //Layout avec les infos etatcivil et contact
        CssLayout idLayout = new CssLayout();
        idLayout.setSizeFull();
        idLayout.setStyleName("flexwrap");

        globalLayout.addComponent(idLayout);
        // Enable Responsive CSS selectors for the layout
        Responsive.makeResponsive(idLayout);

        if (MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {

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

            Panel panelAdresseAnnuelle = new Panel(
                    applicationContext.getMessage(NAME + ".adresseannuelle.title", null, getLocale()) + " "
                            + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee());

            String captionAdresseAnnuelle = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseAnnuelle = new Label();
            formatLabel(fieldAdresseAnnuelle, captionAdresseAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse1());
            formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle);

            String annuelle2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse3());
            if (annuelle2 != null) {
                Label fieldAdresseAnnuelle2 = new Label();
                formatLabel(fieldAdresseAnnuelle2, null, annuelle2);
                formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle2);
            }
            String captionVilleAnnuelle = applicationContext.getMessage(NAME + ".ville.title", null,
                    getLocale());
            Label fieldVilleAnnuelle = new Label();
            formatLabel(fieldVilleAnnuelle, captionVilleAnnuelle,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getVille()));
            formAdresseAnnuelleLayout.addComponent(fieldVilleAnnuelle);

            String captionPaysAnnuelle = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysAnnuelle = new Label();
            formatLabel(fieldPaysAnnuelle, captionPaysAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getPays());
            formAdresseAnnuelleLayout.addComponent(fieldPaysAnnuelle);

            String captionTelephoneAnnuelle = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneAnnuelle = new Label();
            formatLabel(fieldTelephoneAnnuelle, captionTelephoneAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getNumerotel());
            formAdresseAnnuelleLayout.addComponent(fieldTelephoneAnnuelle);

            panelAdresseAnnuelle.setContent(formAdresseAnnuelleLayout);

            HorizontalLayout adresseAnnuelleGlobalLayout = new HorizontalLayout();
            adresseAnnuelleGlobalLayout.setSizeUndefined();
            adresseAnnuelleGlobalLayout.setStyleName("firstitembox");
            adresseAnnuelleGlobalLayout.addComponent(panelAdresseAnnuelle);
            adresseAnnuelleGlobalLayout.setExpandRatio(panelAdresseAnnuelle, 1);
            idLayout.addComponent(adresseAnnuelleGlobalLayout);
        }

        if (MainUI.getCurrent().getEtudiant().getAdresseFixe() != null) {
            FormLayout formAdresseFixeLayout = new FormLayout();
            formAdresseFixeLayout.setSpacing(true);
            formAdresseFixeLayout.setMargin(true);

            Panel panelAdresseFixe = new Panel(
                    applicationContext.getMessage(NAME + ".adressefixe.title", null, getLocale()));

            String captionAdresseFixe = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseFixe = new Label();
            formatLabel(fieldAdresseFixe, captionAdresseFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse1());
            formAdresseFixeLayout.addComponent(fieldAdresseFixe);

            String adfixe2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse3());
            if (adfixe2 != null) {
                Label fieldAdresseFixe2 = new Label();
                formatLabel(fieldAdresseFixe2, null, adfixe2);
                formAdresseFixeLayout.addComponent(fieldAdresseFixe2);
            }

            String captionVilleFixe = applicationContext.getMessage(NAME + ".ville.title", null, getLocale());
            Label fieldVilleFixe = new Label();
            formatLabel(fieldVilleFixe, captionVilleFixe,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getVille()));
            formAdresseFixeLayout.addComponent(fieldVilleFixe);

            String captionPaysFixe = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysFixe = new Label();
            formatLabel(fieldPaysFixe, captionPaysFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getPays());
            formAdresseFixeLayout.addComponent(fieldPaysFixe);

            String captionTelephoneFixe = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneFixe = new Label();
            formatLabel(fieldTelephoneFixe, captionTelephoneFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getNumerotel());
            formAdresseFixeLayout.addComponent(fieldTelephoneFixe);

            panelAdresseFixe.setContent(formAdresseFixeLayout);

            HorizontalLayout adresseFixeGlobalLayout = new HorizontalLayout();
            adresseFixeGlobalLayout.setSizeUndefined();
            adresseFixeGlobalLayout.setStyleName("itembox");
            adresseFixeGlobalLayout.addComponent(panelAdresseFixe);
            adresseFixeGlobalLayout.setExpandRatio(panelAdresseFixe, 1);
            idLayout.addComponent(adresseFixeGlobalLayout);

        }

        addComponent(globalLayout);

        if (userController.isEtudiant() && configController.isModificationAdressesAutorisee()
                && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
            HorizontalLayout btnLayout = new HorizontalLayout();
            btnLayout.setSizeFull();
            btnLayout.setSpacing(true);

            Button btnModifAdresses = new Button(
                    applicationContext.getMessage(NAME + ".bouton.modifieradresses", null, getLocale()));
            btnModifAdresses.setStyleName(ValoTheme.BUTTON_PRIMARY);
            btnModifAdresses.setIcon(FontAwesome.EDIT);
            btnModifAdresses.addClickListener(e -> {
                ModificationAdressesWindow maw = new ModificationAdressesWindow(
                        MainUI.getCurrent().getEtudiant());
                maw.addCloseListener(f -> {
                    init();
                });
                UI.getCurrent().addWindow(maw);
            });
            btnLayout.addComponent(btnModifAdresses);
            btnLayout.setComponentAlignment(btnModifAdresses, Alignment.MIDDLE_LEFT);
            addComponent(btnLayout);
        }
    }
}

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 w  w w . j  av  a2  s  .c  om

        /* 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.EtatCivilView.java

License:Apache License

/**
 * Initialise la vue/*from w  w w . j av  a2 s. c  o  m*/
 */
@PostConstruct
public void init() {

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

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

            LOG.debug(userController.getCurrentUserName() + " init EtatCivilView");

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

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

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

            //Layout avec les infos etatcivil et contact
            CssLayout idLayout = new CssLayout();
            idLayout.setSizeFull();
            idLayout.setStyleName("flexwrap");

            globalLayout.addComponent(idLayout);
            // Enable Responsive CSS selectors for the layout
            Responsive.makeResponsive(idLayout);

            /* Generalites */
            FormLayout formGeneralitesLayout = new FormLayout();
            formGeneralitesLayout.setSpacing(true);
            formGeneralitesLayout.setMargin(true);

            Panel panelGeneralites = new Panel(
                    applicationContext.getMessage(NAME + ".generalites.title", null, getLocale()));

            String captionNumDossier = applicationContext.getMessage(NAME + ".numdossier.title", null,
                    getLocale());
            Label fieldNumDossier = new Label();
            formatLabel(fieldNumDossier, captionNumDossier, MainUI.getCurrent().getEtudiant().getCod_etu());
            formGeneralitesLayout.addComponent(fieldNumDossier);

            String captionNNE = applicationContext.getMessage(NAME + ".nne.title", null, getLocale());
            Label fieldNNE = new Label();
            formatLabel(fieldNNE, captionNNE, MainUI.getCurrent().getEtudiant().getCod_nne());
            formGeneralitesLayout.addComponent(fieldNNE);

            String captionNom = applicationContext.getMessage(NAME + ".nom.title", null, getLocale());
            Label fieldNom = new Label();
            formatLabel(fieldNom, captionNom, MainUI.getCurrent().getEtudiant().getNom());
            formGeneralitesLayout.addComponent(fieldNom);

            String captionMail = applicationContext.getMessage(NAME + ".mail.title", null, getLocale());
            Label mailLabel = new Label();
            mailLabel.setCaption(captionMail);
            String mail = MainUI.getCurrent().getEtudiant().getEmail();
            if (StringUtils.hasText(mail)) {
                mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>";
                mailLabel.setValue(mail);
                mailLabel.setContentMode(ContentMode.HTML);
            }
            mailLabel.setSizeFull();
            formGeneralitesLayout.addComponent(mailLabel);

            String captionNationalite = applicationContext.getMessage(NAME + ".nationalite.title", null,
                    getLocale());
            Label fieldNationalite = new Label();
            formatLabel(fieldNationalite, captionNationalite,
                    MainUI.getCurrent().getEtudiant().getNationalite());
            formGeneralitesLayout.addComponent(fieldNationalite);

            String captionDateNaissance = applicationContext.getMessage(NAME + ".naissance.title", null,
                    getLocale());
            Label fieldDateNaissance = new Label();
            formatLabel(fieldDateNaissance, captionDateNaissance,
                    MainUI.getCurrent().getEtudiant().getDatenaissance());
            formGeneralitesLayout.addComponent(fieldDateNaissance);

            String captionLieuNaissance = applicationContext.getMessage(NAME + ".lieunaissance.title", null,
                    getLocale());
            Label fieldLieuNaissance = new Label();
            formatLabel(fieldLieuNaissance, captionLieuNaissance,
                    MainUI.getCurrent().getEtudiant().getLieunaissance());
            formGeneralitesLayout.addComponent(fieldLieuNaissance);

            String captionDepNaissance = applicationContext.getMessage(NAME + ".depnaissance.title", null,
                    getLocale());
            Label fieldDepNaissance = new Label();
            formatLabel(fieldDepNaissance, captionDepNaissance,
                    MainUI.getCurrent().getEtudiant().getDepartementnaissance());
            formGeneralitesLayout.addComponent(fieldDepNaissance);

            panelGeneralites.setContent(formGeneralitesLayout);

            HorizontalLayout generalitesGlobalLayout = new HorizontalLayout();
            generalitesGlobalLayout.setSizeUndefined();
            generalitesGlobalLayout.setStyleName("firstitembox");
            generalitesGlobalLayout.addComponent(panelGeneralites);
            generalitesGlobalLayout.setExpandRatio(panelGeneralites, 1);
            idLayout.addComponent(generalitesGlobalLayout);

            /* Bac */

            Panel panelBac = new Panel(applicationContext.getMessage(NAME + ".bac.title", null, getLocale()));

            //Si plusieurs bac
            if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                    && MainUI.getCurrent().getEtudiant().getListeBac().size() > 1) {
                panelBac.setCaption(applicationContext.getMessage(NAME + ".bacs.title", null, getLocale()));
                TabSheet bacTabSheet = new TabSheet();
                VerticalLayout vBacLayout = new VerticalLayout();
                vBacLayout.setSizeFull();
                bacTabSheet.setSizeFull();
                bacTabSheet.addStyleName(ValoTheme.TABSHEET_FRAMED);
                for (BacEtatCivil bec : MainUI.getCurrent().getEtudiant().getListeBac()) {

                    FormLayout tabBacLayout = new FormLayout();
                    tabBacLayout.setSizeFull();
                    tabBacLayout.setMargin(false);
                    ajouterBacToView(tabBacLayout, bec);
                    bacTabSheet.addTab(tabBacLayout, bec.getCod_bac(), FontAwesome.GRADUATION_CAP);

                }
                vBacLayout.addComponent(bacTabSheet);
                panelBac.setContent(vBacLayout);
            } else {
                //Si un seul bac
                FormLayout formBacLayout = new FormLayout();
                formBacLayout.setSizeFull();
                if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                        && MainUI.getCurrent().getEtudiant().getListeBac().size() == 1) {
                    formBacLayout.setSpacing(true);
                    formBacLayout.setMargin(true);
                    ajouterBacToView(formBacLayout, MainUI.getCurrent().getEtudiant().getListeBac().get(0));
                }
                panelBac.setContent(formBacLayout);
            }

            HorizontalLayout bacGlobalLayout = new HorizontalLayout();
            bacGlobalLayout.setSizeUndefined();
            bacGlobalLayout.setStyleName("itembox");
            bacGlobalLayout.addComponent(panelBac);
            bacGlobalLayout.setExpandRatio(panelBac, 1);
            idLayout.addComponent(bacGlobalLayout);

            /* Info de contact */
            panelContact = new Panel(applicationContext.getMessage(NAME + ".contact.title", null, getLocale()));
            renseignerPanelContact();
            globalLayout.addComponent(panelContact);

            addComponent(globalLayout);

        } else {
            /* Erreur */
            addComponent(new BasicErreurMessageLayout(applicationContext));
        }
    }
}

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

License:Apache License

/**
 * Initialise la vue/*  www  . j  a  v  a  2  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.InformationsAnnuellesMobileView.java

License:Apache License

public void refresh() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();//  w  ww .  j  a v a2s  .c  o m

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        etuPanel.setContent(photoLayout);

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

        globalLayout.addComponent(slimLayout);

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

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

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

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

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

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

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

            panelInfos.setContent(formInfosLayout);
        } else {

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

        }
        globalLayout.addComponent(panelInfos);

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

    }
}

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

License:Apache License

/**
 * Initialise la vue/*from  ww  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()) {
        // 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.NotesDetailMobileView.java

License:Apache License

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

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

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

            removeAllComponents();

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

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

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

            //Bouton retour
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                MdwTouchkitUI.getCurrent().navigateToResumeNotes();
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

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

            navbar.setExpandRatio(labelNavBar, 1);

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

            addComponent(navbar);

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

            etape = etapeToDisplay;
            codetu = codetuToDisplay;

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

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

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

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

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

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

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

                libSessionLayout.addComponent(sessionLayout);

                notesLayout.addComponent(libSessionLayout);

                boolean blueLevel = false;

                compteurElp = 0;
                elpPere = "";

                HorizontalLayout layoutPere = null;
                int nbFils = 0;

                for (ElementPedagogique elp : lelp) {

                    compteurElp++;

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

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

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

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

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

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

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

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

                    VerticalLayout libVerticalLayout = new VerticalLayout();

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

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

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

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

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

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

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

                    libElpLayout.addComponent(noteLayout);

                    notesLayout.addComponent(libElpLayout);

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

                    }
                }

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

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

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

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

            }

            addComponent(layout);

            setExpandRatio(layout, 1);

        } else {
            refreshJavascript();
        }
    }
}

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

License:Apache License

public void refresh() {

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

        removeAllComponents();//  ww  w  .jav  a 2 s .c  o  m

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

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

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

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

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

        navbar.setExpandRatio(labelNavBar, 1);

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

        addComponent(navbar);

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

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

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

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

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

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

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

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

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

                noteLayout.addComponent(libelleLayout);

                noteLayout.addComponent(notesessionLayout);

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

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

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

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

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

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

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

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

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

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

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

                noteLayout.addComponent(libelleLayout);

                noteLayout.addComponent(notesessionLayout);

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

        }

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