diff --git a/.classpath b/.classpath index 00f9692..456c4ad 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,7 @@ - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7f17fe1..c59d0c6 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,9 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=19 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=19 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -10,5 +11,5 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=19 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/GestionDesInscriptions.jar b/GestionDesInscriptions.jar index e1bba64..31e6bc6 100644 Binary files a/GestionDesInscriptions.jar and b/GestionDesInscriptions.jar differ diff --git a/base.xlsx b/base.xlsx new file mode 100644 index 0000000..efb61f8 Binary files /dev/null and b/base.xlsx differ diff --git a/base.xml b/base.xml index cc6739c..386ca9f 100644 --- a/base.xml +++ b/base.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/fichier.xlsx b/fichier.xlsx deleted file mode 100644 index 4228c6e..0000000 Binary files a/fichier.xlsx and /dev/null differ diff --git a/src/baseUFRHG/CreateCalcWorkbookExample.java b/src/baseUFRHG/CreateCalcWorkbookExample.java index 692daca..cdbb874 100644 --- a/src/baseUFRHG/CreateCalcWorkbookExample.java +++ b/src/baseUFRHG/CreateCalcWorkbookExample.java @@ -20,7 +20,7 @@ public class CreateCalcWorkbookExample { public CreateCalcWorkbookExample(Object[][] data){ - String filePath = Paths.get("").toAbsolutePath().toString()+ "/fichier.xlsx"; + String filePath = Paths.get("").toAbsolutePath().toString()+ "/base.xlsx"; @@ -61,10 +61,14 @@ public class CreateCalcWorkbookExample { int rowNum = 1; for (Object[] rowData : data1) { Row row = sheet.createRow(rowNum++); + int colNum = 0; for (Object cellData : rowData) { Cell cell = row.createCell(colNum++); - if (cellData instanceof String) { + if(cell.getColumnIndex()==0) { + // Dans la colonne A doit se trouver le numéro de l'étudiant de type Integer + cell.setCellValue(Integer.valueOf((String) cellData)); + }else if (cellData instanceof String) { cell.setCellValue((String) cellData); } else if (cellData instanceof Integer) { cell.setCellValue((Integer) cellData); diff --git a/src/baseUFRHG/ReadExcelExample.java b/src/baseUFRHG/ReadExcelExample.java new file mode 100644 index 0000000..12d2655 --- /dev/null +++ b/src/baseUFRHG/ReadExcelExample.java @@ -0,0 +1,93 @@ +package baseUFRHG; + +import java.io.FileInputStream; +import java.io.IOException; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class ReadExcelExample { + + public static void lecture() { + + noeud nBase = recupeBases.recupeLaBase(); + + try (FileInputStream fileInputStream = new FileInputStream("base.xlsx"); + Workbook workbook = new XSSFWorkbook(fileInputStream)) { + + int numSheets = workbook.getNumberOfSheets(); + +// Object[][] data = new Object[numSheets][28]; + +// int indexSheet = 0; + for (int sheetIndex = 0; sheetIndex < numSheets; sheetIndex++) { + Sheet sheet = workbook.getSheetAt(sheetIndex); + + if( nBase.getChild(sheet.getSheetName())!=null ) { + + System.out.println("Feuille : " + sheet.getSheetName()); + noeud nBF = nBase.getChild(sheet.getSheetName()); + + + + for (Row row : sheet) { + int indexCol = 0; + noeud nStudent = null; + + for (Cell cell : row) { + + indexCol = cell.getColumnIndex(); + + if(indexCol==0) { + if (cell.getCellType() == CellType.NUMERIC) { + String idStudent = String.valueOf( (int) cell.getNumericCellValue()); + nStudent = nBF.getChild("n"+idStudent); + } else if(cell.getCellType() == CellType.STRING) { + String idStudent = cell.getStringCellValue(); + nStudent = nBF.getChild("n"+idStudent); + } + } + + + if(nStudent!=null) { + CellType cellType = cell.getCellType(); + if (cellType == CellType.STRING) { + String cellValue = cell.getStringCellValue(); + nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue); + System.out.print(cellValue + " "); + } else if (cellType == CellType.NUMERIC) { + String cellValue = String.valueOf( (int) cell.getNumericCellValue()); + nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue); + System.out.print(cellValue + " "); + } else if (cellType == CellType.BOOLEAN) { + boolean cellValue = cell.getBooleanCellValue(); + nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(),String.valueOf(cellValue)); + System.out.print(cellValue + " "); + } else { + // Autres types de cellules (formules, vides, etc.) + nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(),""); + System.out.print("[Type de cellule non pris en charge] "); + } + } + + + + } + + System.out.println(); // Nouvelle ligne après chaque ligne du tableau + } + + }; + System.out.println(); // Nouvelle ligne entre les feuilles + } + + } catch (IOException e) { + e.printStackTrace(); + } + sauvegardeXMLBase.save(nBase); + } +} diff --git a/src/baseUFRHG/base.java b/src/baseUFRHG/base.java index 382755f..ec23c3c 100644 --- a/src/baseUFRHG/base.java +++ b/src/baseUFRHG/base.java @@ -32,7 +32,7 @@ public class base { userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput); - if(!userInput.isBlank()) { + if(!userInput.isEmpty()) { nBase.addChild(new noeud(userInput)); nBase.setAttribut("defaut_Year", userInput); diff --git a/src/baseUFRHG/demarre.java b/src/baseUFRHG/demarre.java index ae278e5..52559c1 100644 --- a/src/baseUFRHG/demarre.java +++ b/src/baseUFRHG/demarre.java @@ -47,7 +47,7 @@ public class demarre extends JFrame { frmEvalwriter = new JFrame(); frmEvalwriter.setResizable(false); frmEvalwriter.setTitle("Gestion des inscriptions et des groupes - langues - informatique - stage - rentrée"); - frmEvalwriter.setBounds(100, 100, 607, 438); + frmEvalwriter.setBounds(100, 100, 602, 488); int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth(); int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight(); frmEvalwriter.setLocation(( (screenWidth) - frmEvalwriter.getWidth()) / 2, (screenHeight - frmEvalwriter.getHeight()) / 2); @@ -58,7 +58,7 @@ public class demarre extends JFrame { // frmEvalwriter.setIconImage(img.getImage()); btnCreate = new JButton("Exporter base dans classeur MS Excel"); - btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/renommeEvaluaton.png"))); + btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/exportInscriptionToBase.png"))); btnCreate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { noeud nBase = recupeBases.recupeLaBase(); @@ -70,7 +70,7 @@ public class demarre extends JFrame { btnCreate.setFont(new Font("Arial", Font.BOLD, 16)); // btnCreate.addActionListener(this); - btnCreate.setBounds(10, 180, 571, 60); + btnCreate.setBounds(10, 211, 566, 60); frmEvalwriter.getContentPane().add(btnCreate); actCharge = new JButton("Importer des inscriptions depuis CSV (UTF-8, point-virgule)"); @@ -80,33 +80,35 @@ public class demarre extends JFrame { } }); actCharge.setHorizontalAlignment(SwingConstants.LEFT); - actCharge.setIcon(new ImageIcon(demarre.class.getResource("/resources/chargehistoriqueevaluation.png"))); + actCharge.setIcon(new ImageIcon(demarre.class.getResource("/resources/importInscriptionToBase.png"))); actCharge.setBackground(SystemColor.inactiveCaption); // actCharge.addActionListener(this); actCharge.setFont(new Font("Arial", Font.BOLD, 16)); - actCharge.setBounds(10, 109, 571, 60); + actCharge.setBounds(10, 109, 566, 60); frmEvalwriter.getContentPane().add(actCharge); JLabel lblNewLabel = new JLabel(); + lblNewLabel.setIcon(new ImageIcon(demarre.class.getResource("/resources/accueil.png"))); // lblNewLabel.setIcon(new ImageIcon(demarre.class.getResource("/resources/accueilanalysecalc.png"))); lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT); lblNewLabel.setFont(new Font("Pacifico", Font.PLAIN, 26)); - lblNewLabel.setBounds(10, 25, 571, 74); + lblNewLabel.setBounds(10, 14, 571, 60); frmEvalwriter.getContentPane().add(lblNewLabel); - JButton btnNewButton = new JButton("Modifier la base depuis classeur MS Excel"); + JButton btnNewButton = new JButton("Mise à jour de la base depuis classeur MS Excel"); + btnNewButton.setIcon(new ImageIcon(demarre.class.getResource("/resources/majInscriptionToBase.png"))); btnNewButton.setHorizontalAlignment(SwingConstants.LEFT); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - + ReadExcelExample.lecture(); } }); btnNewButton.setFont(new Font("Arial", Font.BOLD, 16)); // btnNewButton.setIcon(new ImageIcon(demarre.class.getResource("/resources/apropos.png"))); - btnNewButton.setBounds(10, 258, 571, 60); + btnNewButton.setBounds(10, 313, 566, 60); frmEvalwriter.getContentPane().add(btnNewButton); - JButton btnTutoriels = new JButton("Modifier la base depuis le gestionnaire"); + JButton btnTutoriels = new JButton("Mise à jour de la base depuis le gestionnaire"); btnTutoriels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { @@ -122,11 +124,22 @@ public class demarre extends JFrame { // btnTutoriels.setIcon(new ImageIcon(demarre.class.getResource("/resources/tutoriel.png"))); btnTutoriels.setHorizontalAlignment(SwingConstants.LEFT); btnTutoriels.setFont(new Font("Arial", Font.BOLD, 16)); - btnTutoriels.setBounds(10, 328, 571, 60); + btnTutoriels.setBounds(10, 375, 566, 60); frmEvalwriter.getContentPane().add(btnTutoriels); + + JLabel lblNewLabel_1 = new JLabel("Inscriptions des étudiants depuis un fichier"); + lblNewLabel_1.setFont(new Font("Arial", Font.BOLD, 14)); + lblNewLabel_1.setBounds(10, 77, 385, 30); + frmEvalwriter.getContentPane().add(lblNewLabel_1); + + JLabel lblNewLabel_1_1 = new JLabel("Exporter la base"); + lblNewLabel_1_1.setFont(new Font("Arial", Font.BOLD, 14)); + lblNewLabel_1_1.setBounds(10, 180, 347, 30); + frmEvalwriter.getContentPane().add(lblNewLabel_1_1); + + JLabel lblNewLabel_1_1_1 = new JLabel("Mise à jour de la base"); + lblNewLabel_1_1_1.setFont(new Font("Arial", Font.BOLD, 14)); + lblNewLabel_1_1_1.setBounds(10, 283, 347, 30); + frmEvalwriter.getContentPane().add(lblNewLabel_1_1_1); } - - - - } diff --git a/src/baseUFRHG/exportBaseToExcel.java b/src/baseUFRHG/exportBaseToExcel.java index 50b7267..305f269 100644 --- a/src/baseUFRHG/exportBaseToExcel.java +++ b/src/baseUFRHG/exportBaseToExcel.java @@ -5,7 +5,7 @@ public class exportBaseToExcel { public static void export(noeud nBase) { - // Données pour les colonnes A et B + // Données Object[][] data = new Object[nBase.getChild(nBase.getAttributes("defaut_Year")).getNumberChildren()][28]; int indexFormation = 0 ; diff --git a/src/baseUFRHG/lectureCSV.java b/src/baseUFRHG/lectureCSV.java index 8f8aea8..6142349 100644 --- a/src/baseUFRHG/lectureCSV.java +++ b/src/baseUFRHG/lectureCSV.java @@ -1,14 +1,9 @@ package baseUFRHG; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; import javax.swing.JFrame; import javax.swing.JLabel; diff --git a/src/baseUFRHG/majBase.java b/src/baseUFRHG/majBase.java index 61be0a8..886cba6 100644 --- a/src/baseUFRHG/majBase.java +++ b/src/baseUFRHG/majBase.java @@ -1,12 +1,5 @@ package baseUFRHG; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; - import javax.swing.JOptionPane; public class majBase { @@ -21,7 +14,7 @@ public class majBase { for(int i = 0 ; i < nCSV.getChildren().size();i++) { if(nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.")!=null) { - if(!nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.").isBlank()) { + if(!nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.").isEmpty()) { if(!isExisteFormationIntoBase(nBase, nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib."))) { nBase.getChild(defaut_Year).addChild(new noeud( supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.")))); } @@ -32,15 +25,8 @@ public class majBase { } - // Sauvegarde de la base - String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml"; - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(directoryName), StandardCharsets.UTF_8))) { - writer.write(nBase.toWrite()); - } catch (IOException e) { - e.printStackTrace(); - } + sauvegardeXMLBase.save(nBase); //Affiche le nombre d'étudiant ajouté à la base. JOptionPane.showMessageDialog(null, "Nombre d'étudiant ajouté à la base : " + String.valueOf(compteurAddStudent)); @@ -65,7 +51,7 @@ public class majBase { private static noeud majStudentIntoBase(noeud nBase, noeud nStudent) { if (nStudent.getAttributes("IAE_-_Etape_lib.")!=null && nStudent.getAttributes("Individu_-_Code_Etudiant")!=null){ - if(isValidEightDigits(nStudent.getAttributes("Individu_-_Code_Etudiant")) && !nStudent.getAttributes("IAE_-_Etape_lib.").isBlank() ) { + if(isValidEightDigits(nStudent.getAttributes("Individu_-_Code_Etudiant")) && !nStudent.getAttributes("IAE_-_Etape_lib.").isEmpty() ) { if(isExisteFormationIntoBase(nBase, nStudent.getAttributes("IAE_-_Etape_lib."))) { noeud nBF = nBase.getChild(defaut_Year).getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nStudent.getAttributes("IAE_-_Etape_lib."))); diff --git a/src/baseUFRHG/noeud.java b/src/baseUFRHG/noeud.java index 2290d5b..657c0d2 100644 --- a/src/baseUFRHG/noeud.java +++ b/src/baseUFRHG/noeud.java @@ -331,7 +331,7 @@ public class noeud { */ public boolean hasContent() { if(this.content!=null) { - if(!this.content.isBlank()) return true; + if(!this.content.isEmpty()) return true; } return false; } diff --git a/src/baseUFRHG/sauvegardeXMLBase.java b/src/baseUFRHG/sauvegardeXMLBase.java new file mode 100644 index 0000000..9c49c8e --- /dev/null +++ b/src/baseUFRHG/sauvegardeXMLBase.java @@ -0,0 +1,24 @@ +package baseUFRHG; + +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; + +public class sauvegardeXMLBase { + + public static void save(noeud nBase) { + + // Sauvegarde de la base + String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml"; + try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(directoryName), StandardCharsets.UTF_8))) { + writer.write(nBase.toWrite()); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/resources/accueil.png b/src/resources/accueil.png new file mode 100644 index 0000000..4428e6f Binary files /dev/null and b/src/resources/accueil.png differ diff --git a/src/resources/exportInscriptionToBase.png b/src/resources/exportInscriptionToBase.png new file mode 100644 index 0000000..7ecfa67 Binary files /dev/null and b/src/resources/exportInscriptionToBase.png differ diff --git a/src/resources/importInscriptionToBase.png b/src/resources/importInscriptionToBase.png new file mode 100644 index 0000000..8f71f0e Binary files /dev/null and b/src/resources/importInscriptionToBase.png differ diff --git a/src/resources/majInscriptionToBase.png b/src/resources/majInscriptionToBase.png new file mode 100644 index 0000000..4e10f90 Binary files /dev/null and b/src/resources/majInscriptionToBase.png differ