Search in sources :

Example 1 with TableFormating

use of fr.univlorraine.ecandidat.vaadin.components.TableFormating in project esup-ecandidat by EsupPortail.

the class ScolGestCandidatDroitProfilView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    super.init(false);
    /*Ajout des parametres globaux*/
    VerticalLayout vlComplement = new VerticalLayout();
    vlComplement.setSpacing(true);
    vlComplement.setWidth(100, Unit.PERCENTAGE);
    Label titleParamDesc = new Label(applicationContext.getMessage("droitprofilind.gestCandidat.param", null, UI.getCurrent().getLocale()));
    titleParamDesc.addStyleName(StyleConstants.VIEW_SUBTITLE);
    vlComplement.addComponent(titleParamDesc);
    TableFormating table = new TableFormating(null, containerReadOnly);
    GestionnaireCandidatListener listener = this;
    table.addGeneratedColumn(SimpleTablePresentation.CHAMPS_VALUE, new ColumnGenerator() {

        /**
         *serialVersionUID*
         */
        private static final long serialVersionUID = 4125366493925127117L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleTablePresentation bean = (SimpleTablePresentation) itemId;
            return parametreController.getLibelleParametresGestionCandidat(bean.getValue().toString());
        }
    });
    table.addGeneratedColumn(SimpleTablePresentation.CHAMPS_ACTION, new ColumnGenerator() {

        /**
         *serialVersionUID*
         */
        private static final long serialVersionUID = 5720531607995628916L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleTablePresentation bean = (SimpleTablePresentation) itemId;
            OneClickButton button = new OneClickButton(applicationContext.getMessage("btnModifier", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
            button.addClickListener(e -> {
                parametreController.changeParametreGestionCandidat(listener, bean.getCode(), bean.getValue().toString(), bean.getTitle());
            });
            return button;
        }
    });
    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, 500);
    table.setColumnWidth(SimpleTablePresentation.CHAMPS_VALUE, 460);
    table.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    vlComplement.addComponent(table);
    Label titleParamInd = new Label(applicationContext.getMessage("droitprofilind.gestCandidat.ind", null, UI.getCurrent().getLocale()));
    titleParamInd.addStyleName(StyleConstants.VIEW_SUBTITLE);
    vlComplement.addComponent(titleParamInd);
    addComplement(vlComplement);
    /* Inscrit la vue aux mises à jour de droitProfil */
    droitProfilIndEntityPusher.registerEntityPushListener(this);
}
Also used : PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) VerticalLayout(com.vaadin.ui.VerticalLayout) UI(com.vaadin.ui.UI) DroitProfilInd(fr.univlorraine.ecandidat.entities.ecandidat.DroitProfilInd) UtilisateurViewTemplate(fr.univlorraine.ecandidat.views.template.UtilisateurViewTemplate) FontAwesome(com.vaadin.server.FontAwesome) Label(com.vaadin.ui.Label) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) SpringView(com.vaadin.spring.annotation.SpringView) ValoTheme(com.vaadin.ui.themes.ValoTheme) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) EntityPushListener(fr.univlorraine.tools.vaadin.EntityPushListener) Resource(javax.annotation.Resource) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) ColumnHeaderMode(com.vaadin.ui.Table.ColumnHeaderMode) ParametreController(fr.univlorraine.ecandidat.controllers.ParametreController) Table(com.vaadin.ui.Table) PostConstruct(javax.annotation.PostConstruct) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) GestionnaireCandidatListener(fr.univlorraine.ecandidat.utils.ListenerUtils.GestionnaireCandidatListener) EntityPusher(fr.univlorraine.tools.vaadin.EntityPusher) View(com.vaadin.navigator.View) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) GestionnaireCandidatListener(fr.univlorraine.ecandidat.utils.ListenerUtils.GestionnaireCandidatListener) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) Table(com.vaadin.ui.Table) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) PostConstruct(javax.annotation.PostConstruct)

Example 2 with TableFormating

use of fr.univlorraine.ecandidat.vaadin.components.TableFormating in project esup-ecandidat by EsupPortail.

the class CommissionParametreView method getTable.

/**
 * @param container
 * @param size
 * @return une table pour formatter les données
 */
private TableFormating getTable(final BeanItemContainer<SimpleTablePresentation> container, final Integer size) {
    TableFormating table = new TableFormating(null, container);
    table.addBooleanColumn(SimpleTablePresentation.CHAMPS_VALUE, false);
    table.setVisibleColumns((Object[]) FIELDS_ORDER);
    table.setColumnCollapsingAllowed(false);
    table.setColumnReorderingAllowed(false);
    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    table.setSelectable(false);
    table.setImmediate(true);
    table.setPageLength(size);
    table.setWidth(100, Unit.PERCENTAGE);
    table.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 300);
    table.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    return table;
}
Also used : TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating)

Example 3 with TableFormating

use of fr.univlorraine.ecandidat.vaadin.components.TableFormating in project esup-ecandidat by EsupPortail.

the class CtrCandParametreView method init.

