Example usage for com.vaadin.ui HorizontalLayout setSizeFull

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

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:fi.jasoft.draganddrop.demos.DragDemo.java

License:Apache License

@Override
protected Component getDemoContent() {
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeFull();

    // source-start
    // Create image
    Image image = new Image(null, new ThemeResource("graphics/bin.jpg"));

    // Enable dropping items on image
    DragAndDrop.enable(image, DragAndDropOperation.DROP)

            // Set custom drop handler
            .onDrop(new DropHandler<Image>() {

                @Override/*from   w w  w . j  a v  a  2s.c  o  m*/
                protected void onDrop(Component component) {

                    // Restor trash bin
                    getSource().setSource(new ThemeResource("graphics/bin.jpg"));

                    // Remove item
                    ((ComponentContainer) component.getParent()).removeComponent(component);
                }
            })

            // Set custom over handler
            .onOver(new DragOverHandler<Image>() {

                @Override
                protected void onOver(Component component) {

                    // Add color to trash bin
                    getSource().setSource(new ThemeResource("graphics/bin2.jpg"));
                }
            })

            // Set custom out handler
            .onOut(new DragOutHandler<Image>() {

                @Override
                protected void onOut(Component component) {

                    // Restore trash bin
                    getSource().setSource(new ThemeResource("graphics/bin.jpg"));
                }
            });

    // source-end

    hl.addComponent(image);
    hl.setComponentAlignment(image, Alignment.TOP_CENTER);

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeUndefined();
    vl.setSpacing(true);
    hl.addComponent(vl);
    hl.setComponentAlignment(vl, Alignment.TOP_CENTER);

    // source-start
    /*
     * Create item list to drag from
     */
    for (int i = 0; i < 5; i++) {
        Label item = new Label("Item " + (i + 1));
        item.setStyleName("item");
        item.setSizeUndefined();

        // Enable dragging the items
        DragAndDrop.enable(item, DragAndDropOperation.DRAG);

        vl.addComponent(item);
    }
    // source-end

    return hl;
}

