diff --git a/base/base.xml b/base/base.xml index 6f86d4b..77b9814 100644 --- a/base/base.xml +++ b/base/base.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/base/base_sauvegarde.xml b/base/base_sauvegarde.xml index 7904eb0..dc7c443 100644 --- a/base/base_sauvegarde.xml +++ b/base/base_sauvegarde.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/baseUFRHG/importInscriptionCSV.java b/src/Inscriptions/importInscriptionCSV.java similarity index 85% rename from src/baseUFRHG/importInscriptionCSV.java rename to src/Inscriptions/importInscriptionCSV.java index d006ff3..007755f 100644 --- a/src/baseUFRHG/importInscriptionCSV.java +++ b/src/Inscriptions/importInscriptionCSV.java @@ -1,4 +1,4 @@ -package baseUFRHG; +package Inscriptions; import java.io.File; @@ -6,6 +6,11 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; +import baseUFRHG.FileChooserCSV; +import baseUFRHG.commandes; +import baseUFRHG.noeud; +import baseUFRHG.recupeBases; + public class importInscriptionCSV { diff --git a/src/baseUFRHG/importInscriptionXLS.java b/src/Inscriptions/importInscriptionXLS.java similarity index 63% rename from src/baseUFRHG/importInscriptionXLS.java rename to src/Inscriptions/importInscriptionXLS.java index cce40b9..96db7cf 100644 --- a/src/baseUFRHG/importInscriptionXLS.java +++ b/src/Inscriptions/importInscriptionXLS.java @@ -1,4 +1,4 @@ -package baseUFRHG; +package Inscriptions; import java.io.File; import java.io.FileInputStream; @@ -15,6 +15,12 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import baseUFRHG.commandes; +import baseUFRHG.noeud; +import baseUFRHG.recupeBases; +import baseUFRHG.sauvegardeXMLBase; +import baseUFRHG.supprimeCaracatresSpeciaux; + public class importInscriptionXLS { public static void importe(File file) { @@ -36,24 +42,62 @@ public class importInscriptionXLS { return; } - + int compteurInscription = 0; try (FileInputStream fileInputStream = new FileInputStream(file.getAbsolutePath()); - Workbook workbook = new XSSFWorkbook(fileInputStream)) { - -// int numSheets = workbook.getNumberOfSheets(); - + + + // Récupère le classeur + Workbook workbook = new XSSFWorkbook(fileInputStream)) { + + // La première feuille du classeur contient toute les inscriptions. + // Il n'est pas utile de parcourir toutes les feuilles (sheet). Sheet sheet = workbook.getSheetAt(0); + // Vérification du nom de la feuille if(!sheet.getSheetName().equals("Inscrits détail")) { JOptionPane.showMessageDialog(null, "Ce n'est pas une feuille d'inscription de luniversité d'Artois."); return; } + //Vérification de la présence des colonnes obligatoires + boolean nomPresent = false; + boolean prenomPresent = false; + boolean codePresent = false; + boolean formationPresent = false; + boolean profilPresent = false; + boolean bacPresent = false; + boolean mailpersoPresent = false; + boolean mailPresent = false; + boolean portablePresent = false; + for (Cell cell : sheet.getRow(0)) { + if(cell.getCellType()==CellType.STRING) { + if(cell.getStringCellValue().equals("Individu - Nom")) nomPresent=true; + if(cell.getStringCellValue().equals("Individu - Prénom")) prenomPresent=true; + if(cell.getStringCellValue().equals("Individu - Code Etudiant")) codePresent=true; + if(cell.getStringCellValue().equals("IAE - Etape (lib.)")) formationPresent=true; + if(cell.getStringCellValue().equals("Profil étudiant (lib.)")) profilPresent=true; + if(cell.getStringCellValue().equals("Bac ou équivalence (lib.)")) bacPresent=true; + if(cell.getStringCellValue().equals("Individu - Email personnel")) mailpersoPresent=true; + if(cell.getStringCellValue().equals("Individu - Email")) mailPresent=true; + if(cell.getStringCellValue().equals("Individu - Tél. portable")) portablePresent=true; + } + } + if(!(nomPresent&&prenomPresent&&codePresent&&formationPresent&&profilPresent + &&bacPresent&&mailpersoPresent&&mailPresent&&portablePresent)) { + JOptionPane.showMessageDialog(null, "Ce n'est pas une feuille d'inscription de luniversité d'Artois."); + return; + } + + + // Entête de la table. Correspond à la première ligne de la feuille Map Head = new HashMap(); - - + + // Parcour les lignes de la feuille. + // Pour chque ligne : récupérer les informations dans des HashMap. + // Head : uniquement pour la première ligne + // student : les informations d'un étudiant. for (Row row : sheet) { Map Student = new HashMap(); @@ -63,24 +107,28 @@ public class importInscriptionXLS { }else { if(cell.getCellType()== CellType.STRING) { Student.put(Head.get(cell.getColumnIndex()), String.valueOf(cell.getStringCellValue())); - }if (cell.getCellType()== CellType.NUMERIC) { + } + if (cell.getCellType()== CellType.NUMERIC) { Student.put(Head.get(cell.getColumnIndex()), String.valueOf(Integer.valueOf((int) cell.getNumericCellValue()))); - } else { - - } - + } } } + + + // Création ou insertion des informations récupéré dans le HashMap Student; if(Student.get("IAE - Etape (lib.)")!=null) { String nameFormation = supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(Student.get("IAE - Etape (lib.)")); noeud nFormation = null; + + // récupère le noeud formation ou bien création du noeud formation if(nYear.getChild(nameFormation)!=null) { nFormation = nYear.getChild(nameFormation); }else { nFormation = new noeud(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nameFormation)); nFormation.setAttribut("Colonne_Groupe_Documentation", "true"); nFormation.setAttribut("Colonne_Groupe_Informatique", "true"); - nFormation.setAttribut("Colonne_Groupe_Langue", "true"); + nFormation.setAttribut("Colonne_Groupe_LV1", "true"); + nFormation.setAttribut("Colonne_Groupe_LV2", "true"); nFormation.setAttribut("Colonne_Groupe_Principal", "true"); nFormation.setAttribut("Colonne_Groupe_Projet", "true"); nFormation.setAttribut("Colonne_Groupe_TD", "true"); @@ -92,6 +140,7 @@ public class importInscriptionXLS { nFormation.setAttribut("Colonne_Stage2", "true"); nYear.addChild(nFormation); } + String nameNoeudStudent = "n"+String.valueOf(Student.get("Individu - Code Etudiant")); noeud nStudent = null; if(nFormation.getChild(nameNoeudStudent)!=null) { @@ -101,6 +150,8 @@ public class importInscriptionXLS { nFormation.addChild(nStudent); } + // Les noms de colonnes obligatoires pour la création + // Le noms des colonnes subissent un traitement pour supprimer les espaces et les carcatères spéciaux. for (Map.Entry entry : Student.entrySet()) { if(entry.getKey().equals("Individu - Nom") || entry.getKey().equals("Individu - Prénom") @@ -115,10 +166,12 @@ public class importInscriptionXLS { } } + // Ajoute les attributs de l'application if(nStudent.getAttributes("Groupe_Principal")==null) nStudent.setAttribut("Groupe_Principal",""); if(nStudent.getAttributes("Groupe_Informatique")==null) nStudent.setAttribut("Groupe_Informatique",""); if(nStudent.getAttributes("Groupe_TD")==null) nStudent.setAttribut("Groupe_TD",""); - if(nStudent.getAttributes("Groupe_Langue")==null) nStudent.setAttribut("Groupe_Langue",""); + if(nStudent.getAttributes("Groupe_LV1")==null) nStudent.setAttribut("Groupe_LV1",""); + if(nStudent.getAttributes("Groupe_LV2")==null) nStudent.setAttribut("Groupe_LV2",""); if(nStudent.getAttributes("Groupe_Doc")==null) nStudent.setAttribut("Groupe_Doc",""); if(nStudent.getAttributes("Groupe_Projet")==null) nStudent.setAttribut("Groupe_Projet",""); if(nStudent.getAttributes("Covoiturage")==null) nStudent.setAttribut("Covoiturage","non"); @@ -138,20 +191,19 @@ public class importInscriptionXLS { if(nStudent.getAttributes("Atelier_pre-rentree_enseignant")==null) nStudent.setAttribut("Atelier_pre-rentree_enseignant",""); if(nStudent.getAttributes("Atelier_pre-rentree_salle")==null) nStudent.setAttribut("Atelier_pre-rentree_salle",""); if(nStudent.getAttributes("Regime")==null) nStudent.setAttribut("Regime",""); - - - System.out.println( nStudent.toWrite()); // Nouvelle ligne après chaque ligne du tableau } + compteurInscription++; } - - } catch (IOException e) { e.printStackTrace(); + JOptionPane.showInternalMessageDialog(null, e.toString()); } - sauvegardeXMLBase.save(commandes.nBase,sauvegardeXMLBase.saveType.SANS_MESSAGE); - JOptionPane.showMessageDialog(null, "Importation des inscriptions et les mises à jour sont réussies."); + sauvegardeXMLBase.save(commandes.nBase,sauvegardeXMLBase.saveType.SANS_MESSAGE,""); + if(compteurInscription>1) JOptionPane.showMessageDialog(null, "Les importations ou les mises à jour
des " + String.valueOf(compteurInscription) +" étudiants sont réussies."); + if(compteurInscription==1) JOptionPane.showMessageDialog(null, "L'importation ou la mise à jour
du seul étudiant est réussi."); + if(compteurInscription==0) JOptionPane.showMessageDialog(null, "Il n'y a pas eu d'importation ou de mise à jour."); } diff --git a/src/baseUFRHG/lectureCSV.java b/src/Inscriptions/lectureCSV.java similarity index 91% rename from src/baseUFRHG/lectureCSV.java rename to src/Inscriptions/lectureCSV.java index 82bb89b..8cac042 100644 --- a/src/baseUFRHG/lectureCSV.java +++ b/src/Inscriptions/lectureCSV.java @@ -1,4 +1,4 @@ -package baseUFRHG; +package Inscriptions; import java.io.BufferedReader; import java.io.FileInputStream; @@ -9,6 +9,10 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; +import baseUFRHG.FileEncodingDetector; +import baseUFRHG.noeud; +import baseUFRHG.supprimeCaracatresSpeciaux; + public class lectureCSV { diff --git a/src/baseUFRHG/majBaseWithCSV.java b/src/Inscriptions/majBaseWithCSV.java similarity index 91% rename from src/baseUFRHG/majBaseWithCSV.java rename to src/Inscriptions/majBaseWithCSV.java index 195cc51..9f8e7eb 100644 --- a/src/baseUFRHG/majBaseWithCSV.java +++ b/src/Inscriptions/majBaseWithCSV.java @@ -1,7 +1,10 @@ -package baseUFRHG; +package Inscriptions; import javax.swing.JOptionPane; +import baseUFRHG.noeud; +import baseUFRHG.sauvegardeXMLBase; +import baseUFRHG.supprimeCaracatresSpeciaux; import baseUFRHG.sauvegardeXMLBase.saveType; public class majBaseWithCSV { @@ -21,7 +24,8 @@ public class majBaseWithCSV { noeud nFormation = new noeud( supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib."))); nFormation.setAttribut("Colonne_Groupe_Documentation", "true"); nFormation.setAttribut("Colonne_Groupe_Informatique", "true"); - nFormation.setAttribut("Colonne_Groupe_Langue", "true"); + nFormation.setAttribut("Colonne_Groupe_LV1", "true"); + nFormation.setAttribut("Colonne_Groupe_LV2", "true"); nFormation.setAttribut("Colonne_Groupe_Principal", "true"); nFormation.setAttribut("Colonne_Groupe_Projet", "true"); nFormation.setAttribut("Colonne_Groupe_TD", "true"); @@ -41,7 +45,7 @@ public class majBaseWithCSV { } // Sauvegarde de la base - sauvegardeXMLBase.save(nBase, saveType.WITH_MESSAGE); + sauvegardeXMLBase.save(nBase, saveType.WITH_DEFAULT_MESSAGE,""); //Affiche le nombre d'étudiant ajouté à la base. JOptionPane.showMessageDialog(null, "Nombre d'étudiant ajouté à la base : " + String.valueOf(compteurAddStudent)); @@ -93,7 +97,8 @@ public class majBaseWithCSV { n.setAttribut("Groupe_Principal",""); n.setAttribut("Groupe_Informatique",""); n.setAttribut("Groupe_TD",""); - n.setAttribut("Groupe_Langue",""); + n.setAttribut("Groupe_LV1",""); + n.setAttribut("Groupe_LV2",""); n.setAttribut("Groupe_Doc",""); n.setAttribut("Groupe_Projet",""); n.setAttribut("Covoiturage","non"); diff --git a/src/baseUFRHG/Window_Help_download_and_install.java b/src/Windows/Window_Help_download_and_install.java similarity index 95% rename from src/baseUFRHG/Window_Help_download_and_install.java rename to src/Windows/Window_Help_download_and_install.java index c207cba..8d1b724 100644 --- a/src/baseUFRHG/Window_Help_download_and_install.java +++ b/src/Windows/Window_Help_download_and_install.java @@ -1,4 +1,4 @@ -package baseUFRHG; +package Windows; import javax.swing.JFrame; import javax.swing.JLabel; diff --git a/src/baseUFRHG/Window_Help_maj_data.java b/src/Windows/Window_Help_maj_data.java similarity index 95% rename from src/baseUFRHG/Window_Help_maj_data.java rename to src/Windows/Window_Help_maj_data.java index 82c8848..e1bca26 100644 --- a/src/baseUFRHG/Window_Help_maj_data.java +++ b/src/Windows/Window_Help_maj_data.java @@ -1,4 +1,4 @@ -package baseUFRHG; +package Windows; import javax.swing.JFrame; import javax.swing.JLabel; diff --git a/src/baseUFRHG/Window_demarre.java b/src/Windows/Window_demarre.java similarity index 93% rename from src/baseUFRHG/Window_demarre.java rename to src/Windows/Window_demarre.java index c36dd90..8478ec3 100644 --- a/src/baseUFRHG/Window_demarre.java +++ b/src/Windows/Window_demarre.java @@ -1,4 +1,4 @@ -package baseUFRHG; +package Windows; import java.awt.Color; import java.awt.Desktop; @@ -24,6 +24,16 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingConstants; +import Inscriptions.importInscriptionCSV; +import Inscriptions.importInscriptionXLS; +import baseUFRHG.FileChooserXLSX; +import baseUFRHG.VersionChecker; +import baseUFRHG.commandes; +import baseUFRHG.exportBaseToExcel; +import baseUFRHG.importAllBaseToExcel; +import baseUFRHG.recupeBases; +import baseUFRHG.sauvegardeXMLBase; + public class Window_demarre extends JFrame { /** @@ -43,15 +53,18 @@ public class Window_demarre extends JFrame { // Vérification d'une nouvelle version dans la forge de Chapril VersionChecker.verificationNewVersion(); + + // mise à jour de la base de données si nouvelle version de l'application utilisé. + commandes.nBase=recupeBases.recupeLaBase(); + VersionChecker.UpdateVersion(commandes.nBase); + + Window_demarre window = new Window_demarre(); //Affichage de la fenêtre window.frmEvalwriter.setVisible(true); - // mise à jour de la base de données si nouvelle version de l'application utilisé. - if(commandes.nBase!=null) { - VersionChecker.UpdateVersion(commandes.nBase); - } + // Créez un Timer Timer timer = new Timer(); @@ -74,7 +87,7 @@ public class Window_demarre extends JFrame { } public Window_demarre() { - commandes.nBase = recupeBases.recupeLaBase(); +// commandes.nBase = recupeBases.recupeLaBase(); initialize(); } diff --git a/src/baseUFRHG/Window_gestionnaire.java b/src/Windows/Window_gestionnaire.java similarity index 81% rename from src/baseUFRHG/Window_gestionnaire.java rename to src/Windows/Window_gestionnaire.java index 93d3f85..9ea8fb7 100644 --- a/src/baseUFRHG/Window_gestionnaire.java +++ b/src/Windows/Window_gestionnaire.java @@ -1,4 +1,6 @@ -package baseUFRHG; +package Windows; + + import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -39,6 +41,7 @@ import javax.swing.JTextPane; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; +import javax.swing.UIManager; import javax.swing.border.BevelBorder; import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; @@ -52,6 +55,11 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import baseUFRHG.sauvegardeXMLBase.saveType; +import baseUFRHG.FileChooserXML; +import baseUFRHG.commandes; +import baseUFRHG.noeud; +import baseUFRHG.recupeBases; +import baseUFRHG.sauvegardeXMLBase; import baseUFRHG.actions.exportEmargement; import baseUFRHG.actions.exportTable; import baseUFRHG.actions.saveTable; @@ -72,7 +80,8 @@ public class Window_gestionnaire extends JFrame { private JComboBox cLV1; private JComboBox cLV2; private JComboBox cInformatique; - private JComboBox cLangue; + private JComboBox cLangueLV1; + private JComboBox cLangueLV2; private JComboBox cDocumentation; private JComboBox cProfil; private JComboBox cGroupePrincipal; @@ -80,7 +89,8 @@ public class Window_gestionnaire extends JFrame { private JComboBox cRegime; private JCheckBoxMenuItem chckToutesLesColonnes = new JCheckBoxMenuItem("Affiche toutes les colonnes"); private JCheckBoxMenuItem chckGroupeTD = new JCheckBoxMenuItem("Groupe TD"); - private JCheckBoxMenuItem chckGroupeLangue = new JCheckBoxMenuItem("Groupe Langue"); + private JCheckBoxMenuItem chckGroupeLV1 = new JCheckBoxMenuItem("Groupe LV1"); + private JCheckBoxMenuItem chckGroupeLV2 = new JCheckBoxMenuItem("Groupe LV2"); private JCheckBoxMenuItem chckGroupeInformatique = new JCheckBoxMenuItem("Groupe Informatique"); private JCheckBoxMenuItem chckGroupeDocumentation = new JCheckBoxMenuItem("Groupe Documentation"); private JCheckBoxMenuItem chckLV1 = new JCheckBoxMenuItem("LV1 : Langue Vivante 1"); @@ -157,13 +167,14 @@ public class Window_gestionnaire extends JFrame { scrollPaneTable.setViewportView(table); JPanel panelFiltre = new JPanel(); - panelFiltre.setPreferredSize(new Dimension(1900, 120)); + panelFiltre.setPreferredSize(new Dimension(1900, 128)); panelFiltre.setBackground(Color.gray); - GridBagLayout gbl_panelFiltre = new GridBagLayout(); - gbl_panelFiltre.columnWidths = new int[]{168, 113, 180, 169, 168, 168, 168, 190, 0}; - gbl_panelFiltre.rowHeights = new int[]{14, 32, 15, 32, 0}; - gbl_panelFiltre.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; - gbl_panelFiltre.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; + + GridBagLayout gbl_panelFiltre = new GridBagLayout(); + gbl_panelFiltre.columnWidths = new int[] {300, 160, 160, 160, 160, 160, 160, 160, 30, 160, 160}; + gbl_panelFiltre.rowHeights = new int[] {14, 32, 14, 32, 2}; + gbl_panelFiltre.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + gbl_panelFiltre.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0}; panelFiltre.setLayout(gbl_panelFiltre); JLabel lblYears = new JLabel("Année"); @@ -179,19 +190,20 @@ public class Window_gestionnaire extends JFrame { JLabel lblGroupeTD = new JLabel("Groupe TD"); lblGroupeTD.setFont(new Font("Tahoma", Font.BOLD, 12)); GridBagConstraints gbc_lblGroupeTD = new GridBagConstraints(); + gbc_lblGroupeTD.anchor = GridBagConstraints.WEST; gbc_lblGroupeTD.insets = new Insets(0, 0, 5, 5); gbc_lblGroupeTD.gridx = 2; gbc_lblGroupeTD.gridy = 0; panelFiltre.add(lblGroupeTD, gbc_lblGroupeTD); - JLabel lblGroupeLangue = new JLabel("Groupe Langue"); - lblGroupeLangue.setFont(new Font("Tahoma", Font.BOLD, 12)); - GridBagConstraints gbc_lblGroupeLangue = new GridBagConstraints(); - gbc_lblGroupeLangue.anchor = GridBagConstraints.WEST; - gbc_lblGroupeLangue.insets = new Insets(0, 0, 5, 5); - gbc_lblGroupeLangue.gridx = 3; - gbc_lblGroupeLangue.gridy = 0; - panelFiltre.add(lblGroupeLangue, gbc_lblGroupeLangue); + JLabel lblGroupeLV1 = new JLabel("Groupe LV1"); + lblGroupeLV1.setFont(new Font("Tahoma", Font.BOLD, 12)); + GridBagConstraints gbc_lblGroupeLV1 = new GridBagConstraints(); + gbc_lblGroupeLV1.anchor = GridBagConstraints.WEST; + gbc_lblGroupeLV1.insets = new Insets(0, 0, 5, 5); + gbc_lblGroupeLV1.gridx = 3; + gbc_lblGroupeLV1.gridy = 0; + panelFiltre.add(lblGroupeLV1, gbc_lblGroupeLV1); JLabel lblGroupePrincipal = new JLabel("Groupe Principal"); lblGroupePrincipal.setFont(new Font("Tahoma", Font.BOLD, 12)); @@ -202,34 +214,60 @@ public class Window_gestionnaire extends JFrame { gbc_lblGroupePrincipal.gridy = 0; panelFiltre.add(lblGroupePrincipal, gbc_lblGroupePrincipal); - JLabel lblLV2 = new JLabel("LV2"); - lblLV2.setFont(new Font("Tahoma", Font.BOLD, 12)); - GridBagConstraints gbc_lblLV2 = new GridBagConstraints(); - gbc_lblLV2.anchor = GridBagConstraints.WEST; - gbc_lblLV2.insets = new Insets(0, 0, 5, 5); - gbc_lblLV2.gridx = 5; - gbc_lblLV2.gridy = 0; - panelFiltre.add(lblLV2, gbc_lblLV2); + JLabel lblGroupeProjet = new JLabel("Groupe Projet"); + lblGroupeProjet.setFont(new Font("Tahoma", Font.BOLD, 12)); + GridBagConstraints gbc_lblGroupeProjet = new GridBagConstraints(); + gbc_lblGroupeProjet.anchor = GridBagConstraints.NORTH; + gbc_lblGroupeProjet.fill = GridBagConstraints.HORIZONTAL; + gbc_lblGroupeProjet.insets = new Insets(0, 0, 5, 5); + gbc_lblGroupeProjet.gridx = 5; + gbc_lblGroupeProjet.gridy = 0; + panelFiltre.add(lblGroupeProjet, gbc_lblGroupeProjet); + + JLabel lblLV1 = new JLabel("LV1"); + lblLV1.setFont(new Font("Tahoma", Font.BOLD, 12)); + GridBagConstraints gbc_lblLV1 = new GridBagConstraints(); + gbc_lblLV1.anchor = GridBagConstraints.WEST; + gbc_lblLV1.insets = new Insets(0, 0, 5, 5); + gbc_lblLV1.gridx = 6; + gbc_lblLV1.gridy = 0; + panelFiltre.add(lblLV1, gbc_lblLV1); JLabel lblProfil = new JLabel("Profil étudiant"); lblProfil.setFont(new Font("Tahoma", Font.BOLD, 12)); GridBagConstraints gbc_lblProfil = new GridBagConstraints(); gbc_lblProfil.anchor = GridBagConstraints.WEST; gbc_lblProfil.insets = new Insets(0, 0, 5, 5); - gbc_lblProfil.gridx = 6; + gbc_lblProfil.gridx = 7; gbc_lblProfil.gridy = 0; panelFiltre.add(lblProfil, gbc_lblProfil); - JLabel lblNonEtudiant = new JLabel("Nom de l'étudiant"); + + + + cYears = new JComboBox(); + cYears.setVisible(true); + cYears.setSelectedItem(defautYear); + + + + JLabel lblNonEtudiant = new JLabel("Nom de l'étudiant "); lblNonEtudiant.setFont(new Font("Tahoma", Font.BOLD, 12)); GridBagConstraints gbc_lblNonEtudiant = new GridBagConstraints(); gbc_lblNonEtudiant.fill = GridBagConstraints.HORIZONTAL; - gbc_lblNonEtudiant.insets = new Insets(0, 0, 5, 0); - gbc_lblNonEtudiant.gridx = 7; + gbc_lblNonEtudiant.insets = new Insets(0, 0, 5, 5); + gbc_lblNonEtudiant.gridx = 8; gbc_lblNonEtudiant.gridy = 0; panelFiltre.add(lblNonEtudiant, gbc_lblNonEtudiant); + GridBagConstraints gbc_cYears = new GridBagConstraints(); + gbc_cYears.fill = GridBagConstraints.BOTH; + gbc_cYears.insets = new Insets(0, 0, 5, 5); + gbc_cYears.gridx = 0; + gbc_cYears.gridy = 1; + panelFiltre.add(cYears, gbc_cYears); - JButton btnReinit = new JButton("Réïnitialise"); + JButton btnReinit = new JButton("Réïnitialise
les filtres"); + btnReinit.setBackground(UIManager.getColor("CheckBoxMenuItem.selectionBackground")); btnReinit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cDocumentation.setSelectedIndex(0); @@ -240,62 +278,52 @@ public class Window_gestionnaire extends JFrame { cGroupeTD.setSelectedIndex(0); cLV1.setSelectedIndex(0); cLV2.setSelectedIndex(0); - cLangue.setSelectedIndex(0); + cLangueLV1.setSelectedIndex(0); + cLangueLV2.setSelectedIndex(0); cRegime.setSelectedIndex(0); majTableGroupes(); } }); - - - cYears = new JComboBox(); - cYears.setSelectedItem(defautYear); - - cYears.setVisible(true); - GridBagConstraints gbc_cYears = new GridBagConstraints(); - gbc_cYears.fill = GridBagConstraints.BOTH; - gbc_cYears.insets = new Insets(0, 0, 5, 5); - gbc_cYears.gridx = 0; - gbc_cYears.gridy = 1; - panelFiltre.add(cYears, gbc_cYears); - - - btnReinit.setFont(new Font("Tahoma", Font.BOLD, 11)); + btnReinit.setFont(new Font("Tahoma", Font.BOLD, 14)); GridBagConstraints gbc_btnReinit = new GridBagConstraints(); + gbc_btnReinit.gridheight = 2; gbc_btnReinit.fill = GridBagConstraints.BOTH; gbc_btnReinit.insets = new Insets(0, 0, 5, 5); gbc_btnReinit.gridx = 1; gbc_btnReinit.gridy = 1; panelFiltre.add(btnReinit, gbc_btnReinit); - cGroupeTD = new JComboBox(); - cGroupeTD.setVisible(true); + cGroupeTD = new JComboBox(); + cGroupeTD.setVisible(true); + // Ajout d'un ActionListener à la JComboBox + cGroupeTD.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + majTableGroupes(); + } + }); + - GridBagConstraints gbc_cGroupeTD = new GridBagConstraints(); - gbc_cGroupeTD.fill = GridBagConstraints.BOTH; - gbc_cGroupeTD.insets = new Insets(0, 0, 5, 5); - gbc_cGroupeTD.gridx = 2; - gbc_cGroupeTD.gridy = 1; - panelFiltre.add(cGroupeTD, gbc_cGroupeTD); + GridBagConstraints gbc_cGroupeTD = new GridBagConstraints(); + gbc_cGroupeTD.fill = GridBagConstraints.BOTH; + gbc_cGroupeTD.insets = new Insets(0, 0, 5, 5); + gbc_cGroupeTD.gridx = 2; + gbc_cGroupeTD.gridy = 1; + panelFiltre.add(cGroupeTD, gbc_cGroupeTD); + + - // Ajout d'un ActionListener à la JComboBox - cGroupeTD.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - majTableGroupes(); - } - }); - - cLangue= new JComboBox(); - GridBagConstraints gbc_cLangue = new GridBagConstraints(); - gbc_cLangue.fill = GridBagConstraints.BOTH; - gbc_cLangue.insets = new Insets(0, 0, 5, 5); - gbc_cLangue.gridx = 3; - gbc_cLangue.gridy = 1; - panelFiltre.add(cLangue, gbc_cLangue); - - cLangue.addActionListener(new ActionListener() { + cLangueLV1= new JComboBox(); + GridBagConstraints gbc_cLangue = new GridBagConstraints(); + gbc_cLangue.fill = GridBagConstraints.BOTH; + gbc_cLangue.insets = new Insets(0, 0, 5, 5); + gbc_cLangue.gridx = 3; + gbc_cLangue.gridy = 1; + panelFiltre.add(cLangueLV1, gbc_cLangue); + + cLangueLV1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { majTableGroupes(); @@ -317,15 +345,30 @@ public class Window_gestionnaire extends JFrame { } }); - cLV2 = new JComboBox(); - GridBagConstraints gbc_cLV2 = new GridBagConstraints(); - gbc_cLV2.fill = GridBagConstraints.BOTH; - gbc_cLV2.insets = new Insets(0, 0, 5, 5); - gbc_cLV2.gridx = 5; - gbc_cLV2.gridy = 1; - panelFiltre.add(cLV2, gbc_cLV2); + cGroupeProjet = new JComboBox(); + GridBagConstraints gbc_cGroupeProjet = new GridBagConstraints(); + gbc_cGroupeProjet.fill = GridBagConstraints.BOTH; + gbc_cGroupeProjet.insets = new Insets(0, 0, 5, 5); + gbc_cGroupeProjet.gridx = 5; + gbc_cGroupeProjet.gridy = 1; + panelFiltre.add(cGroupeProjet, gbc_cGroupeProjet); - cLV2.addActionListener(new ActionListener() { + cGroupeProjet.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + majTableGroupes(); + } + }); + + cLV1= new JComboBox(); + GridBagConstraints gbc_cLV1 = new GridBagConstraints(); + gbc_cLV1.fill = GridBagConstraints.BOTH; + gbc_cLV1.insets = new Insets(0, 0, 5, 5); + gbc_cLV1.gridx = 6; + gbc_cLV1.gridy = 1; + panelFiltre.add(cLV1, gbc_cLV1); + + cLV1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { majTableGroupes(); @@ -336,7 +379,7 @@ public class Window_gestionnaire extends JFrame { GridBagConstraints gbc_cProfil = new GridBagConstraints(); gbc_cProfil.fill = GridBagConstraints.BOTH; gbc_cProfil.insets = new Insets(0, 0, 5, 5); - gbc_cProfil.gridx = 6; + gbc_cProfil.gridx = 7; gbc_cProfil.gridy = 1; panelFiltre.add(cProfil, gbc_cProfil); @@ -349,8 +392,8 @@ public class Window_gestionnaire extends JFrame { textPaneNom.setFont(new Font("Tahoma", Font.BOLD, 12)); GridBagConstraints gbc_textPaneNom = new GridBagConstraints(); gbc_textPaneNom.fill = GridBagConstraints.BOTH; - gbc_textPaneNom.insets = new Insets(0, 0, 5, 0); - gbc_textPaneNom.gridx = 7; + gbc_textPaneNom.insets = new Insets(0, 0, 5, 5); + gbc_textPaneNom.gridx = 8; gbc_textPaneNom.gridy = 1; panelFiltre.add(textPaneNom, gbc_textPaneNom); textPaneNom.getDocument().addDocumentListener(new DocumentListener() { @@ -383,6 +426,7 @@ public class Window_gestionnaire extends JFrame { gbc_lblFormation.gridx = 0; gbc_lblFormation.gridy = 2; panelFiltre.add(lblFormation, gbc_lblFormation); + JLabel lblGroupeInformatique = new JLabel("Groupe Informatique"); lblGroupeInformatique.setFont(new Font("Tahoma", Font.BOLD, 12)); @@ -393,46 +437,39 @@ public class Window_gestionnaire extends JFrame { gbc_lblGroupeInformatique.gridy = 2; panelFiltre.add(lblGroupeInformatique, gbc_lblGroupeInformatique); + JLabel lblGroupeLV2 = new JLabel("Groupe LV2"); + lblGroupeLV2.setFont(new Font("Tahoma", Font.BOLD, 12)); + GridBagConstraints gbc_lblGroupeLV2 = new GridBagConstraints(); + gbc_lblGroupeLV2.anchor = GridBagConstraints.WEST; + gbc_lblGroupeLV2.insets = new Insets(0, 0, 5, 5); + gbc_lblGroupeLV2.gridx = 3; + gbc_lblGroupeLV2.gridy = 2; + panelFiltre.add(lblGroupeLV2, gbc_lblGroupeLV2); + JLabel lblGroupeDocumentation = new JLabel("Groupe Documentation"); lblGroupeDocumentation.setFont(new Font("Tahoma", Font.BOLD, 12)); GridBagConstraints gbc_lblGroupeDocumentation = new GridBagConstraints(); gbc_lblGroupeDocumentation.fill = GridBagConstraints.HORIZONTAL; gbc_lblGroupeDocumentation.insets = new Insets(0, 0, 5, 5); - gbc_lblGroupeDocumentation.gridx = 3; + gbc_lblGroupeDocumentation.gridx = 4; gbc_lblGroupeDocumentation.gridy = 2; panelFiltre.add(lblGroupeDocumentation, gbc_lblGroupeDocumentation); - JLabel lblGroupeProjet = new JLabel("Groupe Projet"); - lblGroupeProjet.setFont(new Font("Tahoma", Font.BOLD, 12)); - GridBagConstraints gbc_lblGroupeProjet = new GridBagConstraints(); - gbc_lblGroupeProjet.anchor = GridBagConstraints.NORTH; - gbc_lblGroupeProjet.fill = GridBagConstraints.HORIZONTAL; - gbc_lblGroupeProjet.insets = new Insets(0, 0, 5, 5); - gbc_lblGroupeProjet.gridx = 4; - gbc_lblGroupeProjet.gridy = 2; - panelFiltre.add(lblGroupeProjet, gbc_lblGroupeProjet); - - JLabel lblLV1 = new JLabel("LV1"); - lblLV1.setFont(new Font("Tahoma", Font.BOLD, 12)); - GridBagConstraints gbc_lblLV1 = new GridBagConstraints(); - gbc_lblLV1.anchor = GridBagConstraints.WEST; - gbc_lblLV1.insets = new Insets(0, 0, 5, 5); - gbc_lblLV1.gridx = 5; - gbc_lblLV1.gridy = 2; - panelFiltre.add(lblLV1, gbc_lblLV1); - - JLabel lblRegime = new JLabel("Régime"); - lblRegime.setFont(new Font("Tahoma", Font.BOLD, 12)); - GridBagConstraints gbc_lblRegime = new GridBagConstraints(); - gbc_lblRegime.anchor = GridBagConstraints.WEST; - gbc_lblRegime.insets = new Insets(0, 0, 5, 5); - gbc_lblRegime.gridx = 6; - gbc_lblRegime.gridy = 2; - panelFiltre.add(lblRegime, gbc_lblRegime); + JLabel lblLV2 = new JLabel("LV2"); + lblLV2.setFont(new Font("Tahoma", Font.BOLD, 12)); + GridBagConstraints gbc_lblLV2 = new GridBagConstraints(); + gbc_lblLV2.anchor = GridBagConstraints.WEST; + gbc_lblLV2.insets = new Insets(0, 0, 5, 5); + gbc_lblLV2.gridx = 6; + gbc_lblLV2.gridy = 2; + panelFiltre.add(lblLV2, gbc_lblLV2); + + // Ajout d'un ActionListener à la JComboBox cFormations = new JComboBox(); + cFormations.setVisible(true); for(noeud nChild : commandes.nBase.getChildren()) { cYears.addItem(nChild.getName()); for(noeud nFormation : nChild.getChildren()) { @@ -440,8 +477,6 @@ public class Window_gestionnaire extends JFrame { } } cFormations.setSelectedIndex(0); - cFormations.setVisible(true); - // Ajout d'un ActionListener à la JComboBox cFormations.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -449,89 +484,24 @@ public class Window_gestionnaire extends JFrame { } }); + + + JLabel lblRegime = new JLabel("Régime"); + lblRegime.setFont(new Font("Tahoma", Font.BOLD, 12)); + GridBagConstraints gbc_lblRegime = new GridBagConstraints(); + gbc_lblRegime.anchor = GridBagConstraints.WEST; + gbc_lblRegime.insets = new Insets(0, 0, 5, 5); + gbc_lblRegime.gridx = 7; + gbc_lblRegime.gridy = 2; + panelFiltre.add(lblRegime, gbc_lblRegime); + GridBagConstraints gbc_cFormations = new GridBagConstraints(); gbc_cFormations.gridwidth = 2; gbc_cFormations.fill = GridBagConstraints.BOTH; - gbc_cFormations.insets = new Insets(0, 0, 0, 5); + gbc_cFormations.insets = new Insets(0, 0, 5, 5); gbc_cFormations.gridx = 0; gbc_cFormations.gridy = 3; panelFiltre.add(cFormations, gbc_cFormations); - - - cInformatique = new JComboBox(); - GridBagConstraints gbc_cInformatique = new GridBagConstraints(); - gbc_cInformatique.fill = GridBagConstraints.BOTH; - gbc_cInformatique.insets = new Insets(0, 0, 0, 5); - gbc_cInformatique.gridx = 2; - gbc_cInformatique.gridy = 3; - panelFiltre.add(cInformatique, gbc_cInformatique); - - cInformatique.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - majTableGroupes(); - } - }); - - cDocumentation = new JComboBox(); - GridBagConstraints gbc_cDocumentation = new GridBagConstraints(); - gbc_cDocumentation.fill = GridBagConstraints.BOTH; - gbc_cDocumentation.insets = new Insets(0, 0, 0, 5); - gbc_cDocumentation.gridx = 3; - gbc_cDocumentation.gridy = 3; - panelFiltre.add(cDocumentation, gbc_cDocumentation); - - cDocumentation.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - majTableGroupes(); - } - }); - - cGroupeProjet = new JComboBox(); - GridBagConstraints gbc_cGroupeProjet = new GridBagConstraints(); - gbc_cGroupeProjet.fill = GridBagConstraints.BOTH; - gbc_cGroupeProjet.insets = new Insets(0, 0, 0, 5); - gbc_cGroupeProjet.gridx = 4; - gbc_cGroupeProjet.gridy = 3; - panelFiltre.add(cGroupeProjet, gbc_cGroupeProjet); - - cGroupeProjet.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - majTableGroupes(); - } - }); - - cLV1= new JComboBox(); - GridBagConstraints gbc_cLV1 = new GridBagConstraints(); - gbc_cLV1.fill = GridBagConstraints.BOTH; - gbc_cLV1.insets = new Insets(0, 0, 0, 5); - gbc_cLV1.gridx = 5; - gbc_cLV1.gridy = 3; - panelFiltre.add(cLV1, gbc_cLV1); - - cLV1.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - majTableGroupes(); - } - }); - - cRegime = new JComboBox(); - GridBagConstraints gbc_cRegime = new GridBagConstraints(); - gbc_cRegime.fill = GridBagConstraints.BOTH; - gbc_cRegime.insets = new Insets(0, 0, 0, 5); - gbc_cRegime.gridx = 6; - gbc_cRegime.gridy = 3; - panelFiltre.add(cRegime, gbc_cRegime); - - cRegime.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - majTableGroupes(); - } - }); JPanel panelNorth = new JPanel(); contentPane.add(panelNorth, BorderLayout.NORTH); @@ -590,8 +560,15 @@ public class Window_gestionnaire extends JFrame { } }); - menuAffichage.add(chckGroupeLangue); - chckGroupeLangue.addItemListener(new ItemListener() { + menuAffichage.add(chckGroupeLV1); + chckGroupeLV1.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if(!ignoreItemStateChange) majAffichageDesChck(); + } + }); + + menuAffichage.add(chckGroupeLV2); + chckGroupeLV2.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if(!ignoreItemStateChange) majAffichageDesChck(); } @@ -695,9 +672,82 @@ public class Window_gestionnaire extends JFrame { scrollPaneFiltre.add(panelFiltre); scrollPaneFiltre.setViewportView(panelFiltre); + + cInformatique = new JComboBox(); + GridBagConstraints gbc_cInformatique = new GridBagConstraints(); + gbc_cInformatique.fill = GridBagConstraints.BOTH; + gbc_cInformatique.insets = new Insets(0, 0, 5, 5); + gbc_cInformatique.gridx = 2; + gbc_cInformatique.gridy = 3; + panelFiltre.add(cInformatique, gbc_cInformatique); + cInformatique.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + majTableGroupes(); + } + }); + + cLangueLV2 = new JComboBox(); + GridBagConstraints gbc_cLangueLV2 = new GridBagConstraints(); + gbc_cLangueLV2.insets = new Insets(0, 0, 5, 5); + gbc_cLangueLV2.fill = GridBagConstraints.HORIZONTAL; + gbc_cLangueLV2.gridx = 3; + gbc_cLangueLV2.gridy = 3; + panelFiltre.add(cLangueLV2, gbc_cLangueLV2); + cLangueLV2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + majTableGroupes(); + } + }); + + cDocumentation = new JComboBox(); + GridBagConstraints gbc_cDocumentation = new GridBagConstraints(); + gbc_cDocumentation.fill = GridBagConstraints.BOTH; + gbc_cDocumentation.insets = new Insets(0, 0, 5, 5); + gbc_cDocumentation.gridx = 4; + gbc_cDocumentation.gridy = 3; + panelFiltre.add(cDocumentation, gbc_cDocumentation); + + cDocumentation.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + majTableGroupes(); + } + }); + + cLV2 = new JComboBox(); + GridBagConstraints gbc_cLV2 = new GridBagConstraints(); + gbc_cLV2.fill = GridBagConstraints.BOTH; + gbc_cLV2.insets = new Insets(0, 0, 5, 5); + gbc_cLV2.gridx = 6; + gbc_cLV2.gridy = 3; + panelFiltre.add(cLV2, gbc_cLV2); + + cLV2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + majTableGroupes(); + } + }); + + cRegime = new JComboBox(); + GridBagConstraints gbc_cRegime = new GridBagConstraints(); + gbc_cRegime.fill = GridBagConstraints.BOTH; + gbc_cRegime.insets = new Insets(0, 0, 5, 5); + gbc_cRegime.gridx = 7; + gbc_cRegime.gridy = 3; + panelFiltre.add(cRegime, gbc_cRegime); + + cRegime.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + majTableGroupes(); + } + }); JPanel panelSouth = new JPanel(); - panelSouth.setPreferredSize(new Dimension(400, 90)); + panelSouth.setPreferredSize(new Dimension(1920, 100)); panelSouth.setBackground(Color.gray); contentPane.add(panelSouth, BorderLayout.SOUTH); panelSouth.setLayout(new BoxLayout(panelSouth, BoxLayout.Y_AXIS)); @@ -787,7 +837,8 @@ public class Window_gestionnaire extends JFrame { String selectedGroupeTD = null; String selectedLV1 = null; String selectedLV2 = null; - String selectedLangue = null; + String selectedGroupeLV1 = null; + String selectedGroupeLV2 = null; String selectedInformatique = null; String selectedDocumentation = null; String selectedProfil = null; @@ -798,7 +849,8 @@ public class Window_gestionnaire extends JFrame { if(cGroupeTD.getItemCount()>0) selectedGroupeTD = cGroupeTD.getSelectedItem().toString(); if(cLV1.getItemCount()>0) selectedLV1 = cLV1.getSelectedItem().toString(); if(cLV2.getItemCount()>0) selectedLV2 = cLV2.getSelectedItem().toString(); - if(cLangue.getItemCount()>0) selectedLangue = cLangue.getSelectedItem().toString(); + if(cLangueLV1.getItemCount()>0) selectedGroupeLV1 = cLangueLV1.getSelectedItem().toString(); + if(cLangueLV2.getItemCount()>0) selectedGroupeLV2 = cLangueLV2.getSelectedItem().toString(); if(cInformatique.getItemCount()>0) selectedInformatique = cInformatique.getSelectedItem().toString(); if(cDocumentation.getItemCount()>0) selectedDocumentation = cDocumentation.getSelectedItem().toString(); if(cProfil.getItemCount()>0) selectedProfil = cProfil.getSelectedItem().toString(); @@ -810,7 +862,8 @@ public class Window_gestionnaire extends JFrame { cGroupeTD.removeAllItems(); cLV1.removeAllItems(); cLV2.removeAllItems(); - cLangue.removeAllItems(); + cLangueLV1.removeAllItems(); + cLangueLV2.removeAllItems(); cInformatique.removeAllItems(); cDocumentation.removeAllItems(); cProfil.removeAllItems(); @@ -821,7 +874,8 @@ public class Window_gestionnaire extends JFrame { List lGroupeTD = new ArrayList(); List lLV1 = new ArrayList(); List lLV2 = new ArrayList(); - List lGroupeLangue = new ArrayList(); + List lGroupeLV1 = new ArrayList(); + List lGroupeLV2 = new ArrayList(); List lGroupeInformatique = new ArrayList(); List lGroupeDocumentation = new ArrayList(); List lProfil = new ArrayList(); @@ -838,7 +892,8 @@ public class Window_gestionnaire extends JFrame { String GroupeTD = nStudent.getAttributes("Groupe_TD"); String LV1 = nStudent.getAttributes("LV1"); String LV2 = nStudent.getAttributes("LV2"); - String GroupeLangue = nStudent.getAttributes("Groupe_Langue"); + String GroupeLV1 = nStudent.getAttributes("Groupe_LV1"); + String GroupeLV2 = nStudent.getAttributes("Groupe_LV2"); String GroupeInformatique = nStudent.getAttributes("Groupe_Informatique"); String Profil = nStudent.getAttributes("Profil_etudiant_lib."); String Documentation = nStudent.getAttributes("Groupe_Doc"); @@ -858,9 +913,13 @@ public class Window_gestionnaire extends JFrame { if(!lLV2.contains(LV2) && !isOnlySpaces) { lLV2.add(LV2); } - isOnlySpaces = GroupeLangue.matches("\\s+"); - if(!lGroupeLangue.contains(GroupeLangue) && !isOnlySpaces) { - lGroupeLangue.add(GroupeLangue); + isOnlySpaces = GroupeLV1.matches("\\s+"); + if(!lGroupeLV1.contains(GroupeLV1) && !isOnlySpaces) { + lGroupeLV1.add(GroupeLV1); + } + isOnlySpaces = GroupeLV2.matches("\\s+"); + if(!lGroupeLV2.contains(GroupeLV2) && !isOnlySpaces) { + lGroupeLV2.add(GroupeLV2); } isOnlySpaces = GroupeInformatique.matches("\\s+"); if(!lGroupeInformatique.contains(GroupeInformatique) && !isOnlySpaces) { @@ -917,13 +976,22 @@ public class Window_gestionnaire extends JFrame { cLV2.setSelectedItem(selectedLV2); } - Collections.sort(lGroupeLangue); - cLangue.addItem(pasChoisi); - for (String option : lGroupeLangue) { - cLangue.addItem(option); + Collections.sort(lGroupeLV1); + cLangueLV1.addItem(pasChoisi); + for (String option : lGroupeLV1) { + cLangueLV1.addItem(option); } - if(selectedLangue!=null)if(lGroupeLangue.contains(selectedLangue)) { - cLangue.setSelectedItem(selectedLangue); + if(selectedGroupeLV1!=null)if(lGroupeLV1.contains(selectedGroupeLV1)) { + cLangueLV1.setSelectedItem(selectedGroupeLV1); + } + + Collections.sort(lGroupeLV2); + cLangueLV2.addItem(pasChoisi); + for (String option : lGroupeLV2) { + cLangueLV2.addItem(option); + } + if(selectedGroupeLV2!=null)if(lGroupeLV2.contains(selectedGroupeLV2)) { + cLangueLV2.setSelectedItem(selectedGroupeLV2); } Collections.sort(lGroupeInformatique); @@ -981,7 +1049,6 @@ public class Window_gestionnaire extends JFrame { } } - } @@ -998,7 +1065,8 @@ public class Window_gestionnaire extends JFrame { String GroupeTD = (String) cGroupeTD.getSelectedItem(); String LV1 = (String) cLV1.getSelectedItem(); String LV2 = (String) cLV2.getSelectedItem(); - String GroupeLangue = (String) cLangue.getSelectedItem(); + String GroupeLV1 = (String) cLangueLV1.getSelectedItem(); + String GroupeLV2 = (String) cLangueLV2.getSelectedItem(); String GroupeInformatique = (String) cInformatique.getSelectedItem(); String Profil = (String) cProfil.getSelectedItem(); String GroupeDocumentation = (String) cDocumentation.getSelectedItem(); @@ -1030,11 +1098,18 @@ public class Window_gestionnaire extends JFrame { LV2 = pasChoisi; } - if(cLangue.getSelectedItem()!=null) { - nTable.setAttribut("Groupe_Langue", cLangue.getSelectedItem().toString()); + if(cLangueLV1.getSelectedItem()!=null) { + nTable.setAttribut("Groupe_LV1", cLangueLV1.getSelectedItem().toString()); }else { - nTable.setAttribut("Groupe_Langue", pasChoisi); - GroupeLangue = pasChoisi; + nTable.setAttribut("Groupe_LV1", pasChoisi); + GroupeLV1 = pasChoisi; + } + + if(cLangueLV2.getSelectedItem()!=null) { + nTable.setAttribut("Groupe_LV2", cLangueLV2.getSelectedItem().toString()); + }else { + nTable.setAttribut("Groupe_LV2", pasChoisi); + GroupeLV2 = pasChoisi; } if(cInformatique.getSelectedItem()!=null) { @@ -1080,7 +1155,7 @@ public class Window_gestionnaire extends JFrame { } - Map dictionary = new HashMap<>(); + Map headTable = new HashMap<>(); noeud nYears = commandes.nBase.getChild(cYears.getSelectedItem().toString()); nTable.setAttribut("Formation", cFormations.getSelectedItem().toString()); @@ -1096,55 +1171,59 @@ public class Window_gestionnaire extends JFrame { for (Map.Entry entry : firstStudent.getAttributes().entrySet()) { String key = entry.getKey(); if(chckToutesLesColonnes.isSelected() ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; }else { if(key.equals("Individu_-_Nom") || key.equals("Individu_-_Prenom") || key.equals("Individu_-_Code_Etudiant")) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckGroupePrincipal.isSelected() && key.equals("Groupe_Principal") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckGroupeTD.isSelected() && key.equals("Groupe_TD") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } - if(chckGroupeLangue.isSelected() && key.equals("Groupe_Langue") ) { - dictionary.put(key, indexCol); + if(chckGroupeLV1.isSelected() && key.equals("Groupe_LV1") ) { + headTable.put(key, indexCol); + indexCol++; + } + if(chckGroupeLV2.isSelected() && key.equals("Groupe_LV2") ) { + headTable.put(key, indexCol); indexCol++; } if(chckGroupeInformatique.isSelected() && key.equals("Groupe_Informatique") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckGroupeDocumentation.isSelected() && key.equals("Groupe_Doc") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckLV1.isSelected() && key.equals("LV1") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckLV2.isSelected() && key.equals("LV2") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckGroupeProjet.isSelected() && key.equals("Groupe_Projet") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckRegime.isSelected() && key.equals("Regime") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckStage1.isSelected() && key.equals("Stage_1") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } if(chckStage2.isSelected() && key.equals("Stage_2") ) { - dictionary.put(key, indexCol); + headTable.put(key, indexCol); indexCol++; } } @@ -1175,52 +1254,57 @@ public class Window_gestionnaire extends JFrame { && ( nStudent.getAttributes("Groupe_Principal").equals(GroupePrincipal) || GroupePrincipal.equals(pasChoisi) ) && ( nStudent.getAttributes("Groupe_Doc").equals(GroupeDocumentation) || GroupeDocumentation.equals(pasChoisi) ) && ( nStudent.getAttributes("Profil_etudiant_lib.").equals(Profil) || Profil.equals(pasChoisi) ) - && ( nStudent.getAttributes("Groupe_Langue").equals(GroupeLangue) || GroupeLangue.equals(pasChoisi) ) + && ( nStudent.getAttributes("Groupe_LV1").equals(GroupeLV1) || GroupeLV1.equals(pasChoisi) ) + && ( nStudent.getAttributes("Groupe_LV2").equals(GroupeLV2) || GroupeLV2.equals(pasChoisi) ) && ( nStudent.getAttributes("LV2").equals(LV2) || LV2.equals(pasChoisi) ) && ( nStudent.getAttributes("Groupe_Informatique").equals(GroupeInformatique) || GroupeInformatique.equals(pasChoisi) ) && ( nStudent.getAttributes("Groupe_TD").equals(GroupeTD) || GroupeTD.equals(pasChoisi) ) && ( nStudent.getAttributes("LV1").equals(LV1) || LV1.equals(pasChoisi) ) ){ - if(dictionary.get(entry.getKey())!=null) { + if(headTable.get(entry.getKey())!=null) { String key = entry.getKey(); if(chckToutesLesColonnes.isSelected() ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][headTable.get(key)] = entry.getValue(); }else { + int indexColumn = headTable.get(key); if(key.equals("Individu_-_Nom") || key.equals("Individu_-_Prenom") || key.equals("Individu_-_Code_Etudiant")) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckGroupePrincipal.isSelected() && key.equals("Groupe_Principal") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckGroupeTD.isSelected() && key.equals("Groupe_TD") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } - if(chckGroupeLangue.isSelected() && key.equals("Groupe_Langue") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + if(chckGroupeLV1.isSelected() && key.equals("Groupe_LV1") ) { + data[indexRow][indexColumn] = entry.getValue(); + } + if(chckGroupeLV2.isSelected() && key.equals("Groupe_LV2") ) { + data[indexRow][indexColumn] = entry.getValue(); } if(chckGroupeInformatique.isSelected() && key.equals("Groupe_Informatique") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckGroupeDocumentation.isSelected() && key.equals("Groupe_Doc") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckLV1.isSelected() && key.equals("LV1") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckLV2.isSelected() && key.equals("LV2") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckGroupeProjet.isSelected() && key.equals("Groupe_Projet") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckRegime.isSelected() && key.equals("Regime") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckStage1.isSelected() && key.equals("Stage_1") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } if(chckStage2.isSelected() && key.equals("Stage_2") ) { - data[indexRow][dictionary.get(key)] = entry.getValue(); + data[indexRow][indexColumn] = entry.getValue(); } } indexCol++; @@ -1246,7 +1330,7 @@ public class Window_gestionnaire extends JFrame { lblInformation.setText("Informations : Nombre d'étudiant = " + compteur); // Obtenir les entrées du dictionnaire sous forme de liste - List> entryList = new ArrayList<>(dictionary.entrySet()); + List> entryList = new ArrayList<>(headTable.entrySet()); // Trier la liste d'entrées par ordre croissant des valeurs Collections.sort(entryList, Comparator.comparingInt(Map.Entry::getValue)); @@ -1292,7 +1376,7 @@ public class Window_gestionnaire extends JFrame { if(!isOnlySpace) { try { nStudent.setAttribut(key, value.trim() ); - sauvegardeXMLBase.save(commandes.nBase, saveType.SANS_MESSAGE); + sauvegardeXMLBase.save(commandes.nBase, saveType.SANS_MESSAGE,""); }catch (Exception e1) { JOptionPane.showMessageDialog(null, "Impossible de sauvegarder ce contenu.", "Erreur", JOptionPane.ERROR_MESSAGE); } @@ -1399,13 +1483,14 @@ public class Window_gestionnaire extends JFrame { nFormation.setAttribut("Colonne_Groupe_Projet", String.valueOf(chckGroupeProjet.isSelected())); nFormation.setAttribut("Colonne_LV1", String.valueOf(chckLV1.isSelected())); nFormation.setAttribut("Colonne_LV2", String.valueOf(chckLV2.isSelected())); - nFormation.setAttribut("Colonne_Groupe_Langue", String.valueOf(chckGroupeLangue.isSelected())); + nFormation.setAttribut("Colonne_Groupe_LV1", String.valueOf(chckGroupeLV1.isSelected())); + nFormation.setAttribut("Colonne_Groupe_LV2", String.valueOf(chckGroupeLV2.isSelected())); nFormation.setAttribut("Colonne_Regime", String.valueOf(chckRegime.isSelected())); nFormation.setAttribut("Colonne_Stage1", String.valueOf(chckStage1.isSelected())); nFormation.setAttribut("Colonne_Stage2", String.valueOf(chckStage2.isSelected())); } - sauvegardeXMLBase.save(commandes.nBase, saveType.SANS_MESSAGE); + sauvegardeXMLBase.save(commandes.nBase, saveType.SANS_MESSAGE,""); majTableGroupes(); } @@ -1424,7 +1509,8 @@ public class Window_gestionnaire extends JFrame { chckGroupeProjet.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_Groupe_Projet"))); chckLV1.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_LV1"))); chckLV2.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_LV2"))); - chckGroupeLangue.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_Groupe_Langue"))); + chckGroupeLV1.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_Groupe_LV1"))); + chckGroupeLV2.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_Groupe_LV2"))); chckRegime.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_Regime"))); chckStage1.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_Stage1"))); chckStage2.setSelected( Boolean.valueOf(nFormation.getAttributes("Colonne_Stage2"))); diff --git a/src/baseUFRHG/VersionChecker.java b/src/baseUFRHG/VersionChecker.java index 9102342..9474fa4 100644 --- a/src/baseUFRHG/VersionChecker.java +++ b/src/baseUFRHG/VersionChecker.java @@ -102,15 +102,46 @@ public class VersionChecker { //Modification de la base si elle est de la version 1.0.1 ou 1.0.2 if(versionDeLaBase.equals("1.0.2")) { + String baseToString = nBase.toWrite(); + String regex = "\\bGroupe_Langue\\b"; + String resultat = baseToString.replaceAll(regex, "Groupe_LV1"); + + regex = "\\bColonne_Groupe_Langue\\b"; + resultat = resultat.replaceAll(regex, "Colonne_Groupe_LV1"); + + nBase= lectureXML.lectureStringToNoeud(resultat); + + for(noeud nFormation : nBase.getFirstChild().getChildren()) { + nFormation.setAttribut("Colonne_Groupe_LV2", "false"); + if(nFormation.getAttributes("Colonne_Groupe_LV1")==null) nFormation.addAttribute("Colonne_Groupe_LV1", "true"); + if(nFormation.getAttributes("Colonne_Groupe_Documentation")==null) nFormation.addAttribute("Colonne_Groupe_Documentation", "true"); + if(nFormation.getAttributes("Colonne_Groupe_Informatique")==null) nFormation.addAttribute("Colonne_Groupe_Informatique", "true"); + if(nFormation.getAttributes("Colonne_Groupe_Principal")==null) nFormation.addAttribute("Colonne_Groupe_Principal", "true"); + if(nFormation.getAttributes("Colonne_Groupe_Projet")==null) nFormation.addAttribute("Colonne_Groupe_Projet", "true"); + if(nFormation.getAttributes("Colonne_Groupe_TD")==null) nFormation.addAttribute("Colonne_Groupe_TD", "true"); + if(nFormation.getAttributes("Colonne_LV1")==null) nFormation.addAttribute("Colonne_LV1", "true"); + if(nFormation.getAttributes("Colonne_LV2")==null) nFormation.addAttribute("Colonne_LV2", "true"); + if(nFormation.getAttributes("Colonne_Regime")==null) nFormation.addAttribute("Colonne_Regime", "true"); + if(nFormation.getAttributes("Colonne_Stage1")==null) nFormation.addAttribute("Colonne_Stage1", "true"); + if(nFormation.getAttributes("Colonne_Stage2")==null) nFormation.addAttribute("Colonne_Stage2", "true"); + if(nFormation.getAttributes("ToutesLesColonnes")==null) nFormation.addAttribute("ToutesLesColonnes", "true"); + + for(noeud nStudent : nFormation.getChildren()) { + nStudent.addAttribute("Groupe_LV2", ""); + } + } + + } // Sauvegarde de la base dans le dossier base - sauvegardeXMLBase.save(nBase,saveType.SANS_MESSAGE); + sauvegardeXMLBase.save(nBase,saveType.WITH_MESSAGE,"Mise à jour de la base
avec la nouvelle version " + commandes.version + ""); + + //chargement dans la classe commandes + commandes.nBase = nBase; - // Avertissement - JOptionPane.showMessageDialog(null, "La base de données a été mise à jour
avec la nouvelle version."); } } diff --git a/src/baseUFRHG/actions/exportEmargement.java b/src/baseUFRHG/actions/exportEmargement.java index 37f2eff..48cd64b 100644 --- a/src/baseUFRHG/actions/exportEmargement.java +++ b/src/baseUFRHG/actions/exportEmargement.java @@ -9,9 +9,9 @@ import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.KeyStroke; +import Windows.Window_gestionnaire; import baseUFRHG.exportBaseToExcel; import baseUFRHG.exportBaseToExcel.exportType; -import baseUFRHG.Window_gestionnaire; import baseUFRHG.noeud; diff --git a/src/baseUFRHG/actions/exportTable.java b/src/baseUFRHG/actions/exportTable.java index f9c4911..eb09df0 100644 --- a/src/baseUFRHG/actions/exportTable.java +++ b/src/baseUFRHG/actions/exportTable.java @@ -10,9 +10,9 @@ import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.KeyStroke; +import Windows.Window_gestionnaire; import baseUFRHG.exportBaseToExcel; import baseUFRHG.exportBaseToExcel.exportType; -import baseUFRHG.Window_gestionnaire; import baseUFRHG.noeud; diff --git a/src/baseUFRHG/actions/saveTable.java b/src/baseUFRHG/actions/saveTable.java index 10ef31e..be4af40 100644 --- a/src/baseUFRHG/actions/saveTable.java +++ b/src/baseUFRHG/actions/saveTable.java @@ -9,8 +9,8 @@ import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.KeyStroke; +import Windows.Window_gestionnaire; import baseUFRHG.commandes; -import baseUFRHG.Window_gestionnaire; import baseUFRHG.sauvegardeXMLBase; import baseUFRHG.sauvegardeXMLBase.saveType; @@ -38,7 +38,7 @@ public class saveTable extends AbstractAction{ public void actionPerformed(ActionEvent e) { // Sauvegarde de la base - sauvegardeXMLBase.save(commandes.nBase,saveType.WITH_MESSAGE); + sauvegardeXMLBase.save(commandes.nBase,saveType.WITH_DEFAULT_MESSAGE,""); instance.majTableFormation(); instance.majTableGroupes(); diff --git a/src/baseUFRHG/base.java b/src/baseUFRHG/base.java index f1048af..d94e3ab 100644 --- a/src/baseUFRHG/base.java +++ b/src/baseUFRHG/base.java @@ -46,7 +46,7 @@ public class base { nBase.addChild(new noeud(userInput)); nBase.setAttribut("defaut_Year", userInput); - sauvegardeXMLBase.save(nBase, saveType.WITH_MESSAGE); + sauvegardeXMLBase.save(nBase, saveType.WITH_DEFAULT_MESSAGE,""); commandes.nBase = nBase; return commandes.nBase; diff --git a/src/baseUFRHG/createEmargement.java b/src/baseUFRHG/createEmargement.java index 20753dc..8dc4931 100644 --- a/src/baseUFRHG/createEmargement.java +++ b/src/baseUFRHG/createEmargement.java @@ -2,12 +2,9 @@ package baseUFRHG; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.print.PageFormat; -import java.awt.print.PrinterJob; import java.io.FileOutputStream; import java.io.IOException; -import javax.print.attribute.standard.PageRanges; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -221,16 +218,11 @@ public class createEmargement extends JFrame{ sheet.autoSizeColumn(0); sheet.autoSizeColumn(2); sheet.autoSizeColumn(3); - - -// // Définir la largeur de la colonne E (6 cm) -// int widthInCharsE = (int) (6 * 256 / 0.146); -// sheet.setColumnWidth(4, widthInCharsE); - // Estimer la largeur de la feuille A4 en unités de 1/256ème de caractère + // Estimer la largeur de la feuille A4 en unités de 1/256ème de caractère int a4WidthUnits = 26000 ; //(17 * 256)/0.146; // Largeur de la feuille A4 en unités de 1/256ème de caractère -// int a4WidthUnits = 16250; - // Obtenir la largeur totale des colonnes A à D en unités de 1/256ème de caractère + + // Obtenir la largeur totale des colonnes A à D en unités de 1/256ème de caractère int widthOfColumnsAtoD = 0; for (int columnIndex = 0; columnIndex < 4; columnIndex++) { widthOfColumnsAtoD += sheet.getColumnWidth(columnIndex); diff --git a/src/baseUFRHG/exportBaseToExcel.java b/src/baseUFRHG/exportBaseToExcel.java index b54a04f..d718ed8 100644 --- a/src/baseUFRHG/exportBaseToExcel.java +++ b/src/baseUFRHG/exportBaseToExcel.java @@ -22,7 +22,7 @@ public class exportBaseToExcel { public static void exportBase() { // Données - Object[][] data = new Object[commandes.nBase.getChild(commandes.nBase.getAttributes("defaut_Year")).getNumberChildren()][29]; + Object[][] data = new Object[commandes.nBase.getChild(commandes.nBase.getAttributes("defaut_Year")).getNumberChildren()][30]; @@ -42,25 +42,26 @@ public class exportBaseToExcel { data[indexFormation][8] = "Individu_-_Email"; data[indexFormation][9] = "Groupe_Principal"; data[indexFormation][10] = "Groupe_TD"; - data[indexFormation][11] = "Groupe_Langue"; - data[indexFormation][12] = "LV1"; - data[indexFormation][13] = "LV2"; - data[indexFormation][14] = "Regime"; - data[indexFormation][15] = "Groupe_Informatique"; - data[indexFormation][16] = "Atelier-rentree_horaire"; - data[indexFormation][17] = "Atelier_pre-rentree_enseignant"; - data[indexFormation][18] = "Atelier_pre-rentree_salle"; - data[indexFormation][19] = "UE_Libre"; - data[indexFormation][20] = "Covoiturage"; - data[indexFormation][21] = "Etudiant_Covoiturage"; - data[indexFormation][22] = "Stage_1"; - data[indexFormation][23] = "Num_convention_1"; - data[indexFormation][24] = "Periode_1"; - data[indexFormation][25] = "Stage_2"; - data[indexFormation][26] = "Num_convention_2"; - data[indexFormation][27] = "Periode_2"; + data[indexFormation][11] = "Groupe_LV1"; + data[indexFormation][12] = "Groupe_LV2"; + data[indexFormation][13] = "LV1"; + data[indexFormation][14] = "LV2"; + data[indexFormation][15] = "Regime"; + data[indexFormation][16] = "Groupe_Informatique"; + data[indexFormation][17] = "Atelier-rentree_horaire"; + data[indexFormation][18] = "Atelier_pre-rentree_enseignant"; + data[indexFormation][19] = "Atelier_pre-rentree_salle"; + data[indexFormation][20] = "UE_Libre"; + data[indexFormation][21] = "Covoiturage"; + data[indexFormation][22] = "Etudiant_Covoiturage"; + data[indexFormation][23] = "Stage_1"; + data[indexFormation][24] = "Num_convention_1"; + data[indexFormation][25] = "Periode_1"; + data[indexFormation][26] = "Stage_2"; + data[indexFormation][27] = "Num_convention_2"; + data[indexFormation][28] = "Periode_2"; - String[][] data1 = new String[formation.getNumberChildren()][28]; + String[][] data1 = new String[formation.getNumberChildren()][29]; int indexStudent = 0; for(noeud nStudent : formation.getChildren()) { @@ -75,26 +76,27 @@ public class exportBaseToExcel { data1[indexStudent][8] = nStudent.getAttributes("Groupe"); data1[indexStudent][9] = nStudent.getAttributes("Groupe_Principal"); data1[indexStudent][10] = nStudent.getAttributes("Groupe_TD"); - data1[indexStudent][11] = nStudent.getAttributes("Groupe_Langue"); - data1[indexStudent][12] = nStudent.getAttributes("LV1"); - data1[indexStudent][13] = nStudent.getAttributes("LV2"); - data1[indexStudent][14] = nStudent.getAttributes("Regime"); - data1[indexStudent][15] = nStudent.getAttributes("Groupe_Informatique"); - data1[indexStudent][16] = nStudent.getAttributes("Atelier-rentree_horaire"); - data1[indexStudent][17] = nStudent.getAttributes("Atelier_pre-rentree_enseignant"); - data1[indexStudent][18] = nStudent.getAttributes("Atelier_pre-rentree_salle"); - data1[indexStudent][19] = nStudent.getAttributes("UE_Libre"); - data1[indexStudent][20] = nStudent.getAttributes("Covoiturage"); - data1[indexStudent][21] = nStudent.getAttributes("Etudiant_Covoiturage"); - data1[indexStudent][22] = nStudent.getAttributes("Stage_1"); - data1[indexStudent][23] = nStudent.getAttributes("Num_convention_1"); - data1[indexStudent][24] = nStudent.getAttributes("Periode_1"); - data1[indexStudent][25] = nStudent.getAttributes("Stage_2"); - data1[indexStudent][26] = nStudent.getAttributes("Num_convention_2"); - data1[indexStudent][27] = nStudent.getAttributes("Periode_2"); + data1[indexStudent][11] = nStudent.getAttributes("Groupe_LV1"); + data1[indexStudent][12] = nStudent.getAttributes("Groupe_LV2"); + data1[indexStudent][13] = nStudent.getAttributes("LV1"); + data1[indexStudent][14] = nStudent.getAttributes("LV2"); + data1[indexStudent][15] = nStudent.getAttributes("Regime"); + data1[indexStudent][16] = nStudent.getAttributes("Groupe_Informatique"); + data1[indexStudent][17] = nStudent.getAttributes("Atelier-rentree_horaire"); + data1[indexStudent][18] = nStudent.getAttributes("Atelier_pre-rentree_enseignant"); + data1[indexStudent][19] = nStudent.getAttributes("Atelier_pre-rentree_salle"); + data1[indexStudent][20] = nStudent.getAttributes("UE_Libre"); + data1[indexStudent][21] = nStudent.getAttributes("Covoiturage"); + data1[indexStudent][22] = nStudent.getAttributes("Etudiant_Covoiturage"); + data1[indexStudent][23] = nStudent.getAttributes("Stage_1"); + data1[indexStudent][24] = nStudent.getAttributes("Num_convention_1"); + data1[indexStudent][25] = nStudent.getAttributes("Periode_1"); + data1[indexStudent][26] = nStudent.getAttributes("Stage_2"); + data1[indexStudent][27] = nStudent.getAttributes("Num_convention_2"); + data1[indexStudent][28] = nStudent.getAttributes("Periode_2"); - data[indexFormation][28] = data1; + data[indexFormation][29] = data1; indexStudent++; } @@ -135,7 +137,7 @@ public class exportBaseToExcel { } - Object[][] data = new Object[1][29]; + Object[][] data = new Object[1][30]; String formation = nTable.getFirstChild().getAttributes("IAE_-_Etape_lib."); @@ -151,26 +153,27 @@ public class exportBaseToExcel { data[0][8] = "Individu_-_Email"; data[0][9] = "Groupe_Principal"; data[0][10] = "Groupe_TD"; - data[0][11] = "Groupe_Langue"; - data[0][12] = "Groupe_Informatique"; - data[0][13] = "LV1"; - data[0][14] = "LV2"; - data[0][15] = "Regime"; - data[0][16] = "Atelier-rentree_horaire"; - data[0][17] = "Atelier_pre-rentree_enseignant"; - data[0][18] = "Atelier_pre-rentree_salle"; - data[0][19] = "UE_Libre"; - data[0][20] = "Covoiturage"; - data[0][21] = "Etudiant_Covoiturage"; - data[0][22] = "Stage_1"; - data[0][23] = "Num_convention_1"; - data[0][24] = "Periode_1"; - data[0][25] = "Stage_2"; - data[0][26] = "Num_convention_2"; - data[0][27] = "Periode_2"; + data[0][11] = "Groupe_LV1"; + data[0][12] = "Groupe_LV2"; + data[0][13] = "Groupe_Informatique"; + data[0][14] = "LV1"; + data[0][15] = "LV2"; + data[0][16] = "Regime"; + data[0][17] = "Atelier-rentree_horaire"; + data[0][18] = "Atelier_pre-rentree_enseignant"; + data[0][19] = "Atelier_pre-rentree_salle"; + data[0][20] = "UE_Libre"; + data[0][21] = "Covoiturage"; + data[0][22] = "Etudiant_Covoiturage"; + data[0][23] = "Stage_1"; + data[0][24] = "Num_convention_1"; + data[0][25] = "Periode_1"; + data[0][26] = "Stage_2"; + data[0][27] = "Num_convention_2"; + data[0][28] = "Periode_2"; - String[][] data1 = new String[nTable.getChildren().size()][27]; + String[][] data1 = new String[nTable.getChildren().size()][28]; int indexStudent = 0; for(noeud nStudent : nTable.getChildren()) { @@ -184,25 +187,26 @@ public class exportBaseToExcel { data1[indexStudent][7] = nStudent.getAttributes("Individu_-_Email"); data1[indexStudent][8] = nStudent.getAttributes("Groupe_Principal"); data1[indexStudent][9] = nStudent.getAttributes("Groupe_TD"); - data1[indexStudent][10] = nStudent.getAttributes("Groupe_Langue"); - data1[indexStudent][11] = nStudent.getAttributes("Groupe_Informatique"); - data1[indexStudent][12] = nStudent.getAttributes("LV1"); - data1[indexStudent][13] = nStudent.getAttributes("LV2"); - data1[indexStudent][14] = nStudent.getAttributes("Regime"); - data1[indexStudent][15] = nStudent.getAttributes("Atelier-rentree_horaire"); - data1[indexStudent][16] = nStudent.getAttributes("Atelier_pre-rentree_enseignant"); - data1[indexStudent][17] = nStudent.getAttributes("Atelier_pre-rentree_salle"); - data1[indexStudent][18] = nStudent.getAttributes("UE_Libre"); - data1[indexStudent][19] = nStudent.getAttributes("Covoiturage"); - data1[indexStudent][20] = nStudent.getAttributes("Etudiant_Covoiturage"); - data1[indexStudent][21] = nStudent.getAttributes("Stage_1"); - data1[indexStudent][22] = nStudent.getAttributes("Num_convention_1"); - data1[indexStudent][23] = nStudent.getAttributes("Periode_1"); - data1[indexStudent][24] = nStudent.getAttributes("Stage_2"); - data1[indexStudent][25] = nStudent.getAttributes("Num_convention_2"); - data1[indexStudent][26] = nStudent.getAttributes("Periode_2"); + data1[indexStudent][10] = nStudent.getAttributes("Groupe_LV1"); + data1[indexStudent][11] = nStudent.getAttributes("Groupe_LV2"); + data1[indexStudent][12] = nStudent.getAttributes("Groupe_Informatique"); + data1[indexStudent][13] = nStudent.getAttributes("LV1"); + data1[indexStudent][14] = nStudent.getAttributes("LV2"); + data1[indexStudent][15] = nStudent.getAttributes("Regime"); + data1[indexStudent][16] = nStudent.getAttributes("Atelier-rentree_horaire"); + data1[indexStudent][17] = nStudent.getAttributes("Atelier_pre-rentree_enseignant"); + data1[indexStudent][18] = nStudent.getAttributes("Atelier_pre-rentree_salle"); + data1[indexStudent][19] = nStudent.getAttributes("UE_Libre"); + data1[indexStudent][20] = nStudent.getAttributes("Covoiturage"); + data1[indexStudent][21] = nStudent.getAttributes("Etudiant_Covoiturage"); + data1[indexStudent][22] = nStudent.getAttributes("Stage_1"); + data1[indexStudent][23] = nStudent.getAttributes("Num_convention_1"); + data1[indexStudent][24] = nStudent.getAttributes("Periode_1"); + data1[indexStudent][25] = nStudent.getAttributes("Stage_2"); + data1[indexStudent][26] = nStudent.getAttributes("Num_convention_2"); + data1[indexStudent][27] = nStudent.getAttributes("Periode_2"); - data[0][28] = data1; + data[0][29] = data1; indexStudent++; } diff --git a/src/baseUFRHG/noeud.java b/src/baseUFRHG/noeud.java index 08ab80e..6c6cd84 100644 --- a/src/baseUFRHG/noeud.java +++ b/src/baseUFRHG/noeud.java @@ -168,6 +168,9 @@ public class noeud implements Cloneable{ * @param value */ public void addAttribute(String nameAttribut, String value) { + if(nameAttribut==null) return; + if(nameAttribut.matches("\\s+")) return; + nameAttribut = nameAttribut.trim(); attributes.put(nameAttribut,value); } @@ -187,7 +190,7 @@ public class noeud implements Cloneable{ */ public String getAttributes(String nameAttribut) { if(nameAttribut == null) return null; - if(nameAttribut.matches("\\s*")) return null; + if(nameAttribut.matches("\\s+")) return null; if(this.attributes.containsKey(nameAttribut)) return this.attributes.get(nameAttribut); return null; } @@ -200,7 +203,7 @@ public class noeud implements Cloneable{ */ public String getAttributesBeginBy(String nameAttribut) { if(nameAttribut == null) return null; - if(nameAttribut.matches("\\s*")) return null; + if(nameAttribut.matches("\\s+")) return null; Pattern pattern = Pattern.compile("^" + nameAttribut +".*$"); for (Map.Entry entry : attributes.entrySet()) { if(pattern.matcher(entry.getKey()).matches()) { @@ -218,7 +221,7 @@ public class noeud implements Cloneable{ */ public Boolean containAttributBeginBy(String nameAttribut) { if(nameAttribut == null) return null; - if(nameAttribut.matches("\\s*")) return null; + if(nameAttribut.matches("\\s+")) return null; Pattern pattern = Pattern.compile("^" + nameAttribut +".*$"); for (Map.Entry entry : attributes.entrySet()) { if(pattern.matcher(entry.getKey()).matches()) { @@ -304,12 +307,15 @@ public class noeud implements Cloneable{ /** - * Obtient la liste des attributs de ce noeud.
+ * Ajoute l'attribut key avec la valeur value.
* @param key * @param value */ public void setAttribut(String key, String value) { - getAttributes().put(key, value); + if(key==null) return; + if(key.matches("\\s+")) return; + key = key.trim(); + this.attributes.put(key, value); } /** @@ -317,7 +323,8 @@ public class noeud implements Cloneable{ * @param nameAttribut */ public void removeAttribut(String nameAttribut) { - getAttributes().remove(nameAttribut); + if(nameAttribut==null) return; + this.attributes.remove(nameAttribut); } /** diff --git a/src/baseUFRHG/recupeBases.java b/src/baseUFRHG/recupeBases.java index 584edc9..c5131a8 100644 --- a/src/baseUFRHG/recupeBases.java +++ b/src/baseUFRHG/recupeBases.java @@ -30,8 +30,8 @@ public class recupeBases { JFrame frame = new JFrame(); JLabel texte = new JLabel("

La base de données ne se trouve pas dans le même dossier que celui de l'application.


" - +"

Une nouvelle base de données a été créée dans le dossier de l'application.

" - + "

La base de données se trouve dans le fichier \"base.xml\".

" + +"

Une nouvelle base de données a été créée dans le dossier nommé \"base\" de l'application.

" + + "

La base de données se trouve dans le fichier XML nommé \"base.xml\".

" + "

" + "

Vous allez devoir saisir l'année universitaire pour débuter et créer la base.

"); JOptionPane.showMessageDialog(frame, texte); diff --git a/src/baseUFRHG/sauvegardeXMLBase.java b/src/baseUFRHG/sauvegardeXMLBase.java index 36b2d63..5644d50 100644 --- a/src/baseUFRHG/sauvegardeXMLBase.java +++ b/src/baseUFRHG/sauvegardeXMLBase.java @@ -15,11 +15,12 @@ public class sauvegardeXMLBase { public static enum saveType{ SANS_MESSAGE, + WITH_DEFAULT_MESSAGE, WITH_MESSAGE, } - public static void save(noeud nBase, saveType type) { + public static void save(noeud nBase, saveType type, String message) { // Sauvegarde de la base String pathToFile = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml"; @@ -48,10 +49,14 @@ public class sauvegardeXMLBase { writer.write(nBase.toWrite()); writer.close(); - if(type==saveType.WITH_MESSAGE) { + if(type==saveType.WITH_DEFAULT_MESSAGE) { JOptionPane.showMessageDialog(null, "La base a été sauvegardée.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE); } + if(type==saveType.WITH_MESSAGE) { + JOptionPane.showMessageDialog(null, message, "Sauvegarde", JOptionPane.INFORMATION_MESSAGE); + } + } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la méthode save", JOptionPane.ERROR_MESSAGE); diff --git a/src/baseUFRHG/supprimeCaracatresSpeciaux.java b/src/baseUFRHG/supprimeCaracatresSpeciaux.java index 25b4202..6bd44fa 100644 --- a/src/baseUFRHG/supprimeCaracatresSpeciaux.java +++ b/src/baseUFRHG/supprimeCaracatresSpeciaux.java @@ -4,7 +4,7 @@ import java.text.Normalizer; public class supprimeCaracatresSpeciaux { - static String TousLesCaracatresSpeciaux(String str) { + public static String TousLesCaracatresSpeciaux(String str) { // Supprimer les accents String normalizedStr = Normalizer.normalize(str, Normalizer.Form.NFD); String accentRemovedStr = normalizedStr.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");