List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:fr.univlorraine.mondossierweb.views.InformationsAnnuellesView.java
License:Apache License
/** * Initialise la vue//from w w w. j av a 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); /* Titre */ Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale())); title.addStyleName(ValoTheme.LABEL_H1); addComponent(title); HorizontalLayout globalLayout = new HorizontalLayout(); globalLayout.setSizeFull(); globalLayout.setSpacing(true); Panel panelInfos = new Panel(applicationContext.getMessage(NAME + ".infos.title", null, getLocale()) + " " + Utils.getAnneeUniversitaireEnCours( etudiantController.getAnneeUnivEnCours(MainUI.getCurrent()))); 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.isEtudiant()) { lano = MainUI.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, MainUI.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, MainUI.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, MainUI.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, MainUI.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); globalLayout.addComponent(panelInfos); //Si on affiche aucun ou un seul numro d'anonymat, on diminue la largeur du panneau. /*if(lano==null || lano.size()<2) { globalLayout.addComponent(new VerticalLayout()); }*/ addComponent(globalLayout); } }
From source file:fr.univlorraine.mondossierweb.views.InscriptionsView.java
License:Apache License
/** * Initialise la vue/*from ww w.ja v a 2s . c om*/ */ @PostConstruct public void init() { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant()) && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) { /* Style */ setMargin(true); setSpacing(true); /* 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); //Si les informations sur les inscriptions n'ont pas dj t rcupres, on les rcupre if (MainUI.getCurrent().getEtudiant().getLibEtablissement() == null) { etudiantController.recupererInscriptions(); } //Test si la rcupration des inscriptions via le WS s'est bien passe if (MainUI.getCurrent().isRecuperationWsInscriptionsOk()) { //Tout c'est bien pass lors de la rcupration des infos via le WS Panel panelInscription = new Panel(MainUI.getCurrent().getEtudiant().getLibEtablissement()); Table inscriptionsTable = new Table(null, new BeanItemContainer<>(Inscription.class, MainUI.getCurrent().getEtudiant().getLinsciae())); inscriptionsTable.setWidth("100%"); String[] colonnes = IA_FIELDS_ORDER; if (userController.isEtudiant()) { colonnes = IA_FIELDS_ORDER_ETU; } inscriptionsTable.setVisibleColumns((Object[]) colonnes); for (String fieldName : colonnes) { inscriptionsTable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale())); } inscriptionsTable.addGeneratedColumn( applicationContext.getMessage(NAME + ".table.lib_etp", null, getLocale()), new LibelleInscriptionColumnGenerator()); //inscriptionsTable.setSortContainerPropertyId("cod_anu"); inscriptionsTable.setColumnCollapsingAllowed(true); inscriptionsTable.setColumnReorderingAllowed(false); inscriptionsTable.setSelectable(false); inscriptionsTable.setImmediate(true); inscriptionsTable.setStyleName("noscrollabletable"); inscriptionsTable.setPageLength(inscriptionsTable.getItemIds().size()); panelInscription.setContent(inscriptionsTable); globalLayout.addComponent(panelInscription); //DAC Panel panelDAC = new Panel(applicationContext.getMessage(NAME + ".dac.title", null, getLocale())); if (MainUI.getCurrent().getEtudiant().getLinscdac() != null && MainUI.getCurrent().getEtudiant().getLinscdac().size() > 0) { Table inscriptionsDAC = new Table(null, new BeanItemContainer<>(Inscription.class, MainUI.getCurrent().getEtudiant().getLinscdac())); inscriptionsDAC.setWidth("100%"); inscriptionsDAC.setVisibleColumns((Object[]) DAC_FIELDS_ORDER); for (String fieldName : DAC_FIELDS_ORDER) { inscriptionsDAC.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".tabledac." + fieldName, null, getLocale())); } inscriptionsDAC.setColumnCollapsingAllowed(true); inscriptionsDAC.setColumnReorderingAllowed(false); inscriptionsDAC.setSelectable(false); inscriptionsDAC.setImmediate(true); inscriptionsDAC.setStyleName("noscrollabletable"); inscriptionsDAC.setPageLength(inscriptionsDAC.getItemIds().size()); panelDAC.setContent(inscriptionsDAC); } else { HorizontalLayout labelDacLayout = new HorizontalLayout(); labelDacLayout.setMargin(true); labelDacLayout.setSizeFull(); Label aucuneDAC = new Label( applicationContext.getMessage(NAME + ".dac.aucune", null, getLocale()) + " " + MainUI.getCurrent().getEtudiant().getLibEtablissement()); aucuneDAC.setStyleName(ValoTheme.LABEL_COLORED); aucuneDAC.addStyleName(ValoTheme.LABEL_BOLD); labelDacLayout.addComponent(aucuneDAC); panelDAC.setContent(labelDacLayout); } globalLayout.addComponent(panelDAC); Panel panelPremInscription = new Panel( applicationContext.getMessage(NAME + ".premiereinsc.title", null, getLocale())); FormLayout formPremInscription = new FormLayout(); formPremInscription.setSpacing(true); formPremInscription.setMargin(true); String captionAnneePremInscription = applicationContext.getMessage(NAME + ".premiereinsc.annee", null, getLocale()); TextField fieldAnneePremInscription = new TextField(captionAnneePremInscription, MainUI.getCurrent().getEtudiant().getAnneePremiereInscrip()); formatTextField(fieldAnneePremInscription); formPremInscription.addComponent(fieldAnneePremInscription); String captionEtbPremInscription = applicationContext.getMessage(NAME + ".premiereinsc.etb", null, getLocale()); TextField fieldEtbPremInscription = new TextField(captionEtbPremInscription, MainUI.getCurrent().getEtudiant().getEtbPremiereInscrip()); formatTextField(fieldEtbPremInscription); formPremInscription.addComponent(fieldEtbPremInscription); panelPremInscription.setContent(formPremInscription); globalLayout.addComponent(panelPremInscription); addComponent(globalLayout); } else { //Il y a eu un soucis lors de la rcupration des infos via le WS Panel panelErreurInscription = new Panel(); Label labelMsgErreur = new Label( applicationContext.getMessage("AllView.erreur.message", null, getLocale())); panelErreurInscription.setContent(labelMsgErreur); addComponent(panelErreurInscription); } } }
From source file:fr.univlorraine.mondossierweb.views.ListeInscritsView.java
License:Apache License
public void initListe() { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && userController.isEnseignant()) { // initialisation de la vue removeAllComponents();/*from www. j a va 2s . c o m*/ listeEtapes = null; listeGroupes = null; // Style setMargin(true); setSpacing(true); setSizeFull(); // Rcupration de l'objet de la SE dont on doit afficher les inscrits code = MainUI.getCurrent().getCodeObjListInscrits(); typeFavori = MainUI.getCurrent().getTypeObjListInscrits(); libelleObj = ""; if (typeIsVet() && MainUI.getCurrent().getEtapeListeInscrits() != null) { libelleObj = MainUI.getCurrent().getEtapeListeInscrits().getLibelle(); } if (typeIsElp() && MainUI.getCurrent().getElpListeInscrits() != null) { libelleObj = MainUI.getCurrent().getElpListeInscrits().getLibelle(); } // Si l'objet est renseign if (code != null && typeFavori != null) { //Panel contenant les filtres d'affichage et le bouton de mise en favori HorizontalLayout panelLayout = new HorizontalLayout(); panelLayout.setSizeFull(); panelLayout.addStyleName("small-font-element"); // Layout contenant les filtres FormLayout formInscritLayout = new FormLayout(); formInscritLayout.setStyleName(ValoTheme.FORMLAYOUT_LIGHT); formInscritLayout.setSpacing(true); formInscritLayout.setMargin(true); panelFormInscrits = new Panel(code + " " + libelleObj); //Affichage d'une liste droulante contenant la liste des annes List<String> lannees = MainUI.getCurrent().getListeAnneeInscrits(); if (lannees != null && lannees.size() > 0) { listeAnnees = new ComboBox(applicationContext.getMessage(NAME + ".annee", null, getLocale())); listeAnnees.setPageLength(5); listeAnnees.setTextInputAllowed(false); listeAnnees.setNullSelectionAllowed(false); listeAnnees.setWidth("150px"); for (String annee : lannees) { listeAnnees.addItem(annee); int anneenplusun = Integer.parseInt(annee) + 1; listeAnnees.setItemCaption(annee, annee + "/" + anneenplusun); } listeAnnees.setValue(MainUI.getCurrent().getAnneeInscrits()); //Gestion de l'vnement sur le changement d'anne listeAnnees.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //faire le changement Map<String, String> parameterMap = new HashMap<>(); parameterMap.put("code", code); parameterMap.put("type", typeFavori); //rcupration de la nouvelle liste if (typeIsVet()) { listeInscritsController.recupererLaListeDesInscrits(parameterMap, selectedValue, MainUI.getCurrent()); } if (typeIsElp()) { listeInscritsController.recupererLaListeDesInscritsELP(parameterMap, selectedValue, MainUI.getCurrent()); } //update de l'affichage initListe(); } }); formInscritLayout.addComponent(listeAnnees); } //Si on affiche la liste des inscrits un ELP //on doit affiche l'tape d'appartenance et ventuellement les groupes //Affichage d'une liste droulante contenant la liste des annes if (typeIsElp()) { List<VersionEtape> letapes = MainUI.getCurrent().getListeEtapesInscrits(); if (letapes != null && letapes.size() > 0) { listeEtapes = new ComboBox( applicationContext.getMessage(NAME + ".etapes", null, getLocale())); listeEtapes.setPageLength(5); listeEtapes.setNullSelectionAllowed(false); listeEtapes.setTextInputAllowed(false); listeEtapes.setRequired(false); listeEtapes.setWidth("400px"); listeEtapes.addItem(TOUTES_LES_ETAPES_LABEL); listeEtapes.setItemCaption(TOUTES_LES_ETAPES_LABEL, TOUTES_LES_ETAPES_LABEL); for (VersionEtape etape : letapes) { String idEtape = etape.getId().getCod_etp() + "/" + etape.getId().getCod_vrs_vet(); listeEtapes.addItem(idEtape); listeEtapes.setItemCaption(idEtape, "[" + idEtape + "] " + etape.getLib_web_vet()); } if (MainUI.getCurrent().getEtapeInscrits() != null) { listeEtapes.setValue(MainUI.getCurrent().getEtapeInscrits()); } else { listeEtapes.setValue(TOUTES_LES_ETAPES_LABEL); } //Gestion de l'vnement sur le changement d'tape listeEtapes.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String vetSelectionnee = (String) event.getProperty().getValue(); if (vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { vetSelectionnee = null; } MainUI.getCurrent().setEtapeInscrits(vetSelectionnee); //faire le changement String groupeSelectionne = ((listeGroupes != null && listeGroupes.getValue() != null) ? (String) listeGroupes.getValue() : null); if (groupeSelectionne != null && groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) { groupeSelectionne = null; } filtrerInscrits(vetSelectionnee, groupeSelectionne); } }); formInscritLayout.addComponent(listeEtapes); } List<ElpDeCollection> lgroupes = MainUI.getCurrent().getListeGroupesInscrits(); if (lgroupes != null && lgroupes.size() > 0) { listeGroupes = new ComboBox(); listeGroupes.setPageLength(5); listeGroupes.setNullSelectionAllowed(false); listeGroupes.setTextInputAllowed(false); listeGroupes.setRequired(false); listeGroupes.setStyleName(ValoTheme.COMBOBOX_BORDERLESS); listeGroupes.setWidth("348px"); listeGroupes.addItem(TOUS_LES_GROUPES_LABEL); listeGroupes.setItemCaption(TOUS_LES_GROUPES_LABEL, TOUS_LES_GROUPES_LABEL); for (ElpDeCollection edc : lgroupes) { for (CollectionDeGroupes cdg : edc.getListeCollection()) { for (Groupe groupe : cdg.getListeGroupes()) { listeGroupes.addItem(groupe.getCleGroupe()); listeGroupes.setItemCaption(groupe.getCleGroupe(), groupe.getLibGroupe()); } } } if (MainUI.getCurrent().getGroupeInscrits() != null) { listeGroupes.setValue(MainUI.getCurrent().getGroupeInscrits()); } else { listeGroupes.setValue(TOUS_LES_GROUPES_LABEL); } //Gestion de l'vnement sur le changement de groupe listeGroupes.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String grpSelectionnee = (String) event.getProperty().getValue(); if (grpSelectionnee.equals(TOUS_LES_GROUPES_LABEL)) { grpSelectionnee = null; } MainUI.getCurrent().setGroupeInscrits(grpSelectionnee); //faire le changement String etapeSelectionnee = ((listeEtapes != null && listeEtapes.getValue() != null) ? (String) listeEtapes.getValue() : null); if (etapeSelectionnee != null && etapeSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { etapeSelectionnee = null; } filtrerInscrits(etapeSelectionnee, grpSelectionnee); } }); HorizontalLayout gpLayout = new HorizontalLayout(); gpLayout.setCaption(applicationContext.getMessage(NAME + ".groupes", null, getLocale())); gpLayout.setMargin(false); gpLayout.setSpacing(false); gpLayout.addComponent(listeGroupes); Button btnDetailGpe = new Button(); btnDetailGpe.setWidth("52px"); btnDetailGpe.setHeight("32px"); btnDetailGpe.setStyleName(ValoTheme.BUTTON_PRIMARY); btnDetailGpe.setIcon(FontAwesome.SEARCH); btnDetailGpe.setDescription( applicationContext.getMessage(NAME + ".detail.groupes", null, getLocale())); btnDetailGpe.addClickListener(e -> { String vet = null; if (listeEtapes != null && listeEtapes.getValue() != null && !listeEtapes.getValue().equals(TOUTES_LES_ETAPES_LABEL)) { vet = listeEtapes.getItemCaption(listeEtapes.getValue()); } DetailGroupesWindow dgw = new DetailGroupesWindow(lgroupes, panelFormInscrits.getCaption(), vet, (String) listeAnnees.getValue()); UI.getCurrent().addWindow(dgw); }); gpLayout.addComponent(btnDetailGpe); formInscritLayout.addComponent(gpLayout); } } panelLayout.addComponent(formInscritLayout); panelLayout.setComponentAlignment(formInscritLayout, Alignment.MIDDLE_LEFT); //Cration du favori pour l'objet concern pas la liste des inscrits List<Favoris> lfav = favorisController.getFavoris(); FavorisPK favpk = new FavorisPK(); favpk.setLogin(userController.getCurrentUserName()); favpk.setIdfav(code); favpk.setTypfav(typeFavori); Favoris favori = new Favoris(); favori.setId(favpk); //Cration du bouton pour ajouter l'objet aux favoris favoriLayout = new VerticalLayout(); favoriLayout.setSizeFull(); favoriLayout.setMargin(true); favoriLayout.setSpacing(true); btnAjoutFavori = new Button( applicationContext.getMessage(NAME + ".btn.ajoutFavori", null, getLocale())); btnAjoutFavori.setIcon(FontAwesome.STAR_O); btnAjoutFavori.addStyleName(ValoTheme.BUTTON_PRIMARY); btnAjoutFavori.setDescription( applicationContext.getMessage(NAME + ".btn.ajoutFavori", null, getLocale())); btnAjoutFavori.addClickListener(e -> { //creation du favori en base sur le clic du bouton favorisController.saveFavori(favori); //On cache le bouton de mise en favori btnAjoutFavori.setVisible(false); //Affichage d'un message de confirmation Notification.show( applicationContext.getMessage(NAME + ".message.favoriAjoute", null, getLocale()), Type.TRAY_NOTIFICATION); }); //Ajout du bouton l'interface favoriLayout.addComponent(btnAjoutFavori); favoriLayout.setComponentAlignment(btnAjoutFavori, Alignment.TOP_RIGHT); if (typeIsElp()) { btnMasquerFiltre = new Button( applicationContext.getMessage(NAME + ".btn.btnMasquerFiltre", null, getLocale())); btnMasquerFiltre.setIcon(FontAwesome.CHEVRON_CIRCLE_UP); btnMasquerFiltre.addStyleName(ValoTheme.BUTTON_FRIENDLY); btnMasquerFiltre.setDescription( applicationContext.getMessage(NAME + ".btn.btnMasquerFiltre", null, getLocale())); btnMasquerFiltre.addClickListener(e -> { panelFormInscrits.setContent(null); if (btnDisplayFiltres != null) { btnDisplayFiltres.setVisible(true); } }); favoriLayout.addComponent(btnMasquerFiltre); favoriLayout.setComponentAlignment(btnMasquerFiltre, Alignment.BOTTOM_RIGHT); } panelLayout.addComponent(favoriLayout); panelLayout.setComponentAlignment(favoriLayout, Alignment.TOP_RIGHT); //Si l'objet est dj en favori if (lfav != null && lfav.contains(favori)) { //On affiche pas le bouton de mise en favori btnAjoutFavori.setVisible(false); } panelFormInscrits.setContent(panelLayout); addComponent(panelFormInscrits); //Rcupration de la liste des inscrits linscrits = MainUI.getCurrent().getListeInscrits(); refreshListeCodind(new BeanItemContainer<>(Inscrit.class, linscrits)); //Test si la liste contient des tudiants if (linscrits != null && linscrits.size() > 0 && listecodind != null && listecodind.size() > 0) { infoLayout = new VerticalLayout(); infoLayout.setSizeFull(); //Layout avec le nb d'inscrit, le bouton trombinoscope et le bouton d'export HorizontalLayout resumeLayout = new HorizontalLayout(); resumeLayout.setWidth("100%"); resumeLayout.setHeight("50px"); //Label affichant le nb d'inscrits infoNbInscrit = new Label( applicationContext.getMessage(NAME + ".message.nbinscrit", null, getLocale()) + " : " + linscrits.size()); leftResumeLayout = new HorizontalLayout(); leftResumeLayout.addComponent(infoNbInscrit); leftResumeLayout.setComponentAlignment(infoNbInscrit, Alignment.MIDDLE_LEFT); Button infoDescriptionButton = new Button(); infoDescriptionButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); infoDescriptionButton.setIcon(FontAwesome.INFO_CIRCLE); infoDescriptionButton.setDescription(applicationContext .getMessage(NAME + ".message.info.predescription", null, getLocale())); infoDescriptionButton.addClickListener(e -> { String message = ""; if (typeIsVet()) { message = applicationContext.getMessage(NAME + ".message.info.vetdescription", null, getLocale()); } if (typeIsElp()) { message = applicationContext.getMessage(NAME + ".message.info.elpdescription", null, getLocale()); } HelpBasicWindow hbw = new HelpBasicWindow(message, applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale())); UI.getCurrent().addWindow(hbw); }); leftResumeLayout.addComponent(infoDescriptionButton); leftResumeLayout.setComponentAlignment(infoDescriptionButton, Alignment.MIDDLE_LEFT); //Bouton export trombinoscope btnExportTrombi = new Button(); btnExportTrombi.setIcon(FontAwesome.FILE_PDF_O); btnExportTrombi.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnExportTrombi.addStyleName("button-icon"); btnExportTrombi.addStyleName("red-button-icon"); btnExportTrombi.setDescription( applicationContext.getMessage(NAME + ".pdf.trombinoscope.link", null, getLocale())); //methode qui permet de generer l'export la demande //Cration du nom du fichier String nomFichier = applicationContext.getMessage("pdf.trombinoscope.title", null, Locale.getDefault()) + "_" + panelFormInscrits.getCaption() + ".pdf"; nomFichier = nomFichier.replaceAll(" ", "_"); StreamResource resource = new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { //recuperation de l'anne slectionne et du libell de l'ELP String annee = (String) listeAnnees.getValue(); String libObj = panelFormInscrits.getCaption(); //cration du trombi en pdf return listeInscritsController.getPdfStream(linscrits, listecodind, libObj, annee); } }, nomFichier); resource.setMIMEType("application/force-download;charset=UTF-8"); resource.setCacheTime(0); //On ajoute le FD sur le bouton d'export if (PropertyUtils.isPushEnabled()) { new MyFileDownloader(resource).extend(btnExportTrombi); } else { FileDownloader fdpdf = new FileDownloader(resource); fdpdf.setOverrideContentType(false); fdpdf.extend(btnExportTrombi); } leftResumeLayout.addComponent(btnExportTrombi); leftResumeLayout.setComponentAlignment(btnExportTrombi, Alignment.MIDDLE_LEFT); //if(!afficherTrombinoscope){ //On cache le bouton d'export pdf btnExportTrombi.setVisible(false); //} //Bouton export liste excel btnExportExcel = new Button(); btnExportExcel.setIcon(FontAwesome.FILE_EXCEL_O); btnExportExcel.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnExportExcel.addStyleName("button-icon"); btnExportExcel .setDescription(applicationContext.getMessage(NAME + ".excel.link", null, getLocale())); String nomFichierXls = applicationContext.getMessage("excel.listeinscrits.title", null, Locale.getDefault()) + "_" + panelFormInscrits.getCaption() + ".xls"; nomFichierXls = nomFichierXls.replaceAll(" ", "_"); StreamResource resourceXls = new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { //recuperation de l'anne slectionne et du libell de l'ELP String annee = (String) listeAnnees.getValue(); String libObj = panelFormInscrits.getCaption(); //cration du trombi en pdf return listeInscritsController.getXlsStream(linscrits, listecodind, listeGroupes, libObj, annee, typeFavori); } }, nomFichierXls); resourceXls.setMIMEType("application/force-download;charset=UTF-8"); resourceXls.setCacheTime(0); //On ajoute le FD sur le bouton d'export if (PropertyUtils.isPushEnabled()) { new MyFileDownloader(resourceXls).extend(btnExportExcel); } else { FileDownloader fd = new FileDownloader(resourceXls); fd.setOverrideContentType(false); fd.extend(btnExportExcel); } //if(!afficherTrombinoscope){ //On change le bouton d'export pdf par le bouton export excel leftResumeLayout.replaceComponent(btnExportTrombi, btnExportExcel); //} resumeLayout.addComponent(leftResumeLayout); //Middle layout avec les bouton de collapse des colonnes middleResumeLayout = new HorizontalLayout(); middleResumeLayout.setSizeFull(); middleResumeLayout.addStyleName("small-font-element"); middleResumeLayout.setSpacing(true); if (!typeIsVet()) { collapseEtp = new CheckBox( applicationContext.getMessage(NAME + ".collapseEtp.title", null, getLocale())); collapseEtp.setValue(true); collapseEtp.addValueChangeListener(e -> { inscritstable.setColumnCollapsed("etape", !collapseEtp.getValue()); }); collapseEtp.setDescription(applicationContext.getMessage(NAME + ".collapseEtp.description", null, getLocale())); middleResumeLayout.addComponent(collapseEtp); middleResumeLayout.setComponentAlignment(collapseEtp, Alignment.MIDDLE_CENTER); } collapseResultatsS1 = new CheckBox( applicationContext.getMessage(NAME + ".collapseResultatsS1.title", null, getLocale())); collapseResultatsS1.setValue(false); collapseResultatsS1.addValueChangeListener(e -> { inscritstable.setColumnCollapsed("notes1", !collapseResultatsS1.getValue()); }); collapseResultatsS1.setDescription(applicationContext .getMessage(NAME + ".collapseResultatsS1.description", null, getLocale())); middleResumeLayout.addComponent(collapseResultatsS1); middleResumeLayout.setComponentAlignment(collapseResultatsS1, Alignment.MIDDLE_CENTER); collapseResultatsS2 = new CheckBox( applicationContext.getMessage(NAME + ".collapseResultatsS2.title", null, getLocale())); collapseResultatsS2.setValue(false); collapseResultatsS2.addValueChangeListener(e -> { inscritstable.setColumnCollapsed("notes2", !collapseResultatsS2.getValue()); }); collapseResultatsS2.setDescription(applicationContext .getMessage(NAME + ".collapseResultatsS2.description", null, getLocale())); middleResumeLayout.addComponent(collapseResultatsS2); middleResumeLayout.setComponentAlignment(collapseResultatsS2, Alignment.MIDDLE_CENTER); resumeLayout.addComponent(middleResumeLayout); HorizontalLayout buttonResumeLayout = new HorizontalLayout(); buttonResumeLayout.setSizeFull(); buttonResumeLayout.setSpacing(true); //Bouton pour afficher les filtres btnDisplayFiltres = new Button(); btnDisplayFiltres.setWidth("52px"); btnDisplayFiltres.setHeight("32px"); btnDisplayFiltres.setStyleName(ValoTheme.BUTTON_FRIENDLY); btnDisplayFiltres.setIcon(FontAwesome.FILTER); btnDisplayFiltres.setDescription( applicationContext.getMessage(NAME + ".btn.displayFilters", null, getLocale())); btnDisplayFiltres.addClickListener(e -> { panelFormInscrits.setContent(panelLayout); btnDisplayFiltres.setVisible(false); }); buttonResumeLayout.addComponent(btnDisplayFiltres); buttonResumeLayout.setComponentAlignment(btnDisplayFiltres, Alignment.MIDDLE_RIGHT); buttonResumeLayout.setExpandRatio(btnDisplayFiltres, 1); btnDisplayFiltres.setVisible(false); //Bouton trombinoscope btnTrombi = new Button( applicationContext.getMessage(NAME + ".message.trombinoscope", null, getLocale())); if (listeInscritsController.isPhotoProviderOperationnel()) { btnTrombi.setIcon(FontAwesome.GROUP); buttonResumeLayout.addComponent(btnTrombi); //Gestion du clic sur le bouton trombinoscope btnTrombi.addClickListener(e -> { //Si on doit afficher une fentre de loading pendant l'excution if (PropertyUtils.isPushEnabled() && PropertyUtils.isShowLoadingIndicator()) { //affichage de la pop-up de loading MainUI.getCurrent().startBusyIndicator(); //Execution de la mthode en parallle dans un thread executorService.execute(new Runnable() { public void run() { MainUI.getCurrent().access(new Runnable() { @Override public void run() { executeDisplayTrombinoscope(); //close de la pop-up de loading MainUI.getCurrent().stopBusyIndicator(); } }); } }); } else { //On ne doit pas afficher de fentre de loading, on excute directement la mthode executeDisplayTrombinoscope(); } }); buttonResumeLayout.setComponentAlignment(btnTrombi, Alignment.MIDDLE_RIGHT); } //Bouton de retour l'affichage de la liste btnRetourListe = new Button( applicationContext.getMessage(NAME + ".message.retourliste", null, getLocale())); btnRetourListe.setIcon(FontAwesome.BARS); buttonResumeLayout.addComponent(btnRetourListe); //if(!afficherTrombinoscope){ btnRetourListe.setVisible(false); //} //Gestion du clic sur le bouton de retour l'affichage de la liste btnRetourListe.addClickListener(e -> { afficherTrombinoscope = false; btnExportTrombi.setVisible(false); leftResumeLayout.replaceComponent(btnExportTrombi, btnExportExcel); btnTrombi.setVisible(true); btnRetourListe.setVisible(false); dataLayout.removeAllComponents(); dataLayout.addComponent(inscritstable); middleResumeLayout.setVisible(true); }); buttonResumeLayout.setComponentAlignment(btnRetourListe, Alignment.MIDDLE_RIGHT); resumeLayout.addComponent(buttonResumeLayout); infoLayout.addComponent(resumeLayout); //Layout qui contient la liste des inscrits et le trombinoscope dataLayout = new VerticalLayout(); dataLayout.setSizeFull(); //Table contenant la liste des inscrits inscritstable = new Table(null, new BeanItemContainer<>(Inscrit.class, linscrits)); inscritstable.addStyleName("table-without-column-selector"); inscritstable.setSizeFull(); inscritstable.setVisibleColumns(new String[0]); String[] fields = INS_FIELDS_ELP; if (typeIsVet()) { fields = INS_FIELDS_VET; } for (String fieldName : fields) { inscritstable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale())); } inscritstable.addGeneratedColumn("cod_etu", new CodEtuColumnGenerator()); inscritstable.setColumnHeader("cod_etu", applicationContext.getMessage(NAME + ".table.cod_etu", null, getLocale())); inscritstable.addGeneratedColumn("email", new MailColumnGenerator()); inscritstable.setColumnHeader("email", applicationContext.getMessage(NAME + ".table.email", null, getLocale())); inscritstable.addGeneratedColumn("notes1", new Session1ColumnGenerator()); inscritstable.setColumnHeader("notes1", applicationContext.getMessage(NAME + ".table.notes1", null, getLocale())); inscritstable.addGeneratedColumn("notes2", new Session2ColumnGenerator()); inscritstable.setColumnHeader("notes2", applicationContext.getMessage(NAME + ".table.notes2", null, getLocale())); //Si on est sur un ELP if (typeIsElp()) { //on affiche l'tape de rattachement inscritstable.addGeneratedColumn("etape", new EtapeColumnGenerator()); inscritstable.setColumnHeader("etape", applicationContext.getMessage(NAME + ".table.etape", null, getLocale())); } String[] fields_to_display = INS_FIELDS_TO_DISPLAY_ELP; if (typeIsVet()) { fields_to_display = INS_FIELDS_TO_DISPLAY_VET; } inscritstable.setVisibleColumns((Object[]) fields_to_display); inscritstable.setColumnCollapsingAllowed(true); inscritstable.setColumnReorderingAllowed(false); //On masque les colonnes de notes par dfaut inscritstable.setColumnCollapsed("notes1", true); inscritstable.setColumnCollapsed("notes2", true); inscritstable.setSelectable(false); inscritstable.setImmediate(true); inscritstable.addStyleName("scrollabletable"); //Si on n'a pas dj demand afficher le trombinoscope //if(!afficherTrombinoscope){ //la layout contient la table dataLayout.addComponent(inscritstable); //} //Layout contenant le gridLayout correspondant au trombinoscope verticalLayoutForTrombi = new VerticalLayout(); verticalLayoutForTrombi.setSizeFull(); verticalLayoutForTrombi.addStyleName("v-scrollablepanel"); //Cration du trombinoscope displayTrombinoscope(); verticalLayoutForTrombi.addComponent(trombiLayout); verticalLayoutForTrombi.setSizeFull(); verticalLayoutForTrombi.setHeight(null); //Si on a demand afficher le trombinoscope /*if(afficherTrombinoscope){ //Le layout contient le trombi afficher dataLayout.addComponent(verticalLayoutForTrombi); }*/ infoLayout.addComponent(dataLayout); infoLayout.setExpandRatio(dataLayout, 1); addComponent(infoLayout); setExpandRatio(infoLayout, 1); //Si on a demand afficher le trombinoscope if (afficherTrombinoscope) { //On execute la procdure d'affichage du trombinoscope executeDisplayTrombinoscope(); } } else { Label infoAucuninscrit = new Label( applicationContext.getMessage(NAME + ".message.aucuninscrit", null, getLocale())); addComponent(infoAucuninscrit); setComponentAlignment(infoAucuninscrit, Alignment.TOP_CENTER); setExpandRatio(infoAucuninscrit, 1); } } } }
From source file:fr.univlorraine.mondossierweb.views.RechercheArborescenteView.java
License:Apache License
/** * Initialise la vue/*from w ww.j a v a 2 s. co m*/ */ @PostConstruct public void init() { //On vrifie le droit d'accder la vue if (userController.isEnseignant()) { /* Style */ setMargin(false); setSpacing(false); setSizeFull(); if (listeBoutonFavoris != null) { listeBoutonFavoris.clear(); } else { listeBoutonFavoris = new LinkedList<ReferencedButton>(); } liste_types_favoris = new LinkedList<String>(); liste_types_favoris.add(Utils.CMP); liste_types_favoris.add(Utils.ELP); liste_types_favoris.add(Utils.VET); liste_types_inscrits = new LinkedList<String>(); liste_types_inscrits.add(Utils.ELP); liste_types_inscrits.add(Utils.VET); liste_types_deplier = new LinkedList<String>(); liste_types_deplier.add(Utils.ELP); liste_types_deplier.add(Utils.VET); recuperationDesfavoris(); HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setMargin(false); btnLayout.setSpacing(false); btnLayout.setWidth("100%"); comboBoxAnneeUniv = new ComboBox(applicationContext.getMessage(NAME + ".anneeuniv", null, getLocale())); comboBoxAnneeUniv.setPageLength(5); comboBoxAnneeUniv.setTextInputAllowed(false); comboBoxAnneeUniv.setNullSelectionAllowed(false); //Initialisation de la liste des annes List<String> lanneeUniv = rechercheArborescenteController.recupererLesDernieresAnneeUniversitaire(); if (lanneeUniv != null && lanneeUniv.size() > 0) { for (String anneeUniv : lanneeUniv) { comboBoxAnneeUniv.addItem(anneeUniv); int anneenplusun = Integer.parseInt(anneeUniv) + 1; comboBoxAnneeUniv.setItemCaption(anneeUniv, anneeUniv + "/" + anneenplusun); } if (annee == null) { annee = etudiantController.getAnneeUnivEnCours(MainUI.getCurrent()); //annee = lanneeUniv.get(0); } } comboBoxAnneeUniv.setValue(annee); comboBoxAnneeUniv.setStyleName(ValoTheme.COMBOBOX_SMALL); comboBoxAnneeUniv.addValueChangeListener(e -> changerAnnee((String) comboBoxAnneeUniv.getValue())); reinitButton = new Button(); reinitButton.setDescription( applicationContext.getMessage(NAME + ".reinitbutton.description", null, getLocale())); reinitButton.addClickListener(e -> { initFromScratch(); }); reinitButton.setStyleName(ValoTheme.BUTTON_DANGER); reinitButton.setIcon(FontAwesome.TIMES); if (!StringUtils.hasText(code)) { reinitButton.setVisible(false); } labelLigneSelectionneeLabel = new Label(); labelLigneSelectionneeLabel .setValue(applicationContext.getMessage(NAME + ".ligneselectionnee", null, getLocale())); labelLigneSelectionneeLabel.addStyleName("label-align-right"); labelLigneSelectionneeLabel.setVisible(false); HorizontalLayout btnLeftLayout = new HorizontalLayout(); btnLeftLayout.setWidth("100%"); btnLeftLayout.setMargin(true); btnLeftLayout.addComponent(comboBoxAnneeUniv); btnLeftLayout.setComponentAlignment(comboBoxAnneeUniv, Alignment.MIDDLE_LEFT); /*btnLeftLayout.addComponent(reinitButton); btnLeftLayout.setComponentAlignment(reinitButton, Alignment.BOTTOM_RIGHT);*/ btnLeftLayout.addComponent(labelLigneSelectionneeLabel); btnLeftLayout.setComponentAlignment(labelLigneSelectionneeLabel, Alignment.MIDDLE_CENTER); btnLayout.addComponent(btnLeftLayout); ligneSelectionneeLabel = new Label(); //ligneSelectionneeLabel.setCaption(applicationContext.getMessage(NAME+".ligneselectionnee", null, getLocale())); ligneSelectionneeLabel.setVisible(false); elpLayout = new FormLayout(); elpLayout.setMargin(false); vetElpSelectionneLabel = new Label(); vetElpSelectionneLabel.setVisible(false); elpLayout.addComponent(vetElpSelectionneLabel); elpLayout.setVisible(false); VerticalLayout ligneLayout = new VerticalLayout(); ligneLayout.addComponent(ligneSelectionneeLabel); ligneLayout.addComponent(elpLayout); HorizontalLayout rightLayout = new HorizontalLayout(); rightLayout.setSizeFull(); rightLayout.setSpacing(true); rightLayout.setMargin(true); rightLayout.addComponent(ligneLayout); rightLayout.setComponentAlignment(ligneLayout, Alignment.MIDDLE_LEFT); rightLayout.addComponent(reinitButton); rightLayout.setComponentAlignment(reinitButton, Alignment.MIDDLE_RIGHT); rightLayout.setExpandRatio(ligneLayout, 1); btnLayout.addComponent(rightLayout); btnLayout.setComponentAlignment(rightLayout, Alignment.MIDDLE_LEFT); addComponent(btnLayout); if (code != null && type != null) { Label elementRecherche = new Label(code + " " + type); elementRecherche.addStyleName(ValoTheme.LABEL_H1); //addComponent(elementRecherche); } table = new TreeTable(); table.setSizeFull(); table.setStyleName("scrollabletable"); table.setSelectable(true); initComposantes(); //gestion du style pour les lignes en favori table.setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(final Table source, final Object itemId, final Object propertyId) { String style = null; if (propertyId == null && markedRows.contains(itemId)) { style = "marked"; } return style; } }); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { selectionnerLigne(event.getItemId()); } }); //gestion du clic sur la fleche pour dplier une entre table.addExpandListener(new ExpandListener() { private static final long serialVersionUID = 8532342540008245348L; @Override public void nodeExpand(ExpandEvent event) { if (event != null && event.getItemId() != null && hc != null && hc.getItem(event.getItemId()) != null && hc.getItem(event.getItemId()).getItemProperty(TYPE_PROPERTY) != null) { selectionnerLigne(event.getItemId()); deplierNoeud((String) event.getItemId(), true); } } }); VerticalLayout tableVerticalLayout = new VerticalLayout(); tableVerticalLayout.setMargin(new MarginInfo(false, true, true, true)); tableVerticalLayout.setSizeFull(); tableVerticalLayout.addComponent(table); tableVerticalLayout.setExpandRatio(table, 1); addComponent(tableVerticalLayout); setExpandRatio(tableVerticalLayout, 1); } }
From source file:fr.univlorraine.mondossierweb.views.windows.ModificationAdressesWindow.java
License:Apache License
/** * Cre une fentre de confirmation/*from w w w . j a va 2 s . c o m*/ * @param message * @param titre */ public ModificationAdressesWindow(Etudiant etudiant) { /* Style */ //setWidth(900, Unit.PIXELS); setModal(true); setResizable(false); setClosable(false); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Layout pour afficher les erreurs */ VerticalLayout erreursLayout = new VerticalLayout(); layout.addComponent(erreursLayout); erreursLayout.setVisible(false); HorizontalLayout panelslayout = new HorizontalLayout(); panelslayout.setMargin(true); panelslayout.setSpacing(true); layout.addComponent(panelslayout); /* Panel adresse annuelle */ Panel adressesAnnuellePanel = new Panel( applicationContext.getMessage(NAME + ".panel.adresseannuelle.title", null, getLocale()) + " " + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee()); FormLayout formAdresseAnnuelleLayout = new FormLayout(); formAdresseAnnuelleLayout.setSpacing(true); formAdresseAnnuelleLayout.setMargin(true); //TypeHebergement String captionHebergement = applicationContext.getMessage(NAME + ".typehebergement", null, getLocale()); TypeHebergementDTO[] hebergements = adresseController.getTypesHebergement(); lhebergement = new NativeSelect(); lhebergement.setCaption(captionHebergement); lhebergement.setNullSelectionAllowed(false); lhebergement.setRequired(true); lhebergement.setWidth("326px"); for (TypeHebergementDTO h : hebergements) { lhebergement.addItem(h.getCodTypeHebergement()); lhebergement.setItemCaption(h.getCodTypeHebergement(), h.getLibWebTypeHebergement()); } lhebergement.setValue(etudiant.getAdresseAnnuelle().getType()); lhebergement.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un hbergement autre que la Domicile parental a t choisi if (!selectedValue.equals(COD_HEBERG_DOMICILE_PARENTAL)) { activeFormulaireAdresseAnnuelle(); } else { desactiveFormulaireAdresseAnnuelle(); } } }); formAdresseAnnuelleLayout.addComponent(lhebergement); //labelChoixHebergement labelChoixHebergement = new Label( applicationContext.getMessage(NAME + ".labelhebergement", null, getLocale())); formAdresseAnnuelleLayout.addComponent(labelChoixHebergement); //AdresseAnnuelle1 fieldAnnu1 = new TextField(applicationContext.getMessage(NAME + ".annu1", null, getLocale())); fieldAnnu1.setValue(etudiant.getAdresseAnnuelle().getAdresse1()); fieldAnnu1.setNullRepresentation(""); fieldAnnu1.setWidth("326px"); fieldAnnu1.setMaxLength(32); fieldAnnu1.setRequired(true); formAdresseAnnuelleLayout.addComponent(fieldAnnu1); //AdresseAnnuelle2 fieldAnnu2 = new TextField(applicationContext.getMessage(NAME + ".annu2", null, getLocale())); fieldAnnu2.setValue(etudiant.getAdresseAnnuelle().getAdresse2()); fieldAnnu2.setNullRepresentation(""); fieldAnnu2.setWidth("326px"); fieldAnnu2.setMaxLength(32); formAdresseAnnuelleLayout.addComponent(fieldAnnu2); //AdresseAnnuelle3 fieldAnnu3 = new TextField(applicationContext.getMessage(NAME + ".annu3", null, getLocale())); fieldAnnu3.setValue(etudiant.getAdresseAnnuelle().getAdresse3()); fieldAnnu3.setNullRepresentation(""); fieldAnnu3.setWidth("326px"); fieldAnnu3.setMaxLength(32); formAdresseAnnuelleLayout.addComponent(fieldAnnu3); //Liste des Pays String captionPays = applicationContext.getMessage(NAME + ".pays1", null, getLocale()); PaysDTO[] pays = adresseController.getPays(); lpays1 = new NativeSelect(); lpays1.setCaption(captionPays); lpays1.setNullSelectionAllowed(false); lpays1.setRequired(true); lpays1.setWidth("326px"); for (PaysDTO p : pays) { lpays1.addItem(p.getCodePay()); lpays1.setItemCaption(p.getCodePay(), p.getLibPay()); } lpays1.setValue(etudiant.getAdresseAnnuelle().getCodPays()); lpays1.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un pays autre que France a t choisi if (!selectedValue.equals(COD_PAY_FRANCE)) { activerChampPourAdresseAnnuelleEtranger(); } else { activerChampPourAdresseAnnuelleEnFrance(); } } }); formAdresseAnnuelleLayout.addComponent(lpays1); //Ville pour adresse l'tranger fieldVilleEtranger1 = new TextField( applicationContext.getMessage(NAME + ".villeetranger1", null, getLocale())); fieldVilleEtranger1.setValue(etudiant.getAdresseAnnuelle().getAdresseetranger()); fieldVilleEtranger1.setNullRepresentation(""); fieldVilleEtranger1.setWidth("326px"); fieldVilleEtranger1.setMaxLength(5); fieldVilleEtranger1.setRequired(true); formAdresseAnnuelleLayout.addComponent(fieldVilleEtranger1); //codePostal1 pour adresses en france fieldCodePostal1 = new TextField(applicationContext.getMessage(NAME + ".codepostal1", null, getLocale())); fieldCodePostal1.setValue(etudiant.getAdresseAnnuelle().getCodePostal()); fieldCodePostal1.setNullRepresentation(""); fieldCodePostal1.setWidth("326px"); fieldCodePostal1.setMaxLength(5); fieldCodePostal1.setRequired(true); //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER); fieldCodePostal1.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { updateListeVillesAnnuelle(event.getText()); } }); formAdresseAnnuelleLayout.addComponent(fieldCodePostal1); //Ville pour adresse en france List<CommuneDTO> villes1 = adresseController.getVilles(etudiant.getAdresseAnnuelle().getCodePostal()); lville1 = new NativeSelect(); lville1.setCaption(applicationContext.getMessage(NAME + ".ville1", null, getLocale())); lville1.setNullSelectionAllowed(false); lville1.setRequired(true); lville1.setWidth("326px"); for (CommuneDTO v : villes1) { lville1.addItem(v.getLibCommune()); lville1.setItemCaption(v.getLibCommune(), v.getLibCommune()); } codePostalVillesAnnu = etudiant.getAdresseAnnuelle().getCodePostal(); lville1.setValue(etudiant.getAdresseAnnuelle().getVille()); lville1.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCodePostalVilleAnnuelle(); } }); formAdresseAnnuelleLayout.addComponent(lville1); //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification if (etudiant.getAdresseAnnuelle().getCodPays().equals(COD_PAY_FRANCE)) { activerChampPourAdresseAnnuelleEnFrance(); } else { activerChampPourAdresseAnnuelleEtranger(); } //Tlphone1 fieldTelephone1 = new TextField(applicationContext.getMessage(NAME + ".tel1", null, getLocale())); fieldTelephone1.setValue(etudiant.getAdresseAnnuelle().getNumerotel()); fieldTelephone1.setNullRepresentation(""); fieldTelephone1.setWidth("326px"); fieldTelephone1.setMaxLength(15); fieldTelephone1.setRequired(false); formAdresseAnnuelleLayout.addComponent(fieldTelephone1); //ajout du panel adresse Annuelle adressesAnnuellePanel.setContent(formAdresseAnnuelleLayout); panelslayout.addComponent(adressesAnnuellePanel); //Si un hbergement autre que la Domicile parental a t choisi if (!etudiant.getAdresseAnnuelle().getType().equals(COD_HEBERG_DOMICILE_PARENTAL)) { activeFormulaireAdresseAnnuelle(); } else { desactiveFormulaireAdresseAnnuelle(); } /* Panel adresse fixe */ Panel adressesFixePanel = new Panel( applicationContext.getMessage(NAME + ".panel.adressefixe.title", null, getLocale())); FormLayout formAdresseFixeLayout = new FormLayout(); formAdresseFixeLayout.setSpacing(true); formAdresseFixeLayout.setMargin(true); //AdresseFixe1 fieldFixe1 = new TextField(applicationContext.getMessage(NAME + ".fixe1", null, getLocale())); fieldFixe1.setValue(etudiant.getAdresseFixe().getAdresse1()); fieldFixe1.setNullRepresentation(""); fieldFixe1.setWidth("326px"); fieldFixe1.setMaxLength(32); fieldFixe1.setRequired(true); formAdresseFixeLayout.addComponent(fieldFixe1); //AdresseFixe2 fieldFixe2 = new TextField(applicationContext.getMessage(NAME + ".fixe2", null, getLocale())); fieldFixe2.setValue(etudiant.getAdresseFixe().getAdresse2()); fieldFixe2.setNullRepresentation(""); fieldFixe2.setWidth("326px"); fieldFixe2.setMaxLength(32); formAdresseFixeLayout.addComponent(fieldFixe2); //AdresseFixe3 fieldFixe3 = new TextField(applicationContext.getMessage(NAME + ".fixe3", null, getLocale())); fieldFixe3.setValue(etudiant.getAdresseFixe().getAdresse3()); fieldFixe3.setNullRepresentation(""); fieldFixe3.setWidth("326px"); fieldFixe3.setMaxLength(32); formAdresseFixeLayout.addComponent(fieldFixe3); //Liste des Pays lpays2 = new NativeSelect(); lpays2.setCaption(captionPays); lpays2.setNullSelectionAllowed(false); lpays2.setRequired(true); lpays2.setWidth("326px"); for (PaysDTO p : pays) { lpays2.addItem(p.getCodePay()); lpays2.setItemCaption(p.getCodePay(), p.getLibPay()); } lpays2.setValue(etudiant.getAdresseFixe().getCodPays()); lpays2.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un pays autre que France a t choisi if (!selectedValue.equals(COD_PAY_FRANCE)) { activerChampPourAdresseFixeEtranger(); } else { activerChampPourAdresseFixeEnFrance(); } } }); formAdresseFixeLayout.addComponent(lpays2); //Ville pour adresse l'tranger fieldVilleEtranger2 = new TextField( applicationContext.getMessage(NAME + ".villeetranger2", null, getLocale())); fieldVilleEtranger2.setValue(etudiant.getAdresseFixe().getAdresseetranger()); fieldVilleEtranger2.setNullRepresentation(""); fieldVilleEtranger2.setWidth("326px"); fieldVilleEtranger2.setMaxLength(5); fieldVilleEtranger2.setRequired(true); formAdresseFixeLayout.addComponent(fieldVilleEtranger2); //codePostal2 pour adresses en france fieldCodePostal2 = new TextField(applicationContext.getMessage(NAME + ".codepostal2", null, getLocale())); fieldCodePostal2.setValue(etudiant.getAdresseFixe().getCodePostal()); fieldCodePostal2.setNullRepresentation(""); fieldCodePostal2.setWidth("326px"); fieldCodePostal2.setMaxLength(5); fieldCodePostal2.setRequired(true); //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER); fieldCodePostal2.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { updateListeVillesFixe(event.getText()); } }); formAdresseFixeLayout.addComponent(fieldCodePostal2); //Ville pour adresse en france List<CommuneDTO> villes2 = adresseController.getVilles(etudiant.getAdresseFixe().getCodePostal()); lville2 = new NativeSelect(); lville2.setCaption(applicationContext.getMessage(NAME + ".ville2", null, getLocale())); lville2.setNullSelectionAllowed(false); lville2.setRequired(true); lville2.setWidth("326px"); for (CommuneDTO v : villes2) { lville2.addItem(v.getLibCommune()); lville2.setItemCaption(v.getLibCommune(), v.getLibCommune()); } codePostalVillesFixe = etudiant.getAdresseFixe().getCodePostal(); lville2.setValue(etudiant.getAdresseFixe().getVille()); lville2.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCodePostalVilleFixe(); } }); formAdresseFixeLayout.addComponent(lville2); //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification if (etudiant.getAdresseFixe().getCodPays().equals(COD_PAY_FRANCE)) { activerChampPourAdresseFixeEnFrance(); } else { activerChampPourAdresseFixeEtranger(); } //Tlphone2 fieldTelephone2 = new TextField(applicationContext.getMessage(NAME + ".tel2", null, getLocale())); fieldTelephone2.setValue(etudiant.getAdresseFixe().getNumerotel()); fieldTelephone2.setNullRepresentation(""); fieldTelephone2.setWidth("326px"); fieldTelephone2.setMaxLength(15); fieldTelephone2.setRequired(false); formAdresseFixeLayout.addComponent(fieldTelephone2); //ajout du panel adresse fixe adressesFixePanel.setContent(formAdresseFixeLayout); panelslayout.addComponent(adressesFixePanel); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); btnValider.setCaption(applicationContext.getMessage(NAME + ".btnValider", null, getLocale())); btnValider.setIcon(FontAwesome.CHECK); btnValider.addStyleName(ValoTheme.BUTTON_PRIMARY); btnValider.addClickListener(e -> { Adresse adresseAnnuelle = new Adresse(); adresseAnnuelle.setType(lhebergement.getValue().toString()); adresseAnnuelle.setAdresse1(fieldAnnu1.getValue()); adresseAnnuelle.setAdresse2(fieldAnnu2.getValue()); adresseAnnuelle.setAdresse3(fieldAnnu3.getValue()); adresseAnnuelle.setCodPays(lpays1.getValue().toString()); adresseAnnuelle.setCodePostal(fieldCodePostal1.getValue()); adresseAnnuelle.setVille((lville1.getValue() == null) ? null : lville1.getValue().toString()); adresseAnnuelle.setAdresseetranger(fieldVilleEtranger1.getValue()); adresseAnnuelle.setNumerotel(fieldTelephone1.getValue()); Adresse adresseFixe = new Adresse(); adresseFixe.setAdresse1(fieldFixe1.getValue()); adresseFixe.setAdresse2(fieldFixe2.getValue()); adresseFixe.setAdresse3(fieldFixe3.getValue()); adresseFixe.setCodPays(lpays2.getValue().toString()); adresseFixe.setCodePostal(fieldCodePostal2.getValue()); adresseFixe.setVille((lville2.getValue() == null) ? null : lville2.getValue().toString()); adresseFixe.setAdresseetranger(fieldVilleEtranger2.getValue()); adresseFixe.setNumerotel(fieldTelephone2.getValue()); erreursLayout.removeAllComponents(); List<String> retour = adresseController.majAdresses(adresseAnnuelle, adresseFixe); if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) { //ajout maj vue adresse etudiantController.recupererAdresses(); close(); } 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); } }); buttonsLayout.addComponent(btnValider); buttonsLayout.setComponentAlignment(btnValider, Alignment.MIDDLE_CENTER); btnAnnuler.setCaption( applicationContext.getMessage("modificationAdressesWindow.btnAnnuler", null, getLocale())); btnAnnuler.setIcon(FontAwesome.TIMES); btnAnnuler.addStyleName(ValoTheme.BUTTON_DANGER); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_CENTER); layout.addComponent(buttonsLayout); /* Centre la fentre */ center(); }
From source file:fr.univlorraine.mondossierweb.views.windows.PreferencesApplicationWindow.java
License:Apache License
/** * Cre une fentre d'dition des preferences applicative * @param prfrence diter// www .jav a 2 s. com */ public PreferencesApplicationWindow(PreferencesApplication prefApp) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Formulaire */ fieldGroup = new BeanFieldGroup<>(PreferencesApplication.class); fieldGroup.setItemDataSource(prefApp); fieldGroup.setFieldFactory(new FieldGroupFieldFactory() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("rawtypes") public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) { if (fieldType == NativeSelect.class) { final NativeSelect field = new NativeSelect(); field.addItem("true"); field.addItem("false"); field.setNullSelectionAllowed(false); field.setImmediate(true); //field.setValue(centre.getTemSrv()); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { field.setValue(event.getProperty().getValue()); } }); return fieldType.cast(field); } else { final TextField field = new TextField(); field.setImmediate(true); field.addTextChangeListener(new FieldEvents.TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { if (!field.isReadOnly()) { field.setValue(event.getText()); } } }); return fieldType.cast(field); } } }); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".confAppTable." + fieldName, null, getLocale()); //Si on est sur un parametre booleen if (fieldName.equals("valeur") && estUneValeurBooleenne(prefApp.getValeur())) { //On forme le nativeSelect Field<?> field = fieldGroup.buildAndBind(caption, fieldName, NativeSelect.class); formLayout.addComponent(field); } else { Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } formLayout.addComponent(field); } } fieldGroup.getField("prefId").setReadOnly(prefApp.getPrefId() != null); fieldGroup.getField("prefDesc").setReadOnly(prefApp.getPrefDesc() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); /* Enregistre la conf saisie */ configController.saveAppParameter(prefApp); /* Ferme la fentre */ close(); } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:fr.univlorraine.mondossierweb.views.windows.SwapUtilisateurWindow.java
License:Apache License
/** * Cre une fentre d'dition du swap utilisateur * @param swap utilisateur diter// w ww . j a v a2 s .c o m */ public SwapUtilisateurWindow(UtilisateurSwap swap, boolean ajout) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ if (ajout) { setCaption(applicationContext.getMessage(NAME + ".title.ajout", null, getLocale())); } else { setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); } /* Formulaire */ fieldGroup = new BeanFieldGroup<>(UtilisateurSwap.class); fieldGroup.setItemDataSource(swap); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".swapUserTable." + fieldName, null, getLocale()); Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } if (field instanceof DateField) { ((DateField) field).setResolution(DateField.RESOLUTION_MIN); } formLayout.addComponent(field); } //fieldGroup.getField("loginCible").setReadOnly(swap.getLoginCible() != null); fieldGroup.getField("loginSource").setReadOnly(swap.getLoginSource() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); boolean commitok = true; if (ajout) { //On regarde si le login source n'est pas dj dans la table String loginSource = (String) fieldGroup.getField("loginSource").getValue(); if (configController.getSwapUtilisateur(loginSource) != null) { commitok = false; //afficher message d'erreur Notification.show(applicationContext.getMessage(NAME + ".error.loginexistant", null, UI.getCurrent().getLocale()), Notification.Type.ERROR_MESSAGE); } } if (commitok) { /* Enregistre le swap saisie */ configController.saveSwap(swap); /* Ferme la fentre */ close(); } } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:gov.osti.doecode.RepositoryForm.java
/** * Create a basic form UI for editing software metadata information. * /*from ww w . j av a 2 s . c o m*/ * @param ui link to the MyUI parent UI */ public RepositoryForm(MyUI ui) { this.ui = ui; setSizeUndefined(); agentGrid.setColumns("firstName", "lastName", "email"); agentGrid.setHeightMode(HeightMode.ROW); agentGrid.setHeightByRows(8); idGrid.setColumns("relationType", "identifierType", "value"); idGrid.setHeightMode(HeightMode.ROW); idGrid.setHeightByRows(8); idForm = new IdentifierForm(this); agentForm = new AgentForm(this); TabSheet tabs = new TabSheet(); tabs.addStyleName(ValoTheme.TABSHEET_FRAMED); tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR); addComponent(tabs); HorizontalLayout main = new HorizontalLayout(); main.setSpacing(true); main.setMargin(true); FormLayout left = new FormLayout(); FormLayout right = new FormLayout(); countryCode.addItems(countryCodes); left.addComponents(url, loadButton, name, openSource, siteOwnershipCode, acronym, doi, countryCode); right.addComponents(keywords, rights, license, operatingSystem, siteAccessionNumber, otherRequirements); loadButton.addClickListener(e -> { try { SoftwareRepository repo = Reader.loadRepository("doecode"); setSoftwareRepository(repo); } catch (IOException ex) { setComponentError(new UserError("Unable to load: " + ex.getMessage())); } }); main.addComponents(left, right); tabs.addTab(main, "Metadata"); Button agentAddButton = new Button("New"); agentAddButton.setStyleName(BaseTheme.BUTTON_LINK); agentAddButton.setIcon(FontAwesome.PLUS); agentAddButton.addClickListener(e -> { agentForm.setAgent(new Agent()); }); VerticalLayout innerAgent = new VerticalLayout(agentAddButton, agentGrid); innerAgent.setSizeUndefined(); HorizontalLayout agentLayout = new HorizontalLayout(innerAgent, agentForm); agentLayout.setSpacing(true); agentLayout.setMargin(true); tabs.addTab(agentLayout, "Agents"); Button idAddButton = new Button("New"); idAddButton.setIcon(FontAwesome.PLUS); idAddButton.setStyleName(BaseTheme.BUTTON_LINK); idAddButton.setSizeUndefined(); idAddButton.addClickListener(e -> { idForm.setIdentifier(new Identifier()); }); VerticalLayout innerId = new VerticalLayout(idAddButton, idGrid); HorizontalLayout idTab = new HorizontalLayout(innerId, idForm); idTab.setSpacing(true); idTab.setMargin(true); tabs.addTab(idTab, "Identifiers"); agentGrid.addSelectionListener(e -> { if (!e.getSelected().isEmpty()) { Agent agent = (Agent) e.getSelected().iterator().next(); agentForm.setAgent(agent); System.out.println("Selected " + agent.getFirstName()); } }); idGrid.addSelectionListener(e -> { if (!e.getSelected().isEmpty()) { Identifier identifier = (Identifier) e.getSelected().iterator().next(); idForm.setIdentifier(identifier); } }); }
From source file:gq.vaccum121.ui.LoginScreen.java
License:Apache License
private void initLayout() { FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined();//from w w w.j av a 2 s .c o m userName = new TextField("Username"); passwordField = new PasswordField("Password"); login = new Button("Login"); loginForm.addComponent(userName); loginForm.addComponent(passwordField); loginForm.addComponent(login); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSizeUndefined(); loginFailedLabel = new Label(); loginLayout.addComponent(loginFailedLabel); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loggedOutLabel = new Label("Good bye!"); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); loggedOutLabel.setSizeUndefined(); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(rootLayout); setSizeFull(); }
From source file:hu.fnf.devel.wishbox.ui.MainPage.java
License:Open Source License
@Override protected void init(VaadinRequest vaadinRequest) { PropertysetItem item = new PropertysetItem(); item.addItemProperty("name", new ObjectProperty<String>("Zaphod")); item.addItemProperty("age", new ObjectProperty<Integer>(42)); // Have some layout FormLayout form = new FormLayout(); HorizontalLayout footer = new HorizontalLayout(); footer.addComponent(new Button("cica")); footer.addComponent(new Button("kutya")); // Now create a binder that can also create the fields // using the default field factory FieldGroup binder = new FieldGroup(item); form.addComponent(binder.buildAndBind("Name", "name")); form.addComponent(binder.buildAndBind("Age", "age")); HorizontalSplitPanel sample = new HorizontalSplitPanel(); sample.setSizeFull();/*from w w w . j ava 2 s .c o m*/ VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel(); verticalSplitPanel.setFirstComponent(form); verticalSplitPanel.setSecondComponent(new Label("masodik")); sample.setSecondComponent(verticalSplitPanel); Table grid = new Table(); grid.setSizeFull(); for (Object i : getItemContiner().getItemIds()) { System.out.println("item ids: " + i.toString()); } grid.setContainerDataSource(getItemContiner()); grid.setSelectable(true); grid.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { final String valueString = String.valueOf(valueChangeEvent.getProperty().getValue()); Notification.show("Value changed:", valueString, Notification.Type.TRAY_NOTIFICATION); } }); sample.setFirstComponent(grid); setContent(sample); // Main window is the primary browser window final Window main = new Window("Hello window"); addWindow(main); // "Hello world" text is added to window as a Label component UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { String email = user.getEmail(); } else { // no user logged in } assert user != null; main.setContent(new Label(user.getUserId())); }