From source file:fi.jasoft.dragdroplayouts.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();/*from   w  ww  .j  ava2 s .co  m*/
    setContent(content);

    Label header = new Label("DragDropLayouts for Vaadin 8");
    header.setStyleName(ValoTheme.LABEL_H1);
    content.addComponent(header);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeFull();
    content.addComponent(hl);
    content.setExpandRatio(hl, 1);

    VerticalSplitPanel split = new VerticalSplitPanel();
    hl.addComponent(split);
    hl.setExpandRatio(split, 1);

    CssLayout placeHolder = new CssLayout(new Label("No view selected."));
    placeHolder.setSizeFull();
    split.setFirstComponent(placeHolder);

    Panel codePanel = new Panel(codeLabel);
    codePanel.setSizeFull();
    split.setSecondComponent(codePanel);

    navigator = new Navigator(this, placeHolder);

    navigator.addViewChangeListener(new ViewChangeListener() {

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
            DemoView view = (DemoView) event.getNewView();
            selection.getSelectionModel().select(view);
            codeLabel.setValue(getFormattedSourceCode(view.getSource()));
            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
            // TODO Auto-generated method stub

        }
    });

    try {
        addView(new DragdropAbsoluteLayoutDemo(navigator));
        addView(new DragdropVerticalLayoutDemo(navigator));
        addView(new DragdropHorizontalLayoutDemo(navigator));
        addView(new DragdropGridLayoutDemo(navigator));
        addView(new DragdropCssLayoutDemo(navigator));
        addView(new DragdropFormLayoutDemo(navigator));
        addView(new DragdropPanelDemo(navigator));

        addView(new DragdropLayoutDraggingDemo(navigator));
        addView(new DragdropHorizontalSplitPanelDemo(navigator));
        addView(new DragdropVerticalSplitPanelDemo(navigator));
        addView(new DragdropTabsheetDemo(navigator));
        addView(new DragdropAccordionDemo(navigator));

        addView(new DragdropDragFilterDemo(navigator));
        addView(new DragdropCaptionModeDemo(navigator));

        addView(new DragdropV7VerticalLayoutDemo(navigator));
        addView(new DragdropV7HorizontalLayoutDemo(navigator));

        // addView(new DragdropIframeDragging(navigator));

    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    hl.addComponent(selection = createViewSelection(), 0);

    String fragment = Page.getCurrent().getUriFragment();
    if (fragment == null || fragment.equals("")) {
        navigator.navigateTo(DragdropAbsoluteLayoutDemo.NAME);
    }
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropDragCaptionDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(true);/*from w ww . j  a v  a2 s.c o  m*/
    layout.setSpacing(true);

    DDPanel panel1 = new DDPanel("Source");
    panel1.setWidth("200px");
    panel1.setHeight("200px");
    panel1.setDragMode(LayoutDragMode.CLONE);
    panel1.setDropHandler(new DefaultPanelDropHandler());

    panel1.setDragCaptionProvider(component -> new DragCaption(
            "<u>Custom drag caption:</u><br/>" + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE,
            ContentMode.HTML));

    layout.addComponent(panel1);

    Button content = new Button("Drag me!");
    content.setSizeFull();
    panel1.setContent(content);

    DDPanel panel2 = new DDPanel("Destination");
    panel2.setWidth("200px");
    panel2.setHeight("200px");
    panel2.setDragMode(LayoutDragMode.CLONE);
    panel2.setDropHandler(new DefaultPanelDropHandler());

    panel2.setDragCaptionProvider(component -> new DragCaption(
            "Drag caption goes back! " + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE));

    layout.addComponent(panel2);

    // end-source
    Label label = new Label("In this demo you can drag the button."
            + "\nYou will see custom drag caption(with icon) provided by DragCaptionProvider");
    label.setContentMode(ContentMode.PREFORMATTED);
    return new VerticalLayout(label, layout);
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropHorizontalSplitPanelDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    CssLayout root = new CssLayout();
    root.setSizeFull();/*from   www.j a  v  a2  s. c o  m*/

    Label lbl = new Label("To the left are some buttons, and to the right is a horizontal split panel. "
            + "Try dragging the buttons on to the splitpanel. If a component already exists in the SplitPanel it is replaced with the dragged one.");
    root.addComponent(lbl);

    // Wrapping components in a horizontal layout
    HorizontalLayout inner = new HorizontalLayout();
    inner.setMargin(true);
    inner.setSizeFull();
    inner.setSpacing(true);
    root.addComponent(inner);

    // Add some buttons to a vertical layout with dragging enabled
    final DDVerticalLayout btns = new DDVerticalLayout();
    btns.setDragMode(LayoutDragMode.CLONE);
    btns.setSizeUndefined();
    btns.setSpacing(true);
    String caption = "Button ";
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    inner.addComponent(btns);

    // Create a drag & drop horizontal split panel
    final DDHorizontalSplitPanel panel = new DDHorizontalSplitPanel();
    panel.setSizeFull();

    inner.addComponent(panel);
    inner.setExpandRatio(panel, 1);

    // Enable dragging
    panel.setDragMode(LayoutDragMode.CLONE);

    // Enable dropping
    panel.setDropHandler(new DefaultHorizontalSplitPanelDropHandler());

    // end-source
    return root;
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropIframeDragging.java

License:Apache License

@Override
public Component getLayout() {
    HorizontalLayout root = new HorizontalLayout();
    root.setSizeFull();
    root.setSpacing(true);/*  ww w . j av  a  2  s  .  c o  m*/
    setCompositionRoot(root);

    // Add a layout where shimming is turned on
    root.addComponent(createShimmedLayout());

    // Add a layout where shimming is turned off
    root.addComponent(createUnShimmedLayout());

    return root;
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropPanelDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    layout.setMargin(true);//w w w.  j a  v a2s  . c  o m
    layout.setSpacing(true);

    DDPanel panel1 = new DDPanel("Source");
    panel1.setWidth("200px");
    panel1.setHeight("200px");
    panel1.setDragMode(LayoutDragMode.CLONE);
    panel1.setDropHandler(new DefaultPanelDropHandler());
    layout.addComponent(panel1);

    Button content = new Button("Drag me!");
    content.setSizeFull();
    panel1.setContent(content);

    DDPanel panel2 = new DDPanel("Destination");
    panel2.setWidth("200px");
    panel2.setHeight("200px");
    panel2.setDragMode(LayoutDragMode.CLONE);
    panel2.setDropHandler(new DefaultPanelDropHandler());
    layout.addComponent(panel2);

    // end-source
    return new VerticalLayout(new Label("In this demo you can drag the button from one Panel to the other one"),
            layout);
}

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

License:Apache License

/**
 * Initialise la vue//ww  w . j a  v  a  2 s . 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 ava  2s.  co m

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            }

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

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

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

License:Apache License

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

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

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

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

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

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

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

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

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

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

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

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

        addComponent(globalLayout);
    }
}

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

License:Apache License

private void renseignerPanelContact() {

    VerticalLayout contactLayout = new VerticalLayout();

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

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

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

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

    contactLayout.addComponent(formContactLayout);

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

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

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

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

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

    panelContact.setContent(contactLayout);

}