List of usage examples for com.vaadin.ui NativeSelect NativeSelect
public NativeSelect()
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.MainView.java
private Component createThemeSelect() { final NativeSelect ns = new NativeSelect(); ns.setNullSelectionAllowed(false);/*ww w. ja v a 2s . com*/ ns.setId("themeSelect"); ns.addContainerProperty("caption", String.class, ""); ns.setItemCaptionPropertyId("caption"); // ns.setValue("tests-valo"); return ns; }
From source file:de.decidr.ui.view.WorkflowModelsComponent.java
License:Apache License
/** * This method initializes the components for the workflow model component. *//*from w ww .j ava 2 s.com*/ protected void init() { label = new Label("<h2> Workflow models </h2>"); label.setContentMode(Label.CONTENT_XHTML); showModelsFromLabel = new Label("Show Models from: "); viewSelect = new NativeSelect(); for (int i = 0; i < models.length; i++) { viewSelect.addItem(models[i]); } viewSelect.setNullSelectionAllowed(false); viewSelect.setValue(models[0]); viewSelect.setImmediate(true); viewSelect.addListener(new Property.ValueChangeListener() { /** * Serial version uid */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { initView(); } }); initView(); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SearchEngineView.java
License:Open Source License
public void initUI() { mainlayout = new Panel(); mainlayout.addStyleName(ValoTheme.PANEL_BORDERLESS); // Search bar // *----------- search text field .... search button-----------* VerticalLayout searchbar = new VerticalLayout(); searchbar.setWidth(100, Unit.PERCENTAGE); setResponsive(true);//w w w. j a va 2 s. com searchbar.setResponsive(true); // searchbar.setWidth(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setResponsive(true); buttonLayout.setWidth(75, Unit.PERCENTAGE); // searchbar.setSpacing(true); final TextField searchfield = new TextField(); searchfield.setHeight("44px"); searchfield.setImmediate(true); searchfield.setResponsive(true); searchfield.setWidth(75, Unit.PERCENTAGE); buttonLayout.setSpacing(true); searchfield.setInputPrompt("search DB"); // searchfield.setCaption("QSearch"); // searchfield.setWidth(25.0f, Unit.EM); // searchfield.setWidth(60, Unit.PERCENTAGE); // TODO would be nice to have a autofill or something similar // searchFieldLayout.addComponent(searchfield); searchbar.addComponent(searchfield); searchbar.setComponentAlignment(searchfield, Alignment.MIDDLE_RIGHT); final NativeSelect navsel = new NativeSelect(); navsel.addItem("Whole DB"); navsel.addItem("Projects Only"); navsel.addItem("Experiments Only"); navsel.addItem("Samples Only"); navsel.setValue("Whole DB"); navsel.setHeight("20px"); navsel.setNullSelectionAllowed(false); navsel.setResponsive(true); navsel.setWidth(100, Unit.PERCENTAGE); navsel.addValueChangeListener(new Property.ValueChangeListener() { /** * */ private static final long serialVersionUID = -6896454887050432147L; @Override public void valueChange(ValueChangeEvent event) { // TODO Auto-generated method stub Notification.show((String) navsel.getValue()); switch ((String) navsel.getValue()) { case "Whole DB": datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples")); break; case "Projects Only": datahandler.setShowOptions(Arrays.asList("Projects")); break; case "Experiments Only": datahandler.setShowOptions(Arrays.asList("Experiments")); break; case "Samples Only": datahandler.setShowOptions(Arrays.asList("Samples")); break; default: datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples")); break; } } }); searchbar.addComponent(buttonLayout); searchbar.setComponentAlignment(buttonLayout, Alignment.MIDDLE_RIGHT); Button searchOk = new Button(""); searchOk.setStyleName(ValoTheme.BUTTON_TINY); // searchOk.addStyleName(ValoTheme.BUTTON_BORDERLESS); searchOk.setIcon(FontAwesome.SEARCH); searchOk.setSizeUndefined(); // searchOk.setWidth(15.0f, Unit.EM); searchOk.setResponsive(true); searchOk.setHeight("20px"); searchOk.addClickListener(new ClickListener() { private static final long serialVersionUID = -2409450448301908214L; @Override public void buttonClick(ClickEvent event) { String queryString = (String) searchfield.getValue().toString(); LOGGER.debug("the query was " + queryString); if (searchfield.getValue() == null || searchfield.getValue().toString().equals("") || searchfield.getValue().toString().trim().length() == 0) { Notification.show("Query field was empty!", Type.WARNING_MESSAGE); } else { try { /** * Sample foundSample = datahandler.getOpenBisClient() .getSampleByIdentifier( * matcher.group(0).toString()); */ datahandler.setSampleResults(querySamples(queryString)); datahandler.setExpResults(queryExperiments(queryString)); datahandler.setProjResults(queryProjects(queryString)); datahandler.setLastQueryString(queryString); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add("view" + queryString); message.add("searchresults"); state.notifyObservers(message); } catch (Exception e) { LOGGER.error("after query: ", e); Notification.show("No Sample found for given barcode.", Type.WARNING_MESSAGE); } } } }); // setClickShortcut() would add global shortcut, instead we // 'scope' the shortcut to the panel: mainlayout.addAction(new com.vaadin.ui.Button.ClickShortcut(searchOk, KeyCode.ENTER)); // searchfield.addItems(this.getSearchResults("Q")); searchfield.setDescription(infotext); searchfield.addValidator(new NullValidator("Field must not be empty", false)); searchfield.setValidationVisible(false); buttonLayout.addComponent(navsel); // buttonLayout.addComponent(new Label("")); buttonLayout.addComponent(searchOk); // searchFieldLayout.setComponentAlignment(searchOk, Alignment.TOP_RIGHT); // buttonLayout.setExpandRatio(searchOk, 1); // buttonLayout.setExpandRatio(navsel, 1); // searchFieldLayout.setSpacing(true); buttonLayout.setComponentAlignment(searchOk, Alignment.BOTTOM_RIGHT); // buttonLayout.setComponentAlignment(navsel, Alignment.BOTTOM_LEFT); buttonLayout.setExpandRatio(searchOk, 1); buttonLayout.setExpandRatio(navsel, 2); // searchbar.setMargin(new MarginInfo(true, false, true, false)); mainlayout.setContent(searchbar); // mainlayout.setComponentAlignment(searchbar, Alignment.MIDDLE_RIGHT); // mainlayout.setWidth(100, Unit.PERCENTAGE); setCompositionRoot(mainlayout); }
From source file:edu.nps.moves.mmowgli.modules.administration.SubCardsGameDesignPanel.java
License:Open Source License
@Override public void initGui() { setMargin(true);//from w w w . java 2 s . c o m setSpacing(true); expandFields = new CardTypeFields(CardType.getExpandTypeTL(), globs); expandTypeSelect = new NativeSelect(); addComponent(renderFields(expandFields, expandTypeSelect, "1 Choose EXPAND card type for this round")); expandFields.initGui(); counterFields = new CardTypeFields(CardType.getCounterTypeTL(), globs); counterTypeSelect = new NativeSelect(); addComponent(renderFields(counterFields, counterTypeSelect, "2 Choose COUNTER card type for this round")); counterFields.initGui(); adaptFields = new CardTypeFields(CardType.getAdaptTypeTL(), globs); adaptTypeSelect = new NativeSelect(); addComponent(renderFields(adaptFields, adaptTypeSelect, "3 Choose ADAPT card type for this round")); adaptFields.initGui(); exploreFields = new CardTypeFields(CardType.getExploreTypeTL(), globs); exploreTypeSelect = new NativeSelect(); addComponent(renderFields(exploreFields, exploreTypeSelect, "4 Choose EXPLORE card type for this round")); exploreFields.initGui(); fillSelectCommon(expandTypeSelect, CardType.getDefinedExpandTypesTL()); fillSelectCommon(counterTypeSelect, CardType.getDefinedCounterTypesTL()); fillSelectCommon(adaptTypeSelect, CardType.getDefinedAdaptTypesTL()); fillSelectCommon(exploreTypeSelect, CardType.getDefinedExploreTypesTL()); expandTypeSelect.addValueChangeListener(myCardTypeListener); counterTypeSelect.addValueChangeListener(myCardTypeListener); adaptTypeSelect.addValueChangeListener(myCardTypeListener); exploreTypeSelect.addValueChangeListener(myCardTypeListener); addComponent(childCardsWarning = new Label("(Cannot change types at this point.)"), 0); adjustRO(); // will set above to (in)visible }
From source file:edu.nps.moves.mmowgli.modules.administration.TopCardsGameDesignPanel.java
License:Open Source License
@Override public void initGui() { super.initGui(); positiveFields = new CardTypeFields(CardType.getCurrentPositiveIdeaCardTypeTL(), globals); positiveTypeSelect = new NativeSelect(); addComponent(renderFields(positiveFields, positiveTypeSelect, "1 Choose POSITIVE top card type for this round", cantEditPositiveTypeWarning)); positiveFields.initGui();/* ww w . j av a2 s . c o m*/ negativeFields = new CardTypeFields(CardType.getCurrentNegativeIdeaCardTypeTL(), globals); negativeTypeSelect = new NativeSelect(); addComponent(renderFields(negativeFields, negativeTypeSelect, "2 Choose NEGATIVE top card type for this round", cantEditNegativeTypeWarning)); negativeFields.initGui(); fillSelectCommonTL(positiveTypeSelect, CardType.getDefinedPositiveTypesTL()); fillSelectCommonTL(negativeTypeSelect, CardType.getDefinedNegativeTypesTL()); positiveTypeSelect.addValueChangeListener(myCardTypeListener); negativeTypeSelect.addValueChangeListener(myCardTypeListener); addComponent(childCardsWarning = new Label( "(Can only change card types for this round during PREPARE phase, or during earlier rounds.)"), 0); adjustRO(); // will set above to (in)visible }
From source file:facs.components.Booking.java
License:Open Source License
NativeSelect initCalendars(List<String> devices) { String selectDeviceCaption = "Please select a device:"; String selectDeviceDescription = "Please select a device to ask for a booking request or to book!"; NativeSelect selectDevice = new NativeSelect(); selectDevice.addItems(devices);/*from w w w .ja v a 2s. com*/ selectDevice.setCaption(selectDeviceCaption); selectDevice.setDescription(selectDeviceDescription); selectDevice.setNullSelectionAllowed(false); return selectDevice; }
From source file:fi.jasoft.simplecalendar.demo.SimpleCalendarDemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { setLocale(DEFAULT_LOCALE);// ww w .j a v a 2 s . com VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); Label lbl = new Label("SimpleCalendar"); lbl.setStyleName(Reindeer.LABEL_H1); content.addComponent(lbl); HorizontalLayout layout = new HorizontalLayout(); layout.setWidth("100%"); layout.setSpacing(true); final SimpleCalendar calendar = new SimpleCalendar(); calendar.setImmediate(true); calendar.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { Notification.show(calendar.getValue().toString()); } }); calendar.setMultiSelect(true); layout.addComponent(calendar); Label description = new Label("A calendar component that supports the following features:<ul>" + "<li>Selecting multiple dates by control click</li>" + "<li>Range selection with shift click</li>" + "<li>Keyboard navigation with arrow keys</li>" + "<li>Possibility to disable certain dates</li>" + "<li>Date tooltips</li>" + "<li>Limit start and end dates of calendar</li>" + "<li>Selecting multiple locales", ContentMode.HTML); layout.addComponent(description); layout.setExpandRatio(description, 1); content.addComponent(layout); BeanItemContainer<Locale> locales = new BeanItemContainer<Locale>(Locale.class); locales.addAll(Arrays.asList(Locale.getAvailableLocales())); NativeSelect localeSelect = new NativeSelect(); localeSelect.setContainerDataSource(locales); localeSelect.setValue(DEFAULT_LOCALE); localeSelect.setImmediate(true); localeSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY); localeSelect.setItemCaptionPropertyId("displayName"); localeSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { calendar.setLocale((Locale) event.getProperty().getValue()); } }); content.addComponent(new HorizontalLayout(new Label("Locale:"), localeSelect)); final CheckBox disableWeekends = new CheckBox("Disable weekends", false); disableWeekends.setImmediate(true); disableWeekends.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (disableWeekends.getValue()) { calendar.setDisabledWeekDays(Weekday.SATURDAY, Weekday.SUNDAY); } else { calendar.setDisabledWeekDays(); } } }); content.addComponent(disableWeekends); final CheckBox disable15th = new CheckBox("Disable 15th each month", false); disable15th.setImmediate(true); disable15th.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (disable15th.getValue()) { calendar.setDisabledMonthlyDates(15); } else { calendar.setDisabledMonthlyDates(); } } }); content.addComponent(disable15th); final CheckBox disableToday = new CheckBox("Disable todays date", false); disableToday.setImmediate(true); disableToday.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (disableToday.getValue()) { calendar.setDisabledDates(new Date()); } else { calendar.setDisabledDates(); } } }); content.addComponent(disableToday); final CheckBox allowFutureDate = new CheckBox("Only allow future dates", false); allowFutureDate.setImmediate(true); allowFutureDate.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (allowFutureDate.getValue()) { calendar.setStartDate(new Date()); } else { calendar.setStartDate(null); } } }); content.addComponent(allowFutureDate); final CheckBox allowPastDate = new CheckBox("Only allow past dates", false); allowPastDate.setImmediate(true); allowPastDate.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (allowPastDate.getValue()) { calendar.setEndDate(new Date()); } else { calendar.setEndDate(null); } } }); content.addComponent(allowPastDate); setContent(content); }
From source file:fr.univlorraine.mondossierweb.views.windows.FiltreInscritsMobileWindow.java
License:Apache License
/** * Cre une fentre//from www. j a v a2s.c o m */ public FiltreInscritsMobileWindow() { setWidth("95%"); setModal(true); setResizable(false); setClosable(true); setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); setStyleName("v-popover-blank"); typeFavori = MdwTouchkitUI.getCurrent().getTypeObjListInscrits(); GridLayout layout = new GridLayout(1, 2); layout.setWidth("100%"); layout.setSpacing(true); layout.setMargin(true); setContent(layout); //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()) { //GESTION DES ETAPES List<VersionEtape> letapes = MdwTouchkitUI.getCurrent().getListeEtapesInscrits(); if (letapes != null && letapes.size() > 0) { Label etapeLabel = new Label(applicationContext.getMessage(NAME + ".etape", null, getLocale())); layout.addComponent(etapeLabel); layout.setComponentAlignment(etapeLabel, Alignment.BOTTOM_LEFT); listeEtapes = new NativeSelect(); listeEtapes.setNullSelectionAllowed(false); listeEtapes.setRequired(false); listeEtapes.setWidth("100%"); 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 (MdwTouchkitUI.getCurrent().getEtapeInscrits() != null) { listeEtapes.setValue(MdwTouchkitUI.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) { vetSelectionnee = (String) event.getProperty().getValue(); if (vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { vetSelectionnee = null; } MdwTouchkitUI.getCurrent().setEtapeInscrits(vetSelectionnee); //faire le changement groupeSelectionne = ((listeGroupes != null && listeGroupes.getValue() != null) ? (String) listeGroupes.getValue() : null); if (groupeSelectionne != null && groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) { groupeSelectionne = null; } //update de l'affichage //initListe(); } }); layout.addComponent(listeEtapes); } //GESTION DES GROUPES List<ElpDeCollection> lgroupes = MdwTouchkitUI.getCurrent().getListeGroupesInscrits(); if (lgroupes != null && lgroupes.size() > 0) { // Label "GROUPE" HorizontalLayout gLayout = new HorizontalLayout(); gLayout.setSizeFull(); Label groupeLabel = new Label(applicationContext.getMessage(NAME + ".groupe", null, getLocale())); gLayout.addComponent(groupeLabel); gLayout.setComponentAlignment(groupeLabel, Alignment.MIDDLE_LEFT); layout.addComponent(gLayout); //Liste droulante pour choisir le groupe listeGroupes = new NativeSelect(); listeGroupes.setNullSelectionAllowed(false); listeGroupes.setRequired(false); listeGroupes.setWidth("100%"); 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()); } } } //On pr-remplie le groupe choisi si on en a dj choisi un if (MdwTouchkitUI.getCurrent().getGroupeInscrits() != null) { listeGroupes.setValue(MdwTouchkitUI.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) { groupeSelectionne = (String) event.getProperty().getValue(); if (groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) { groupeSelectionne = null; } MdwTouchkitUI.getCurrent().setGroupeInscrits(groupeSelectionne); //faire le changement vetSelectionnee = ((listeEtapes != null && listeEtapes.getValue() != null) ? (String) listeEtapes.getValue() : null); if (vetSelectionnee != null && vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) { vetSelectionnee = null; } } }); layout.addComponent(listeGroupes); } } // Bouton "Filtrer" HorizontalLayout bLayout = new HorizontalLayout(); bLayout.setSizeFull(); Button closeButton = new Button(applicationContext.getMessage(NAME + ".filtrerBtn", null, getLocale())); closeButton.setStyleName(ValoTheme.BUTTON_PRIMARY); closeButton.addStyleName("v-popover-button"); demandeFiltrage = false; closeButton.addClickListener(e -> { //retourner vetSelectionnee et groupeSelectionne; demandeFiltrage = true; close(); }); bLayout.addComponent(closeButton); bLayout.setComponentAlignment(closeButton, Alignment.MIDDLE_CENTER); layout.addComponent(bLayout); }
From source file:fr.univlorraine.mondossierweb.views.windows.ModificationAdressesWindow.java
License:Apache License
/** * Cre une fentre de confirmation/*from w w w . j av a2s.c o m*/ * @param message * @param titre */ public ModificationAdressesWindow(Etudiant etudiant) { /* Style */ //setWidth(900, Unit.PIXELS); setModal(true); setResizable(false); setClosable(false); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Layout pour afficher les erreurs */ VerticalLayout erreursLayout = new VerticalLayout(); layout.addComponent(erreursLayout); erreursLayout.setVisible(false); HorizontalLayout panelslayout = new HorizontalLayout(); panelslayout.setMargin(true); panelslayout.setSpacing(true); layout.addComponent(panelslayout); /* Panel adresse annuelle */ Panel adressesAnnuellePanel = new Panel( applicationContext.getMessage(NAME + ".panel.adresseannuelle.title", null, getLocale()) + " " + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee()); FormLayout formAdresseAnnuelleLayout = new FormLayout(); formAdresseAnnuelleLayout.setSpacing(true); formAdresseAnnuelleLayout.setMargin(true); //TypeHebergement String captionHebergement = applicationContext.getMessage(NAME + ".typehebergement", null, getLocale()); TypeHebergementDTO[] hebergements = adresseController.getTypesHebergement(); lhebergement = new NativeSelect(); lhebergement.setCaption(captionHebergement); lhebergement.setNullSelectionAllowed(false); lhebergement.setRequired(true); lhebergement.setWidth("326px"); for (TypeHebergementDTO h : hebergements) { lhebergement.addItem(h.getCodTypeHebergement()); lhebergement.setItemCaption(h.getCodTypeHebergement(), h.getLibWebTypeHebergement()); } lhebergement.setValue(etudiant.getAdresseAnnuelle().getType()); lhebergement.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un hbergement autre que la Domicile parental a t choisi if (!selectedValue.equals(COD_HEBERG_DOMICILE_PARENTAL)) { activeFormulaireAdresseAnnuelle(); } else { desactiveFormulaireAdresseAnnuelle(); } } }); formAdresseAnnuelleLayout.addComponent(lhebergement); //labelChoixHebergement labelChoixHebergement = new Label( applicationContext.getMessage(NAME + ".labelhebergement", null, getLocale())); formAdresseAnnuelleLayout.addComponent(labelChoixHebergement); //AdresseAnnuelle1 fieldAnnu1 = new TextField(applicationContext.getMessage(NAME + ".annu1", null, getLocale())); fieldAnnu1.setValue(etudiant.getAdresseAnnuelle().getAdresse1()); fieldAnnu1.setNullRepresentation(""); fieldAnnu1.setWidth("326px"); fieldAnnu1.setMaxLength(32); fieldAnnu1.setRequired(true); formAdresseAnnuelleLayout.addComponent(fieldAnnu1); //AdresseAnnuelle2 fieldAnnu2 = new TextField(applicationContext.getMessage(NAME + ".annu2", null, getLocale())); fieldAnnu2.setValue(etudiant.getAdresseAnnuelle().getAdresse2()); fieldAnnu2.setNullRepresentation(""); fieldAnnu2.setWidth("326px"); fieldAnnu2.setMaxLength(32); formAdresseAnnuelleLayout.addComponent(fieldAnnu2); //AdresseAnnuelle3 fieldAnnu3 = new TextField(applicationContext.getMessage(NAME + ".annu3", null, getLocale())); fieldAnnu3.setValue(etudiant.getAdresseAnnuelle().getAdresse3()); fieldAnnu3.setNullRepresentation(""); fieldAnnu3.setWidth("326px"); fieldAnnu3.setMaxLength(32); formAdresseAnnuelleLayout.addComponent(fieldAnnu3); //Liste des Pays String captionPays = applicationContext.getMessage(NAME + ".pays1", null, getLocale()); PaysDTO[] pays = adresseController.getPays(); lpays1 = new NativeSelect(); lpays1.setCaption(captionPays); lpays1.setNullSelectionAllowed(false); lpays1.setRequired(true); lpays1.setWidth("326px"); for (PaysDTO p : pays) { lpays1.addItem(p.getCodePay()); lpays1.setItemCaption(p.getCodePay(), p.getLibPay()); } lpays1.setValue(etudiant.getAdresseAnnuelle().getCodPays()); lpays1.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un pays autre que France a t choisi if (!selectedValue.equals(COD_PAY_FRANCE)) { activerChampPourAdresseAnnuelleEtranger(); } else { activerChampPourAdresseAnnuelleEnFrance(); } } }); formAdresseAnnuelleLayout.addComponent(lpays1); //Ville pour adresse l'tranger fieldVilleEtranger1 = new TextField( applicationContext.getMessage(NAME + ".villeetranger1", null, getLocale())); fieldVilleEtranger1.setValue(etudiant.getAdresseAnnuelle().getAdresseetranger()); fieldVilleEtranger1.setNullRepresentation(""); fieldVilleEtranger1.setWidth("326px"); fieldVilleEtranger1.setMaxLength(5); fieldVilleEtranger1.setRequired(true); formAdresseAnnuelleLayout.addComponent(fieldVilleEtranger1); //codePostal1 pour adresses en france fieldCodePostal1 = new TextField(applicationContext.getMessage(NAME + ".codepostal1", null, getLocale())); fieldCodePostal1.setValue(etudiant.getAdresseAnnuelle().getCodePostal()); fieldCodePostal1.setNullRepresentation(""); fieldCodePostal1.setWidth("326px"); fieldCodePostal1.setMaxLength(5); fieldCodePostal1.setRequired(true); //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER); fieldCodePostal1.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { updateListeVillesAnnuelle(event.getText()); } }); formAdresseAnnuelleLayout.addComponent(fieldCodePostal1); //Ville pour adresse en france List<CommuneDTO> villes1 = adresseController.getVilles(etudiant.getAdresseAnnuelle().getCodePostal()); lville1 = new NativeSelect(); lville1.setCaption(applicationContext.getMessage(NAME + ".ville1", null, getLocale())); lville1.setNullSelectionAllowed(false); lville1.setRequired(true); lville1.setWidth("326px"); for (CommuneDTO v : villes1) { lville1.addItem(v.getLibCommune()); lville1.setItemCaption(v.getLibCommune(), v.getLibCommune()); } codePostalVillesAnnu = etudiant.getAdresseAnnuelle().getCodePostal(); lville1.setValue(etudiant.getAdresseAnnuelle().getVille()); lville1.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCodePostalVilleAnnuelle(); } }); formAdresseAnnuelleLayout.addComponent(lville1); //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification if (etudiant.getAdresseAnnuelle().getCodPays().equals(COD_PAY_FRANCE)) { activerChampPourAdresseAnnuelleEnFrance(); } else { activerChampPourAdresseAnnuelleEtranger(); } //Tlphone1 fieldTelephone1 = new TextField(applicationContext.getMessage(NAME + ".tel1", null, getLocale())); fieldTelephone1.setValue(etudiant.getAdresseAnnuelle().getNumerotel()); fieldTelephone1.setNullRepresentation(""); fieldTelephone1.setWidth("326px"); fieldTelephone1.setMaxLength(15); fieldTelephone1.setRequired(false); formAdresseAnnuelleLayout.addComponent(fieldTelephone1); //ajout du panel adresse Annuelle adressesAnnuellePanel.setContent(formAdresseAnnuelleLayout); panelslayout.addComponent(adressesAnnuellePanel); //Si un hbergement autre que la Domicile parental a t choisi if (!etudiant.getAdresseAnnuelle().getType().equals(COD_HEBERG_DOMICILE_PARENTAL)) { activeFormulaireAdresseAnnuelle(); } else { desactiveFormulaireAdresseAnnuelle(); } /* Panel adresse fixe */ Panel adressesFixePanel = new Panel( applicationContext.getMessage(NAME + ".panel.adressefixe.title", null, getLocale())); FormLayout formAdresseFixeLayout = new FormLayout(); formAdresseFixeLayout.setSpacing(true); formAdresseFixeLayout.setMargin(true); //AdresseFixe1 fieldFixe1 = new TextField(applicationContext.getMessage(NAME + ".fixe1", null, getLocale())); fieldFixe1.setValue(etudiant.getAdresseFixe().getAdresse1()); fieldFixe1.setNullRepresentation(""); fieldFixe1.setWidth("326px"); fieldFixe1.setMaxLength(32); fieldFixe1.setRequired(true); formAdresseFixeLayout.addComponent(fieldFixe1); //AdresseFixe2 fieldFixe2 = new TextField(applicationContext.getMessage(NAME + ".fixe2", null, getLocale())); fieldFixe2.setValue(etudiant.getAdresseFixe().getAdresse2()); fieldFixe2.setNullRepresentation(""); fieldFixe2.setWidth("326px"); fieldFixe2.setMaxLength(32); formAdresseFixeLayout.addComponent(fieldFixe2); //AdresseFixe3 fieldFixe3 = new TextField(applicationContext.getMessage(NAME + ".fixe3", null, getLocale())); fieldFixe3.setValue(etudiant.getAdresseFixe().getAdresse3()); fieldFixe3.setNullRepresentation(""); fieldFixe3.setWidth("326px"); fieldFixe3.setMaxLength(32); formAdresseFixeLayout.addComponent(fieldFixe3); //Liste des Pays lpays2 = new NativeSelect(); lpays2.setCaption(captionPays); lpays2.setNullSelectionAllowed(false); lpays2.setRequired(true); lpays2.setWidth("326px"); for (PaysDTO p : pays) { lpays2.addItem(p.getCodePay()); lpays2.setItemCaption(p.getCodePay(), p.getLibPay()); } lpays2.setValue(etudiant.getAdresseFixe().getCodPays()); lpays2.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un pays autre que France a t choisi if (!selectedValue.equals(COD_PAY_FRANCE)) { activerChampPourAdresseFixeEtranger(); } else { activerChampPourAdresseFixeEnFrance(); } } }); formAdresseFixeLayout.addComponent(lpays2); //Ville pour adresse l'tranger fieldVilleEtranger2 = new TextField( applicationContext.getMessage(NAME + ".villeetranger2", null, getLocale())); fieldVilleEtranger2.setValue(etudiant.getAdresseFixe().getAdresseetranger()); fieldVilleEtranger2.setNullRepresentation(""); fieldVilleEtranger2.setWidth("326px"); fieldVilleEtranger2.setMaxLength(5); fieldVilleEtranger2.setRequired(true); formAdresseFixeLayout.addComponent(fieldVilleEtranger2); //codePostal2 pour adresses en france fieldCodePostal2 = new TextField(applicationContext.getMessage(NAME + ".codepostal2", null, getLocale())); fieldCodePostal2.setValue(etudiant.getAdresseFixe().getCodePostal()); fieldCodePostal2.setNullRepresentation(""); fieldCodePostal2.setWidth("326px"); fieldCodePostal2.setMaxLength(5); fieldCodePostal2.setRequired(true); //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER); fieldCodePostal2.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { updateListeVillesFixe(event.getText()); } }); formAdresseFixeLayout.addComponent(fieldCodePostal2); //Ville pour adresse en france List<CommuneDTO> villes2 = adresseController.getVilles(etudiant.getAdresseFixe().getCodePostal()); lville2 = new NativeSelect(); lville2.setCaption(applicationContext.getMessage(NAME + ".ville2", null, getLocale())); lville2.setNullSelectionAllowed(false); lville2.setRequired(true); lville2.setWidth("326px"); for (CommuneDTO v : villes2) { lville2.addItem(v.getLibCommune()); lville2.setItemCaption(v.getLibCommune(), v.getLibCommune()); } codePostalVillesFixe = etudiant.getAdresseFixe().getCodePostal(); lville2.setValue(etudiant.getAdresseFixe().getVille()); lville2.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCodePostalVilleFixe(); } }); formAdresseFixeLayout.addComponent(lville2); //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification if (etudiant.getAdresseFixe().getCodPays().equals(COD_PAY_FRANCE)) { activerChampPourAdresseFixeEnFrance(); } else { activerChampPourAdresseFixeEtranger(); } //Tlphone2 fieldTelephone2 = new TextField(applicationContext.getMessage(NAME + ".tel2", null, getLocale())); fieldTelephone2.setValue(etudiant.getAdresseFixe().getNumerotel()); fieldTelephone2.setNullRepresentation(""); fieldTelephone2.setWidth("326px"); fieldTelephone2.setMaxLength(15); fieldTelephone2.setRequired(false); formAdresseFixeLayout.addComponent(fieldTelephone2); //ajout du panel adresse fixe adressesFixePanel.setContent(formAdresseFixeLayout); panelslayout.addComponent(adressesFixePanel); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); btnValider.setCaption(applicationContext.getMessage(NAME + ".btnValider", null, getLocale())); btnValider.setIcon(FontAwesome.CHECK); btnValider.addStyleName(ValoTheme.BUTTON_PRIMARY); btnValider.addClickListener(e -> { Adresse adresseAnnuelle = new Adresse(); adresseAnnuelle.setType(lhebergement.getValue().toString()); adresseAnnuelle.setAdresse1(fieldAnnu1.getValue()); adresseAnnuelle.setAdresse2(fieldAnnu2.getValue()); adresseAnnuelle.setAdresse3(fieldAnnu3.getValue()); adresseAnnuelle.setCodPays(lpays1.getValue().toString()); adresseAnnuelle.setCodePostal(fieldCodePostal1.getValue()); adresseAnnuelle.setVille((lville1.getValue() == null) ? null : lville1.getValue().toString()); adresseAnnuelle.setAdresseetranger(fieldVilleEtranger1.getValue()); adresseAnnuelle.setNumerotel(fieldTelephone1.getValue()); Adresse adresseFixe = new Adresse(); adresseFixe.setAdresse1(fieldFixe1.getValue()); adresseFixe.setAdresse2(fieldFixe2.getValue()); adresseFixe.setAdresse3(fieldFixe3.getValue()); adresseFixe.setCodPays(lpays2.getValue().toString()); adresseFixe.setCodePostal(fieldCodePostal2.getValue()); adresseFixe.setVille((lville2.getValue() == null) ? null : lville2.getValue().toString()); adresseFixe.setAdresseetranger(fieldVilleEtranger2.getValue()); adresseFixe.setNumerotel(fieldTelephone2.getValue()); erreursLayout.removeAllComponents(); List<String> retour = adresseController.majAdresses(adresseAnnuelle, adresseFixe); if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) { //ajout maj vue adresse etudiantController.recupererAdresses(); close(); } else { //affichage erreurs if (retour != null && retour.size() > 0) { String errorMsg = ""; for (String erreur : retour) { if (!errorMsg.equals("")) errorMsg = errorMsg + "<br />"; errorMsg = errorMsg + erreur; } Label labelErreur = new Label(errorMsg); labelErreur.setContentMode(ContentMode.HTML); labelErreur.setStyleName(ValoTheme.LABEL_FAILURE); erreursLayout.addComponent(labelErreur); } erreursLayout.setVisible(true); } }); buttonsLayout.addComponent(btnValider); buttonsLayout.setComponentAlignment(btnValider, Alignment.MIDDLE_CENTER); btnAnnuler.setCaption( applicationContext.getMessage("modificationAdressesWindow.btnAnnuler", null, getLocale())); btnAnnuler.setIcon(FontAwesome.TIMES); btnAnnuler.addStyleName(ValoTheme.BUTTON_DANGER); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_CENTER); layout.addComponent(buttonsLayout); /* Centre la fentre */ center(); }
From source file:fr.univlorraine.mondossierweb.views.windows.PreferencesApplicationWindow.java
License:Apache License
/** * Cre une fentre d'dition des preferences applicative * @param prfrence diter//from w w w.j a va2 s . c o m */ public PreferencesApplicationWindow(PreferencesApplication prefApp) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Formulaire */ fieldGroup = new BeanFieldGroup<>(PreferencesApplication.class); fieldGroup.setItemDataSource(prefApp); fieldGroup.setFieldFactory(new FieldGroupFieldFactory() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("rawtypes") public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) { if (fieldType == NativeSelect.class) { final NativeSelect field = new NativeSelect(); field.addItem("true"); field.addItem("false"); field.setNullSelectionAllowed(false); field.setImmediate(true); //field.setValue(centre.getTemSrv()); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { field.setValue(event.getProperty().getValue()); } }); return fieldType.cast(field); } else { final TextField field = new TextField(); field.setImmediate(true); field.addTextChangeListener(new FieldEvents.TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { if (!field.isReadOnly()) { field.setValue(event.getText()); } } }); return fieldType.cast(field); } } }); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".confAppTable." + fieldName, null, getLocale()); //Si on est sur un parametre booleen if (fieldName.equals("valeur") && estUneValeurBooleenne(prefApp.getValeur())) { //On forme le nativeSelect Field<?> field = fieldGroup.buildAndBind(caption, fieldName, NativeSelect.class); formLayout.addComponent(field); } else { Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } formLayout.addComponent(field); } } fieldGroup.getField("prefId").setReadOnly(prefApp.getPrefId() != null); fieldGroup.getField("prefDesc").setReadOnly(prefApp.getPrefDesc() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); /* Enregistre la conf saisie */ configController.saveAppParameter(prefApp); /* Ferme la fentre */ close(); } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }