List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:fr.univlorraine.mondossierweb.views.windows.ModificationAdressesWindow.java
License:Apache License
/** * Cre une fentre de confirmation/*ww w .j av a 2s . c om*/ * @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 ww .j av a 2 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(); }
From source file:fr.univlorraine.mondossierweb.views.windows.SignificationsMobileWindow.java
License:Apache License
/** * Cre une fentre// w ww . j a v a 2 s.co m */ public SignificationsMobileWindow(boolean afficherSignificationIndicateurProfondeur) { setWidth("95%"); setHeight("95%"); setCaption(applicationContext.getMessage("significationsWindow.title", null, getLocale())); setModal(true); setResizable(false); setClosable(false); setStyleName("v-popover-blank"); VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); setContent(layout); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setWidth("100%"); panelLayout.setStyleName("v-scrollableelement"); panelLayout.setSpacing(true); panelLayout.setMargin(true); if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) { Panel panelSignificationResultats = new Panel(); panelSignificationResultats.setCaption( applicationContext.getMessage(NAME + ".info.significations.resultats", null, getLocale())); panelSignificationResultats.addStyleName("significationpanel"); panelSignificationResultats.setWidth("100%"); VerticalLayout significationLayout = new VerticalLayout(); significationLayout.setWidth("100%"); significationLayout.setMargin(true); significationLayout.setSpacing(true); Set<String> ss = MdwTouchkitUI.getCurrent().getEtudiant().getSignificationResultats().keySet(); for (String k : ss) { if (k != null && !k.equals("") && !k.equals(" ")) { HorizontalLayout signLayout = new HorizontalLayout(); signLayout.setSizeFull(); signLayout.setMargin(true); signLayout.setSpacing(true); Label codeLabel = new Label(k); codeLabel.setStyleName(ValoTheme.LABEL_BOLD); codeLabel.addStyleName("v-label-align-right"); signLayout.addComponent(codeLabel); Label valueLabel = new Label( "" + MdwTouchkitUI.getCurrent().getEtudiant().getSignificationResultats().get(k)); signLayout.addComponent(valueLabel); significationLayout.addComponent(signLayout); } } panelSignificationResultats.setContent(significationLayout); panelLayout.addComponent(panelSignificationResultats); } if (afficherSignificationIndicateurProfondeur) { Panel panelSignificationIndicateurs = new Panel(); panelSignificationIndicateurs.setCaption( applicationContext.getMessage(NAME + ".info.significations.indicateurs", null, getLocale())); panelSignificationIndicateurs.addStyleName("significationpanel"); panelSignificationIndicateurs.setWidth("100%"); VerticalLayout significationLayout = new VerticalLayout(); significationLayout.setMargin(true); significationLayout.setSpacing(true); significationLayout.setWidth("100%"); //1er NIVEAU HorizontalLayout levelLayout1 = new HorizontalLayout(); levelLayout1.setWidth("100%"); HorizontalLayout levelMainLayout1 = new HorizontalLayout(); levelMainLayout1.setWidth("100%"); levelMainLayout1.setSpacing(true); levelMainLayout1.setStyleName("level-indicator-layout"); int k = 0; for (int i = 0; i < 1; i++) { //Ajout d'un level k++; Label libLevelLayout = new Label(); libLevelLayout.setSizeFull(); libLevelLayout.setHeight("8px"); libLevelLayout.setStyleName("layout-level-green-indicator"); levelMainLayout1.addComponent(libLevelLayout); } //On pense avoir 7 level maxi for (int j = k; j < 8; j++) { Label libLevelSpaceLayout = new Label(); libLevelSpaceLayout.setSizeFull(); libLevelSpaceLayout.setHeight("8px"); levelMainLayout1.addComponent(libLevelSpaceLayout); } levelLayout1.addComponent(levelMainLayout1); levelLayout1.addComponent(new Label("1er niveau")); significationLayout.addComponent(levelLayout1); //2em NIVEAU HorizontalLayout levelLayout2 = new HorizontalLayout(); levelLayout2.setSizeFull(); HorizontalLayout levelMainLayout2 = new HorizontalLayout(); levelMainLayout2.setSizeFull(); levelMainLayout2.setSpacing(true); levelMainLayout2.setStyleName("level-indicator-layout"); k = 0; for (int i = 0; i < 2; i++) { //Ajout d'un level k++; Label libLevelLayout = new Label(); libLevelLayout.setSizeFull(); libLevelLayout.setHeight("8px"); libLevelLayout.setStyleName("layout-level-green-indicator"); levelMainLayout2.addComponent(libLevelLayout); } //On pense avoir 7 level maxi for (int j = k; j < 8; j++) { Label libLevelSpaceLayout = new Label(); libLevelSpaceLayout.setSizeFull(); libLevelSpaceLayout.setHeight("8px"); levelMainLayout2.addComponent(libLevelSpaceLayout); } levelLayout2.addComponent(levelMainLayout2); levelLayout2.addComponent(new Label("2em niveau")); significationLayout.addComponent(levelLayout2); //3em NIVEAU HorizontalLayout levelLayout3 = new HorizontalLayout(); levelLayout3.setSizeFull(); HorizontalLayout levelMainLayout3 = new HorizontalLayout(); levelMainLayout3.setSizeFull(); levelMainLayout3.setSpacing(true); levelMainLayout3.setStyleName("level-indicator-layout"); k = 0; for (int i = 0; i < 3; i++) { //Ajout d'un level k++; Label libLevelLayout = new Label(); libLevelLayout.setSizeFull(); libLevelLayout.setHeight("8px"); libLevelLayout.setStyleName("layout-level-green-indicator"); levelMainLayout3.addComponent(libLevelLayout); } //On pense avoir 7 level maxi for (int j = k; j < 8; j++) { Label libLevelSpaceLayout = new Label(); libLevelSpaceLayout.setSizeFull(); libLevelSpaceLayout.setHeight("8px"); levelMainLayout3.addComponent(libLevelSpaceLayout); } levelLayout3.addComponent(levelMainLayout3); levelLayout3.addComponent(new Label("3em niveau")); significationLayout.addComponent(levelLayout3); //4em NIVEAU HorizontalLayout levelLayout4 = new HorizontalLayout(); levelLayout4.setSizeFull(); HorizontalLayout levelMainLayout4 = new HorizontalLayout(); levelMainLayout4.setSizeFull(); levelMainLayout4.setSpacing(true); levelMainLayout4.setStyleName("level-indicator-layout"); k = 0; for (int i = 0; i < 4; i++) { //Ajout d'un level k++; Label libLevelLayout = new Label(); libLevelLayout.setSizeFull(); libLevelLayout.setHeight("8px"); libLevelLayout.setStyleName("layout-level-green-indicator"); levelMainLayout4.addComponent(libLevelLayout); } //On pense avoir 7 level maxi for (int j = k; j < 8; j++) { Label libLevelSpaceLayout = new Label(); libLevelSpaceLayout.setSizeFull(); libLevelSpaceLayout.setHeight("8px"); levelMainLayout4.addComponent(libLevelSpaceLayout); } levelLayout4.addComponent(levelMainLayout4); levelLayout4.addComponent(new Label("4em niveau")); significationLayout.addComponent(levelLayout4); //ETC HorizontalLayout levelLayoutEtc = new HorizontalLayout(); levelLayoutEtc.setSizeFull(); levelLayoutEtc.addComponent(new Label("...")); levelLayoutEtc.addComponent(new Label("")); significationLayout.addComponent(levelLayoutEtc); panelSignificationIndicateurs.setContent(significationLayout); panelLayout.addComponent(panelSignificationIndicateurs); } layout.addComponent(panelLayout); // close button HorizontalLayout bLayout = new HorizontalLayout(); bLayout.setSizeFull(); bLayout.setHeight("50px"); Button closeButton = new Button(); //closeButton.setCaption(applicationContext.getMessage("significationsWindow.btnFermer", null, getLocale())); closeButton.setStyleName(ValoTheme.BUTTON_PRIMARY); closeButton.addStyleName("v-popover-button"); closeButton.setIcon(FontAwesome.CHECK); closeButton.addClickListener(e -> { close(); }); bLayout.addComponent(closeButton); bLayout.setComponentAlignment(closeButton, Alignment.MIDDLE_CENTER); layout.addComponent(bLayout); layout.setExpandRatio(panelLayout, 1); }
From source file:fr.univlorraine.mondossierweb.views.windows.SwapUtilisateurWindow.java
License:Apache License
/** * Cre une fentre d'dition du swap utilisateur * @param swap utilisateur diter//from ww w .j a v a2s . c om */ public SwapUtilisateurWindow(UtilisateurSwap swap, boolean ajout) { /* 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 */ if (ajout) { setCaption(applicationContext.getMessage(NAME + ".title.ajout", null, getLocale())); } else { setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); } /* Formulaire */ fieldGroup = new BeanFieldGroup<>(UtilisateurSwap.class); fieldGroup.setItemDataSource(swap); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".swapUserTable." + fieldName, null, getLocale()); Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } if (field instanceof DateField) { ((DateField) field).setResolution(DateField.RESOLUTION_MIN); } formLayout.addComponent(field); } //fieldGroup.getField("loginCible").setReadOnly(swap.getLoginCible() != null); fieldGroup.getField("loginSource").setReadOnly(swap.getLoginSource() != 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(); boolean commitok = true; if (ajout) { //On regarde si le login source n'est pas dj dans la table String loginSource = (String) fieldGroup.getField("loginSource").getValue(); if (configController.getSwapUtilisateur(loginSource) != null) { commitok = false; //afficher message d'erreur Notification.show(applicationContext.getMessage(NAME + ".error.loginexistant", null, UI.getCurrent().getLocale()), Notification.Type.ERROR_MESSAGE); } } if (commitok) { /* Enregistre le swap saisie */ configController.saveSwap(swap); /* Ferme la fentre */ close(); } } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:gms.demo.service.presentation.ui.CreateMemberInfoPanel.java
License:Open Source License
CreateMemberInfoPanel(MainUI app) { this.app = app; // createButton form and data source Form form = new Form(); form.setCaption("Create New MemberInfo"); form.setWriteThrough(false);// www .j a v a 2 s . c om form.setItemDataSource(propertysetItem); // validation // todo: more of these form.getField(PORT).addValidator(new IntegerValidator(PORT + " field must be an integer.")); // buttons createButton = new Button("Create", form, "commit"); Button resetButton = new Button("Reset", form, "discard"); cancelButton = new Button("Cancel"); form.getFooter().addComponent(createButton); form.getFooter().addComponent(resetButton); form.getFooter().addComponent(cancelButton); form.setWidth(24f, Sizeable.UNITS_EM); // explanatory text Label instructions = new Label(INSTRUCTIONS_TEXT, Label.CONTENT_XHTML); instructions.setWidth(24f, Sizeable.UNITS_EM); // now add to panel HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSpacing(true); hLayout.addComponent(form); hLayout.addComponent(instructions); hLayout.setComponentAlignment(instructions, Alignment.MIDDLE_LEFT); addComponent(hLayout); }
From source file:info.magnolia.ui.form.field.MultiField.java
License:Open Source License
/** * Create a single element.<br>/* ww w. ja v a2 s .co m*/ * This single element is composed of:<br> * - a configured field <br> * - a remove Button<br> */ private Component createEntryComponent(Object propertyId, Property<?> property) { final HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeight(-1, Unit.PIXELS); final Field<?> field = createLocalField(fieldDefinition, property, true); // creates property datasource if given property is null layout.addComponent(field); // bind the field's property to the item if (property == null) { property = field.getPropertyDataSource(); ((PropertysetItem) getPropertyDataSource().getValue()).addItemProperty(propertyId, property); } final Property<?> propertyReference = property; // set layout to full width layout.setWidth(100, Unit.PERCENTAGE); // distribute space in favour of field over delete button layout.setExpandRatio(field, 1); if (definition.isReadOnly()) { return layout; } // move up Button Button moveUpButton = new Button(); moveUpButton.setHtmlContentAllowed(true); moveUpButton.setCaption("<span class=\"" + "icon-arrow2_n" + "\"></span>"); moveUpButton.addStyleName("inline"); moveUpButton.setDescription(buttonCaptionMoveUp); moveUpButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { onMove(layout, propertyReference, true); } }); // move down Button Button moveDownButton = new Button(); moveDownButton.setHtmlContentAllowed(true); moveDownButton.setCaption("<span class=\"" + "icon-arrow2_s" + "\"></span>"); moveDownButton.addStyleName("inline"); moveDownButton.setDescription(buttonCaptionMoveDown); moveDownButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { onMove(layout, propertyReference, false); } }); // Delete Button Button deleteButton = new Button(); deleteButton.setHtmlContentAllowed(true); deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>"); deleteButton.addStyleName("inline"); deleteButton.setDescription(buttonCaptionRemove); deleteButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { onDelete(layout, propertyReference); } }); layout.addComponents(moveUpButton, moveDownButton, deleteButton); // make sure button stays aligned with the field and not with the optional field label when used layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_RIGHT); layout.setComponentAlignment(moveUpButton, Alignment.BOTTOM_RIGHT); layout.setComponentAlignment(moveDownButton, Alignment.BOTTOM_RIGHT); return layout; }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Build the Completed Action Layout.//from w ww. j a v a2s . c o m */ protected Layout createCompletedActionLayout() { // Action Button (Upload new or delete). Default is always Upload HorizontalLayout actionLayout = new HorizontalLayout(); actionLayout.setSizeUndefined(); actionLayout.addStyleName("buttons"); actionLayout.setSpacing(true); // Add Upload Button getUpload().setButtonCaption(getCaption(selectAnotherCaption, null)); actionLayout.addComponent(getUpload()); // Add Remove Button if a file is present. if (!getValue().isEmpty()) { Button delete = createDeleteButton(); actionLayout.addComponent(delete); actionLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); } return actionLayout; }
From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java
public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker, final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes, final NodeType nodeType) { super("Add New Node"); setModal(true);/* w ww . ja v a 2s . c o m*/ setWidth(650, Unit.PIXELS); setHeight(450, Unit.PIXELS); GridLayout content = new GridLayout(1, 3); content.setSizeFull(); content.setMargin(true); content.setSpacing(true); HorizontalLayout topContent = new HorizontalLayout(); topContent.setSpacing(true); content.addComponent(topContent); topContent.addComponent(new Label("Nodes:")); final ComboBox hadoopNodes = new ComboBox(); hadoopNodes.setId("HadoopNodesCb"); hadoopNodes.setImmediate(true); hadoopNodes.setTextInputAllowed(false); hadoopNodes.setNullSelectionAllowed(false); hadoopNodes.setRequired(true); hadoopNodes.setWidth(200, Unit.PIXELS); for (EnvironmentContainerHost node : nodes) { hadoopNodes.addItem(node); hadoopNodes.setItemCaption(node, node.getHostname()); } if (nodes.size() == 0) { return; } hadoopNodes.setValue(nodes.iterator().next()); topContent.addComponent(hadoopNodes); final Button addNodeBtn = new Button("Add"); addNodeBtn.setId("AddSelectedNode"); topContent.addComponent(addNodeBtn); final Button ok = new Button("Ok"); addNodeBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addNodeBtn.setEnabled(false); ok.setEnabled(false); showProgress(); EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue(); final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(), containerHost.getHostname(), nodeType); executorService.execute(new Runnable() { public void run() { while (track) { TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY, trackID); if (po != null) { setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n" + po.getLog()); if (po.getState() != OperationState.RUNNING) { hideProgress(); ok.setEnabled(true); break; } } else { setOutput("Product operation not found. Check logs"); break; } try { Thread.sleep(1000); } catch (InterruptedException ex) { break; } } } }); } }); outputTxtArea = new TextArea("Operation output"); outputTxtArea.setId("outputTxtArea"); outputTxtArea.setRows(13); outputTxtArea.setColumns(43); outputTxtArea.setImmediate(true); outputTxtArea.setWordwrap(true); content.addComponent(outputTxtArea); indicator = new Label(); indicator.setId("indicator"); indicator.setIcon(new ThemeResource("img/spinner.gif")); indicator.setContentMode(ContentMode.HTML); indicator.setHeight(11, Unit.PIXELS); indicator.setWidth(50, Unit.PIXELS); indicator.setVisible(false); ok.setId("btnOk"); ok.setStyleName("default"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //close window track = false; close(); } }); HorizontalLayout bottomContent = new HorizontalLayout(); bottomContent.addComponent(indicator); bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT); bottomContent.addComponent(ok); content.addComponent(bottomContent); content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT); setContent(content); }
From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java
public Manager(final ExecutorService executorService, final Accumulo accumulo, Hadoop hadoop, final Zookeeper zookeeper, Tracker tracker, EnvironmentManager environmentManager) throws NamingException { this.executorService = executorService; this.accumulo = accumulo; this.hadoop = hadoop; this.zookeeper = zookeeper; this.tracker = tracker; this.environmentManager = environmentManager; contentRoot = new GridLayout(); contentRoot.setSpacing(true);/*from www.j a v a2s.co m*/ contentRoot.setMargin(true); contentRoot.setSizeFull(); contentRoot.setRows(10); contentRoot.setColumns(1); //tables go here mastersTable = createTableTemplate("Masters"); mastersTable.setId("MastersTable"); tracersTable = createTableTemplate("Tracers"); tracersTable.setId("TracersTable"); slavesTable = createTableTemplate("Tablet Servers"); slavesTable.setId("Slavestable"); HorizontalLayout controlsContent = new HorizontalLayout(); controlsContent.setSpacing(true); controlsContent.setHeight(100, Sizeable.Unit.PERCENTAGE); Label clusterNameLabel = new Label("Select the cluster"); controlsContent.addComponent(clusterNameLabel); controlsContent.setComponentAlignment(clusterNameLabel, Alignment.MIDDLE_CENTER); ComboBox clustersCombo = getClusterCombo(); controlsContent.addComponent(clustersCombo); controlsContent.setComponentAlignment(clustersCombo, Alignment.MIDDLE_CENTER); refreshClustersBtn = getRefreshClustersButton(); controlsContent.addComponent(refreshClustersBtn); controlsContent.setComponentAlignment(refreshClustersBtn, Alignment.MIDDLE_CENTER); checkAllBtn = getCheckAllButton(); controlsContent.addComponent(checkAllBtn); controlsContent.setComponentAlignment(checkAllBtn, Alignment.MIDDLE_CENTER); startClusterBtn = getStartAllButton(); controlsContent.addComponent(startClusterBtn); controlsContent.setComponentAlignment(startClusterBtn, Alignment.MIDDLE_CENTER); stopClusterBtn = getStopAllButton(); controlsContent.addComponent(stopClusterBtn); controlsContent.setComponentAlignment(stopClusterBtn, Alignment.MIDDLE_CENTER); destroyClusterBtn = getDestroyClusterButton(); controlsContent.addComponent(destroyClusterBtn); controlsContent.setComponentAlignment(destroyClusterBtn, Alignment.MIDDLE_CENTER); addTracerBtn = getAddTracerNodeButton(); controlsContent.addComponent(addTracerBtn); controlsContent.setComponentAlignment(addTracerBtn, Alignment.MIDDLE_CENTER); addTabletServerButton = getAddSlaveButton(); controlsContent.addComponent(addTabletServerButton); controlsContent.setComponentAlignment(addTabletServerButton, Alignment.MIDDLE_CENTER); //auto scale button autoScaleBtn = new CheckBox(AUTO_SCALE_BUTTON_CAPTION); autoScaleBtn.setValue(false); autoScaleBtn.addStyleName("default"); controlsContent.addComponent(autoScaleBtn); controlsContent.setComponentAlignment(autoScaleBtn, Alignment.MIDDLE_CENTER); autoScaleBtn.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final Property.ValueChangeEvent event) { if (accumuloClusterConfig == null) { show("Select cluster"); } else { boolean value = (Boolean) event.getProperty().getValue(); accumuloClusterConfig.setAutoScaling(value); try { accumulo.saveConfig(accumuloClusterConfig); } catch (ClusterException e) { show(e.getMessage()); } } } }); addStyleName(refreshClustersBtn, checkAllBtn, startClusterBtn, stopClusterBtn, destroyClusterBtn, addTracerBtn, addTabletServerButton); PROGRESS_ICON.setVisible(false); PROGRESS_ICON.setId("indicator"); controlsContent.addComponent(PROGRESS_ICON); controlsContent.setComponentAlignment(PROGRESS_ICON, Alignment.MIDDLE_CENTER); contentRoot.addComponent(controlsContent, 0, 0); contentRoot.addComponent(mastersTable, 0, 1, 0, 3); contentRoot.addComponent(tracersTable, 0, 4, 0, 6); contentRoot.addComponent(slavesTable, 0, 7, 0, 9); }
From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaAbstractFormPropertyRenderer.java
License:Apache License
protected void addButton(String operation, HorizontalLayout buttons, final String item, final Table table) { final String finalOperation = operation; final Button button = new Button(); if (operation.equals(MODIFICA.name())) button.setIcon(new ThemeResource("img/edit.png")); else if (operation.equals(CANCELLAZIONE.name())) button.setIcon(new ThemeResource("img/delete.png")); else/*from w ww. ja v a 2 s . co m*/ button.setIcon(new ThemeResource("img/task-16.png")); button.addStyleName(BUTTON_LINK); I18nManager i18nManager = get().getI18nManager(); button.setDescription(i18nManager.getMessage(operation)); buttons.addComponent(button); buttons.setComponentAlignment(button, BOTTOM_RIGHT); button.addListener(new ClickListener() { private static final long serialVersionUID = -6091586145870618870L; public void buttonClick(ClickEvent event) { // Extract the submitted values from the form. Throws // exception // when validation fails. try { table.select(item); Map<String, String> formProperties = greenareaFormPropertiesForm .getGreenareaFormPropertiesComponent().getFormPropertyValues(); setOperation(formProperties, finalOperation); greenareaFormPropertiesForm.getMainTitle() .setPropertyDataSource(new ObjectProperty<String>( greenareaFormPropertiesForm.getMainTitle().getValue() + " > " + finalOperation, String.class)); FormPropertiesEvent formPropertiesEvent = greenareaFormPropertiesForm.new FormPropertiesEvent( greenareaFormPropertiesForm, TYPE_SUBMIT, formProperties); greenareaFormPropertiesForm.fireEvent(formPropertiesEvent); button.setComponentError(null); } catch (InvalidValueException ive) { // Error is presented to user by the form component } } }); }