Search in sources :

Example 1 with PjCandidat_

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

the class CandidatAdminView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    isSiScolApo = parametreController.getSiScolMode().equals(ConstanteUtils.SI_SCOL_APOGEE);
    isSiScolApoPJ = parametreController.getSiScolMode().equals(ConstanteUtils.SI_SCOL_APOGEE) && candidatPieceController.isWsPJEnable();
    setSizeFull();
    setMargin(true);
    setSpacing(true);
    globalLayout.setSizeFull();
    globalLayout.setSpacing(true);
    addComponent(globalLayout);
    addComponent(errorLabel);
    /* Titre */
    title.addStyleName(StyleConstants.VIEW_TITLE);
    globalLayout.addComponent(title);
    /* Lock */
    lockLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    lockLabel.setVisible(false);
    globalLayout.addComponent(lockLabel);
    /* Layout pour le compte */
    VerticalLayout cptMinLayout = new VerticalLayout();
    cptMinLayout.setSizeFull();
    cptMinLayout.setSpacing(true);
    /* Layout de controle */
    controlLayout.setWidth(100, Unit.PERCENTAGE);
    controlLayout.setSpacing(true);
    cptMinLayout.addComponent(controlLayout);
    /* Boutons candidat */
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    controlLayout.addComponent(buttonsLayout);
    controlLayout.setExpandRatio(buttonsLayout, 1);
    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.addClickListener(e -> {
        candidatController.editAdminCptMin(cptMin, this);
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);
    if (isSiScolApo) {
        Button btnSyncApogee = new Button(applicationContext.getMessage("btnSyncApo", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
        btnSyncApogee.setDisableOnClick(true);
        btnSyncApogee.addClickListener(e -> {
            candidatController.synchronizeCandidat(cptMin, this);
            btnSyncApogee.setEnabled(true);
        });
        buttonsLayout.addComponent(btnSyncApogee);
        buttonsLayout.setComponentAlignment(btnSyncApogee, Alignment.MIDDLE_CENTER);
    }
    OneClickButton btnDelete = new OneClickButton(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()), FontAwesome.TRASH_O);
    btnDelete.addClickListener(e -> {
        candidatController.deleteCandidat(cptMin, this);
    });
    buttonsLayout.addComponent(btnDelete);
    buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_RIGHT);
    btnDeleteCnil.setCaption(applicationContext.getMessage("candidat.delete.cnil", null, UI.getCurrent().getLocale()));
    btnDeleteCnil.addClickListener(e -> {
        candidatController.deleteCandidatCnil(cptMin, this);
    });
    controlLayout.addComponent(btnDeleteCnil);
    controlLayout.setComponentAlignment(btnDeleteCnil, Alignment.MIDDLE_RIGHT);
    /* La table */
    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.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 250);
    table.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    cptMinLayout.addComponent(table);
    cptMinLayout.setExpandRatio(table, 1);
    table.setSizeFull();
    globalLayout.addComponent(cptMinLayout);
    globalLayout.setExpandRatio(cptMinLayout, 3);
    /* Les pièces */
    if (isSiScolApoPJ) {
        VerticalLayout pjLayout = new VerticalLayout();
        pjLayout.setSizeFull();
        pjLayout.setSpacing(true);
        /* Titre */
        titlePJ.addStyleName(StyleConstants.VIEW_TITLE);
        globalLayout.addComponent(titlePJ);
        /* Boutons candidat */
        buttonsLayoutPj.setWidth(100, Unit.PERCENTAGE);
        buttonsLayoutPj.setSpacing(true);
        pjLayout.addComponent(buttonsLayoutPj);
        Button btnSyncPjApogee = new Button(applicationContext.getMessage("candidat.admin.pj.btnSyncPjApo", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
        btnSyncPjApogee.setDisableOnClick(true);
        btnSyncPjApogee.addClickListener(e -> {
            candidatPieceController.adminSynchronizePJCandidat(cptMin, this);
            btnSyncPjApogee.setEnabled(true);
        });
        buttonsLayoutPj.addComponent(btnSyncPjApogee);
        buttonsLayoutPj.setComponentAlignment(btnSyncPjApogee, Alignment.MIDDLE_CENTER);
        containerPj.addNestedContainerProperty(PjCandidat_.id.getName() + "." + PjCandidatPK_.codAnuPjCandidat.getName());
        containerPj.addNestedContainerProperty(PjCandidat_.id.getName() + "." + PjCandidatPK_.codTpjPjCandidat.getName());
        for (String fieldName : FIELDS_ORDER_PJ) {
            tablePj.setColumnHeader(fieldName, applicationContext.getMessage("candidat.admin.pj.table." + fieldName, null, UI.getCurrent().getLocale()));
        }
        tablePj.addGeneratedColumn("file", new ColumnGenerator() {

            @Override
            public Object generateCell(final Table source, final Object itemId, final Object columnId) {
                final PjCandidat pjCandidat = (PjCandidat) itemId;
                if (pjCandidat != null && pjCandidat.getNomFicPjCandidat() != null && !pjCandidat.getNomFicPjCandidat().equals("")) {
                    String nomFichier = pjCandidat.getNomFicPjCandidat();
                    OnDemandFileLayout fileLayout = new OnDemandFileLayout(pjCandidat.getNomFicPjCandidat());
                    /* Viewer si JPG */
                    if (MethodUtils.isImgFileName(nomFichier)) {
                        fileLayout.addBtnViewerClickListener(e -> {
                            InputStream is = fileController.getInputStreamFromPjCandidat(pjCandidat);
                            if (is != null) {
                                ImageViewerWindow iv = new ImageViewerWindow(new OnDemandFile(nomFichier, is), null);
                                UI.getCurrent().addWindow(iv);
                            }
                        });
                    /* Opener si PDF */
                    } else if (MethodUtils.isPdfFileName(nomFichier)) {
                        fileLayout.addBtnViewerPdfBrowserOpener(new OnDemandStreamFile() {

                            @Override
                            public OnDemandFile getOnDemandFile() {
                                InputStream is = fileController.getInputStreamFromPjCandidat(pjCandidat);
                                return new OnDemandFile(nomFichier, is);
                            }
                        });
                    }
                    /* Bouton download */
                    fileLayout.addBtnDownloadFileDownloader(new OnDemandStreamFile() {

                        @Override
                        public OnDemandFile getOnDemandFile() {
                            InputStream is = fileController.getInputStreamFromPjCandidat(pjCandidat);
                            if (is != null) {
                                return new OnDemandFile(nomFichier, is);
                            }
                            return null;
                        }
                    });
                    return fileLayout;
                }
                return null;
            }
        });
        tablePj.setVisibleColumns((Object[]) FIELDS_ORDER_PJ);
        tablePj.setColumnCollapsingAllowed(true);
        tablePj.setColumnReorderingAllowed(true);
        tablePj.setSelectable(false);
        tablePj.setImmediate(true);
        globalLayout.addComponent(tablePj);
        globalLayout.setExpandRatio(tablePj, 1);
        pjLayout.addComponent(tablePj);
        pjLayout.setExpandRatio(tablePj, 1);
        tablePj.setSizeFull();
        globalLayout.addComponent(pjLayout);
        globalLayout.setExpandRatio(pjLayout, 2);
    }
}
Also used : PjCandidat(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat) OnDemandStreamFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) OnDemandFileLayout(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileLayout) FontAwesome(com.vaadin.server.FontAwesome) CandidatAdminListener(fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatAdminListener) CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) Label(com.vaadin.ui.Label) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) SpringView(com.vaadin.spring.annotation.SpringView) ValoTheme(com.vaadin.ui.themes.ValoTheme) CandidatPieceController(fr.univlorraine.ecandidat.controllers.CandidatPieceController) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) PjCandidat_(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat_) MethodUtils(fr.univlorraine.ecandidat.utils.MethodUtils) Resource(javax.annotation.Resource) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) FileController(fr.univlorraine.ecandidat.controllers.FileController) ApplicationContext(org.springframework.context.ApplicationContext) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) PjCandidatPK_(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidatPK_) ImageViewerWindow(fr.univlorraine.ecandidat.views.windows.ImageViewerWindow) ColumnHeaderMode(com.vaadin.ui.Table.ColumnHeaderMode) ParametreController(fr.univlorraine.ecandidat.controllers.ParametreController) PjCandidat(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat) List(java.util.List) Button(com.vaadin.ui.Button) Table(com.vaadin.ui.Table) HorizontalLayout(com.vaadin.ui.HorizontalLayout) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) PostConstruct(javax.annotation.PostConstruct) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) UserController(fr.univlorraine.ecandidat.controllers.UserController) View(com.vaadin.navigator.View) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) InputStream(java.io.InputStream) CandidatController(fr.univlorraine.ecandidat.controllers.CandidatController) OnDemandStreamFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile) Table(com.vaadin.ui.Table) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) InputStream(java.io.InputStream) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) ImageViewerWindow(fr.univlorraine.ecandidat.views.windows.ImageViewerWindow) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) Button(com.vaadin.ui.Button) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) VerticalLayout(com.vaadin.ui.VerticalLayout) OnDemandFileLayout(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileLayout) PostConstruct(javax.annotation.PostConstruct)

Aggregations

BeanItemContainer (com.vaadin.data.util.BeanItemContainer)1 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 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 Table (com.vaadin.ui.Table)1 ColumnGenerator (com.vaadin.ui.Table.ColumnGenerator)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 CandidatController (fr.univlorraine.ecandidat.controllers.CandidatController)1 CandidatPieceController (fr.univlorraine.ecandidat.controllers.CandidatPieceController)1 FileController (fr.univlorraine.ecandidat.controllers.FileController)1 ParametreController (fr.univlorraine.ecandidat.controllers.ParametreController)1