Search in sources :

Example 1 with Langue

use of fr.univlorraine.ecandidat.entities.ecandidat.Langue in project esup-ecandidat by EsupPortail.

the class I18nField method initContent.

/**
 * @see com.vaadin.ui.CustomField#initContent()
 */
@Override
protected Component initContent() {
    /* Ajout de la langue par defaut */
    HorizontalLayout hlLangueDef = new HorizontalLayout();
    listLayoutTraductions.add(hlLangueDef);
    hlLangueDef.setSpacing(true);
    hlLangueDef.setWidth(100, Unit.PERCENTAGE);
    layoutLangue.addComponent(hlLangueDef);
    /* Si il y a d'autres langue en service on met le drapeau */
    if (listeLangueEnService.size() > 0 || listeTraduction.size() > 1) {
        Image flag = new Image(null, new ThemeResource("images/flags/" + langueParDefaut.getCodLangue() + ".png"));
        HorizontalLayout hlFlag = new HorizontalLayout();
        hlFlag.setWidth(75, Unit.PIXELS);
        hlFlag.addComponent(flag);
        hlFlag.setComponentAlignment(flag, Alignment.MIDDLE_CENTER);
        hlLangueDef.addComponent(hlFlag);
    }
    /* La valeur de la traduction */
    AbstractField<String> tfVal = getNewValueComponent();
    tfVal.setId(langueParDefaut.getCodLangue());
    tfVal.setWidth(100, Unit.PERCENTAGE);
    /* Recuperation de la valeur de la traduction par defaut dans la liste des traductions */
    if (listeTraduction.size() != 0) {
        Optional<I18nTraduction> opt = listeTraduction.stream().filter(l -> l.getLangue().getCodLangue().equals(langueParDefaut.getCodLangue())).findFirst();
        if (opt.isPresent()) {
            tfVal.setValue(opt.get().getValTrad());
        }
    }
    hlLangueDef.addComponent(tfVal);
    hlLangueDef.setExpandRatio(tfVal, 1);
    listeTraduction.stream().filter(l -> !l.getLangue().getCodLangue().equals(langueParDefaut.getCodLangue())).forEach(traductionOther -> {
        /* Ajout d'une langue inactive si elle existe */
        Optional<Langue> opt = listeLangueEnService.stream().filter(langueEnService -> langueEnService.getCodLangue().equals(traductionOther.getLangue().getCodLangue())).findFirst();
        if (opt.isPresent()) {
            /* Ajout des autres langues si elles n'existent pas déjà */
            layoutLangue.addComponent(getLangueLayout(traductionOther));
        } else {
            layoutLangue.addComponent(getLangueLayoutInactive(traductionOther));
        }
    });
    checkVisibleAddLangue();
    return layoutComplet;
}
Also used : ThemeResource(com.vaadin.server.ThemeResource) CustomField(com.vaadin.ui.CustomField) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) ComboBox(com.vaadin.ui.ComboBox) Langue(fr.univlorraine.ecandidat.entities.ecandidat.Langue) ArrayList(java.util.ArrayList) FontAwesome(com.vaadin.server.FontAwesome) Image(com.vaadin.ui.Image) IRequiredField(fr.univlorraine.ecandidat.vaadin.form.IRequiredField) InvalidValueException(com.vaadin.data.Validator.InvalidValueException) I18n(fr.univlorraine.ecandidat.entities.ecandidat.I18n) ComboBoxLangue(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxLangue) ValoTheme(com.vaadin.ui.themes.ValoTheme) MethodUtils(fr.univlorraine.ecandidat.utils.MethodUtils) RichTextArea(com.vaadin.ui.RichTextArea) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) I18nTraduction(fr.univlorraine.ecandidat.entities.ecandidat.I18nTraduction) Serializable(java.io.Serializable) TypeTraduction(fr.univlorraine.ecandidat.entities.ecandidat.TypeTraduction) List(java.util.List) AbstractField(com.vaadin.ui.AbstractField) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Optional(java.util.Optional) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Component(com.vaadin.ui.Component) Langue(fr.univlorraine.ecandidat.entities.ecandidat.Langue) ComboBoxLangue(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxLangue) I18nTraduction(fr.univlorraine.ecandidat.entities.ecandidat.I18nTraduction) ThemeResource(com.vaadin.server.ThemeResource) Image(com.vaadin.ui.Image) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 2 with Langue

use of fr.univlorraine.ecandidat.entities.ecandidat.Langue in project esup-ecandidat by EsupPortail.

the class I18nField method checkVisibleAddLangue.

/**
 * Modifie la visibilité du bouton d'ajout de langue
 */
