use of fr.univlorraine.ecandidat.entities.ecandidat.AlertSva in project esup-ecandidat by EsupPortail.
the class CandidatureViewTemplate method getStyleSva.
/**
* @param candidature
* @param listeAlerteSva
* @param dateSva
* @param definitifSva
* @return le style sva correspondand
*/
public String getStyleSva(final Candidature candidature, final List<AlertSva> listeAlerteSva, final String dateSva, final Boolean definitifSva) {
if (dateSva.equals(NomenclatureUtils.CAND_DAT_NO_DAT) || listeAlerteSva.size() == 0) {
return null;
}
final TypeDecisionCandidature typeDecisionCandidature = candidature.getLastTypeDecision();
// dans le cas de seulement les avis définitif
if (definitifSva) {
if (typeDecisionCandidature != null && typeDecisionCandidature.getTemValidTypeDecCand() && typeDecisionCandidature.getTypeDecision().getTemDefinitifTypDec()) {
return null;
}
} else // autres cas
{
if (typeDecisionCandidature != null && typeDecisionCandidature.getTemValidTypeDecCand()) {
return null;
}
}
/* On cherche la date à utiliser */
LocalDate dateToUse = null;
switch(dateSva) {
case NomenclatureUtils.CAND_DAT_CRE:
dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatCreCand());
break;
case NomenclatureUtils.CAND_DAT_ANNUL:
dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatAnnulCand());
break;
case NomenclatureUtils.CAND_DAT_ACCEPT:
dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatAcceptCand());
break;
case NomenclatureUtils.CAND_DAT_TRANS:
dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatTransDossierCand());
break;
case NomenclatureUtils.CAND_DAT_RECEPT:
dateToUse = candidature.getDatReceptDossierCand();
break;
case NomenclatureUtils.CAND_DAT_COMPLET:
dateToUse = candidature.getDatCompletDossierCand();
break;
case NomenclatureUtils.CAND_DAT_INCOMPLET:
dateToUse = candidature.getDatIncompletDossierCand();
break;
default:
dateToUse = null;
break;
}
if (dateToUse == null) {
return null;
}
/* Calcul le nombre de jour */
final Long nbDays = ChronoUnit.DAYS.between(dateToUse, LocalDate.now());
Integer nbJourSva = null;
for (final AlertSva alert : listeAlerteSva) {
if (nbDays >= alert.getNbJourSva() && (nbJourSva == null || nbJourSva < alert.getNbJourSva())) {
nbJourSva = alert.getNbJourSva();
}
}
/* On renvoi la couleur de la ligne */
if (nbJourSva != null) {
return StyleConstants.GRID_ROW_SVA + "-" + nbJourSva;
}
return null;
}
use of fr.univlorraine.ecandidat.entities.ecandidat.AlertSva in project esup-ecandidat by EsupPortail.
the class ScolAlertSvaView method init.
/**
* Initialise la vue
*/
@PostConstruct
public void init() {
/* Style */
setSizeFull();
setMargin(true);
setSpacing(true);
/* Titre */
Label titleParam = new Label(applicationContext.getMessage("alertSva.title", null, UI.getCurrent().getLocale()));
titleParam.addStyleName(StyleConstants.VIEW_TITLE);
addComponent(titleParam);
CustomPanel panelMessage = new CustomPanel(applicationContext.getMessage("informations", null, UI.getCurrent().getLocale()), FontAwesome.INFO_CIRCLE);
panelMessage.setMessage(applicationContext.getMessage("alertSva.info", null, UI.getCurrent().getLocale()));
panelMessage.setWidthMax();
panelMessage.setMargin(true);
addComponent(panelMessage);
/* Choix de la date */
HorizontalLayout paramLayout = new HorizontalLayout();
paramLayout.setSpacing(true);
addComponent(paramLayout);
/* Table des parametres */
TableFormating table = new TableFormating(null, parametreContainer);
table.addBooleanColumn(SimpleTablePresentation.CHAMPS_VALUE, false);
String[] FIELDS_ORDER_PARAM = { SimpleTablePresentation.CHAMPS_TITLE, SimpleTablePresentation.CHAMPS_VALUE };
table.setVisibleColumns((Object[]) FIELDS_ORDER_PARAM);
table.setColumnCollapsingAllowed(false);
table.setColumnReorderingAllowed(false);
table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
table.setSelectable(false);
table.setImmediate(true);
table.setPageLength(2);
table.setWidth(100, Unit.PERCENTAGE);
table.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 350);
table.setColumnWidth(SimpleTablePresentation.CHAMPS_VALUE, 200);
table.setCellStyleGenerator((components, itemId, columnId) -> {
if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
return (ValoTheme.LABEL_BOLD);
}
return null;
});
paramLayout.addComponent(table);
paramLayout.setComponentAlignment(table, Alignment.MIDDLE_CENTER);
OneClickButton buttonDate = new OneClickButton(applicationContext.getMessage("btnModifier", null, UI.getCurrent().getLocale()), FontAwesome.CALENDAR);
buttonDate.addClickListener(e -> {
parametreController.changeSVAParametre(this, parametreDateSva, parametreDefinitif);
});
paramLayout.addComponent(buttonDate);
paramLayout.setComponentAlignment(buttonDate, Alignment.MIDDLE_CENTER);
/* Boutons */
HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setWidth(100, Unit.PERCENTAGE);
buttonsLayout.setSpacing(true);
addComponent(buttonsLayout);
OneClickButton btnNew = new OneClickButton(applicationContext.getMessage("alertSva.btnNouveau", null, UI.getCurrent().getLocale()), FontAwesome.PLUS);
btnNew.setEnabled(true);
btnNew.addClickListener(e -> {
alertSvaController.editNewAlertSva();
});
buttonsLayout.addComponent(btnNew);
buttonsLayout.setComponentAlignment(btnNew, Alignment.MIDDLE_LEFT);
OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
btnEdit.setEnabled(false);
btnEdit.addClickListener(e -> {
if (alertSvaTable.getValue() instanceof AlertSva) {
alertSvaController.editAlertSva((AlertSva) alertSvaTable.getValue());
}
});
buttonsLayout.addComponent(btnEdit);
buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_CENTER);
OneClickButton btnDelete = new OneClickButton(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()), FontAwesome.TRASH_O);
btnDelete.setEnabled(false);
btnDelete.addClickListener(e -> {
if (alertSvaTable.getValue() instanceof AlertSva) {
alertSvaController.deleteAlertSva((AlertSva) alertSvaTable.getValue());
}
});
buttonsLayout.addComponent(btnDelete);
buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_RIGHT);
/* Table des alertSvas */
BeanItemContainer<AlertSva> container = new BeanItemContainer<>(AlertSva.class, cacheController.getAlertesSva());
alertSvaTable.setContainerDataSource(container);
alertSvaTable.addBooleanColumn(AlertSva_.tesSva.getName());
alertSvaTable.setSizeFull();
alertSvaTable.setVisibleColumns((Object[]) FIELDS_ORDER);
for (String fieldName : FIELDS_ORDER) {
alertSvaTable.setColumnHeader(fieldName, applicationContext.getMessage("alertSva.table." + fieldName, null, UI.getCurrent().getLocale()));
}
alertSvaTable.addGeneratedColumn(AlertSva_.colorSva.getName(), new ColumnGenerator() {
@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
AlertSva alertSva = (AlertSva) itemId;
HorizontalLayout hlColor = new HorizontalLayout();
hlColor.setSpacing(true);
Label labelColor = new Label("<div style='border:1px solid;width:20px;height:20px;background:" + alertSva.getColorSva() + ";'></div>", ContentMode.HTML);
Label labelTxt = new Label(alertSva.getColorSva());
hlColor.addComponent(labelColor);
hlColor.setComponentAlignment(labelColor, Alignment.MIDDLE_LEFT);
hlColor.addComponent(labelTxt);
hlColor.setComponentAlignment(labelTxt, Alignment.MIDDLE_LEFT);
return hlColor;
}
});
alertSvaTable.setSortContainerPropertyId(AlertSva_.nbJourSva.getName());
alertSvaTable.setColumnCollapsingAllowed(true);
alertSvaTable.setColumnReorderingAllowed(true);
alertSvaTable.setSelectable(true);
alertSvaTable.setImmediate(true);
alertSvaTable.addItemSetChangeListener(e -> alertSvaTable.sanitizeSelection());
alertSvaTable.addValueChangeListener(e -> {
/* Les boutons d'édition et de suppression de alertSva sont actifs seulement si une alertSva est sélectionnée. */
boolean alertSvaIsSelectedEdit = alertSvaTable.getValue() instanceof AlertSva;
btnEdit.setEnabled(alertSvaIsSelectedEdit);
btnDelete.setEnabled(alertSvaIsSelectedEdit);
});
alertSvaTable.addItemClickListener(e -> {
if (e.isDoubleClick()) {
alertSvaTable.select(e.getItemId());
btnEdit.click();
}
});
addComponent(alertSvaTable);
setExpandRatio(alertSvaTable, 1);
/* Inscrit la vue aux mises à jour de alerteSva */
alertSvaEntityPusher.registerEntityPushListener(this);
}
use of fr.univlorraine.ecandidat.entities.ecandidat.AlertSva in project esup-ecandidat by EsupPortail.
the class AlertSvaController method getListAlertSvaCss.
/**
* @return la liste des style scc a renvoyer
*/
public List<String> getListAlertSvaCss() {
List<String> liste = new ArrayList<>();
List<AlertSva> listeAlerteSva = getAlertSvaEnService();
/* On ajoute les css colorisant les lignes pour sva */
for (AlertSva alert : listeAlerteSva) {
liste.add("." + StyleConstants.GRID + " ." + StyleConstants.GRID_ROW_SVA + "-" + alert.getNbJourSva() + " ." + StyleConstants.GRID_CELL + " { background-color: " + alert.getColorSva() + "; }");
}
return liste;
}
Aggregations