/* Composants */
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);
    /* Récupération du centre de canidature en cours */
    securityCtrCandFonc = userController.getCtrCandFonctionnalite(NomenclatureUtils.FONCTIONNALITE_PARAM);
    if (securityCtrCandFonc.hasNoRight()) {
        return;
    }
    /* Titre */
    Label titleParam = new Label(applicationContext.getMessage("ctrCand.parametre.title", new Object[] { securityCtrCandFonc.getCtrCand().getLibCtrCand() }, UI.getCurrent().getLocale()));
    titleParam.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleParam);
    /* Descriptif */
    Label titleParamDesc = new Label(applicationContext.getMessage("ctrCand.parametre.title.desc", null, UI.getCurrent().getLocale()));
    titleParamDesc.addStyleName(StyleConstants.VIEW_SUBTITLE);
    addComponent(titleParamDesc);
    containerReadOnly = new BeanItemContainer<>(SimpleTablePresentation.class);
    TableFormating paramReadOnlyTable = new TableFormating(null, containerReadOnly);
    paramReadOnlyTable.addBooleanColumn(SimpleTablePresentation.CHAMPS_VALUE, false);
    paramReadOnlyTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    paramReadOnlyTable.setColumnCollapsingAllowed(false);
    paramReadOnlyTable.setColumnReorderingAllowed(false);
    paramReadOnlyTable.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    paramReadOnlyTable.setSelectable(false);
    paramReadOnlyTable.setImmediate(true);
    paramReadOnlyTable.setPageLength(4);
    paramReadOnlyTable.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 300);
    paramReadOnlyTable.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    addComponent(paramReadOnlyTable);
    paramReadOnlyTable.setWidth(100, Unit.PERCENTAGE);
    /* Parametres */
    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    addComponent(buttonsLayout);
    Label titleParamParam = new Label(applicationContext.getMessage("ctrCand.parametre.title.param", null, UI.getCurrent().getLocale()));
    titleParamParam.setSizeUndefined();
    titleParamParam.addStyleName(StyleConstants.VIEW_SUBTITLE);
    buttonsLayout.addComponent(titleParamParam);
    buttonsLayout.setComponentAlignment(titleParamParam, Alignment.MIDDLE_CENTER);
    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.addClickListener(e -> {
        centreCandidatureController.editCentreCandidature(securityCtrCandFonc.getCtrCand(), false);
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setExpandRatio(btnEdit, 1);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);
    TableFormating paramTable = new TableFormating(null, container);
    paramTable.addBooleanColumn(SimpleTablePresentation.CHAMPS_VALUE, false);
    paramTable.setSizeFull();
    paramTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    paramTable.setColumnCollapsingAllowed(false);
    paramTable.setColumnReorderingAllowed(false);
    paramTable.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    paramTable.setSelectable(false);
    paramTable.setImmediate(true);
    paramTable.setPageLength(18);
    paramTable.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 300);
    paramTable.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    addComponent(paramTable);
    miseAJourContainer(securityCtrCandFonc.getCtrCand());
    setExpandRatio(paramTable, 1);
    /* Gestion du readOnly */
    if (securityCtrCandFonc.isWrite()) {
        buttonsLayout.setVisible(true);
    } else {
        buttonsLayout.setVisible(false);
    }
    /* Inscrit la vue aux mises à jour de centreCandidature */
    centreCandidatureEntityPusher.registerEntityPushListener(this);
}
Also used : SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Label(com.vaadin.ui.Label) HorizontalLayout(com.vaadin.ui.HorizontalLayout) PostConstruct(javax.annotation.PostConstruct)

Example 4 with TableFormating

use of fr.univlorraine.ecandidat.vaadin.components.TableFormating 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);
}
Also used : AlertSva(fr.univlorraine.ecandidat.entities.ecandidat.AlertSva) Table(com.vaadin.ui.Table) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Label(com.vaadin.ui.Label) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) CustomPanel(fr.univlorraine.ecandidat.vaadin.components.CustomPanel) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) PostConstruct(javax.annotation.PostConstruct)

Aggregations

TableFormating (fr.univlorraine.ecandidat.vaadin.components.TableFormating)4 Label (com.vaadin.ui.Label)3 OneClickButton (fr.univlorraine.ecandidat.vaadin.components.OneClickButton)3 PostConstruct (javax.annotation.PostConstruct)3 BeanItemContainer (com.vaadin.data.util.BeanItemContainer)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Table (com.vaadin.ui.Table)2 ColumnGenerator (com.vaadin.ui.Table.ColumnGenerator)2 SimpleTablePresentation (fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation)2 View (com.vaadin.navigator.View)1 ViewChangeEvent (com.vaadin.navigator.ViewChangeListener.ViewChangeEvent)1 FontAwesome (com.vaadin.server.FontAwesome)1 SpringView (com.vaadin.spring.annotation.SpringView)1 ColumnHeaderMode (com.vaadin.ui.Table.ColumnHeaderMode)1 UI (com.vaadin.ui.UI)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 ValoTheme (com.vaadin.ui.themes.ValoTheme)1 StyleConstants (fr.univlorraine.ecandidat.StyleConstants)1 ParametreController (fr.univlorraine.ecandidat.controllers.ParametreController)1 AlertSva (fr.univlorraine.ecandidat.entities.ecandidat.AlertSva)1