Composant ModalDataTable - TecostNetwork/Network GitHub Wiki

Exemple d'appel à la popup


public void showHistory(ActionEvent e) {
    Antecedent antecedent = BeanResolver.getBean(Antecedent.class);
    antecedent = antecedent.reload();
    AntecedentService.initialize(antecedent);
    ModalDataTable.show(AntecedentService.createHistoryTable(antecedent.getVersions()), Translator.$("/Antecedent/Antecedent modification history"));
}

Exemple de création du modèle de table

public static TableModel createHistoryTable(List<AntecedentVersion> antecedents) {

    TableModel table = new TableModel();
    TableCol col1 = new TableCol(Translator.$("/Modification"), true);
    TableCol col2 = new TableCol(Translator.$("/Period"), true);
    TableCol col3 = new TableCol(Translator.$("/Antecedent/Type"), false);
    TableCol col4 = new TableCol(Translator.$("/Antecedent/Diagnostic"), false);
    TableCol col5 = new TableCol(Translator.$("/Antecedent/Diagnostic by"), false);
    TableCol col6 = new TableCol(Translator.$("/Comment"), false);
    TableCol col7 = new TableCol(Translator.$("/Docs"), false);
    TableCol col8 = new TableCol(Translator.$("/Active"), false);

    table.setSortedCol(col1);
    table.setColumns(Arrays.asList(col1, col2, col3, col4, col5, col6, col7, col8));

    int i = 0;
    for (AntecedentVersion antecedent : antecedents) {
        TableRow row = new TableRow(i++);
        row.getCellsByCols().put(col1, new TableCell(new TableCellTrace(antecedent.getModification(), false)));
        row.getCellsByCols().put(col2, new TableCell(new TableCellDate(DateUtils.toJavaUtilDate(antecedent.getStartDate())), new TableCellDate(DateUtils.toJavaUtilDate(antecedent.getEndDate()))));
        row.getCellsByCols().put(col4, new TableCell(new TableCellText(antecedent.getDiagnostic())));
        row.getCellsByCols().put(col5, new TableCell(antecedent.getDoctor() != null ? new TableCellText(antecedent.getDoctor().getName()) : new TableCellText()));
        row.getCellsByCols().put(col3, new TableCell(new TableCellText(antecedent.getType().getTranslation())));
        row.getCellsByCols().put(col6, new TableCell(new TableCellText(antecedent.getComment())));
        List<TableCellContent> docCell = new ArrayList<>();
        antecedent.getDocuments().stream().forEach(doc -> {
            docCell.add(new TableCellGeneralDocument(doc));
        });
        row.getCellsByCols().put(col7, new TableCell(docCell));
        row.getCellsByCols().put(col8, new TableCell(new TableCellText(Translator.$("/" + antecedent.getActive().toString()))));
        table.getRows().add(row);
    }

    return table;
}