List of usage examples for com.vaadin.ui FormLayout addComponent
@Override public void addComponent(Component c)
From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java
License:Apache License
/** * Initialise la vue/* w ww. j av a 2s. c o m*/ */ @PostConstruct public void init() { LOG.debug(userController.getCurrentUserName() + " EtatCivilView"); //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())) { if (MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) { LOG.debug(userController.getCurrentUserName() + " init EtatCivilView"); /* Style */ setMargin(true); setSpacing(true); /* Titre */ Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale())); title.addStyleName(ValoTheme.LABEL_H1); addComponent(title); VerticalLayout globalLayout = new VerticalLayout(); globalLayout.setSizeFull(); globalLayout.setSpacing(true); //Layout avec les infos etatcivil et contact CssLayout idLayout = new CssLayout(); idLayout.setSizeFull(); idLayout.setStyleName("flexwrap"); globalLayout.addComponent(idLayout); // Enable Responsive CSS selectors for the layout Responsive.makeResponsive(idLayout); /* Generalites */ FormLayout formGeneralitesLayout = new FormLayout(); formGeneralitesLayout.setSpacing(true); formGeneralitesLayout.setMargin(true); Panel panelGeneralites = new Panel( applicationContext.getMessage(NAME + ".generalites.title", null, getLocale())); String captionNumDossier = applicationContext.getMessage(NAME + ".numdossier.title", null, getLocale()); Label fieldNumDossier = new Label(); formatLabel(fieldNumDossier, captionNumDossier, MainUI.getCurrent().getEtudiant().getCod_etu()); formGeneralitesLayout.addComponent(fieldNumDossier); String captionNNE = applicationContext.getMessage(NAME + ".nne.title", null, getLocale()); Label fieldNNE = new Label(); formatLabel(fieldNNE, captionNNE, MainUI.getCurrent().getEtudiant().getCod_nne()); formGeneralitesLayout.addComponent(fieldNNE); String captionNom = applicationContext.getMessage(NAME + ".nom.title", null, getLocale()); Label fieldNom = new Label(); formatLabel(fieldNom, captionNom, MainUI.getCurrent().getEtudiant().getNom()); formGeneralitesLayout.addComponent(fieldNom); String captionMail = applicationContext.getMessage(NAME + ".mail.title", null, getLocale()); Label mailLabel = new Label(); mailLabel.setCaption(captionMail); String mail = MainUI.getCurrent().getEtudiant().getEmail(); if (StringUtils.hasText(mail)) { mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>"; mailLabel.setValue(mail); mailLabel.setContentMode(ContentMode.HTML); } mailLabel.setSizeFull(); formGeneralitesLayout.addComponent(mailLabel); String captionNationalite = applicationContext.getMessage(NAME + ".nationalite.title", null, getLocale()); Label fieldNationalite = new Label(); formatLabel(fieldNationalite, captionNationalite, MainUI.getCurrent().getEtudiant().getNationalite()); formGeneralitesLayout.addComponent(fieldNationalite); String captionDateNaissance = applicationContext.getMessage(NAME + ".naissance.title", null, getLocale()); Label fieldDateNaissance = new Label(); formatLabel(fieldDateNaissance, captionDateNaissance, MainUI.getCurrent().getEtudiant().getDatenaissance()); formGeneralitesLayout.addComponent(fieldDateNaissance); String captionLieuNaissance = applicationContext.getMessage(NAME + ".lieunaissance.title", null, getLocale()); Label fieldLieuNaissance = new Label(); formatLabel(fieldLieuNaissance, captionLieuNaissance, MainUI.getCurrent().getEtudiant().getLieunaissance()); formGeneralitesLayout.addComponent(fieldLieuNaissance); String captionDepNaissance = applicationContext.getMessage(NAME + ".depnaissance.title", null, getLocale()); Label fieldDepNaissance = new Label(); formatLabel(fieldDepNaissance, captionDepNaissance, MainUI.getCurrent().getEtudiant().getDepartementnaissance()); formGeneralitesLayout.addComponent(fieldDepNaissance); panelGeneralites.setContent(formGeneralitesLayout); HorizontalLayout generalitesGlobalLayout = new HorizontalLayout(); generalitesGlobalLayout.setSizeUndefined(); generalitesGlobalLayout.setStyleName("firstitembox"); generalitesGlobalLayout.addComponent(panelGeneralites); generalitesGlobalLayout.setExpandRatio(panelGeneralites, 1); idLayout.addComponent(generalitesGlobalLayout); /* Bac */ Panel panelBac = new Panel(applicationContext.getMessage(NAME + ".bac.title", null, getLocale())); //Si plusieurs bac if (MainUI.getCurrent().getEtudiant().getListeBac() != null && MainUI.getCurrent().getEtudiant().getListeBac().size() > 1) { panelBac.setCaption(applicationContext.getMessage(NAME + ".bacs.title", null, getLocale())); TabSheet bacTabSheet = new TabSheet(); VerticalLayout vBacLayout = new VerticalLayout(); vBacLayout.setSizeFull(); bacTabSheet.setSizeFull(); bacTabSheet.addStyleName(ValoTheme.TABSHEET_FRAMED); for (BacEtatCivil bec : MainUI.getCurrent().getEtudiant().getListeBac()) { FormLayout tabBacLayout = new FormLayout(); tabBacLayout.setSizeFull(); tabBacLayout.setMargin(false); ajouterBacToView(tabBacLayout, bec); bacTabSheet.addTab(tabBacLayout, bec.getCod_bac(), FontAwesome.GRADUATION_CAP); } vBacLayout.addComponent(bacTabSheet); panelBac.setContent(vBacLayout); } else { //Si un seul bac FormLayout formBacLayout = new FormLayout(); formBacLayout.setSizeFull(); if (MainUI.getCurrent().getEtudiant().getListeBac() != null && MainUI.getCurrent().getEtudiant().getListeBac().size() == 1) { formBacLayout.setSpacing(true); formBacLayout.setMargin(true); ajouterBacToView(formBacLayout, MainUI.getCurrent().getEtudiant().getListeBac().get(0)); } panelBac.setContent(formBacLayout); } HorizontalLayout bacGlobalLayout = new HorizontalLayout(); bacGlobalLayout.setSizeUndefined(); bacGlobalLayout.setStyleName("itembox"); bacGlobalLayout.addComponent(panelBac); bacGlobalLayout.setExpandRatio(panelBac, 1); idLayout.addComponent(bacGlobalLayout); /* Info de contact */ panelContact = new Panel(applicationContext.getMessage(NAME + ".contact.title", null, getLocale())); renseignerPanelContact(); globalLayout.addComponent(panelContact); addComponent(globalLayout); } else { /* Erreur */ addComponent(new BasicErreurMessageLayout(applicationContext)); } } }
From source file:fr.univlorraine.mondossierweb.views.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 .java 2s .c om*/ /* Layout avec les champ 'Portable' et 'Email personnel' */ FormLayout formContactLayout = new FormLayout(); formContactLayout.setSpacing(true); formContactLayout.setMargin(true); String captionTelPortable = applicationContext.getMessage(NAME + ".portable.title", null, getLocale()); fieldTelPortable = new TextField(captionTelPortable, MainUI.getCurrent().getEtudiant().getTelPortable()); formatTextField(fieldTelPortable); fieldTelPortable.setMaxLength(15); formContactLayout.addComponent(fieldTelPortable); if (userController.isEtudiant()) { String captionMailPerso = applicationContext.getMessage(NAME + ".mailperso.title", null, getLocale()); fieldMailPerso = new TextField(captionMailPerso, MainUI.getCurrent().getEtudiant().getEmailPerso()); formatTextField(fieldMailPerso); fieldMailPerso.setMaxLength(200); formContactLayout.addComponent(fieldMailPerso); } contactLayout.addComponent(formContactLayout); /* Si user tudiant , modifications autorise des coordonnes de contact * et si l'tudiant possde une addresse annuelle, on affiche les boutons de modification */ if (userController.isEtudiant() && configController.isModificationCoordonneesPersoAutorisee() && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) { //Layout pour les boutons de modification HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setSizeFull(); btnLayout.setSpacing(true); btnLayout.setMargin(true); //Bouton pour valider la modification btnValidModifCoordonneesPerso = new Button( applicationContext.getMessage(NAME + ".bouton.validercoordonnees", null, getLocale())); btnValidModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_FRIENDLY); btnValidModifCoordonneesPerso.setIcon(FontAwesome.CHECK); btnValidModifCoordonneesPerso.addClickListener(e -> { erreursLayout.removeAllComponents(); List<String> retour = etudiantController.updateContact(fieldTelPortable.getValue(), fieldMailPerso.getValue(), MainUI.getCurrent().getEtudiant().getCod_etu()); //si modif ok if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) { etudiantController.recupererEtatCivil(); renseignerPanelContact(); } else { //affichage erreurs if (retour != null && retour.size() > 0) { String errorMsg = ""; for (String erreur : retour) { if (!errorMsg.equals("")) errorMsg = errorMsg + "<br />"; errorMsg = errorMsg + erreur; } Label labelErreur = new Label(errorMsg); labelErreur.setContentMode(ContentMode.HTML); labelErreur.setStyleName(ValoTheme.LABEL_FAILURE); erreursLayout.addComponent(labelErreur); } erreursLayout.setVisible(true); } }); btnValidModifCoordonneesPerso.setVisible(false); btnLayout.addComponent(btnValidModifCoordonneesPerso); btnLayout.setComponentAlignment(btnValidModifCoordonneesPerso, Alignment.MIDDLE_CENTER); //Bouton pour annuler la modification btnAnnulerModifCoordonneesPerso = new Button( applicationContext.getMessage(NAME + ".bouton.annulercoordonnees", null, getLocale())); btnAnnulerModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_DANGER); btnAnnulerModifCoordonneesPerso.setIcon(FontAwesome.TIMES); btnAnnulerModifCoordonneesPerso.addClickListener(e -> { erreursLayout.removeAllComponents(); fieldMailPerso.setValue(MainUI.getCurrent().getEtudiant().getEmailPerso()); fieldMailPerso.setEnabled(false); fieldMailPerso.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); fieldTelPortable.setValue(MainUI.getCurrent().getEtudiant().getTelPortable()); fieldTelPortable.setEnabled(false); fieldTelPortable.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); btnValidModifCoordonneesPerso.setVisible(false); btnAnnulerModifCoordonneesPerso.setVisible(false); btnModifCoordonneesPerso.setVisible(true); }); btnAnnulerModifCoordonneesPerso.setVisible(false); btnLayout.addComponent(btnAnnulerModifCoordonneesPerso); btnLayout.setComponentAlignment(btnAnnulerModifCoordonneesPerso, Alignment.MIDDLE_CENTER); //Bouton pour activer la modification des donnes btnModifCoordonneesPerso = new Button( applicationContext.getMessage(NAME + ".bouton.modifiercoordonnees", null, getLocale())); btnModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_PRIMARY); btnModifCoordonneesPerso.setIcon(FontAwesome.EDIT); btnModifCoordonneesPerso.addClickListener(e -> { fieldMailPerso.setEnabled(true); fieldMailPerso.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS); fieldTelPortable.setEnabled(true); fieldTelPortable.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS); btnValidModifCoordonneesPerso.setVisible(true); btnAnnulerModifCoordonneesPerso.setVisible(true); btnModifCoordonneesPerso.setVisible(false); }); btnLayout.addComponent(btnModifCoordonneesPerso); btnLayout.setComponentAlignment(btnModifCoordonneesPerso, Alignment.MIDDLE_CENTER); contactLayout.addComponent(btnLayout); } panelContact.setContent(contactLayout); }
From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java
License:Apache License
private void ajouterBacToView(FormLayout formBacLayout, BacEtatCivil bec) { String captionBac = applicationContext.getMessage(NAME + ".codebac.title", null, getLocale()); Label fieldBac = new Label(); formatLabel(fieldBac, captionBac, bec.getLib_bac()); formBacLayout.addComponent(fieldBac); String captionAnneeBac = applicationContext.getMessage(NAME + ".anneebac.title", null, getLocale()); Label fieldAnneeBac = new Label(); formatLabel(fieldAnneeBac, captionAnneeBac, bec.getDaa_obt_bac_iba()); formBacLayout.addComponent(fieldAnneeBac); String captionMentionBac = applicationContext.getMessage(NAME + ".mentionbac.title", null, getLocale()); Label fieldMentionBac = new Label(); formatLabel(fieldMentionBac, captionMentionBac, bec.getCod_mnb()); formBacLayout.addComponent(fieldMentionBac); String captionTypeEtbBac = applicationContext.getMessage(NAME + ".typeetbbac.title", null, getLocale()); Label fieldTypeEtbBac = new Label(); formatLabel(fieldTypeEtbBac, captionTypeEtbBac, bec.getCod_tpe()); formBacLayout.addComponent(fieldTypeEtbBac); String captionEtbBac = applicationContext.getMessage(NAME + ".etbbac.title", null, getLocale()); Label fieldEtbBac = new Label(); formatLabel(fieldEtbBac, captionEtbBac, bec.getCod_etb()); formBacLayout.addComponent(fieldEtbBac); String captionDepBac = applicationContext.getMessage(NAME + ".depbac.title", null, getLocale()); Label fieldDepBac = new Label(); formatLabel(fieldDepBac, captionDepBac, bec.getCod_dep()); formBacLayout.addComponent(fieldDepBac); }
From source file:fr.univlorraine.mondossierweb.views.FavorisMobileView.java
License:Apache License
/** * Initialise la vue//w w w .ja v a 2 s. c om */ @PostConstruct public void init() { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) { removeAllComponents(); /* Style */ setSizeFull(); liste_types_inscrits = new LinkedList<String>(); liste_types_inscrits.add("ELP"); liste_types_inscrits.add("VET"); liste_type_arbo = new LinkedList<String>(); liste_type_arbo.add("CMP"); liste_type_arbo.add("VET"); List<Favoris> lfav = favorisController.getFavoris(); //NAVBAR HorizontalLayout navbar = new HorizontalLayout(); navbar.setSizeFull(); navbar.setHeight("40px"); navbar.setStyleName("navigation-bar"); //Bouton info infoButton = new Button(); infoButton.setIcon(FontAwesome.INFO); infoButton.setStyleName("v-nav-button"); infoButton.addClickListener(e -> { /** * NOUVELLE VERSION */ Notification note = new Notification( applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()), "", Notification.TYPE_TRAY_NOTIFICATION, true); note.setPosition(Position.MIDDLE_CENTER); note.setDelayMsec(6000); note.show(UI.getCurrent().getPage()); /** * ANCIENNE VERSION */ /* //afficher message HelpMobileWindow hbw = new HelpMobileWindow(applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()),applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()),false); UI.getCurrent().addWindow(hbw); */ }); navbar.addComponent(infoButton); navbar.setComponentAlignment(infoButton, Alignment.MIDDLE_LEFT); //Title Label labelFav = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale())); labelFav.setStyleName("v-label-navbar"); navbar.addComponent(labelFav); navbar.setComponentAlignment(labelFav, Alignment.MIDDLE_CENTER); //Bouton Search Button searchButton = new Button(); searchButton.setIcon(FontAwesome.SEARCH); searchButton.setStyleName("v-nav-button"); navbar.addComponent(searchButton); navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT); searchButton.addClickListener(e -> { ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME); }); navbar.setExpandRatio(labelFav, 1); addComponent(navbar); VerticalLayout globalLayout = new VerticalLayout(); globalLayout.setSizeFull(); globalLayout.setSpacing(true); globalLayout.setMargin(true); FormLayout labelLayout = new FormLayout(); labelLayout.setSizeFull(); labelLayout.setMargin(false); labelLayout.setSpacing(false); Label infoLabel = new Label(applicationContext.getMessage(NAME + ".info.label", null, getLocale())); infoLabel.setStyleName(ValoTheme.LABEL_SMALL); infoLabel.setIcon(FontAwesome.INFO_CIRCLE); infoLabel.setWidth("100%"); labelLayout.addComponent(infoLabel); globalLayout.addComponent(labelLayout); if (lfav != null && lfav.size() > 0) { if (favorisContientVet(lfav)) { Panel vetPanel = new Panel( applicationContext.getMessage(NAME + ".vetpanel.title", null, getLocale())); vetPanel.setStyleName("centertitle-panel"); vetPanel.addStyleName("v-colored-panel-caption"); vetPanel.setSizeFull(); VerticalLayout vetLayout = new VerticalLayout(); vetLayout.setSizeFull(); vetLayout.setHeight(null); int i = 0; for (Favoris fav : lfav) { if (fav.getId().getTypfav().equals(Utils.VET)) { i++; HorizontalLayout favVetLayout = new HorizontalLayout(); favVetLayout.setSizeFull(); favVetLayout.setMargin(true); favVetLayout.setSpacing(true); favVetLayout.setStyleName("v-layout-multiline"); favVetLayout.setWidth("100%"); favVetLayout.setHeight("100%"); Button codeButton = new Button(fav.getId().getIdfav()); codeButton.setCaption(fav.getId().getIdfav()); Utils.setButtonStyle(codeButton); codeButton.setWidth("90px"); codeButton.addClickListener(e -> { accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav()); }); Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(), fav.getId().getIdfav())); Utils.setButtonStyle(libButton); libButton.setHeight("100%"); libButton.setWidth("100%"); libButton.addClickListener(e -> { accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav()); }); favVetLayout.addComponent(codeButton); //favVetLayout.setComponentAlignment(codeButton, Alignment.MIDDLE_CENTER); favVetLayout.addComponent(libButton); favVetLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER); favVetLayout.setExpandRatio(libButton, 1); vetLayout.addComponent(favVetLayout); if (i > 1) { favVetLayout.addStyleName("line-separator"); } } } vetPanel.setContent(vetLayout); globalLayout.addComponent(vetPanel); } if (favorisContientElp(lfav)) { Panel elpPanel = new Panel( applicationContext.getMessage(NAME + ".elppanel.title", null, getLocale())); elpPanel.setStyleName("centertitle-panel"); elpPanel.addStyleName("v-colored-panel-caption"); elpPanel.setSizeFull(); VerticalLayout elpLayout = new VerticalLayout(); elpLayout.setSizeFull(); elpLayout.setHeight(null); int i = 0; for (Favoris fav : lfav) { if (fav.getId().getTypfav().equals(Utils.ELP)) { i++; HorizontalLayout favElpLayout = new HorizontalLayout(); favElpLayout.setSizeFull(); favElpLayout.setMargin(true); favElpLayout.setSpacing(true); favElpLayout.setStyleName("v-layout-multiline"); favElpLayout.setWidth("100%"); favElpLayout.setHeight("100%"); Button codeButton = new Button(fav.getId().getIdfav()); Utils.setButtonStyle(codeButton); codeButton.setWidth("90px"); codeButton.addClickListener(e -> { accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav()); }); Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(), fav.getId().getIdfav())); Utils.setButtonStyle(libButton); libButton.setHeight("100%"); libButton.setWidth("100%"); libButton.addClickListener(e -> { accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav()); }); favElpLayout.addComponent(codeButton); favElpLayout.addComponent(libButton); favElpLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER); favElpLayout.setExpandRatio(libButton, 1); elpLayout.addComponent(favElpLayout); if (i > 1) { favElpLayout.addStyleName("line-separator"); } } } elpPanel.setContent(elpLayout); globalLayout.addComponent(elpPanel); } } labelAucunFavoriLayout = new HorizontalLayout(); labelAucunFavoriLayout.setMargin(true); labelAucunFavoriLayout.setSizeFull(); Button aucunFavoris = new Button( applicationContext.getMessage(NAME + ".favoris.aucun", null, getLocale())); aucunFavoris.setStyleName("v-nav-button"); aucunFavoris.addStyleName(ValoTheme.BUTTON_LINK); aucunFavoris.addClickListener(e -> { ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME); }); labelAucunFavoriLayout.addComponent(aucunFavoris); labelAucunFavoriLayout.setVisible(false); globalLayout.addComponent(labelAucunFavoriLayout); if (lfav == null || lfav.size() == 0) { labelAucunFavoriLayout.setVisible(true); } //addComponent(globalLayout); contentLayout.setStyleName("v-scrollableelement"); contentLayout.addComponent(globalLayout); addComponent(contentLayout); setExpandRatio(contentLayout, 1); } }
From source file:fr.univlorraine.mondossierweb.views.InformationsAnnuellesMobileView.java
License:Apache License
public void refresh() { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MdwTouchkitUI && (userController.isEnseignant() || userController.isEtudiant()) && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) { removeAllComponents();/*from w ww .j a va 2s. c om*/ /* Style */ setMargin(false); setSpacing(false); setSizeFull(); //NAVBAR HorizontalLayout navbar = new HorizontalLayout(); navbar.setSizeFull(); navbar.setHeight("40px"); navbar.setStyleName("navigation-bar"); //Bouton retour if (userController.isEnseignant()) { returnButton = new Button(); returnButton.setIcon(FontAwesome.ARROW_LEFT); //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY); returnButton.setStyleName("v-nav-button"); returnButton.addClickListener(e -> { if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent() .getDossierEtuFromView().equals(ListeInscritsMobileView.NAME)) { MdwTouchkitUI.getCurrent().navigateToListeInscrits(); } else { if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent() .getDossierEtuFromView().equals(RechercheMobileView.NAME)) { MdwTouchkitUI.getCurrent().navigateToRecherche(null); } } }); navbar.addComponent(returnButton); navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT); } //Title Label labelTrombi = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom()); labelTrombi.setStyleName("v-label-navbar"); navbar.addComponent(labelTrombi); navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER); if (userController.isEnseignant()) { //Si on ne peut pas dj revenir sur la recherche via le bouton 'retour' if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() == null || !MdwTouchkitUI.getCurrent().getDossierEtuFromView().equals(RechercheMobileView.NAME)) { //Bouton Search Button searchButton = new Button(); searchButton.setIcon(FontAwesome.SEARCH); searchButton.setStyleName("v-nav-button"); navbar.addComponent(searchButton); navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT); searchButton.addClickListener(e -> { ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME); }); } } navbar.setExpandRatio(labelTrombi, 1); addComponent(navbar); VerticalLayout globalLayout = new VerticalLayout(); //globalLayout.setSizeFull(); globalLayout.setSpacing(true); globalLayout.setMargin(true); globalLayout.setStyleName("v-scrollableelement"); VerticalLayout slimLayout = new VerticalLayout(); slimLayout.setSpacing(false); slimLayout.setMargin(false); //slimLayout.setStyleName("v-scrollableelement"); String mail = MdwTouchkitUI.getCurrent().getEtudiant().getEmail(); if (StringUtils.hasText(mail)) { Panel mailPanel = new Panel(); mailPanel.setStyleName("panel-without-bottom-line-separator"); HorizontalLayout mailLayout = new HorizontalLayout(); mailLayout.setSizeFull(); mailLayout.setHeight("25px"); Label mailLabel = new Label(); mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>"; mailLabel.setValue(mail); mailLabel.setContentMode(ContentMode.HTML); mailLabel.setSizeFull(); mailLabel.addStyleName("label-centre"); mailLayout.addComponent(mailLabel); mailLayout.setComponentAlignment(mailLabel, Alignment.MIDDLE_CENTER); mailPanel.setContent(mailLayout); slimLayout.addComponent(mailPanel); slimLayout.setComponentAlignment(mailPanel, Alignment.MIDDLE_CENTER); } Panel etuPanel = new Panel(); HorizontalLayout photoLayout = new HorizontalLayout(); photoLayout.setId(MdwTouchkitUI.getCurrent().getEtudiant().getCod_ind()); photoLayout.setSizeFull(); if (MdwTouchkitUI.getCurrent().getEtudiant().getPhoto() != null) { Image fotoEtudiant = new Image(null, new ExternalResource(MdwTouchkitUI.getCurrent().getEtudiant().getPhoto())); fotoEtudiant.setWidth("120px"); fotoEtudiant.setStyleName(ValoTheme.BUTTON_LINK); photoLayout.addComponent(fotoEtudiant); } VerticalLayout nomCodeLayout = new VerticalLayout(); //nomCodeLayout.setSizeFull(); nomCodeLayout.setSpacing(false); Label labelNomEtudiant = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom()); labelNomEtudiant.setSizeFull(); labelNomEtudiant.setStyleName(ValoTheme.LABEL_BOLD); labelNomEtudiant.addStyleName("label-centre"); nomCodeLayout.addComponent(labelNomEtudiant); nomCodeLayout.setComponentAlignment(labelNomEtudiant, Alignment.MIDDLE_CENTER); //nomCodeLayout.setExpandRatio(labelNomEtudiant, 1); Label codetuLabel = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getCod_etu()); codetuLabel.setSizeFull(); codetuLabel.setStyleName(ValoTheme.LABEL_TINY); codetuLabel.addStyleName("label-centre"); nomCodeLayout.addComponent(codetuLabel); nomCodeLayout.setComponentAlignment(codetuLabel, Alignment.MIDDLE_CENTER); photoLayout.addComponent(nomCodeLayout); photoLayout.setComponentAlignment(nomCodeLayout, Alignment.MIDDLE_CENTER); photoLayout.setExpandRatio(nomCodeLayout, 1); etuPanel.setContent(photoLayout); slimLayout.addComponent(etuPanel); slimLayout.setComponentAlignment(etuPanel, Alignment.MIDDLE_CENTER); globalLayout.addComponent(slimLayout); Panel panelInfos = new Panel(applicationContext.getMessage(NAME + ".infos.title", null, getLocale()) + " " + Utils.getAnneeUniversitaireEnCours( etudiantController.getAnneeUnivEnCours(MdwTouchkitUI.getCurrent()))); panelInfos.setStyleName("centertitle-panel"); panelInfos.addStyleName("v-colored-panel-caption"); //Si l'tudiant est inscrit pour l'anne en cours if (MdwTouchkitUI.getCurrent().getEtudiant().isInscritPourAnneeEnCours()) { FormLayout formInfosLayout = new FormLayout(); formInfosLayout.setSpacing(true); formInfosLayout.setMargin(true); //Numro Anonymat visible que si l'utilisateur est tudiant List<Anonymat> lano = null; if (!userController.isEnseignant() && userController.isEtudiant()) { lano = MdwTouchkitUI.getCurrent().getEtudiant().getNumerosAnonymat(); if (lano != null) { //Si l'tudiant n'a qu'un seul numro d'anonymat if (lano.size() == 1) { String captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymat.title", null, getLocale()); TextField fieldNumAnonymat = new TextField(captionNumAnonymat, MdwTouchkitUI .getCurrent().getEtudiant().getNumerosAnonymat().get(0).getCod_etu_ano()); formatTextField(fieldNumAnonymat); //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE); //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale())); formInfosLayout.addComponent(fieldNumAnonymat); } //Si l'tudiant a plusieurs numros d'anonymat if (lano.size() > 1) { int i = 0; for (Anonymat ano : lano) { String captionNumAnonymat = ""; if (i == 0) { //Pour le premier numro affich on affiche le libell du champ captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymats.title", null, getLocale()); } TextField fieldNumAnonymat = new TextField(captionNumAnonymat, ano.getCod_etu_ano() + " (" + ano.getLib_man() + ")"); formatTextField(fieldNumAnonymat); if (i == 0) { //Pour le premier numro affich on affiche l'info bulle //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE); //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale())); } formInfosLayout.addComponent(fieldNumAnonymat); i++; } } } } String captionBousier = applicationContext.getMessage(NAME + ".boursier.title", null, getLocale()); TextField fieldNumBoursier = new TextField(captionBousier, MdwTouchkitUI.getCurrent().getEtudiant().isBoursier() ? applicationContext.getMessage(NAME + ".boursier.oui", null, getLocale()) : applicationContext.getMessage(NAME + ".boursier.non", null, getLocale())); formatTextField(fieldNumBoursier); formInfosLayout.addComponent(fieldNumBoursier); String captionSalarie = applicationContext.getMessage(NAME + ".salarie.title", null, getLocale()); TextField fieldSalarie = new TextField(captionSalarie, MdwTouchkitUI.getCurrent().getEtudiant().isTemSalarie() == true ? applicationContext.getMessage(NAME + ".salarie.oui", null, getLocale()) : applicationContext.getMessage(NAME + ".salarie.non", null, getLocale())); formatTextField(fieldSalarie); formInfosLayout.addComponent(fieldSalarie); String captionAmenagementEtude = applicationContext.getMessage(NAME + ".amenagementetude.title", null, getLocale()); TextField fieldAmenagementEtude = new TextField(captionAmenagementEtude, MdwTouchkitUI.getCurrent().getEtudiant().isTemAmenagementEtude() == true ? applicationContext.getMessage(NAME + ".amenagementetude.oui", null, getLocale()) : applicationContext.getMessage(NAME + ".amenagementetude.non", null, getLocale())); formatTextField(fieldAmenagementEtude); formInfosLayout.addComponent(fieldAmenagementEtude); panelInfos.setContent(formInfosLayout); } else { HorizontalLayout labelNonInscritLayout = new HorizontalLayout(); labelNonInscritLayout.setMargin(true); labelNonInscritLayout.setSizeFull(); Label labelNonInscrit = new Label( applicationContext.getMessage(NAME + ".inscrit.non", null, getLocale())); labelNonInscrit.setStyleName(ValoTheme.LABEL_COLORED); labelNonInscrit.addStyleName(ValoTheme.LABEL_BOLD); labelNonInscrit.setWidth("100%"); labelNonInscrit.addStyleName("label-centre"); labelNonInscritLayout.addComponent(labelNonInscrit); panelInfos.setContent(labelNonInscritLayout); } globalLayout.addComponent(panelInfos); addComponent(globalLayout); setExpandRatio(globalLayout, 1); } }
From source file:fr.univlorraine.mondossierweb.views.InformationsAnnuellesView.java
License:Apache License
/** * Initialise la vue//from w w w . j ava2s . 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 w w w. j av a2 s . c om*/ */ @PostConstruct public void init() { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant()) && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) { /* Style */ setMargin(true); setSpacing(true); /* 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 w w w . j a v a 2 s . c om*/ 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.windows.ModificationAdressesWindow.java
License:Apache License
/** * Cre une fentre de confirmation/*from w w w . j ava 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/*from ww w .jav a 2s. c om*/ */ 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(); }