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