List of usage examples for com.vaadin.ui ComboBox ComboBox
protected ComboBox(DataCommunicator<T> dataCommunicator)
From source file:eu.lod2.ExportSelector2.java
License:Apache License
public ExportSelector2(LOD2DemoState st, Boolean update, String cap) { // The internal state state = st;/*from www. j ava 2 s . c o m*/ updateCurrentGraph = update; HorizontalLayout layout = new HorizontalLayout(); status = new Label(""); // the graph selector // it displays all acceptable graphs in Virtuoso // XXX TODO show only those which are editable in OntoWiki graphSelector = new ComboBox(cap); graphSelector.setDebugId(this.getClass().getSimpleName() + "_graphSelector"); graphSelector.setNewItemsAllowed(true); graphSelector.setImmediate(true); graphSelector.setNewItemHandler(this); graphSelector.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); graphSelector.addListener(this); addCandidateGraphs(graphSelector); layout.addComponent(graphSelector); layout.addComponent(status); /* XXX TODO Exploring the content of the graph requires some more work. String windowurl = "http://localhost:8080/lod2statworkbench/explore"; layout.addComponent(new Link("Explore", new ExternalResource(windowurl), "explore-this", -1, -1, Window.BORDER_DEFAULT)); */ // The composition root MUST be set setCompositionRoot(layout); }
From source file:eu.lod2.ExportSelector3.java
License:Apache License
public ExportSelector3(LOD2DemoState st, Boolean update, String cap) { // The internal state state = st;/* w w w . j av a 2s .co m*/ updateCurrentGraph = update; HorizontalLayout layout = new HorizontalLayout(); status = new Label(""); // the graph selector // it displays all acceptable graphs in Virtuoso // XXX TODO show only those which are editable in OntoWiki graphSelector = new ComboBox(cap); graphSelector.setDebugId(this.getClass().getSimpleName() + "_graphSelector"); graphSelector.setNewItemsAllowed(true); graphSelector.setImmediate(true); graphSelector.setNewItemHandler(this); graphSelector.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); graphSelector.addListener(this); addCandidateGraphs(graphSelector); layout.addComponent(graphSelector); layout.addComponent(status); /* XXX TODO Exploring the content of the graph requires some more work. String windowurl = "http://localhost:8080/lod2statworkbench/explore"; layout.addComponent(new Link("Explore", new ExternalResource(windowurl), "explore-this", -1, -1, Window.BORDER_DEFAULT)); */ // The composition root MUST be set setCompositionRoot(layout); }
From source file:eu.lod2.SameAsLinking.java
License:Apache License
public SameAsLinking(LOD2DemoState st) { // The internal state state = st;/*from w w w .j a v a2s. co m*/ VerticalLayout panel = new VerticalLayout(); Label description = new Label( "Import public links between individuals (URI's) from the current graph to external resources using " + "the online service SameAs.org."); panel.addComponent(description); exportGraph = new ExportSelector(state); exportGraph.setDebugId(this.getClass().getSimpleName() + "_exportGraph"); panel.addComponent(exportGraph); uriSelector = new ComboBox("Select URI to link: "); uriSelector.setDebugId(this.getClass().getSimpleName() + "_uriSelector"); uriSelector.setDescription("The selector contains uri's only if a current graph has a value."); panel.addComponent(uriSelector); Button sameAsLinking = new Button("Extract Links", new ClickListener() { public void buttonClick(ClickEvent event) { doSameAsLinking(); }; }); sameAsLinking.setDebugId(this.getClass().getSimpleName() + "_sameAsLinking"); sameAsLinking.setEnabled(false); sameAsLinking.setDescription("The operation is active only if a current graph has a value."); panel.addComponent(sameAsLinking); resultUser = new Label(""); panel.addComponent(resultUser); // if the current graph is selected then if (state.getCurrentGraph() != null && !state.getCurrentGraph().equals("")) { // activate linking button sameAsLinking.setEnabled(true); // retrieve list of candidate uri's addCandidateURIs(uriSelector); } ; // The composition root MUST be set setCompositionRoot(panel); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatinterfaceUI.java
License:Open Source License
@SuppressWarnings("deprecation") private void createTab_Queries() { VerticalLayout tab_queries = new VerticalLayout(); tab_queries.setCaption("Queries"); tabsheet.addTab(tab_queries);/* ww w. java 2 s . c o m*/ Panel p_sparql = new Panel("Sparql query"); p_sparql.setWidth("900"); VerticalLayout sparql_layout = new VerticalLayout(); final ComboBox queries = new ComboBox("Select a query"); queries.setInvalidAllowed(false); queries.setNullSelectionAllowed(false); queries.setNewItemsAllowed(false); queries.addItem("Sites"); queries.setValue("Sites"); queries.addItem("Structural model links"); queries.addItem("Project name"); queries.addItem("List implements links"); queries.setWidth("400"); queries.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -5188369735622627751L; public void valueChange(ValueChangeEvent event) { if (queries.getValue() != null) { if (queries.getValue().equals("Sites")) sparql_query_area.setValue(DrumbeatConstants.query_sites); if (queries.getValue().equals("Structural model links")) sparql_query_area.setValue(DrumbeatConstants.query_structural_links); if (queries.getValue().equals("Project name")) sparql_query_area.setValue(DrumbeatConstants.query_structural_project); if (queries.getValue().equals("List implements links")) sparql_query_area.setValue(DrumbeatConstants.query_implemens); } } }); sparql_layout.addComponent(queries); sparql_layout.addComponent(sparql_query_area); sparql_query_area.setValue(DrumbeatConstants.query_sites); Button sparql_button = new Button("Query", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { sparql_result_rtarea.setValue(marmotta.httpGetQuery2html(sparql_query_area.getValue())); } }); Button sparql_button_json = new Button("Query and download JSON"); OnDemandFileDownloader jsonDownloader = new OnDemandFileDownloader(createOnDemandJSON_Resource(), "JSON", this); jsonDownloader.extend(sparql_button_json); Button sparql_button_xml = new Button("Query and download XML"); OnDemandFileDownloader xmlDownloader = new OnDemandFileDownloader(createOnDemandXMLResource(), "XML", this); xmlDownloader.extend(sparql_button_xml); HorizontalLayout hor_sparql_buttons = new HorizontalLayout(); hor_sparql_buttons.addComponent(sparql_button); hor_sparql_buttons.addComponent(sparql_button_json); hor_sparql_buttons.addComponent(sparql_button_xml); sparql_layout.addComponent(hor_sparql_buttons); sparql_layout.addComponent(sparql_result_rtarea); sparql_query_area.setWidth("800"); sparql_query_area.setHeight("400"); sparql_result_rtarea.setWidth("800"); p_sparql.setContent(sparql_layout); tab_queries.addComponent(p_sparql); }
From source file:fi.semantum.strategia.widget.NumberTrafficValuation.java
License:Open Source License
@Override public Runnable getEditor(VerticalLayout layout, final Main main, final Meter meter) { Indicator indicator = meter.getPossibleIndicator(main.getDatabase()); String unit = indicator.getUnit(); final ComboBox combo = new ComboBox("Valitse mittarin mritystapa"); combo.addItem(State.INCREASE3); combo.addItem(State.DECREASE3); combo.addItem(State.INCREASE2); combo.addItem(State.DECREASE2); combo.setInvalidAllowed(false);//from www . j a v a 2 s .c o m combo.setNullSelectionAllowed(false); combo.setWidth("100%"); combo.addStyleName(ValoTheme.COMBOBOX_TINY); layout.addComponent(combo); layout.setComponentAlignment(combo, Alignment.TOP_CENTER); layout.setExpandRatio(combo, 0.0f); final VerticalLayout vl1 = new VerticalLayout(); vl1.setHeight("50px"); vl1.setWidth("100%"); vl1.setStyleName("redBlock"); layout.addComponent(vl1); layout.setComponentAlignment(vl1, Alignment.TOP_CENTER); layout.setExpandRatio(vl1, 0.0f); final Label l1 = new Label(" > " + df.format(greenLimit.doubleValue()) + " " + unit); l1.setSizeUndefined(); l1.addStyleName(ValoTheme.LABEL_LARGE); vl1.addComponent(l1); vl1.setComponentAlignment(l1, Alignment.MIDDLE_CENTER); HorizontalLayout hl1 = new HorizontalLayout(); hl1.setSpacing(true); layout.addComponent(hl1); layout.setComponentAlignment(hl1, Alignment.TOP_LEFT); final TextField tf1 = new TextField(); tf1.setValue(df.format(greenLimit.doubleValue())); tf1.setWidth("150px"); tf1.setCaption("Suurempi raja-arvo"); tf1.setStyleName(ValoTheme.TEXTFIELD_TINY); tf1.setValidationVisible(true); hl1.addComponent(tf1); Label unit1 = new Label(); unit1.setSizeUndefined(); unit1.setCaption(""); unit1.setValue(unit); hl1.addComponent(unit1); hl1.setComponentAlignment(unit1, Alignment.MIDDLE_LEFT); final VerticalLayout vl2 = new VerticalLayout(); vl2.setHeight("50px"); vl2.setWidth("100%"); vl2.addStyleName("yellowBlock"); layout.addComponent(vl2); layout.setComponentAlignment(vl2, Alignment.TOP_CENTER); layout.setExpandRatio(vl2, 0.0f); final Label l2 = new Label(); l2.setSizeUndefined(); l2.addStyleName(ValoTheme.LABEL_LARGE); vl2.addComponent(l2); vl2.setComponentAlignment(l2, Alignment.MIDDLE_CENTER); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); layout.addComponent(hl2); layout.setComponentAlignment(hl2, Alignment.TOP_LEFT); final TextField tf2 = new TextField(); tf2.setWidth("150px"); tf2.setCaption("Pienempi raja-arvo"); tf2.setStyleName(ValoTheme.TEXTFIELD_TINY); tf2.setValidationVisible(true); hl2.addComponent(tf2); hl2.setComponentAlignment(tf2, Alignment.TOP_CENTER); Label unit2 = new Label(); unit2.setSizeUndefined(); unit2.setCaption(""); unit2.setValue("" + unit); hl2.addComponent(unit2); hl2.setComponentAlignment(unit2, Alignment.MIDDLE_LEFT); final VerticalLayout vl3 = new VerticalLayout(); vl3.setHeight("50px"); vl3.setWidth("100%"); vl3.addStyleName("greenBlock"); layout.addComponent(vl3); layout.setComponentAlignment(vl3, Alignment.TOP_CENTER); layout.setExpandRatio(vl3, 0.0f); final Label l3 = new Label(); l3.setSizeUndefined(); l3.addStyleName(ValoTheme.LABEL_LARGE); vl3.addComponent(l3); vl3.setComponentAlignment(l3, Alignment.MIDDLE_CENTER); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 8396168732300003038L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; State currentState = getState(); if (currentState.equals(combo.getValue())) return; if (State.DECREASE3.equals(combo.getValue())) { makeThree = true; if (State.INCREASE3.equals(currentState)) { swap(); } else if (State.INCREASE2.equals(currentState)) { redLimit = greenLimit; greenLimit = null; } } else if (State.INCREASE3.equals(combo.getValue())) { makeThree = true; if (State.DECREASE3.equals(currentState)) { swap(); } else if (State.DECREASE2.equals(currentState)) { greenLimit = redLimit; redLimit = null; } } else if (State.INCREASE2.equals(combo.getValue())) { if (State.DECREASE3.equals(currentState)) { greenLimit = redLimit; } else if (State.DECREASE2.equals(currentState)) { greenLimit = redLimit; } redLimit = null; makeThree = false; } else if (State.DECREASE2.equals(combo.getValue())) { if (State.INCREASE3.equals(currentState)) { redLimit = greenLimit; } else if (State.INCREASE2.equals(currentState)) { redLimit = greenLimit; } greenLimit = null; makeThree = false; } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); tf1.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -5484608577999300097L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; if (State.DECREASE3.equals(combo.getValue())) { if (makeThree) greenLimit = redLimit; redLimit = new BigDecimal(tf1.getValue()); } else if (State.INCREASE3.equals(combo.getValue())) { if (makeThree) redLimit = greenLimit; greenLimit = new BigDecimal(tf1.getValue()); } else if (State.INCREASE2.equals(combo.getValue())) { greenLimit = new BigDecimal(tf1.getValue()); } else if (State.DECREASE2.equals(combo.getValue())) { redLimit = new BigDecimal(tf1.getValue()); } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); tf2.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 5825320869230527588L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; // This should not happen! if (State.INCREASE2.equals(combo.getValue()) || State.DECREASE2.equals(combo.getValue())) return; if (State.DECREASE3.equals(combo.getValue())) { greenLimit = new BigDecimal(tf2.getValue()); } else if (State.INCREASE3.equals(combo.getValue())) { redLimit = new BigDecimal(tf2.getValue()); } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); return null; }
From source file:fr.amapj.view.engine.enumselector.EnumSearcher.java
License:Open Source License
/** * Permet de crer une combo box permettant de choisir parmi une liste de Enum * pour etre utilis dans les tableaux/*from ww w . j a va 2s. c o m*/ * * @param binder * @param title * @param enumeration donne la fois la liste afficher et la valeur par dfaut * @param propertyId * @return */ static public <T extends Enum<T>> ComboBox createEnumSearcher(String title, T enumeration) { ComboBox comboBox = new ComboBox(title); EnumSet<T> enums = EnumSet.allOf(enumeration.getDeclaringClass()); for (T en : enums) { String caption = en.toString(); comboBox.addItem(en); comboBox.setItemCaption(en, caption); } comboBox.setValue(enumeration); return comboBox; }
From source file:fr.amapj.view.engine.popup.formpopup.AbstractFormPopup.java
License:Open Source License
protected <T> ComboBox addGeneralComboField(String title, List<T> items, String propertyId, GenericUtils.ToString<T> f, IValidator... validators) { ComboBox comboBox = new ComboBox(title); comboBox.setImmediate(true);//from ww w . java2 s . c o m for (T item : items) { String caption = f == null ? item.toString() : f.toString(item); comboBox.addItem(item); comboBox.setItemCaption(item, caption); } binder.bind(comboBox, propertyId); form.addComponent(comboBox); validatorManager.add(comboBox, title, propertyId, validators); return comboBox; }
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. j ava 2 s . c o m listeEtapes = null; listeGroupes = null; // Style setMargin(true); setSpacing(true); setSizeFull(); // Rcupration de l'objet de la SE dont on doit afficher les inscrits code = MainUI.getCurrent().getCodeObjListInscrits(); typeFavori = MainUI.getCurrent().getTypeObjListInscrits(); libelleObj = ""; if (typeIsVet() && MainUI.getCurrent().getEtapeListeInscrits() != null) { libelleObj = MainUI.getCurrent().getEtapeListeInscrits().getLibelle(); } if (typeIsElp() && MainUI.getCurrent().getElpListeInscrits() != null) { libelleObj = MainUI.getCurrent().getElpListeInscrits().getLibelle(); } // Si l'objet est renseign if (code != null && typeFavori != null) { //Panel contenant les filtres d'affichage et le bouton de mise en favori HorizontalLayout panelLayout = new HorizontalLayout(); panelLayout.setSizeFull(); panelLayout.addStyleName("small-font-element"); // Layout contenant les filtres FormLayout formInscritLayout = new FormLayout(); formInscritLayout.setStyleName(ValoTheme.FORMLAYOUT_LIGHT); formInscritLayout.setSpacing(true); formInscritLayout.setMargin(true); panelFormInscrits = new Panel(code + " " + libelleObj); //Affichage d'une liste droulante contenant la liste des annes List<String> lannees = MainUI.getCurrent().getListeAnneeInscrits(); if (lannees != null && lannees.size() > 0) { listeAnnees = new ComboBox(applicationContext.getMessage(NAME + ".annee", null, getLocale())); listeAnnees.setPageLength(5); listeAnnees.setTextInputAllowed(false); listeAnnees.setNullSelectionAllowed(false); listeAnnees.setWidth("150px"); for (String annee : lannees) { listeAnnees.addItem(annee); int anneenplusun = Integer.parseInt(annee) + 1; listeAnnees.setItemCaption(annee, annee + "/" + anneenplusun); } listeAnnees.setValue(MainUI.getCurrent().getAnneeInscrits()); //Gestion de l'vnement sur le changement d'anne listeAnnees.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //faire le changement Map<String, String> parameterMap = new HashMap<>(); parameterMap.put("code", code); parameterMap.put("type", typeFavori); //rcupration de la nouvelle liste if (typeIsVet()) { listeInscritsController.recupererLaListeDesInscrits(parameterMap, selectedValue, MainUI.getCurrent()); } if (typeIsElp()) { listeInscritsController.recupererLaListeDesInscritsELP(parameterMap, selectedValue, MainUI.getCurrent()); } //update de l'affichage initListe(); } }); formInscritLayout.addComponent(listeAnnees); } //Si on affiche la liste des inscrits un ELP //on doit affiche l'tape d'appartenance et ventuellement les groupes //Affichage d'une liste droulante contenant la liste des annes if (typeIsElp()) { List<VersionEtape> letapes = MainUI.getCurrent().getListeEtapesInscrits(); if (letapes != null && letapes.size() > 0) { listeEtapes = new ComboBox( applicationContext.getMessage(NAME + ".etapes", null, getLocale())); listeEtapes.setPageLength(5); listeEtapes.setNullSelectionAllowed(false); listeEtapes.setTextInputAllowed(false); listeEtapes.setRequired(false); listeEtapes.setWidth("400px"); listeEtapes.addItem(TOUTES_LES_ETAPES_LABEL); listeEtapes.setItemCaption(TOUTES_LES_ETAPES_LABEL, TOUTES_LES_ETAPES_LABEL); for (VersionEtape etape : letapes) { String idEtape = etape.getId().getCod_etp() + "/" + etape.getId().getCod_vrs_vet(); listeEtapes.addItem(idEtape); listeEtapes.setItemCaption(idEtape, "[" + idEtape + "] " + etape.getLib_web_vet()); } if (MainUI.getCurrent().getEtapeInscrits() != null) { listeEtapes.setValue(MainUI.getCurrent().getEtapeInscrits()); } else { listeEtapes.setValue(TOUTES_LES_ETAPES_LABEL); } //Gestion de l'vnement sur le changement d'tape listeEtapes.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String vetSelectionnee = (String) event.getProperty().getValue(); if (vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { vetSelectionnee = null; } MainUI.getCurrent().setEtapeInscrits(vetSelectionnee); //faire le changement String groupeSelectionne = ((listeGroupes != null && listeGroupes.getValue() != null) ? (String) listeGroupes.getValue() : null); if (groupeSelectionne != null && groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) { groupeSelectionne = null; } filtrerInscrits(vetSelectionnee, groupeSelectionne); } }); formInscritLayout.addComponent(listeEtapes); } List<ElpDeCollection> lgroupes = MainUI.getCurrent().getListeGroupesInscrits(); if (lgroupes != null && lgroupes.size() > 0) { listeGroupes = new ComboBox(); listeGroupes.setPageLength(5); listeGroupes.setNullSelectionAllowed(false); listeGroupes.setTextInputAllowed(false); listeGroupes.setRequired(false); listeGroupes.setStyleName(ValoTheme.COMBOBOX_BORDERLESS); listeGroupes.setWidth("348px"); listeGroupes.addItem(TOUS_LES_GROUPES_LABEL); listeGroupes.setItemCaption(TOUS_LES_GROUPES_LABEL, TOUS_LES_GROUPES_LABEL); for (ElpDeCollection edc : lgroupes) { for (CollectionDeGroupes cdg : edc.getListeCollection()) { for (Groupe groupe : cdg.getListeGroupes()) { listeGroupes.addItem(groupe.getCleGroupe()); listeGroupes.setItemCaption(groupe.getCleGroupe(), groupe.getLibGroupe()); } } } if (MainUI.getCurrent().getGroupeInscrits() != null) { listeGroupes.setValue(MainUI.getCurrent().getGroupeInscrits()); } else { listeGroupes.setValue(TOUS_LES_GROUPES_LABEL); } //Gestion de l'vnement sur le changement de groupe listeGroupes.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String grpSelectionnee = (String) event.getProperty().getValue(); if (grpSelectionnee.equals(TOUS_LES_GROUPES_LABEL)) { grpSelectionnee = null; } MainUI.getCurrent().setGroupeInscrits(grpSelectionnee); //faire le changement String etapeSelectionnee = ((listeEtapes != null && listeEtapes.getValue() != null) ? (String) listeEtapes.getValue() : null); if (etapeSelectionnee != null && etapeSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { etapeSelectionnee = null; } filtrerInscrits(etapeSelectionnee, grpSelectionnee); } }); HorizontalLayout gpLayout = new HorizontalLayout(); gpLayout.setCaption(applicationContext.getMessage(NAME + ".groupes", null, getLocale())); gpLayout.setMargin(false); gpLayout.setSpacing(false); gpLayout.addComponent(listeGroupes); Button btnDetailGpe = new Button(); btnDetailGpe.setWidth("52px"); btnDetailGpe.setHeight("32px"); btnDetailGpe.setStyleName(ValoTheme.BUTTON_PRIMARY); btnDetailGpe.setIcon(FontAwesome.SEARCH); btnDetailGpe.setDescription( applicationContext.getMessage(NAME + ".detail.groupes", null, getLocale())); btnDetailGpe.addClickListener(e -> { String vet = null; if (listeEtapes != null && listeEtapes.getValue() != null && !listeEtapes.getValue().equals(TOUTES_LES_ETAPES_LABEL)) { vet = listeEtapes.getItemCaption(listeEtapes.getValue()); } DetailGroupesWindow dgw = new DetailGroupesWindow(lgroupes, panelFormInscrits.getCaption(), vet, (String) listeAnnees.getValue()); UI.getCurrent().addWindow(dgw); }); gpLayout.addComponent(btnDetailGpe); formInscritLayout.addComponent(gpLayout); } } panelLayout.addComponent(formInscritLayout); panelLayout.setComponentAlignment(formInscritLayout, Alignment.MIDDLE_LEFT); //Cration du favori pour l'objet concern pas la liste des inscrits List<Favoris> lfav = favorisController.getFavoris(); FavorisPK favpk = new FavorisPK(); favpk.setLogin(userController.getCurrentUserName()); favpk.setIdfav(code); favpk.setTypfav(typeFavori); Favoris favori = new Favoris(); favori.setId(favpk); //Cration du bouton pour ajouter l'objet aux favoris favoriLayout = new VerticalLayout(); favoriLayout.setSizeFull(); favoriLayout.setMargin(true); favoriLayout.setSpacing(true); btnAjoutFavori = new Button( applicationContext.getMessage(NAME + ".btn.ajoutFavori", null, getLocale())); btnAjoutFavori.setIcon(FontAwesome.STAR_O); btnAjoutFavori.addStyleName(ValoTheme.BUTTON_PRIMARY); btnAjoutFavori.setDescription( applicationContext.getMessage(NAME + ".btn.ajoutFavori", null, getLocale())); btnAjoutFavori.addClickListener(e -> { //creation du favori en base sur le clic du bouton favorisController.saveFavori(favori); //On cache le bouton de mise en favori btnAjoutFavori.setVisible(false); //Affichage d'un message de confirmation Notification.show( applicationContext.getMessage(NAME + ".message.favoriAjoute", null, getLocale()), Type.TRAY_NOTIFICATION); }); //Ajout du bouton l'interface favoriLayout.addComponent(btnAjoutFavori); favoriLayout.setComponentAlignment(btnAjoutFavori, Alignment.TOP_RIGHT); if (typeIsElp()) { btnMasquerFiltre = new Button( applicationContext.getMessage(NAME + ".btn.btnMasquerFiltre", null, getLocale())); btnMasquerFiltre.setIcon(FontAwesome.CHEVRON_CIRCLE_UP); btnMasquerFiltre.addStyleName(ValoTheme.BUTTON_FRIENDLY); btnMasquerFiltre.setDescription( applicationContext.getMessage(NAME + ".btn.btnMasquerFiltre", null, getLocale())); btnMasquerFiltre.addClickListener(e -> { panelFormInscrits.setContent(null); if (btnDisplayFiltres != null) { btnDisplayFiltres.setVisible(true); } }); favoriLayout.addComponent(btnMasquerFiltre); favoriLayout.setComponentAlignment(btnMasquerFiltre, Alignment.BOTTOM_RIGHT); } panelLayout.addComponent(favoriLayout); panelLayout.setComponentAlignment(favoriLayout, Alignment.TOP_RIGHT); //Si l'objet est dj en favori if (lfav != null && lfav.contains(favori)) { //On affiche pas le bouton de mise en favori btnAjoutFavori.setVisible(false); } panelFormInscrits.setContent(panelLayout); addComponent(panelFormInscrits); //Rcupration de la liste des inscrits linscrits = MainUI.getCurrent().getListeInscrits(); refreshListeCodind(new BeanItemContainer<>(Inscrit.class, linscrits)); //Test si la liste contient des tudiants if (linscrits != null && linscrits.size() > 0 && listecodind != null && listecodind.size() > 0) { infoLayout = new VerticalLayout(); infoLayout.setSizeFull(); //Layout avec le nb d'inscrit, le bouton trombinoscope et le bouton d'export HorizontalLayout resumeLayout = new HorizontalLayout(); resumeLayout.setWidth("100%"); resumeLayout.setHeight("50px"); //Label affichant le nb d'inscrits infoNbInscrit = new Label( applicationContext.getMessage(NAME + ".message.nbinscrit", null, getLocale()) + " : " + linscrits.size()); leftResumeLayout = new HorizontalLayout(); leftResumeLayout.addComponent(infoNbInscrit); leftResumeLayout.setComponentAlignment(infoNbInscrit, Alignment.MIDDLE_LEFT); Button infoDescriptionButton = new Button(); infoDescriptionButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); infoDescriptionButton.setIcon(FontAwesome.INFO_CIRCLE); infoDescriptionButton.setDescription(applicationContext .getMessage(NAME + ".message.info.predescription", null, getLocale())); infoDescriptionButton.addClickListener(e -> { String message = ""; if (typeIsVet()) { message = applicationContext.getMessage(NAME + ".message.info.vetdescription", null, getLocale()); } if (typeIsElp()) { message = applicationContext.getMessage(NAME + ".message.info.elpdescription", null, getLocale()); } HelpBasicWindow hbw = new HelpBasicWindow(message, applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale())); UI.getCurrent().addWindow(hbw); }); leftResumeLayout.addComponent(infoDescriptionButton); leftResumeLayout.setComponentAlignment(infoDescriptionButton, Alignment.MIDDLE_LEFT); //Bouton export trombinoscope btnExportTrombi = new Button(); btnExportTrombi.setIcon(FontAwesome.FILE_PDF_O); btnExportTrombi.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnExportTrombi.addStyleName("button-icon"); btnExportTrombi.addStyleName("red-button-icon"); btnExportTrombi.setDescription( applicationContext.getMessage(NAME + ".pdf.trombinoscope.link", null, getLocale())); //methode qui permet de generer l'export la demande //Cration du nom du fichier String nomFichier = applicationContext.getMessage("pdf.trombinoscope.title", null, Locale.getDefault()) + "_" + panelFormInscrits.getCaption() + ".pdf"; nomFichier = nomFichier.replaceAll(" ", "_"); StreamResource resource = new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { //recuperation de l'anne slectionne et du libell de l'ELP String annee = (String) listeAnnees.getValue(); String libObj = panelFormInscrits.getCaption(); //cration du trombi en pdf return listeInscritsController.getPdfStream(linscrits, listecodind, libObj, annee); } }, nomFichier); resource.setMIMEType("application/force-download;charset=UTF-8"); resource.setCacheTime(0); //On ajoute le FD sur le bouton d'export if (PropertyUtils.isPushEnabled()) { new MyFileDownloader(resource).extend(btnExportTrombi); } else { FileDownloader fdpdf = new FileDownloader(resource); fdpdf.setOverrideContentType(false); fdpdf.extend(btnExportTrombi); } leftResumeLayout.addComponent(btnExportTrombi); leftResumeLayout.setComponentAlignment(btnExportTrombi, Alignment.MIDDLE_LEFT); //if(!afficherTrombinoscope){ //On cache le bouton d'export pdf btnExportTrombi.setVisible(false); //} //Bouton export liste excel btnExportExcel = new Button(); btnExportExcel.setIcon(FontAwesome.FILE_EXCEL_O); btnExportExcel.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnExportExcel.addStyleName("button-icon"); btnExportExcel .setDescription(applicationContext.getMessage(NAME + ".excel.link", null, getLocale())); String nomFichierXls = applicationContext.getMessage("excel.listeinscrits.title", null, Locale.getDefault()) + "_" + panelFormInscrits.getCaption() + ".xls"; nomFichierXls = nomFichierXls.replaceAll(" ", "_"); StreamResource resourceXls = new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { //recuperation de l'anne slectionne et du libell de l'ELP String annee = (String) listeAnnees.getValue(); String libObj = panelFormInscrits.getCaption(); //cration du trombi en pdf return listeInscritsController.getXlsStream(linscrits, listecodind, listeGroupes, libObj, annee, typeFavori); } }, nomFichierXls); resourceXls.setMIMEType("application/force-download;charset=UTF-8"); resourceXls.setCacheTime(0); //On ajoute le FD sur le bouton d'export if (PropertyUtils.isPushEnabled()) { new MyFileDownloader(resourceXls).extend(btnExportExcel); } else { FileDownloader fd = new FileDownloader(resourceXls); fd.setOverrideContentType(false); fd.extend(btnExportExcel); } //if(!afficherTrombinoscope){ //On change le bouton d'export pdf par le bouton export excel leftResumeLayout.replaceComponent(btnExportTrombi, btnExportExcel); //} resumeLayout.addComponent(leftResumeLayout); //Middle layout avec les bouton de collapse des colonnes middleResumeLayout = new HorizontalLayout(); middleResumeLayout.setSizeFull(); middleResumeLayout.addStyleName("small-font-element"); middleResumeLayout.setSpacing(true); if (!typeIsVet()) { collapseEtp = new CheckBox( applicationContext.getMessage(NAME + ".collapseEtp.title", null, getLocale())); collapseEtp.setValue(true); collapseEtp.addValueChangeListener(e -> { inscritstable.setColumnCollapsed("etape", !collapseEtp.getValue()); }); collapseEtp.setDescription(applicationContext.getMessage(NAME + ".collapseEtp.description", null, getLocale())); middleResumeLayout.addComponent(collapseEtp); middleResumeLayout.setComponentAlignment(collapseEtp, Alignment.MIDDLE_CENTER); } collapseResultatsS1 = new CheckBox( applicationContext.getMessage(NAME + ".collapseResultatsS1.title", null, getLocale())); collapseResultatsS1.setValue(false); collapseResultatsS1.addValueChangeListener(e -> { inscritstable.setColumnCollapsed("notes1", !collapseResultatsS1.getValue()); }); collapseResultatsS1.setDescription(applicationContext .getMessage(NAME + ".collapseResultatsS1.description", null, getLocale())); middleResumeLayout.addComponent(collapseResultatsS1); middleResumeLayout.setComponentAlignment(collapseResultatsS1, Alignment.MIDDLE_CENTER); collapseResultatsS2 = new CheckBox( applicationContext.getMessage(NAME + ".collapseResultatsS2.title", null, getLocale())); collapseResultatsS2.setValue(false); collapseResultatsS2.addValueChangeListener(e -> { inscritstable.setColumnCollapsed("notes2", !collapseResultatsS2.getValue()); }); collapseResultatsS2.setDescription(applicationContext .getMessage(NAME + ".collapseResultatsS2.description", null, getLocale())); middleResumeLayout.addComponent(collapseResultatsS2); middleResumeLayout.setComponentAlignment(collapseResultatsS2, Alignment.MIDDLE_CENTER); resumeLayout.addComponent(middleResumeLayout); HorizontalLayout buttonResumeLayout = new HorizontalLayout(); buttonResumeLayout.setSizeFull(); buttonResumeLayout.setSpacing(true); //Bouton pour afficher les filtres btnDisplayFiltres = new Button(); btnDisplayFiltres.setWidth("52px"); btnDisplayFiltres.setHeight("32px"); btnDisplayFiltres.setStyleName(ValoTheme.BUTTON_FRIENDLY); btnDisplayFiltres.setIcon(FontAwesome.FILTER); btnDisplayFiltres.setDescription( applicationContext.getMessage(NAME + ".btn.displayFilters", null, getLocale())); btnDisplayFiltres.addClickListener(e -> { panelFormInscrits.setContent(panelLayout); btnDisplayFiltres.setVisible(false); }); buttonResumeLayout.addComponent(btnDisplayFiltres); buttonResumeLayout.setComponentAlignment(btnDisplayFiltres, Alignment.MIDDLE_RIGHT); buttonResumeLayout.setExpandRatio(btnDisplayFiltres, 1); btnDisplayFiltres.setVisible(false); //Bouton trombinoscope btnTrombi = new Button( applicationContext.getMessage(NAME + ".message.trombinoscope", null, getLocale())); if (listeInscritsController.isPhotoProviderOperationnel()) { btnTrombi.setIcon(FontAwesome.GROUP); buttonResumeLayout.addComponent(btnTrombi); //Gestion du clic sur le bouton trombinoscope btnTrombi.addClickListener(e -> { //Si on doit afficher une fentre de loading pendant l'excution if (PropertyUtils.isPushEnabled() && PropertyUtils.isShowLoadingIndicator()) { //affichage de la pop-up de loading MainUI.getCurrent().startBusyIndicator(); //Execution de la mthode en parallle dans un thread executorService.execute(new Runnable() { public void run() { MainUI.getCurrent().access(new Runnable() { @Override public void run() { executeDisplayTrombinoscope(); //close de la pop-up de loading MainUI.getCurrent().stopBusyIndicator(); } }); } }); } else { //On ne doit pas afficher de fentre de loading, on excute directement la mthode executeDisplayTrombinoscope(); } }); buttonResumeLayout.setComponentAlignment(btnTrombi, Alignment.MIDDLE_RIGHT); } //Bouton de retour l'affichage de la liste btnRetourListe = new Button( applicationContext.getMessage(NAME + ".message.retourliste", null, getLocale())); btnRetourListe.setIcon(FontAwesome.BARS); buttonResumeLayout.addComponent(btnRetourListe); //if(!afficherTrombinoscope){ btnRetourListe.setVisible(false); //} //Gestion du clic sur le bouton de retour l'affichage de la liste btnRetourListe.addClickListener(e -> { afficherTrombinoscope = false; btnExportTrombi.setVisible(false); leftResumeLayout.replaceComponent(btnExportTrombi, btnExportExcel); btnTrombi.setVisible(true); btnRetourListe.setVisible(false); dataLayout.removeAllComponents(); dataLayout.addComponent(inscritstable); middleResumeLayout.setVisible(true); }); buttonResumeLayout.setComponentAlignment(btnRetourListe, Alignment.MIDDLE_RIGHT); resumeLayout.addComponent(buttonResumeLayout); infoLayout.addComponent(resumeLayout); //Layout qui contient la liste des inscrits et le trombinoscope dataLayout = new VerticalLayout(); dataLayout.setSizeFull(); //Table contenant la liste des inscrits inscritstable = new Table(null, new BeanItemContainer<>(Inscrit.class, linscrits)); inscritstable.addStyleName("table-without-column-selector"); inscritstable.setSizeFull(); inscritstable.setVisibleColumns(new String[0]); String[] fields = INS_FIELDS_ELP; if (typeIsVet()) { fields = INS_FIELDS_VET; } for (String fieldName : fields) { inscritstable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale())); } inscritstable.addGeneratedColumn("cod_etu", new CodEtuColumnGenerator()); inscritstable.setColumnHeader("cod_etu", applicationContext.getMessage(NAME + ".table.cod_etu", null, getLocale())); inscritstable.addGeneratedColumn("email", new MailColumnGenerator()); inscritstable.setColumnHeader("email", applicationContext.getMessage(NAME + ".table.email", null, getLocale())); inscritstable.addGeneratedColumn("notes1", new Session1ColumnGenerator()); inscritstable.setColumnHeader("notes1", applicationContext.getMessage(NAME + ".table.notes1", null, getLocale())); inscritstable.addGeneratedColumn("notes2", new Session2ColumnGenerator()); inscritstable.setColumnHeader("notes2", applicationContext.getMessage(NAME + ".table.notes2", null, getLocale())); //Si on est sur un ELP if (typeIsElp()) { //on affiche l'tape de rattachement inscritstable.addGeneratedColumn("etape", new EtapeColumnGenerator()); inscritstable.setColumnHeader("etape", applicationContext.getMessage(NAME + ".table.etape", null, getLocale())); } String[] fields_to_display = INS_FIELDS_TO_DISPLAY_ELP; if (typeIsVet()) { fields_to_display = INS_FIELDS_TO_DISPLAY_VET; } inscritstable.setVisibleColumns((Object[]) fields_to_display); inscritstable.setColumnCollapsingAllowed(true); inscritstable.setColumnReorderingAllowed(false); //On masque les colonnes de notes par dfaut inscritstable.setColumnCollapsed("notes1", true); inscritstable.setColumnCollapsed("notes2", true); inscritstable.setSelectable(false); inscritstable.setImmediate(true); inscritstable.addStyleName("scrollabletable"); //Si on n'a pas dj demand afficher le trombinoscope //if(!afficherTrombinoscope){ //la layout contient la table dataLayout.addComponent(inscritstable); //} //Layout contenant le gridLayout correspondant au trombinoscope verticalLayoutForTrombi = new VerticalLayout(); verticalLayoutForTrombi.setSizeFull(); verticalLayoutForTrombi.addStyleName("v-scrollablepanel"); //Cration du trombinoscope displayTrombinoscope(); verticalLayoutForTrombi.addComponent(trombiLayout); verticalLayoutForTrombi.setSizeFull(); verticalLayoutForTrombi.setHeight(null); //Si on a demand afficher le trombinoscope /*if(afficherTrombinoscope){ //Le layout contient le trombi afficher dataLayout.addComponent(verticalLayoutForTrombi); }*/ infoLayout.addComponent(dataLayout); infoLayout.setExpandRatio(dataLayout, 1); addComponent(infoLayout); setExpandRatio(infoLayout, 1); //Si on a demand afficher le trombinoscope if (afficherTrombinoscope) { //On execute la procdure d'affichage du trombinoscope executeDisplayTrombinoscope(); } } else { Label infoAucuninscrit = new Label( applicationContext.getMessage(NAME + ".message.aucuninscrit", null, getLocale())); addComponent(infoAucuninscrit); setComponentAlignment(infoAucuninscrit, Alignment.TOP_CENTER); setExpandRatio(infoAucuninscrit, 1); } } } }
From source file:fr.univlorraine.mondossierweb.views.RechercheArborescenteView.java
License:Apache License
/** * Initialise la vue// www .j a v a2 s.c o m */ @PostConstruct public void init() { //On vrifie le droit d'accder la vue if (userController.isEnseignant()) { /* Style */ setMargin(false); setSpacing(false); setSizeFull(); if (listeBoutonFavoris != null) { listeBoutonFavoris.clear(); } else { listeBoutonFavoris = new LinkedList<ReferencedButton>(); } liste_types_favoris = new LinkedList<String>(); liste_types_favoris.add(Utils.CMP); liste_types_favoris.add(Utils.ELP); liste_types_favoris.add(Utils.VET); liste_types_inscrits = new LinkedList<String>(); liste_types_inscrits.add(Utils.ELP); liste_types_inscrits.add(Utils.VET); liste_types_deplier = new LinkedList<String>(); liste_types_deplier.add(Utils.ELP); liste_types_deplier.add(Utils.VET); recuperationDesfavoris(); HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setMargin(false); btnLayout.setSpacing(false); btnLayout.setWidth("100%"); comboBoxAnneeUniv = new ComboBox(applicationContext.getMessage(NAME + ".anneeuniv", null, getLocale())); comboBoxAnneeUniv.setPageLength(5); comboBoxAnneeUniv.setTextInputAllowed(false); comboBoxAnneeUniv.setNullSelectionAllowed(false); //Initialisation de la liste des annes List<String> lanneeUniv = rechercheArborescenteController.recupererLesDernieresAnneeUniversitaire(); if (lanneeUniv != null && lanneeUniv.size() > 0) { for (String anneeUniv : lanneeUniv) { comboBoxAnneeUniv.addItem(anneeUniv); int anneenplusun = Integer.parseInt(anneeUniv) + 1; comboBoxAnneeUniv.setItemCaption(anneeUniv, anneeUniv + "/" + anneenplusun); } if (annee == null) { annee = etudiantController.getAnneeUnivEnCours(MainUI.getCurrent()); //annee = lanneeUniv.get(0); } } comboBoxAnneeUniv.setValue(annee); comboBoxAnneeUniv.setStyleName(ValoTheme.COMBOBOX_SMALL); comboBoxAnneeUniv.addValueChangeListener(e -> changerAnnee((String) comboBoxAnneeUniv.getValue())); reinitButton = new Button(); reinitButton.setDescription( applicationContext.getMessage(NAME + ".reinitbutton.description", null, getLocale())); reinitButton.addClickListener(e -> { initFromScratch(); }); reinitButton.setStyleName(ValoTheme.BUTTON_DANGER); reinitButton.setIcon(FontAwesome.TIMES); if (!StringUtils.hasText(code)) { reinitButton.setVisible(false); } labelLigneSelectionneeLabel = new Label(); labelLigneSelectionneeLabel .setValue(applicationContext.getMessage(NAME + ".ligneselectionnee", null, getLocale())); labelLigneSelectionneeLabel.addStyleName("label-align-right"); labelLigneSelectionneeLabel.setVisible(false); HorizontalLayout btnLeftLayout = new HorizontalLayout(); btnLeftLayout.setWidth("100%"); btnLeftLayout.setMargin(true); btnLeftLayout.addComponent(comboBoxAnneeUniv); btnLeftLayout.setComponentAlignment(comboBoxAnneeUniv, Alignment.MIDDLE_LEFT); /*btnLeftLayout.addComponent(reinitButton); btnLeftLayout.setComponentAlignment(reinitButton, Alignment.BOTTOM_RIGHT);*/ btnLeftLayout.addComponent(labelLigneSelectionneeLabel); btnLeftLayout.setComponentAlignment(labelLigneSelectionneeLabel, Alignment.MIDDLE_CENTER); btnLayout.addComponent(btnLeftLayout); ligneSelectionneeLabel = new Label(); //ligneSelectionneeLabel.setCaption(applicationContext.getMessage(NAME+".ligneselectionnee", null, getLocale())); ligneSelectionneeLabel.setVisible(false); elpLayout = new FormLayout(); elpLayout.setMargin(false); vetElpSelectionneLabel = new Label(); vetElpSelectionneLabel.setVisible(false); elpLayout.addComponent(vetElpSelectionneLabel); elpLayout.setVisible(false); VerticalLayout ligneLayout = new VerticalLayout(); ligneLayout.addComponent(ligneSelectionneeLabel); ligneLayout.addComponent(elpLayout); HorizontalLayout rightLayout = new HorizontalLayout(); rightLayout.setSizeFull(); rightLayout.setSpacing(true); rightLayout.setMargin(true); rightLayout.addComponent(ligneLayout); rightLayout.setComponentAlignment(ligneLayout, Alignment.MIDDLE_LEFT); rightLayout.addComponent(reinitButton); rightLayout.setComponentAlignment(reinitButton, Alignment.MIDDLE_RIGHT); rightLayout.setExpandRatio(ligneLayout, 1); btnLayout.addComponent(rightLayout); btnLayout.setComponentAlignment(rightLayout, Alignment.MIDDLE_LEFT); addComponent(btnLayout); if (code != null && type != null) { Label elementRecherche = new Label(code + " " + type); elementRecherche.addStyleName(ValoTheme.LABEL_H1); //addComponent(elementRecherche); } table = new TreeTable(); table.setSizeFull(); table.setStyleName("scrollabletable"); table.setSelectable(true); initComposantes(); //gestion du style pour les lignes en favori table.setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(final Table source, final Object itemId, final Object propertyId) { String style = null; if (propertyId == null && markedRows.contains(itemId)) { style = "marked"; } return style; } }); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { selectionnerLigne(event.getItemId()); } }); //gestion du clic sur la fleche pour dplier une entre table.addExpandListener(new ExpandListener() { private static final long serialVersionUID = 8532342540008245348L; @Override public void nodeExpand(ExpandEvent event) { if (event != null && event.getItemId() != null && hc != null && hc.getItem(event.getItemId()) != null && hc.getItem(event.getItemId()).getItemProperty(TYPE_PROPERTY) != null) { selectionnerLigne(event.getItemId()); deplierNoeud((String) event.getItemId(), true); } } }); VerticalLayout tableVerticalLayout = new VerticalLayout(); tableVerticalLayout.setMargin(new MarginInfo(false, true, true, true)); tableVerticalLayout.setSizeFull(); tableVerticalLayout.addComponent(table); tableVerticalLayout.setExpandRatio(table, 1); addComponent(tableVerticalLayout); setExpandRatio(tableVerticalLayout, 1); } }
From source file:gov.va.ds4p.ds4pmobileportal.ui.PatientSelectView.java
License:Open Source License
private void buildView() { try {//from w ww. jav a 2 s. c o m CssLayout content = new CssLayout(); content.setWidth("100%"); setCaption("Patient Selection"); VerticalComponentGroup vGroup = new VerticalComponentGroup(); Label selectaction = new Label( "<div style='color:#333;'><p>You must select a patient first prior to demonstrating" + " <b>Data Segementation for Privacy</b> use cases.</p>" + "<p> After patient is selected you may perform a secured" + " eHealth Exchange (pull) or eHealth Direct (push) demonstration.</p></div>", Label.CONTENT_XHTML); patientList = new ComboBox("Available Patients"); populatePatientList(); patientList.addListener(new ComboBox.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String val = (String) patientList.getValue(); String valName = (String) patientList.getItemCaption(val); AdminContext.getSessionAttributes().setSelectedPatientId(val); AdminContext.getSessionAttributes().setSelectedPatientName(valName); setSessionValues(val); } }); patientList.setImmediate(true); patientList.setTextInputAllowed(false); vGroup.addComponent(selectaction); vGroup.addComponent(patientList); content.addComponent(vGroup); setContent(content); } catch (Exception ex) { ex.printStackTrace(); } }