List of usage examples for com.vaadin.ui HorizontalLayout addStyleName
@Override public void addStyleName(String style)
From source file:fr.amapj.view.views.producteur.ProducteurSelectorPart.java
License:Open Source License
public HorizontalLayout getChoixProducteurComponent() { // Partie choix du producteur HorizontalLayout toolbar1 = new HorizontalLayout(); toolbar1.addStyleName("producteur-selectorpart"); if (allowedProducteurs.size() > 1) { constructMultipleProducteur(toolbar1); } else {//from www . j a v a 2 s . c o m constructOneProducteur(toolbar1); } toolbar1.setSpacing(true); toolbar1.setWidth("100%"); return toolbar1; }
From source file:fr.amapj.view.views.saisiepermanence.SaisiePermanenceListPart.java
License:Open Source License
@Override public void enterIn(ViewChangeEvent event) { // Lecture dans la base de donnes mcInfos = new BeanItemContainer<PermanenceDTO>(PermanenceDTO.class); // Bind it to a component cdesTable = createTable(mcInfos);//from w ww . j a v a 2s . c om // Titre des colonnes cdesTable.setVisibleColumns(new String[] { "datePermanence", "utilisateurs", "numeroSession" }); cdesTable.setColumnHeader("datePermanence", "Date"); cdesTable.setColumnHeader("utilisateurs", "Personnes de permanence"); cdesTable.setColumnHeader("numeroSession", "Numro de la session"); cdesTable.setConverter("datePermanence", new DateToStringConverter()); cdesTable.setSelectable(true); cdesTable.setImmediate(true); // Activation au desactivation des boutons delete et edit cdesTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { setModificationsEnabled(event.getProperty().getValue() != null); } private void setModificationsEnabled(boolean b) { enableButtonBar(b); } }); cdesTable.setSizeFull(); cdesTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { cdesTable.select(event.getItemId()); } } }); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addStyleName("stdlistpart-hlayout-button"); Label title2 = new Label("Planning des permanences"); title2.setSizeUndefined(); title2.addStyleName("stdlistpart-text-title"); newButton = new Button("Crer une nouvelle permanence"); newButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleAjouter(); } }); editButton = new Button("Modifier"); editButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleEditer(); } }); deleteButton = new Button("Supprimer"); deleteButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleSupprimer(); } }); planifButton = new Button("Planifier"); planifButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handlePlanification(); } }); rappelButton = new Button("Envoyer un rappel"); rappelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleRappel(); } }); deleteListButton = new Button("Supprimer plusieurs permanences"); deleteListButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleDeleteList(); } }); searchField = new TextField(); searchField.setInputPrompt("Rechercher par nom"); searchField.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { textFilter = event.getText(); updateFilters(); } }); toolbar.addComponent(newButton); toolbar.addComponent(editButton); toolbar.addComponent(deleteButton); toolbar.addComponent(planifButton); toolbar.addComponent(rappelButton); toolbar.addComponent(deleteListButton); toolbar.addComponent(searchField); toolbar.setWidth("100%"); toolbar.setExpandRatio(searchField, 1); toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT); addComponent(title2); addComponent(toolbar); addComponent(LinkCreator.createLink(new EGPlanningPermanence(new Date()))); addComponent(cdesTable); setExpandRatio(cdesTable, 1); setSizeFull(); setMargin(true); setSpacing(true); refreshTable(); }
From source file:fr.ortec.dsi.pointage.presentation.ihm.view.TextFields.java
License:Apache License
public TextFields() { setMargin(true);//from w w w . j av a 2 s.com setSpacing(true); Label h1 = new Label("Text Fields"); h1.addStyleName(ValoTheme.LABEL_H1); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); addComponent(row); TextField tf = new TextField("Normal"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Custom color"); tf.addStyleName("color1"); row.addComponent(tf); tf = new TextField("User Color"); tf.addStyleName("color2"); row.addComponent(tf); tf = new TextField("Themed"); tf.addStyleName("color3"); row.addComponent(tf); tf = new TextField("Error"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); row.addComponent(tf); tf = new TextField("Error, borderless"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); row.addComponent(tf); tf = new TextField("Small"); tf.setValue("Field value"); tf.addStyleName(ValoTheme.TEXTFIELD_SMALL); row.addComponent(tf); tf = new TextField("Large"); tf.setValue("Field value"); tf.addStyleName(ValoTheme.TEXTFIELD_LARGE); tf.setIcon(testIcon.get(true)); row.addComponent(tf); tf = new TextField(); tf.setValue("Font, no caption"); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField(); tf.setValue("Image, no caption"); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); CssLayout group = new CssLayout(); group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); row.addComponent(group); Button button = new Button("Do It"); // button.addStyleName(ValoTheme.BUTTON_PRIMARY); group.addComponent(button); tf = new TextField("Right-aligned"); tf.setValue("1,234"); tf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); row.addComponent(tf); tf = new TextField("Tiny"); tf.setValue("Field value"); tf.addStyleName(ValoTheme.TEXTFIELD_TINY); row.addComponent(tf); tf = new TextField("Huge"); tf.setValue("Field value"); tf.addStyleName(ValoTheme.TEXTFIELD_HUGE); row.addComponent(tf); h1 = new Label("Text Areas"); h1.addStyleName(ValoTheme.LABEL_H1); addComponent(h1); row = new HorizontalLayout(); row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); addComponent(row); RichTextArea rta = new RichTextArea(); rta.setValue("<b>Some</b> <i>rich</i> content"); row.addComponent(rta); rta = new RichTextArea("Read-only"); rta.setValue("<b>Some</b> <i>rich</i> content"); rta.setReadOnly(true); row.addComponent(rta); }
From source file:fr.univlorraine.mondossierweb.MainUI.java
License:Apache License
/** * Construction du menu tudiant/*www . jav a 2 s .c o m*/ */ private void buildMainMenuEtudiant() { //Si l'tudiant dont on affiche le dossier est renseign if (etudiant != null) { //Ajout du style au menu mainMenu.setPrimaryStyleName(ValoTheme.MENU_PART); //On fixe la largeur du menu mainMenu.setWidth("233px"); //Si on a une url pour la photo de l'tudiant if (etudiant.getPhoto() != null) { //Layout contenant la photo HorizontalLayout photoLayout = new HorizontalLayout(); //Ajout du style au layout photoLayout.addStyleName(ValoTheme.MENU_SUBTITLE); //On fixe la largeur du layout photoLayout.setWidth(213, Unit.PIXELS); //La layout a des marges photoLayout.setMargin(true); //Bouton qui indique, en fonction de l'icone, si l'tudiant est inscrit pour l'anne en cours. Par dfaut, icone indiquant que l'tudiant est inscrit Button etuInscritBtn = new Button("", FontAwesome.CHECK_CIRCLE); //Ajout du style au bouton etuInscritBtn.setPrimaryStyleName(ValoTheme.BUTTON_BORDERLESS); //Si l'tudiant est inscrit pour l'anne en cours if (etudiant.isInscritPourAnneeEnCours()) { //On fixe la description du bouton etuInscritBtn.setDescription("Inscrit pour l'anne universitaire " + Utils.getAnneeUniversitaireEnCours(etudiantController.getAnneeUnivEnCours(this))); } else { //On change l'icone du bouton pour indiquer que l'tudiant n'est pas inscrit etuInscritBtn.setIcon(FontAwesome.EXCLAMATION_CIRCLE); //On fixe la description du bouton etuInscritBtn.setDescription("Non Inscrit pour l'anne universitaire " + Utils.getAnneeUniversitaireEnCours(etudiantController.getAnneeUnivEnCours(this))); } //Ajout d'un lment vide dans le layout photoLayout.addComponent(new HorizontalLayout()); //Cration de l'image contenant la photo Image fotoEtudiant = new Image(null, new ExternalResource(etudiant.getPhoto())); fotoEtudiant.setWidth("120px"); //Ajout de la photo au layout photoLayout.addComponent(fotoEtudiant); //Alignement de la photo photoLayout.setComponentAlignment(fotoEtudiant, Alignment.MIDDLE_CENTER); //La photo prend toute la place disponible dans son layout photoLayout.setExpandRatio(fotoEtudiant, 1); //Ajout au layout du bouton, qui indique, en fonction de l'icone, si l'tudiant est inscrit pour l'anne en cours photoLayout.addComponent(etuInscritBtn); //Ajout du layout de la photo au menu mainMenu.addComponent(photoLayout); } //Ajout du Prnom/Nom et codetu de l'tudiant dans le menu Label usernameLabel = new Label(etudiant.getNom() + "<br />" + etudiant.getCod_etu(), ContentMode.HTML); usernameLabel.addStyleName(ValoTheme.MENU_SUBTITLE); usernameLabel.addStyleName("retourALaLigneAutomatique"); usernameLabel.setSizeUndefined(); mainMenu.addComponent(usernameLabel); /* Etat Civil */ addItemMenu("Etat-civil", EtatCivilView.NAME, FontAwesome.USER); //info annuelles visibles que si tudiant inscrit pour l'anne en cours if (etudiant.isInscritPourAnneeEnCours()) { addItemMenu("Informations annuelles", InformationsAnnuellesView.NAME, FontAwesome.INFO_CIRCLE); } /* Adresses */ addItemMenu(applicationContext.getMessage(AdressesView.NAME + ".title", null, getLocale()), AdressesView.NAME, FontAwesome.HOME); /* Inscriptions */ addItemMenu("Inscriptions", InscriptionsView.NAME, FontAwesome.FILE_TEXT); /* Calendrier */ addItemMenu("Calendrier des preuves", CalendrierView.NAME, FontAwesome.CALENDAR); /* Notes et Rsultats */ addItemMenu(applicationContext.getMessage(NotesView.NAME + ".title", null, getLocale()), NotesView.NAME, FontAwesome.LIST); /* Sparation avant Bouton "Aide" */ CssLayout bottomMainMenu1 = new CssLayout(); bottomMainMenu1.setStyleName(ValoTheme.MENU_SUBTITLE); bottomMainMenu1.setSizeUndefined(); mainMenu.addComponent(bottomMainMenu1); /* Aide */ Button helpBtn = new Button(applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()), FontAwesome.SUPPORT); helpBtn.setPrimaryStyleName(ValoTheme.MENU_ITEM); helpBtn.addClickListener(e -> { UI.getCurrent() .addWindow(new HelpBasicWindow( applicationContext.getMessage("helpWindow.text.etudiant", null, getLocale()), applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()), true)); }); mainMenu.addComponent(helpBtn); /* Deconnexion */ //Voir si on peut accder l'appli hors ENT, le dtecter, et afficher le bouton dconnexion if (configController.isLogoutCasPropose() && userController.isEtudiant()) { Button decoBtn = new Button("Dconnexion", FontAwesome.SIGN_OUT); decoBtn.setPrimaryStyleName(ValoTheme.MENU_ITEM); decoBtn.addClickListener(e -> { getUI().getPage().setLocation("j_spring_security_logout"); }); mainMenu.addComponent(decoBtn); } /* Sparation */ CssLayout bottomMainMenu = new CssLayout(); bottomMainMenu.setStyleName(ValoTheme.MENU_SUBTITLE); bottomMainMenu.setSizeUndefined(); mainMenu.addComponent(bottomMainMenu); } }
From source file:fr.univlorraine.mondossierweb.views.FavorisMobileView.java
License:Apache License
/** * Initialise la vue/* w ww . ja v a2 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.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();/*w w w. jav a2s .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.NotesDetailMobileView.java
License:Apache License
@SuppressWarnings("deprecation") public void refresh(Etape etapeToDisplay, String codetuToDisplay) { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MdwTouchkitUI && (userController.isEnseignant() || userController.isEtudiant()) && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) { //On repassera dans la cration que si on n'a pas dej cr la vue if (codetu == null || !codetuToDisplay.equals(codetu)) { codetu = null;//from w w w .j a v a 2s. c o m } //On repassera dans la cration que si on n'a pas dej cr la vue if (etape == null || !etapeToDisplay.getAnnee().equals(etape.getAnnee()) || !etapeToDisplay.getCode().equals(etape.getCode()) || !etapeToDisplay.getVersion().equals(etape.getVersion())) { etape = null; } //On repassera dans la cration que si on n'a pas dej cr la vue if (codetu == null || etape == null) { compteurElp = 0; removeAllComponents(); /* Style */ setMargin(false); setSpacing(false); setSizeFull(); //Test si user enseignant if (userController.isEnseignant()) { //On recupere les notes pour un enseignant etudiantController.renseigneDetailNotesEtResultatsEnseignant(etapeToDisplay); } else { //On rcupre les notes pour un tudiant etudiantController.renseigneDetailNotesEtResultats(etapeToDisplay); } //NAVBAR HorizontalLayout navbar = new HorizontalLayout(); navbar.setSizeFull(); navbar.setHeight("40px"); navbar.setStyleName("navigation-bar"); //Bouton retour returnButton = new Button(); returnButton.setIcon(FontAwesome.ARROW_LEFT); //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY); returnButton.setStyleName("v-nav-button"); returnButton.addClickListener(e -> { MdwTouchkitUI.getCurrent().navigateToResumeNotes(); }); navbar.addComponent(returnButton); navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT); //Titre Label labelNavBar = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom()); labelNavBar.setStyleName("v-label-navbar"); navbar.addComponent(labelNavBar); navbar.setComponentAlignment(labelNavBar, Alignment.MIDDLE_CENTER); navbar.setExpandRatio(labelNavBar, 1); //Significations if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) { significationButton = new Button(); significationButton.setIcon(FontAwesome.INFO_CIRCLE); significationButton.setStyleName("v-nav-button"); significationButton.addClickListener(e -> { //afficher les significations SignificationsMobileWindow w = new SignificationsMobileWindow(true); UI.getCurrent().addWindow(w); }); navbar.addComponent(significationButton); navbar.setComponentAlignment(significationButton, Alignment.MIDDLE_RIGHT); } addComponent(navbar); layoutList = new HashMap<String, LinkedList<HorizontalLayout>>(); etape = etapeToDisplay; codetu = codetuToDisplay; /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName("v-scrollableelement"); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); List<ElementPedagogique> lelp = MdwTouchkitUI.getCurrent().getEtudiant().getElementsPedagogiques(); if (lelp != null && lelp.size() > 0) { //Panel notesPanel = new Panel(); //notesPanel.setSizeFull(); VerticalLayout notesLayout = new VerticalLayout(); //notesLayout.setSpacing(true); HorizontalLayout libSessionLayout = new HorizontalLayout(); libSessionLayout.setSizeFull(); libSessionLayout.addComponent(new Label()); HorizontalLayout sessionLayout = new HorizontalLayout(); sessionLayout.setSizeFull(); Label session1 = new Label("Session1"); session1.setStyleName("label-bold-with-bottom"); sessionLayout.addComponent(session1); Label session2 = new Label("Session2"); session2.setStyleName("label-bold-with-bottom"); sessionLayout.addComponent(session2); libSessionLayout.addComponent(sessionLayout); notesLayout.addComponent(libSessionLayout); boolean blueLevel = false; compteurElp = 0; elpPere = ""; HorizontalLayout layoutPere = null; int nbFils = 0; for (ElementPedagogique elp : lelp) { compteurElp++; //Si on est sur un element de niveau 1, diffrent du premier element de la liste (qui est un rappel de l'etape) if (elp.getLevel() == 1 && compteurElp > 1) { blueLevel = !blueLevel; } HorizontalLayout libElpLayout = new HorizontalLayout(); if (compteurElp > 1) { if (elp.getLevel() == 1) { //Si le pere prcdent n'avait aucun fils if (layoutPere != null && nbFils == 0) { layoutPere.setStyleName("layout-bottom-line-separator"); } layoutPere = libElpLayout; nbFils = 0; //Sur un elp de niveau 1, il est sur fond sombre libElpLayout.addStyleName("main-layout-bottom-line-separator"); //ajout dans la hashMap layoutList.put(elp.getCode(), new LinkedList<HorizontalLayout>()); elpPere = elp.getCode(); libElpLayout.setId("layout_pere_" + elp.getCode()); } else { nbFils++; libElpLayout.addStyleName("layout-bottom-line-separator"); libElpLayout.setId(compteurElp + "_" + elp.getCode() + "_layout_fils_" + elpPere); //ajout dans la hashMap layoutList.get(elpPere).add(libElpLayout); } } else { //on affiche la racine (qui est un rappel de l'etape) en blanc sur un fond trs sombre libElpLayout.addStyleName("root-layout-bottom-line-separator"); } libElpLayout.setSizeFull(); libElpLayout.setHeight("100%"); VerticalLayout libVerticalLayout = new VerticalLayout(); Label libElpLabel = new Label(elp.getLibelle()); if (elp.isEpreuve()) { libElpLabel.setStyleName("bold-italic-label"); } else { libElpLabel.setStyleName("bold-label"); } libVerticalLayout.addComponent(libElpLabel); //Si on n'est pas sur le premier elp de la liste (rappel de l'tape) on affiche un indicateur de niveau if (compteurElp > 1) { HorizontalLayout levelMainLayout = new HorizontalLayout(); levelMainLayout.setSizeFull(); levelMainLayout.setSpacing(true); levelMainLayout.setStyleName("level-indicator-layout"); int k = 0; for (int i = 0; i < elp.getLevel(); i++) { //Ajout d'un level k++; Label libLevelLayout = new Label(); libLevelLayout.setSizeFull(); libLevelLayout.setHeight("8px"); if (blueLevel) { libLevelLayout.setStyleName("layout-level-blue-indicator"); } else { libLevelLayout.setStyleName("layout-level-green-indicator"); } levelMainLayout.addComponent(libLevelLayout); } //On pense avoir 7 level maxi for (int j = k; j < 8; j++) { Label libLevelSpaceLayout = new Label(); libLevelSpaceLayout.setSizeFull(); libLevelSpaceLayout.setHeight("8px"); levelMainLayout.addComponent(libLevelSpaceLayout); } libVerticalLayout.addComponent(levelMainLayout); } libElpLayout.addComponent(libVerticalLayout); HorizontalLayout noteLayout = new HorizontalLayout(); noteLayout.setSizeFull(); VerticalLayout vlsession1 = new VerticalLayout(); Label note1 = new Label(elp.getNote1()); if (!StringUtils.hasText(elp.getNote2())) { if (elp.isEpreuve()) { note1.setStyleName("bold-italic-label"); } else { note1.setStyleName("bold-label"); } } vlsession1.addComponent(note1); if (StringUtils.hasText(elp.getRes1())) { Label adm1 = new Label(elp.getRes1()); if (!StringUtils.hasText(elp.getRes2())) { if (elp.isEpreuve()) { adm1.setStyleName("bold-italic-label"); } else { adm1.setStyleName("bold-label"); } } vlsession1.addComponent(adm1); } noteLayout.addComponent(vlsession1); VerticalLayout vlsession2 = new VerticalLayout(); Label note2 = new Label(elp.getNote2()); if (StringUtils.hasText(elp.getNote2())) { if (elp.isEpreuve()) { note2.setStyleName("bold-italic-label"); } else { note2.setStyleName("bold-label"); } } vlsession2.addComponent(note2); if (StringUtils.hasText(elp.getRes2())) { Label adm2 = new Label(elp.getRes2()); if (StringUtils.hasText(elp.getRes2())) { if (elp.isEpreuve()) { adm2.setStyleName("bold-italic-label"); } else { adm2.setStyleName("bold-label"); } } vlsession2.addComponent(adm2); } noteLayout.addComponent(vlsession2); libElpLayout.addComponent(noteLayout); notesLayout.addComponent(libElpLayout); //Au dpart, on cache les lments de niveau suprieur 1 if (compteurElp > 1 && elp.getLevel() > 1) { //libElpLayout.setVisible(false); Page.getCurrent().getJavaScript().execute("document.getElementById('" + libElpLayout.getId() + "').style.display=\"none\";"); } } //Cas o le dernier lment tait un lment le pere qui n'avait aucun fils if (layoutPere != null && nbFils == 0) { layoutPere.setStyleName("layout-bottom-line-separator"); } //Ajout du javascript for (Entry<String, LinkedList<HorizontalLayout>> entry : layoutList.entrySet()) { String pere = entry.getKey(); LinkedList<HorizontalLayout> listeLayoutFils = entry.getValue(); // traitements if (listeLayoutFils != null && listeLayoutFils.size() > 0) { String affichagejavascriptfils = ""; for (HorizontalLayout hl : listeLayoutFils) { affichagejavascriptfils += "if(document.getElementById('" + hl.getId() + "').style.display==\"none\"){document.getElementById('" + hl.getId() + "').style.display = \"block\";}else{document.getElementById('" + hl.getId() + "').style.display = \"none\";}"; } //sur le clic du layout pere, on affiche les fils Page.getCurrent().getJavaScript().execute("document.getElementById('" + "layout_pere_" + pere + "').onclick=function(){ " + affichagejavascriptfils + "};"); } } layout.addComponent(notesLayout); layout.setExpandRatio(notesLayout, 1); } else { setHeight(30, Unit.PERCENTAGE); HorizontalLayout messageLayout = new HorizontalLayout(); messageLayout.setSpacing(true); messageLayout.setMargin(true); Label labelAucunResultat = new Label( applicationContext.getMessage(NAME + ".message.aucuneresultat", null, getLocale())); labelAucunResultat.setStyleName(ValoTheme.LABEL_BOLD); messageLayout.addComponent(labelAucunResultat); layout.addComponent(messageLayout); } addComponent(layout); setExpandRatio(layout, 1); } else { refreshJavascript(); } } }
From source file:info.magnolia.messages.app.MessagesViewImpl.java
License:Open Source License
@Inject public MessagesViewImpl(SimpleTranslator i18n) { this.i18n = i18n; // create form and data item final Message message = new Message(); // message POJO BeanItem<Message> messageItem = new BeanItem<Message>(message); final FieldGroup form = new FieldGroup(); form.setItemDataSource(messageItem); Field<String> subjectField = createSubjectTextField(); Field<String> messageBodyField = createMessageBodyTextField(); Field<?> typeField = createTypeSelectionField(); Field<?> scopeField = createScopeSelectionField(); userOrGroupIdField = createUserOrGroupIdTextField(); // disable user/group field if not necessary scopeField.addValueChangeListener(new ValueChangeListener() { @Override//w w w . ja v a 2 s . co m public void valueChange(ValueChangeEvent event) { updateUserOrGroupField((String) event.getProperty().getValue()); } }); form.bind(subjectField, "title"); form.bind(messageBodyField, "content"); form.bind(typeField, "type"); form.bind(scopeField, "scope"); form.bind(userOrGroupIdField, "user"); // FieldGroup overrides fields' own enabled property with its own. updateUserOrGroupField(message.getScope()); FormLayout layout = new FormLayout(); layout.addComponent(subjectField); layout.addComponent(messageBodyField); layout.addComponent(typeField); layout.addComponent(scopeField); layout.addComponent(userOrGroupIdField); layout.setSpacing(true); layout.setMargin(false); layout.setWidth("100%"); // send button NativeButton sendButton = new NativeButton(i18n.translate("messages-app.app.button.sendMessage"), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { form.commit(); String subject = message.getTitle(); String content = message.getContent(); MessageType type = message.getType(); String scope = message.getScope(); if (MESSAGE_SCOPE_LOCAL.equals(scope)) { listener.handleLocalMessage(type, subject, content); } else if (MESSAGE_SCOPE_GLOBAL.equals(scope)) { listener.handleGlobalMessage(type, subject, content); } else if (MESSAGE_SCOPE_GROUP.equals(scope)) { // message is bound to FieldGroup - hence the group name is to be retrieved from the user field of the message final String groupName = message.getUser(); listener.handleGroupMessage(groupName, type, subject, content); } else { // User... final String userName = message.getUser(); listener.handleUserMessage(userName, type, subject, content); } } catch (CommitException e) { } } }); sendButton.addStyleName("btn-dialog"); sendButton.addStyleName("commit"); // reset button NativeButton resetButton = new NativeButton(i18n.translate("messages-app.app.button.reset"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { message.reset(); form.discard(); } }); resetButton.addStyleName("btn-dialog"); resetButton.addStyleName("cancel"); HorizontalLayout buttons = new HorizontalLayout(); buttons.addStyleName("buttons"); buttons.setSpacing(true); buttons.addComponent(sendButton); buttons.addComponent(resetButton); layout.addComponent(buttons); // intro text Label intro = new Label(i18n.translate("messages-app.app.label.intro"), ContentMode.HTML); intro.addStyleName("intro"); CssLayout container = new CssLayout(); container.setSizeFull(); container.addStyleName("small-app-panel"); container.addComponent(layout); CssLayout root = new CssLayout(); root.setSizeFull(); root.setWidth("900px"); root.setStyleName("small-app"); root.addComponent(intro); root.addComponent(container); component = root; }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Build the Completed Action Layout.//from w ww . j a v a 2 s .co m */ protected Layout createCompletedActionLayout() { // Action Button (Upload new or delete). Default is always Upload HorizontalLayout actionLayout = new HorizontalLayout(); actionLayout.setSizeUndefined(); actionLayout.addStyleName("buttons"); actionLayout.setSpacing(true); // Add Upload Button getUpload().setButtonCaption(getCaption(selectAnotherCaption, null)); actionLayout.addComponent(getUpload()); // Add Remove Button if a file is present. if (!getValue().isEmpty()) { Button delete = createDeleteButton(); actionLayout.addComponent(delete); actionLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); } return actionLayout; }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre una vista. La colocar en el lado derecho * * @param ui/*from www. jav a2s .com*/ * @param view */ public static void addView(MyUI ui, AbstractView view) { if (view == null) { System.out.println("abriendo vista null"); ui.getViewDisplay().removeAllComponents(); } else { System.out.println("abriendo vista " + view.getClass().getName() + "::" + view.getViewId()); ViewLayout v = new ViewLayout(view); if (view instanceof AbstractDialog) { AbstractDialog d = (AbstractDialog) view; // Create a sub-window and set the content Window subWindow = new Window(((AbstractDialog) view).getTitle()); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok; if (d instanceof AbstractAddRecordDialog) { ok = new Button("Add record", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { //if (d.isCloseOnOk()) subWindow.close(); ((AbstractAddRecordDialog) view).addAndClean(v.getView().getForm().getData()); } }); } else { ok = new Button(d.getOkText(), e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (d.isCloseOnOk()) subWindow.close(); ((AbstractDialog) view).onOk(v.getView().getForm().getData()); } }); } ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); footer.addComponents(footerText); for (AbstractAction a : d.getActions()) { Button b = new Button(a.getName(), e -> { a.run(); }); //b.addStyleName(ValoTheme.BUTTON_); //b.setClickShortcut(ShortcutAction.KeyCode.ENTER); if ("previous".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_LEFT); } else if ("next".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_RIGHT); } footer.addComponent(b); } if (d instanceof AbstractListEditorDialog) { AbstractListEditorDialog lv = (AbstractListEditorDialog) d; Property<Integer> pos = new SimpleObjectProperty<>(); pos.setValue(lv.getInitialPos()); Button prev = new Button("Previous", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() > 0) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() - 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); prev.setIcon(VaadinIcons.ANGLE_LEFT); footer.addComponent(prev); Button next = new Button("Next", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() < lv.getListSize() - 1) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() + 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); next.setIcon(VaadinIcons.ANGLE_RIGHT); footer.addComponent(next); pos.addListener(new ChangeListener<Integer>() { @Override public void changed(ObservableValue<? extends Integer> observable, Integer oldValue, Integer newValue) { if (newValue <= 0) { prev.setEnabled(false); } else { prev.setEnabled(true); } if (newValue < lv.getListSize() - 1) { next.setEnabled(true); } else { next.setEnabled(false); } } }); } footer.addComponents(ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI ui.addWindow(subWindow); } else { System.out.println("aadiendo vista al contenedor de vistas"); ui.getViewDisplay().removeAllComponents(); ui.getViewDisplay().addComponent(v); ui.refreshMenu(v.getArea(), v.getMenu()); } } }