List of usage examples for com.vaadin.ui VerticalLayout setVisible
@Override public void setVisible(boolean visible)
From source file:fi.semantum.strategia.widget.NumberTrafficValuation.java
License:Open Source License
private void applyValues(Main main, Meter meter, ComboBox combo, VerticalLayout vl1, Label l1, VerticalLayout vl2, Label l2, VerticalLayout vl3, Label l3, TextField tf1, TextField tf2) { inApply = true;//from w w w. j av a 2 s .c om Indicator indicator = meter.getPossibleIndicator(main.getDatabase()); String unit = indicator.getUnit(); combo.select(getState()); final double highDouble = getHighLimit().doubleValue(); final double lowDouble = getLowLimit().doubleValue(); String highLimit = df.format(highDouble); String lowLimit = df.format(lowDouble); tf1.setValue(highLimit); l1.setValue(highLimit + " < arvo " + unit); if (isIncrease()) { vl1.setStyleName("greenBlock"); } else { vl1.setStyleName("redBlock"); } tf1.removeAllValidators(); tf1.addValidator(new Validator() { private static final long serialVersionUID = 5929569929930454714L; @Override public void validate(Object value) throws InvalidValueException { try { double d = Double.parseDouble((String) value); if (d < lowDouble) throw new InvalidValueException("Value is too small"); } catch (NumberFormatException e) { throw new InvalidValueException(e.getMessage()); } } }); if (isTwo()) { l3.setVisible(false); vl3.setVisible(false); tf2.setVisible(false); tf1.setCaption("Raja-arvo"); if (isIncrease()) { vl2.setStyleName("redBlock"); } else { vl2.setStyleName("greenBlock"); } l2.setValue("arvo < " + lowLimit + " " + unit); } else { vl3.setVisible(true); l3.setVisible(true); tf2.setVisible(true); tf1.setCaption("Suurempi raja-arvo"); tf2.setCaption("Pienempi raja-arvo"); vl2.setStyleName("yellowBlock"); l2.setValue(lowLimit + " < arvo < " + highLimit + " " + unit); l3.setValue("arvo < " + lowLimit + " " + unit); tf2.setValue(lowLimit); if (isIncrease()) { vl3.setStyleName("redBlock"); } else { vl3.setStyleName("greenBlock"); } tf2.removeAllValidators(); tf2.addValidator(new Validator() { private static final long serialVersionUID = 5929569929930454714L; @Override public void validate(Object value) throws InvalidValueException { try { double d = Double.parseDouble((String) value); if (d > highDouble) throw new InvalidValueException("Value is too large"); } catch (NumberFormatException e) { throw new InvalidValueException(e.getMessage()); } } }); } inApply = false; }
From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java
License:Apache License
private void renseignerPanelContact() { VerticalLayout contactLayout = new VerticalLayout(); /* Layout pour afficher les erreurs */ VerticalLayout erreursLayout = new VerticalLayout(); contactLayout.addComponent(erreursLayout); erreursLayout.setVisible(false); /* Layout avec les champ 'Portable' et 'Email personnel' */ FormLayout formContactLayout = new FormLayout(); formContactLayout.setSpacing(true);/*from www . j a va 2s .com*/ formContactLayout.setMargin(true); String captionTelPortable = applicationContext.getMessage(NAME + ".portable.title", null, getLocale()); fieldTelPortable = new TextField(captionTelPortable, MainUI.getCurrent().getEtudiant().getTelPortable()); formatTextField(fieldTelPortable); fieldTelPortable.setMaxLength(15); formContactLayout.addComponent(fieldTelPortable); if (userController.isEtudiant()) { String captionMailPerso = applicationContext.getMessage(NAME + ".mailperso.title", null, getLocale()); fieldMailPerso = new TextField(captionMailPerso, MainUI.getCurrent().getEtudiant().getEmailPerso()); formatTextField(fieldMailPerso); fieldMailPerso.setMaxLength(200); formContactLayout.addComponent(fieldMailPerso); } contactLayout.addComponent(formContactLayout); /* Si user tudiant , modifications autorise des coordonnes de contact * et si l'tudiant possde une addresse annuelle, on affiche les boutons de modification */ if (userController.isEtudiant() && configController.isModificationCoordonneesPersoAutorisee() && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) { //Layout pour les boutons de modification HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setSizeFull(); btnLayout.setSpacing(true); btnLayout.setMargin(true); //Bouton pour valider la modification btnValidModifCoordonneesPerso = new Button( applicationContext.getMessage(NAME + ".bouton.validercoordonnees", null, getLocale())); btnValidModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_FRIENDLY); btnValidModifCoordonneesPerso.setIcon(FontAwesome.CHECK); btnValidModifCoordonneesPerso.addClickListener(e -> { erreursLayout.removeAllComponents(); List<String> retour = etudiantController.updateContact(fieldTelPortable.getValue(), fieldMailPerso.getValue(), MainUI.getCurrent().getEtudiant().getCod_etu()); //si modif ok if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) { etudiantController.recupererEtatCivil(); renseignerPanelContact(); } else { //affichage erreurs if (retour != null && retour.size() > 0) { String errorMsg = ""; for (String erreur : retour) { if (!errorMsg.equals("")) errorMsg = errorMsg + "<br />"; errorMsg = errorMsg + erreur; } Label labelErreur = new Label(errorMsg); labelErreur.setContentMode(ContentMode.HTML); labelErreur.setStyleName(ValoTheme.LABEL_FAILURE); erreursLayout.addComponent(labelErreur); } erreursLayout.setVisible(true); } }); btnValidModifCoordonneesPerso.setVisible(false); btnLayout.addComponent(btnValidModifCoordonneesPerso); btnLayout.setComponentAlignment(btnValidModifCoordonneesPerso, Alignment.MIDDLE_CENTER); //Bouton pour annuler la modification btnAnnulerModifCoordonneesPerso = new Button( applicationContext.getMessage(NAME + ".bouton.annulercoordonnees", null, getLocale())); btnAnnulerModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_DANGER); btnAnnulerModifCoordonneesPerso.setIcon(FontAwesome.TIMES); btnAnnulerModifCoordonneesPerso.addClickListener(e -> { erreursLayout.removeAllComponents(); fieldMailPerso.setValue(MainUI.getCurrent().getEtudiant().getEmailPerso()); fieldMailPerso.setEnabled(false); fieldMailPerso.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); fieldTelPortable.setValue(MainUI.getCurrent().getEtudiant().getTelPortable()); fieldTelPortable.setEnabled(false); fieldTelPortable.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); btnValidModifCoordonneesPerso.setVisible(false); btnAnnulerModifCoordonneesPerso.setVisible(false); btnModifCoordonneesPerso.setVisible(true); }); btnAnnulerModifCoordonneesPerso.setVisible(false); btnLayout.addComponent(btnAnnulerModifCoordonneesPerso); btnLayout.setComponentAlignment(btnAnnulerModifCoordonneesPerso, Alignment.MIDDLE_CENTER); //Bouton pour activer la modification des donnes btnModifCoordonneesPerso = new Button( applicationContext.getMessage(NAME + ".bouton.modifiercoordonnees", null, getLocale())); btnModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_PRIMARY); btnModifCoordonneesPerso.setIcon(FontAwesome.EDIT); btnModifCoordonneesPerso.addClickListener(e -> { fieldMailPerso.setEnabled(true); fieldMailPerso.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS); fieldTelPortable.setEnabled(true); fieldTelPortable.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS); btnValidModifCoordonneesPerso.setVisible(true); btnAnnulerModifCoordonneesPerso.setVisible(true); btnModifCoordonneesPerso.setVisible(false); }); btnLayout.addComponent(btnModifCoordonneesPerso); btnLayout.setComponentAlignment(btnModifCoordonneesPerso, Alignment.MIDDLE_CENTER); contactLayout.addComponent(btnLayout); } panelContact.setContent(contactLayout); }
From source file:fr.univlorraine.mondossierweb.views.windows.ModificationAdressesWindow.java
License:Apache License
/** * Cre une fentre de confirmation/*from w w w . j ava 2 s .c o m*/ * @param message * @param titre */ public ModificationAdressesWindow(Etudiant etudiant) { /* Style */ //setWidth(900, Unit.PIXELS); setModal(true); setResizable(false); setClosable(false); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Layout pour afficher les erreurs */ VerticalLayout erreursLayout = new VerticalLayout(); layout.addComponent(erreursLayout); erreursLayout.setVisible(false); HorizontalLayout panelslayout = new HorizontalLayout(); panelslayout.setMargin(true); panelslayout.setSpacing(true); layout.addComponent(panelslayout); /* Panel adresse annuelle */ Panel adressesAnnuellePanel = new Panel( applicationContext.getMessage(NAME + ".panel.adresseannuelle.title", null, getLocale()) + " " + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee()); FormLayout formAdresseAnnuelleLayout = new FormLayout(); formAdresseAnnuelleLayout.setSpacing(true); formAdresseAnnuelleLayout.setMargin(true); //TypeHebergement String captionHebergement = applicationContext.getMessage(NAME + ".typehebergement", null, getLocale()); TypeHebergementDTO[] hebergements = adresseController.getTypesHebergement(); lhebergement = new NativeSelect(); lhebergement.setCaption(captionHebergement); lhebergement.setNullSelectionAllowed(false); lhebergement.setRequired(true); lhebergement.setWidth("326px"); for (TypeHebergementDTO h : hebergements) { lhebergement.addItem(h.getCodTypeHebergement()); lhebergement.setItemCaption(h.getCodTypeHebergement(), h.getLibWebTypeHebergement()); } lhebergement.setValue(etudiant.getAdresseAnnuelle().getType()); lhebergement.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un hbergement autre que la Domicile parental a t choisi if (!selectedValue.equals(COD_HEBERG_DOMICILE_PARENTAL)) { activeFormulaireAdresseAnnuelle(); } else { desactiveFormulaireAdresseAnnuelle(); } } }); formAdresseAnnuelleLayout.addComponent(lhebergement); //labelChoixHebergement labelChoixHebergement = new Label( applicationContext.getMessage(NAME + ".labelhebergement", null, getLocale())); formAdresseAnnuelleLayout.addComponent(labelChoixHebergement); //AdresseAnnuelle1 fieldAnnu1 = new TextField(applicationContext.getMessage(NAME + ".annu1", null, getLocale())); fieldAnnu1.setValue(etudiant.getAdresseAnnuelle().getAdresse1()); fieldAnnu1.setNullRepresentation(""); fieldAnnu1.setWidth("326px"); fieldAnnu1.setMaxLength(32); fieldAnnu1.setRequired(true); formAdresseAnnuelleLayout.addComponent(fieldAnnu1); //AdresseAnnuelle2 fieldAnnu2 = new TextField(applicationContext.getMessage(NAME + ".annu2", null, getLocale())); fieldAnnu2.setValue(etudiant.getAdresseAnnuelle().getAdresse2()); fieldAnnu2.setNullRepresentation(""); fieldAnnu2.setWidth("326px"); fieldAnnu2.setMaxLength(32); formAdresseAnnuelleLayout.addComponent(fieldAnnu2); //AdresseAnnuelle3 fieldAnnu3 = new TextField(applicationContext.getMessage(NAME + ".annu3", null, getLocale())); fieldAnnu3.setValue(etudiant.getAdresseAnnuelle().getAdresse3()); fieldAnnu3.setNullRepresentation(""); fieldAnnu3.setWidth("326px"); fieldAnnu3.setMaxLength(32); formAdresseAnnuelleLayout.addComponent(fieldAnnu3); //Liste des Pays String captionPays = applicationContext.getMessage(NAME + ".pays1", null, getLocale()); PaysDTO[] pays = adresseController.getPays(); lpays1 = new NativeSelect(); lpays1.setCaption(captionPays); lpays1.setNullSelectionAllowed(false); lpays1.setRequired(true); lpays1.setWidth("326px"); for (PaysDTO p : pays) { lpays1.addItem(p.getCodePay()); lpays1.setItemCaption(p.getCodePay(), p.getLibPay()); } lpays1.setValue(etudiant.getAdresseAnnuelle().getCodPays()); lpays1.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un pays autre que France a t choisi if (!selectedValue.equals(COD_PAY_FRANCE)) { activerChampPourAdresseAnnuelleEtranger(); } else { activerChampPourAdresseAnnuelleEnFrance(); } } }); formAdresseAnnuelleLayout.addComponent(lpays1); //Ville pour adresse l'tranger fieldVilleEtranger1 = new TextField( applicationContext.getMessage(NAME + ".villeetranger1", null, getLocale())); fieldVilleEtranger1.setValue(etudiant.getAdresseAnnuelle().getAdresseetranger()); fieldVilleEtranger1.setNullRepresentation(""); fieldVilleEtranger1.setWidth("326px"); fieldVilleEtranger1.setMaxLength(5); fieldVilleEtranger1.setRequired(true); formAdresseAnnuelleLayout.addComponent(fieldVilleEtranger1); //codePostal1 pour adresses en france fieldCodePostal1 = new TextField(applicationContext.getMessage(NAME + ".codepostal1", null, getLocale())); fieldCodePostal1.setValue(etudiant.getAdresseAnnuelle().getCodePostal()); fieldCodePostal1.setNullRepresentation(""); fieldCodePostal1.setWidth("326px"); fieldCodePostal1.setMaxLength(5); fieldCodePostal1.setRequired(true); //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER); fieldCodePostal1.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { updateListeVillesAnnuelle(event.getText()); } }); formAdresseAnnuelleLayout.addComponent(fieldCodePostal1); //Ville pour adresse en france List<CommuneDTO> villes1 = adresseController.getVilles(etudiant.getAdresseAnnuelle().getCodePostal()); lville1 = new NativeSelect(); lville1.setCaption(applicationContext.getMessage(NAME + ".ville1", null, getLocale())); lville1.setNullSelectionAllowed(false); lville1.setRequired(true); lville1.setWidth("326px"); for (CommuneDTO v : villes1) { lville1.addItem(v.getLibCommune()); lville1.setItemCaption(v.getLibCommune(), v.getLibCommune()); } codePostalVillesAnnu = etudiant.getAdresseAnnuelle().getCodePostal(); lville1.setValue(etudiant.getAdresseAnnuelle().getVille()); lville1.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCodePostalVilleAnnuelle(); } }); formAdresseAnnuelleLayout.addComponent(lville1); //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification if (etudiant.getAdresseAnnuelle().getCodPays().equals(COD_PAY_FRANCE)) { activerChampPourAdresseAnnuelleEnFrance(); } else { activerChampPourAdresseAnnuelleEtranger(); } //Tlphone1 fieldTelephone1 = new TextField(applicationContext.getMessage(NAME + ".tel1", null, getLocale())); fieldTelephone1.setValue(etudiant.getAdresseAnnuelle().getNumerotel()); fieldTelephone1.setNullRepresentation(""); fieldTelephone1.setWidth("326px"); fieldTelephone1.setMaxLength(15); fieldTelephone1.setRequired(false); formAdresseAnnuelleLayout.addComponent(fieldTelephone1); //ajout du panel adresse Annuelle adressesAnnuellePanel.setContent(formAdresseAnnuelleLayout); panelslayout.addComponent(adressesAnnuellePanel); //Si un hbergement autre que la Domicile parental a t choisi if (!etudiant.getAdresseAnnuelle().getType().equals(COD_HEBERG_DOMICILE_PARENTAL)) { activeFormulaireAdresseAnnuelle(); } else { desactiveFormulaireAdresseAnnuelle(); } /* Panel adresse fixe */ Panel adressesFixePanel = new Panel( applicationContext.getMessage(NAME + ".panel.adressefixe.title", null, getLocale())); FormLayout formAdresseFixeLayout = new FormLayout(); formAdresseFixeLayout.setSpacing(true); formAdresseFixeLayout.setMargin(true); //AdresseFixe1 fieldFixe1 = new TextField(applicationContext.getMessage(NAME + ".fixe1", null, getLocale())); fieldFixe1.setValue(etudiant.getAdresseFixe().getAdresse1()); fieldFixe1.setNullRepresentation(""); fieldFixe1.setWidth("326px"); fieldFixe1.setMaxLength(32); fieldFixe1.setRequired(true); formAdresseFixeLayout.addComponent(fieldFixe1); //AdresseFixe2 fieldFixe2 = new TextField(applicationContext.getMessage(NAME + ".fixe2", null, getLocale())); fieldFixe2.setValue(etudiant.getAdresseFixe().getAdresse2()); fieldFixe2.setNullRepresentation(""); fieldFixe2.setWidth("326px"); fieldFixe2.setMaxLength(32); formAdresseFixeLayout.addComponent(fieldFixe2); //AdresseFixe3 fieldFixe3 = new TextField(applicationContext.getMessage(NAME + ".fixe3", null, getLocale())); fieldFixe3.setValue(etudiant.getAdresseFixe().getAdresse3()); fieldFixe3.setNullRepresentation(""); fieldFixe3.setWidth("326px"); fieldFixe3.setMaxLength(32); formAdresseFixeLayout.addComponent(fieldFixe3); //Liste des Pays lpays2 = new NativeSelect(); lpays2.setCaption(captionPays); lpays2.setNullSelectionAllowed(false); lpays2.setRequired(true); lpays2.setWidth("326px"); for (PaysDTO p : pays) { lpays2.addItem(p.getCodePay()); lpays2.setItemCaption(p.getCodePay(), p.getLibPay()); } lpays2.setValue(etudiant.getAdresseFixe().getCodPays()); lpays2.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String selectedValue = (String) event.getProperty().getValue(); //Si un pays autre que France a t choisi if (!selectedValue.equals(COD_PAY_FRANCE)) { activerChampPourAdresseFixeEtranger(); } else { activerChampPourAdresseFixeEnFrance(); } } }); formAdresseFixeLayout.addComponent(lpays2); //Ville pour adresse l'tranger fieldVilleEtranger2 = new TextField( applicationContext.getMessage(NAME + ".villeetranger2", null, getLocale())); fieldVilleEtranger2.setValue(etudiant.getAdresseFixe().getAdresseetranger()); fieldVilleEtranger2.setNullRepresentation(""); fieldVilleEtranger2.setWidth("326px"); fieldVilleEtranger2.setMaxLength(5); fieldVilleEtranger2.setRequired(true); formAdresseFixeLayout.addComponent(fieldVilleEtranger2); //codePostal2 pour adresses en france fieldCodePostal2 = new TextField(applicationContext.getMessage(NAME + ".codepostal2", null, getLocale())); fieldCodePostal2.setValue(etudiant.getAdresseFixe().getCodePostal()); fieldCodePostal2.setNullRepresentation(""); fieldCodePostal2.setWidth("326px"); fieldCodePostal2.setMaxLength(5); fieldCodePostal2.setRequired(true); //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER); fieldCodePostal2.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { updateListeVillesFixe(event.getText()); } }); formAdresseFixeLayout.addComponent(fieldCodePostal2); //Ville pour adresse en france List<CommuneDTO> villes2 = adresseController.getVilles(etudiant.getAdresseFixe().getCodePostal()); lville2 = new NativeSelect(); lville2.setCaption(applicationContext.getMessage(NAME + ".ville2", null, getLocale())); lville2.setNullSelectionAllowed(false); lville2.setRequired(true); lville2.setWidth("326px"); for (CommuneDTO v : villes2) { lville2.addItem(v.getLibCommune()); lville2.setItemCaption(v.getLibCommune(), v.getLibCommune()); } codePostalVillesFixe = etudiant.getAdresseFixe().getCodePostal(); lville2.setValue(etudiant.getAdresseFixe().getVille()); lville2.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCodePostalVilleFixe(); } }); formAdresseFixeLayout.addComponent(lville2); //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification if (etudiant.getAdresseFixe().getCodPays().equals(COD_PAY_FRANCE)) { activerChampPourAdresseFixeEnFrance(); } else { activerChampPourAdresseFixeEtranger(); } //Tlphone2 fieldTelephone2 = new TextField(applicationContext.getMessage(NAME + ".tel2", null, getLocale())); fieldTelephone2.setValue(etudiant.getAdresseFixe().getNumerotel()); fieldTelephone2.setNullRepresentation(""); fieldTelephone2.setWidth("326px"); fieldTelephone2.setMaxLength(15); fieldTelephone2.setRequired(false); formAdresseFixeLayout.addComponent(fieldTelephone2); //ajout du panel adresse fixe adressesFixePanel.setContent(formAdresseFixeLayout); panelslayout.addComponent(adressesFixePanel); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); btnValider.setCaption(applicationContext.getMessage(NAME + ".btnValider", null, getLocale())); btnValider.setIcon(FontAwesome.CHECK); btnValider.addStyleName(ValoTheme.BUTTON_PRIMARY); btnValider.addClickListener(e -> { Adresse adresseAnnuelle = new Adresse(); adresseAnnuelle.setType(lhebergement.getValue().toString()); adresseAnnuelle.setAdresse1(fieldAnnu1.getValue()); adresseAnnuelle.setAdresse2(fieldAnnu2.getValue()); adresseAnnuelle.setAdresse3(fieldAnnu3.getValue()); adresseAnnuelle.setCodPays(lpays1.getValue().toString()); adresseAnnuelle.setCodePostal(fieldCodePostal1.getValue()); adresseAnnuelle.setVille((lville1.getValue() == null) ? null : lville1.getValue().toString()); adresseAnnuelle.setAdresseetranger(fieldVilleEtranger1.getValue()); adresseAnnuelle.setNumerotel(fieldTelephone1.getValue()); Adresse adresseFixe = new Adresse(); adresseFixe.setAdresse1(fieldFixe1.getValue()); adresseFixe.setAdresse2(fieldFixe2.getValue()); adresseFixe.setAdresse3(fieldFixe3.getValue()); adresseFixe.setCodPays(lpays2.getValue().toString()); adresseFixe.setCodePostal(fieldCodePostal2.getValue()); adresseFixe.setVille((lville2.getValue() == null) ? null : lville2.getValue().toString()); adresseFixe.setAdresseetranger(fieldVilleEtranger2.getValue()); adresseFixe.setNumerotel(fieldTelephone2.getValue()); erreursLayout.removeAllComponents(); List<String> retour = adresseController.majAdresses(adresseAnnuelle, adresseFixe); if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) { //ajout maj vue adresse etudiantController.recupererAdresses(); close(); } else { //affichage erreurs if (retour != null && retour.size() > 0) { String errorMsg = ""; for (String erreur : retour) { if (!errorMsg.equals("")) errorMsg = errorMsg + "<br />"; errorMsg = errorMsg + erreur; } Label labelErreur = new Label(errorMsg); labelErreur.setContentMode(ContentMode.HTML); labelErreur.setStyleName(ValoTheme.LABEL_FAILURE); erreursLayout.addComponent(labelErreur); } erreursLayout.setVisible(true); } }); buttonsLayout.addComponent(btnValider); buttonsLayout.setComponentAlignment(btnValider, Alignment.MIDDLE_CENTER); btnAnnuler.setCaption( applicationContext.getMessage("modificationAdressesWindow.btnAnnuler", null, getLocale())); btnAnnuler.setIcon(FontAwesome.TIMES); btnAnnuler.addStyleName(ValoTheme.BUTTON_DANGER); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_CENTER); layout.addComponent(buttonsLayout); /* Centre la fentre */ center(); }
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java
License:Open Source License
public AdminAuthView() { setSizeFull();/*w ww. ja v a2s. c o m*/ VerticalLayout header = new VerticalLayout(); header.setSizeFull(); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); addComponents(header, content); setExpandRatio(header, 1); setExpandRatio(content, 6); welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>"); welcomeText.setContentMode(ContentMode.HTML); welcomeText.setSizeUndefined(); header.addComponent(welcomeText); header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER); Panel controlPanel = new Panel("Administrator control panel"); controlPanel.setSizeUndefined(); Panel addCoordPanel = new Panel("Create a new coordinator"); addCoordPanel.setSizeUndefined(); Panel messagesPanel = new Panel("Administrator messages"); messagesPanel.setWidth("580px"); Table adminMessagesTable = new Table(); adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource()); adminMessagesTable.setColumnWidth("inputEvent", 180); adminMessagesTable.setSizeFull(); VerticalLayout controlLayout = new VerticalLayout(controlPanel); controlLayout.setSizeFull(); controlLayout.setMargin(false); controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER); VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel); coordOperationsLayout.setSizeFull(); coordOperationsLayout.setMargin(false); coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER); /******************************************/ coordOperationsLayout.setVisible(true); // main layout in the middle addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator" /******************************************/ HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel); VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable); messagesExternalLayout.setSizeFull(); messagesExternalLayout.setMargin(false); messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER); messagesInternalLayout.setMargin(false); messagesInternalLayout.setSizeFull(); messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER); messagesPanel.setContent(messagesInternalLayout); TextField idCoordAdd = new TextField(); TextField loginCoord = new TextField(); PasswordField pwdCoord = new PasswordField(); Label idCaptionAdd = new Label("ID"); Label loginCaption = new Label("Login"); Label pwdCaption = new Label("Password"); idCaptionAdd.setSizeUndefined(); idCoordAdd.setSizeUndefined(); loginCaption.setSizeUndefined(); loginCoord.setSizeUndefined(); pwdCaption.setSizeUndefined(); pwdCoord.setSizeUndefined(); Button validateNewCoord = new Button("Validate"); validateNewCoord.setClickShortcut(KeyCode.ENTER); validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY); GridLayout addCoordinatorLayout = new GridLayout(2, 4); addCoordinatorLayout.setSpacing(true); addCoordinatorLayout.setMargin(true); addCoordinatorLayout.setSizeFull(); addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption, pwdCoord); addCoordinatorLayout.addComponent(validateNewCoord, 1, 3); addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT); addCoordPanel.setContent(addCoordinatorLayout); content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setExpandRatio(controlLayout, 20); content.setExpandRatio(coordOperationsLayout, 10); content.setExpandRatio(messagesExternalLayout, 28); Button addCoordinator = new Button("Add coordinator"); Button deleteCoordinator = new Button("Delete coordinator"); addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE); VerticalLayout buttons = new VerticalLayout(); buttons.setMargin(true); buttons.setSpacing(true); buttons.setSizeFull(); buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); controlPanel.setContent(buttons); buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn); /******* DELETE COORDINATOR PANEL BEGIN *********/ Label idCaptionDel = new Label("ID"); TextField idCoordDel = new TextField(); Panel delCoordPanel = new Panel("Delete a coordinator"); coordOperationsLayout.addComponent(delCoordPanel); delCoordPanel.setVisible(false); coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER); delCoordPanel.setSizeUndefined(); GridLayout delCoordinatorLayout = new GridLayout(2, 2); delCoordinatorLayout.setSpacing(true); delCoordinatorLayout.setMargin(true); delCoordinatorLayout.setSizeFull(); Button deleteCoordBtn = new Button("Delete"); deleteCoordBtn.setClickShortcut(KeyCode.ENTER); deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY); delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel); delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1); delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT); delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT); delCoordPanel.setContent(delCoordinatorLayout); /******* DELETE COORDINATOR PANEL END *********/ /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/ addCoordinator.addClickListener(event -> { if (!addCoordPanel.isVisible()) { delCoordPanel.setVisible(false); addCoordPanel.setVisible(true); idCoordAdd.focus(); } else addCoordPanel.setVisible(false); }); deleteCoordinator.addClickListener(event -> { if (!delCoordPanel.isVisible()) { addCoordPanel.setVisible(false); delCoordPanel.setVisible(true); idCoordDel.focus(); } else delCoordPanel.setVisible(false); }); /************************************************* MAIN BUTTONS LOGIC END *************************************************/ /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/ validateNewCoord.addClickListener(event -> { String currentURL = Page.getCurrent().getLocation().toString(); int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName); String iCrashURL = currentURL.substring(0, strIndexCreator); String googleShebang = "#!"; String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang; try { sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())), new DtLogin(new PtString(loginCoord.getValue())), new DtPassword(new PtString(pwdCoord.getValue()))); // open new browser tab with the newly created coordinator console... // "_blank" instructs the browser to open a new tab instead of a new window... // unhappily not all browsers interpret it correctly, // some versions of some browsers might still open a new window instead (notably Firefox)! Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank"); } catch (Exception e) { e.printStackTrace(); } idCoordAdd.setValue(""); loginCoord.setValue(""); pwdCoord.setValue(""); idCoordAdd.focus(); }); /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/ /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/ deleteCoordBtn.addClickListener(event -> { IcrashSystem sys = IcrashSystem.getInstance(); try { sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue()))); } catch (Exception e) { e.printStackTrace(); } idCoordDel.setValue(""); idCoordDel.focus(); }); /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/ }
From source file:org.abstractform.binding.vaadin.VaadinBindingFormToolkit.java
License:Apache License
private ComponentContainer addValidationSummaryField(Component oldMain, boolean validationSummaryVisible) { // add error sumary layout VerticalLayout main = new VerticalLayout(); VerticalLayout summary = new VerticalLayout(); summary.setVisible(validationSummaryVisible); main.addComponent(summary);//from www . j a v a2 s . c o m main.addComponent(oldMain); return main; }
From source file:org.abstractform.vaadin.VaadinFormToolkit.java
License:Apache License
private AbstractComponentContainer buildDrawer(final Drawer drawer, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { VerticalLayout layout = new VerticalLayout(); final Button button = new Button(); // button.setStyleName(BaseTheme.BUTTON_LINK); button.setCaption("\u25B6" + drawer.getName()); final VerticalLayout innerLayout = new VerticalLayout(); for (Component component : drawer.getChildList()) { ComponentContainer container = buildComponent(component, mapComponents, fieldIdList, extraObjects); innerLayout.addComponent(container); }//from www . j a v a2 s. com button.addListener(new Button.ClickListener() { private static final long serialVersionUID = 4970466538378502562L; @Override public void buttonClick(ClickEvent event) { innerLayout.setVisible(!innerLayout.isVisible()); if (innerLayout.isVisible()) { button.setCaption("\u25BC" + drawer.getName()); } else { button.setCaption("\u25B6" + drawer.getName()); } } }); layout.addComponent(button); layout.addComponent(innerLayout); innerLayout.setVisible(false); return layout; }
From source file:probe.com.view.body.quantdatasetsoverview.quantproteinstabsheet.peptidescontainer.popupcomponents.PeptideSequenceContainer.java
public void showPtms(boolean show) { for (VerticalLayout ptmLayout : ptmsLayoutMap) { ptmLayout.setVisible(show); }/* w w w. j a va2 s . c o m*/ }
From source file:roart.client.MyVaadinUI.java
private void setVisibilities() { if ((boolean) getSession().getAttribute("authenticate")) { Button login = (Button) getSession().getAttribute("login"); Button logout = (Button) getSession().getAttribute("logout"); if (!getSession().getAttribute(Constants.USER).equals(Constants.NONE)) { login.setVisible(false);/* ww w. ja va2s . c om*/ logout.setVisible(true); } else { logout.setVisible(false); login.setVisible(true); } } VerticalLayout cpTab = (VerticalLayout) getSession().getAttribute("controlpanel"); if (Constants.ADMIN.equals(getSession().getAttribute(Constants.USER))) { cpTab.setVisible(true); statLabel.setVisible(true); ClientRunner.uiset.putIfAbsent(this, "value"); } else { cpTab.setVisible(false); statLabel.setVisible(false); ClientRunner.uiset.remove(this, "value"); } VerticalLayout sTab = (VerticalLayout) getSession().getAttribute("search"); if (!Constants.NONE.equals(getSession().getAttribute(Constants.USER))) { sTab.setVisible(true); } else { sTab.setVisible(false); } }
From source file:views.ProjectView.java
License:Open Source License
public void initProjectInfos(Collection<ProjectInfo> collection) { projectMap = new HashMap<String, ProjectInfo>(); projectTable.removeAllItems();/*from w w w . j a v a2 s. c o m*/ for (ProjectInfo p : collection) { String code = p.getProjectCode(); projectMap.put(code, p); List<Object> row = new ArrayList<Object>(); row.add(code); row.add(p.getProjectName()); row.add(p.getSpace()); row.add(p.getInvestigator()); projectTable.addItem(row.toArray(new Object[row.size()]), code); } // sort ascending by Project ID // projectTable.sort(new Object[] {"Sub-Project"}, new boolean[] {true}); VerticalLayout projectInfo = new VerticalLayout(); projectInfo.setVisible(false); altName = new TextField("Short Title"); altName.setWidth("300px"); altName.setStyleName(Styles.textStyle); investigator = new ComboBox("Principal Investigator", personMap.keySet()); investigator.setStyleName(Styles.boxStyle); investigator.setFilteringMode(FilteringMode.CONTAINS); contact = new ComboBox("Contact Person", personMap.keySet()); contact.setStyleName(Styles.boxStyle); contact.setFilteringMode(FilteringMode.CONTAINS); manager = new ComboBox("Project Manager", personMap.keySet()); manager.setStyleName(Styles.boxStyle); manager.setFilteringMode(FilteringMode.CONTAINS); submitInfo = new Button("Change Project Information"); projectInfo.addComponent(altName); projectInfo.addComponent(investigator); projectInfo.addComponent(contact); projectInfo.addComponent(manager); projectInfo.addComponent(submitInfo); projectInfo.setSpacing(true); addComponent(projectInfo); projectTable.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = -3035074733968253748L; @Override public void valueChange(ValueChangeEvent event) { projectInfo.setVisible(false); Object item = projectTable.getValue(); if (item != null) { projectInfo.setVisible(true); projectInfo.setCaption(projectMap.get(item).getProjectCode()); System.out.println(projectMap.get(item)); altName.setValue(projectMap.get(item).getProjectName()); investigator.setValue(projectMap.get(item).getInvestigator()); contact.setValue(projectMap.get(item).getContact()); manager.setValue(projectMap.get(item).getManager()); } } }); }