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;
}
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);
}
}
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;
}
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;
}
}
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);
}
Aggregations