private void checkVisibleAddLangue() {
    if (listeLangueEnService.size() == 0) {
        btnAddLangue.setVisible(false);
    } else {
        List<I18nTraduction> i18nTraductions = getValue().getI18nTraductions();
        for (Langue langue : listeLangueEnService) {
            Optional<I18nTraduction> opt = i18nTraductions.stream().filter(l -> l.getLangue().getCodLangue().equals(langue.getCodLangue())).findFirst();
            if (!opt.isPresent()) {
                btnAddLangue.setVisible(true);
                return;
            }
        }
        btnAddLangue.setVisible(false);
    }
}
Also used : ThemeResource(com.vaadin.server.ThemeResource) CustomField(com.vaadin.ui.CustomField) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) ComboBox(com.vaadin.ui.ComboBox) Langue(fr.univlorraine.ecandidat.entities.ecandidat.Langue) ArrayList(java.util.ArrayList) FontAwesome(com.vaadin.server.FontAwesome) Image(com.vaadin.ui.Image) IRequiredField(fr.univlorraine.ecandidat.vaadin.form.IRequiredField) InvalidValueException(com.vaadin.data.Validator.InvalidValueException) I18n(fr.univlorraine.ecandidat.entities.ecandidat.I18n) ComboBoxLangue(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxLangue) ValoTheme(com.vaadin.ui.themes.ValoTheme) MethodUtils(fr.univlorraine.ecandidat.utils.MethodUtils) RichTextArea(com.vaadin.ui.RichTextArea) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) I18nTraduction(fr.univlorraine.ecandidat.entities.ecandidat.I18nTraduction) Serializable(java.io.Serializable) TypeTraduction(fr.univlorraine.ecandidat.entities.ecandidat.TypeTraduction) List(java.util.List) AbstractField(com.vaadin.ui.AbstractField) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Optional(java.util.Optional) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Component(com.vaadin.ui.Component) Langue(fr.univlorraine.ecandidat.entities.ecandidat.Langue) ComboBoxLangue(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxLangue) I18nTraduction(fr.univlorraine.ecandidat.entities.ecandidat.I18nTraduction)

Example 3 with Langue

use of fr.univlorraine.ecandidat.entities.ecandidat.Langue in project esup-ecandidat by EsupPortail.

the class I18nField method getValueField.

/**
 * Recupere la valeur du champs contenant la liste de traduction
 *
 * @param i18n
 * @return la liste des traductions
 */
@SuppressWarnings("unchecked")
private List<I18nTraduction> getValueField(final I18n i18n) {
    List<I18nTraduction> listeToRet = new ArrayList<>();
    listLayoutTraductions.forEach(e -> {
        if (e.getComponentCount() == 0) {
            return;
        }
        // langue par défaut
        if (e.getComponent(0) instanceof TextField || e.getComponent(0) instanceof RichTextArea) {
            AbstractField<String> tf = (AbstractField<String>) e.getComponent(0);
            listeToRet.add(new I18nTraduction(MethodUtils.cleanHtmlValue(tf.getValue()), i18n, langueParDefaut));
        } else if (e.getComponent(0) instanceof HorizontalLayout) {
            AbstractField<String> tf = (AbstractField<String>) e.getComponent(1);
            listeToRet.add(new I18nTraduction(MethodUtils.cleanHtmlValue(tf.getValue()), i18n, new Langue(tf.getId())));
        } else {
            ComboBox cbLangue = (ComboBox) e.getComponent(0);
            Langue langue = (Langue) cbLangue.getValue();
            AbstractField<String> tf = (AbstractField<String>) e.getComponent(1);
            listeToRet.add(new I18nTraduction(tf.getValue(), i18n, langue));
        }
    });
    return listeToRet;
}
Also used : RichTextArea(com.vaadin.ui.RichTextArea) AbstractField(com.vaadin.ui.AbstractField) Langue(fr.univlorraine.ecandidat.entities.ecandidat.Langue) ComboBoxLangue(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxLangue) I18nTraduction(fr.univlorraine.ecandidat.entities.ecandidat.I18nTraduction) ComboBox(com.vaadin.ui.ComboBox) ArrayList(java.util.ArrayList) TextField(com.vaadin.ui.TextField) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 4 with Langue

use of fr.univlorraine.ecandidat.entities.ecandidat.Langue in project esup-ecandidat by EsupPortail.

the class CacheController method getLangueDefault.

/**
 * @return la langne par défaut du cache
 */
public Langue getLangueDefault() {
    final Langue langue = mapCache.getFromCache(ConstanteUtils.CACHE_LANGUE_DEFAULT, Langue.class);
    if (langue == null) {
        final Langue langueLoad = langueController.getLangueDefaultToCache();
        mapCache.putToCache(ConstanteUtils.CACHE_LANGUE_DEFAULT, langueLoad, Langue.class);
        return langueLoad;
    } else {
        return langue;
    }
}
Also used : Langue(fr.univlorraine.ecandidat.entities.ecandidat.Langue)

Example 5 with Langue

use of fr.univlorraine.ecandidat.entities.ecandidat.Langue in project esup-ecandidat by EsupPortail.

