2023-04-01 09:54:28 +02:00
package baseEvaluations ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.List ;
import javax.swing.table.AbstractTableModel ;
import MEPTL.commandes ;
import cXML.node ;
public class myTableBaseEvaluation extends AbstractTableModel {
2024-04-21 13:26:19 +02:00
private String [ ] [ ] evaluation = new String [ 0 ] [ 6 ] ;
private List < String > columNames = new ArrayList < > ( Arrays . asList ( new String [ ] { " Nom de l'évaluation " , " Date de création " , " Date de modification " , " Titre de l'exercice " , " Propriété personnalisé Sujet " , " Nom du fichier d'analyse " } ) ) ;
2023-04-01 09:54:28 +02:00
/ * *
*
* /
private static final long serialVersionUID = 1L ;
@Override
public int getRowCount ( ) {
return evaluation . length ;
}
@Override
public int getColumnCount ( ) {
return columNames . size ( ) ;
}
@Override
public String getValueAt ( int rowIndex , int columnIndex ) {
return evaluation [ rowIndex ] [ columnIndex ] ;
}
@Override
public void setValueAt ( Object aValue , int rowIndex , int columnIndex ) {
evaluation [ rowIndex ] [ columnIndex ] = ( String ) aValue ;
fireTableCellUpdated ( rowIndex , columnIndex ) ;
}
public String getColumnName ( int column ) {
return columNames . get ( column ) ;
}
public String getNameEvaluation ( int rowIndex ) {
return evaluation [ rowIndex ] [ 0 ] ;
}
2024-04-06 13:44:21 +02:00
2023-04-01 09:54:28 +02:00
public void addOrUpdate ( ) {
evaluation = new String [ commandes . evaluationsBase . getNodes ( ) . size ( ) ] [ columNames . size ( ) ] ;
for ( int i = 0 ; i < commandes . evaluationsBase . getNodes ( ) . size ( ) ; i + + ) {
2024-04-21 13:26:19 +02:00
String dateCreation = " " ;
2023-04-01 09:54:28 +02:00
evaluation [ i ] [ 0 ] = commandes . evaluationsBase . getNodes ( ) . get ( i ) . getAttributs ( ) . get ( " name " ) ;
2024-04-21 13:26:19 +02:00
if ( commandes . evaluationsBase . getNodes ( ) . get ( i ) . getAttributs ( ) . get ( " date " ) ! = null ) {
dateCreation = calcul . formatDateWriter . DateEnClairFR ( calcul . formatDateWriter . DateLibreOffice ( commandes . evaluationsBase . getNodes ( ) . get ( i ) . getAttributs ( ) . get ( " date " ) ) ) ;
}
evaluation [ i ] [ 1 ] = dateCreation ;
if ( commandes . evaluationsBase . getNodes ( ) . get ( i ) . getAttributs ( ) . get ( " dateModification " ) ! = null ) {
evaluation [ i ] [ 2 ] = calcul . formatDateWriter . DateEnClairFR ( calcul . formatDateWriter . DateLibreOffice ( commandes . evaluationsBase . getNodes ( ) . get ( i ) . getAttributs ( ) . get ( " dateModification " ) ) ) ;
} else {
evaluation [ i ] [ 2 ] = dateCreation ;
}
2023-04-01 09:54:28 +02:00
node fichier = commandes . evaluationsBase . getNodes ( ) . get ( i ) . retourneFirstEnfantsByName ( " fichier " ) ;
2024-04-21 13:26:19 +02:00
evaluation [ i ] [ 3 ] = fichier . getAttributs ( ) . get ( " titre " ) ;
evaluation [ i ] [ 4 ] = fichier . getAttributs ( ) . get ( " metaSujet " ) ;
evaluation [ i ] [ 5 ] = fichier . getAttributs ( ) . get ( " analysis_filename " ) ;
2023-04-01 09:54:28 +02:00
}
fireTableRowsInserted ( 0 , commandes . evaluationsBase . getNodes ( ) . size ( ) - 1 ) ;
}
}