the class CandidatCompteMinimaView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setMargin(true);
    setSpacing(true);
    setSizeFull();
    /* Titre */
    HorizontalLayout hlLangue = new HorizontalLayout();
    hlLangue.setWidth(100, Unit.PERCENTAGE);
    hlLangue.setSpacing(true);
    /* Le titre */
    labelTitle.addStyleName(StyleConstants.VIEW_TITLE);
    hlLangue.addComponent(labelTitle);
    hlLangue.setExpandRatio(labelTitle, 1);
    hlLangue.setComponentAlignment(labelTitle, Alignment.MIDDLE_LEFT);
    if (cacheController.getLangueEnServiceWithoutDefault().size() > 0) {
        Langue langueDef = cacheController.getLangueDefault();
        Image flagDef = new Image(null, new ThemeResource("images/flags/" + langueDef.getCodLangue() + ".png"));
        flagDef.addClickListener(e -> updateLangue(langueDef));
        flagDef.addStyleName(StyleConstants.CLICKABLE);
        hlLangue.addComponent(flagDef);
        hlLangue.setComponentAlignment(flagDef, Alignment.MIDDLE_CENTER);
        cacheController.getLangueEnServiceWithoutDefault().forEach(langue -> {
            Image flag = new Image(null, new ThemeResource("images/flags/" + langue.getCodLangue() + ".png"));
            flag.addClickListener(e -> updateLangue(langue));
            flag.addStyleName(StyleConstants.CLICKABLE);
            hlLangue.addComponent(flag);
            hlLangue.setComponentAlignment(flag, Alignment.MIDDLE_CENTER);
        });
    }
    addComponent(hlLangue);
    /* Panel scrollable de contenu */
    Panel panelContent = new Panel();
    panelContent.setSizeFull();
    panelContent.addStyleName(ValoTheme.PANEL_BORDERLESS);
    addComponent(panelContent);
    setExpandRatio(panelContent, 1);
    VerticalLayout vlContent = new VerticalLayout();
    vlContent.setSpacing(true);
    panelContent.setContent(vlContent);
    restResult.setContentMode(ContentMode.HTML);
    restResult.addStyleName(StyleConstants.LABEL_MORE_BOLD);
    restResult.addStyleName(ValoTheme.LABEL_COLORED);
    restResult.setValue("");
    vlContent.addComponent(restResult);
    /* Texte */
    labelAccueil.setValue("");
    labelAccueil.setContentMode(ContentMode.HTML);
    vlContent.addComponent(labelAccueil);
    connexionLayout.addStyleName(StyleConstants.ACCUEIL_COMPTE_PANEL);
    connexionLayout.addCasListener(() -> userController.connectCAS());
    connexionLayout.addStudentListener((user, pwd) -> userController.connectCandidatInterne(user, pwd));
    connexionLayout.addForgotPasswordListener(() -> {
        UI.getCurrent().addWindow(new CandidatIdOublieWindow(ConstanteUtils.FORGOT_MODE_ID_OUBLIE));
    });
    connexionLayout.addForgotCodeActivationListener(() -> {
        UI.getCurrent().addWindow(new CandidatIdOublieWindow(ConstanteUtils.FORGOT_MODE_CODE_ACTIVATION));
    });
    vlContent.addComponent(connexionLayout);
}
Also used : Panel(com.vaadin.ui.Panel) Langue(fr.univlorraine.ecandidat.entities.ecandidat.Langue) CandidatIdOublieWindow(fr.univlorraine.ecandidat.views.windows.CandidatIdOublieWindow) ThemeResource(com.vaadin.server.ThemeResource) VerticalLayout(com.vaadin.ui.VerticalLayout) Image(com.vaadin.ui.Image) HorizontalLayout(com.vaadin.ui.HorizontalLayout) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Langue (fr.univlorraine.ecandidat.entities.ecandidat.Langue)14 HorizontalLayout (com.vaadin.ui.HorizontalLayout)9 ThemeResource (com.vaadin.server.ThemeResource)8 Image (com.vaadin.ui.Image)8 VerticalLayout (com.vaadin.ui.VerticalLayout)6 ComboBoxLangue (fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxLangue)5 ArrayList (java.util.ArrayList)5 PostConstruct (javax.annotation.PostConstruct)5 AbstractField (com.vaadin.ui.AbstractField)4 ComboBox (com.vaadin.ui.ComboBox)4 Label (com.vaadin.ui.Label)4 RichTextArea (com.vaadin.ui.RichTextArea)4 TextField (com.vaadin.ui.TextField)4 I18nTraduction (fr.univlorraine.ecandidat.entities.ecandidat.I18nTraduction)4 OneClickButton (fr.univlorraine.ecandidat.vaadin.components.OneClickButton)4 List (java.util.List)4 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)3 FontAwesome (com.vaadin.server.FontAwesome)3 Alignment (com.vaadin.ui.Alignment)3 Component (com.vaadin.ui.Component)3