diff --git a/GestionDesInscriptions_1.jar b/GestionDesInscriptions_1.jar index 17edc42..2f8c784 100644 Binary files a/GestionDesInscriptions_1.jar and b/GestionDesInscriptions_1.jar differ diff --git a/GestionDesInscriptions_2.jar b/GestionDesInscriptions_2.jar index 7f16d31..e60e56e 100644 Binary files a/GestionDesInscriptions_2.jar and b/GestionDesInscriptions_2.jar differ diff --git a/GestionDesInscriptions_3.jar b/GestionDesInscriptions_3.jar index 225e0d2..04b2aca 100644 Binary files a/GestionDesInscriptions_3.jar and b/GestionDesInscriptions_3.jar differ diff --git a/L1 Géo et amé _ Aménag..xlsx b/L1 Géo et amé _ Aménag..xlsx new file mode 100644 index 0000000..48b397a Binary files /dev/null and b/L1 Géo et amé _ Aménag..xlsx differ diff --git a/L2 Géo et amé _ Aménag..xlsx b/L2 Géo et amé _ Aménag..xlsx new file mode 100644 index 0000000..0c00c47 Binary files /dev/null and b/L2 Géo et amé _ Aménag..xlsx differ diff --git a/L2 Histoire.xlsx b/L2 Histoire.xlsx new file mode 100644 index 0000000..288809a Binary files /dev/null and b/L2 Histoire.xlsx differ diff --git a/L3 Histoire _ Patrimoine.xlsx b/L3 Histoire _ Patrimoine.xlsx new file mode 100644 index 0000000..41f21aa Binary files /dev/null and b/L3 Histoire _ Patrimoine.xlsx differ diff --git a/base.xlsx b/base.xlsx index 886bcb8..1c30c0c 100644 Binary files a/base.xlsx and b/base.xlsx differ diff --git a/base.xml b/base.xml index be7073b..9c2e00a 100644 --- a/base.xml +++ b/base.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/baseUFRHG/CreateCalcWorkbook.java b/src/baseUFRHG/CreateCalcWorkbook.java index 07c4ee1..33a6695 100644 --- a/src/baseUFRHG/CreateCalcWorkbook.java +++ b/src/baseUFRHG/CreateCalcWorkbook.java @@ -34,34 +34,38 @@ public class CreateCalcWorkbook extends JFrame{ private ProcessTask processTask; private JFrame fr; JPanel panel; + String nameFile; - public CreateCalcWorkbook(Object[][] data){ - fr = new JFrame(); - fr.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + public CreateCalcWorkbook(Object[][] data, String nameFile){ + + this.nameFile = nameFile; + + this.fr = new JFrame(); + this.fr.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - fr.setTitle("Création du classeur"); - fr.getContentPane().setLayout(new BorderLayout()); + this.fr.setTitle("Création du classeur"); + this.fr.getContentPane().setLayout(new BorderLayout()); - panel = new JPanel(); - panel.setLayout(new BorderLayout()); - panel.setPreferredSize(new Dimension(300, 50)); + this.panel = new JPanel(); + this.panel.setLayout(new BorderLayout()); + this.panel.setPreferredSize(new Dimension(300, 50)); JLabel titleLabel = new JLabel("Processus"); titleLabel.setHorizontalAlignment(SwingConstants.CENTER); - panel.add(titleLabel, BorderLayout.NORTH); + this.panel.add(titleLabel, BorderLayout.NORTH); - progressBar = new JProgressBar(0, data.length); - progressBar.setStringPainted(true); - panel.add(progressBar, BorderLayout.CENTER); + this.progressBar = new JProgressBar(0, data.length); + this.progressBar.setStringPainted(true); + this.panel.add(progressBar, BorderLayout.CENTER); - fr.getContentPane().add(panel, BorderLayout.CENTER); + this.fr.getContentPane().add(panel, BorderLayout.CENTER); - fr.pack(); + this.fr.pack(); - fr.setLocationRelativeTo(null); // Centre la fenêtre à l'écran - fr.setVisible(true); + this.fr.setLocationRelativeTo(null); // Centre la fenêtre à l'écran + this.fr.setVisible(true); - fr.setVisible(true); + this.fr.setVisible(true); processTask = new ProcessTask(data); processTask.execute(); @@ -81,7 +85,7 @@ public class CreateCalcWorkbook extends JFrame{ @Override protected Void doInBackground() throws Exception { - String filePath = Paths.get("").toAbsolutePath().toString()+ "/base.xlsx"; + String filePath = Paths.get("").toAbsolutePath().toString()+ "/"+ nameFile +".xlsx"; try (Workbook workbook = new XSSFWorkbook()) { int rows = data.length; // Nombre de lignes diff --git a/src/baseUFRHG/actions/exportTable.java b/src/baseUFRHG/actions/exportTable.java new file mode 100644 index 0000000..a22bd7a --- /dev/null +++ b/src/baseUFRHG/actions/exportTable.java @@ -0,0 +1,47 @@ +package baseUFRHG.actions; + +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.ImageIcon; + +import baseUFRHG.demarre; +import baseUFRHG.exportBaseToExcel; +import baseUFRHG.gestionnaire; +import baseUFRHG.noeud; + + + +public class exportTable extends AbstractAction{ + private noeud nTable = null; + private gestionnaire instance; + + public exportTable(gestionnaire instance) { + + this.instance = instance; + putValue( Action.NAME, "Exporter table Ms Excel" ); + putValue( Action.SMALL_ICON, new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")) ); + putValue( Action.LARGE_ICON_KEY, new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")) ); + putValue( Action.SHORT_DESCRIPTION, "Exporter la table dans un classeur Ms Excel." ); + + } + /** + * + */ + private static final long serialVersionUID = 1L; + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + instance.majTableGroupes(); + this.nTable = instance.nTable; + if(nTable!=null) { + System.out.println(nTable.toWrite()); + exportBaseToExcel.exportTable(nTable); + }else { + System.out.println("nTable = null"); + } + } + +} diff --git a/src/baseUFRHG/commandes.java b/src/baseUFRHG/commandes.java index a48b67c..ac2e732 100644 --- a/src/baseUFRHG/commandes.java +++ b/src/baseUFRHG/commandes.java @@ -3,6 +3,6 @@ package baseUFRHG; public class commandes { public static noeud nBase = null; - + } diff --git a/src/baseUFRHG/demarre.java b/src/baseUFRHG/demarre.java index 98c1816..5fbe3e8 100644 --- a/src/baseUFRHG/demarre.java +++ b/src/baseUFRHG/demarre.java @@ -66,7 +66,7 @@ public class demarre extends JFrame { commandes.nBase = recupeBases.recupeLaBase(); } //Exporte la base dans un classeur Excel. - exportBaseToExcel.export(); + exportBaseToExcel.exportBase(); } }); btnCreate.setHorizontalAlignment(SwingConstants.LEFT); diff --git a/src/baseUFRHG/exportBaseToExcel.java b/src/baseUFRHG/exportBaseToExcel.java index 2618bfe..bdf6b30 100644 --- a/src/baseUFRHG/exportBaseToExcel.java +++ b/src/baseUFRHG/exportBaseToExcel.java @@ -8,7 +8,7 @@ public class exportBaseToExcel { - public static void export() { + public static void exportBase() { // Données Object[][] data = new Object[commandes.nBase.getChild(commandes.nBase.getAttributes("defaut_Year")).getNumberChildren()][29]; @@ -90,7 +90,7 @@ public class exportBaseToExcel { } if(data.length>0) { - new CreateCalcWorkbook(data); + new CreateCalcWorkbook(data,"Base"); }else { JPanel panel = new JPanel(); JLabel message = new JLabel("

La base de données est nulle.

"); @@ -105,7 +105,90 @@ public class exportBaseToExcel { - + public static void exportTable(noeud nTable) { + // Données + Object[][] data = new Object[1][29]; + + String formation = nTable.getFirstChild().getAttributes("IAE_-_Etape_lib."); + + + data[0][0] = nTable.getFirstChild().getAttributes("IAE_-_Etape_lib."); + data[0][1] = "Formation"; + data[0][2] = "Individu_-_Code_Etudiant"; + data[0][3] = "Individu_-_Prenom"; + data[0][4] = "Individu_-_Nom"; + data[0][5] = "Profil_etudiant_lib."; + data[0][6] = "Individu_-_Tel._portable"; + data[0][7] = "Individu_-_Email_personnel"; + data[0][8] = "Individu_-_Email"; + data[0][9] = "Groupe"; + data[0][10] = "Groupe_Principal"; + data[0][11] = "Groupe_TD"; + data[0][12] = "Groupe_Langue"; + data[0][13] = "LV1"; + data[0][14] = "LV2"; + data[0][15] = "Groupe_Informatique"; + 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"; + + + String[][] data1 = new String[nTable.getChildren().size()][27]; + + int indexStudent = 0; + for(noeud nStudent : nTable.getChildren()) { + data1[indexStudent][0] = nStudent.getAttributes("IAE_-_Etape_lib.");; + data1[indexStudent][1] = nStudent.getAttributes("Individu_-_Code_Etudiant"); + data1[indexStudent][2] = nStudent.getAttributes("Individu_-_Prenom"); + data1[indexStudent][3] = nStudent.getAttributes("Individu_-_Nom"); + data1[indexStudent][4] = nStudent.getAttributes("Profil_etudiant_lib."); + data1[indexStudent][5] = nStudent.getAttributes("Individu_-_Tel._portable"); + data1[indexStudent][6] = nStudent.getAttributes("Individu_-_Email_personnel"); + data1[indexStudent][7] = nStudent.getAttributes("Individu_-_Email"); + 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("Groupe_Informatique"); + 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"); + + data[0][28] = data1; + indexStudent++; + } + + + + if(data.length>0) { + new CreateCalcWorkbook(data,formation); + }else { + JPanel panel = new JPanel(); + JLabel message = new JLabel("

La base de données est nulle.

"); + panel.add(message); + JOptionPane.showMessageDialog(null, panel, "Erreur", JOptionPane.ERROR_MESSAGE); + } + } } diff --git a/src/baseUFRHG/gestionnaire.java b/src/baseUFRHG/gestionnaire.java index d6f23a2..fffa4b4 100644 --- a/src/baseUFRHG/gestionnaire.java +++ b/src/baseUFRHG/gestionnaire.java @@ -26,6 +26,8 @@ import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; +import baseUFRHG.actions.exportTable; + public class gestionnaire extends JFrame { /** @@ -44,7 +46,7 @@ public class gestionnaire extends JFrame { private JLabel lblNewLabel; private String defautYear = null; private JPanel panelNorth; - private JMenu mnNewMenu; + public noeud nTable = null; @@ -58,6 +60,7 @@ public class gestionnaire extends JFrame { commandes.nBase = recupeBases.recupeLaBase(); } initialize(); + } @@ -176,17 +179,20 @@ public class gestionnaire extends JFrame { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("Fichier"); - JMenuItem openItem = new JMenuItem("Ouvrir"); - JMenuItem saveItem = new JMenuItem("Enregistrer"); + JMenuItem exportItem = fileMenu.add(new exportTable(this)); + JMenuItem saveItem = new JMenuItem("Enregistrer les modifications"); JMenuItem exitItem = new JMenuItem("Quitter"); - fileMenu.add(openItem); + fileMenu.add(exportItem); fileMenu.add(saveItem); fileMenu.addSeparator(); // Ajouter une séparation entre les éléments du menu fileMenu.add(exitItem); menuBar.add(fileMenu); + + + panelNorth.add(menuBar, BorderLayout.NORTH); @@ -207,8 +213,13 @@ public class gestionnaire extends JFrame { private void majTableFormation() { noeud nYears = commandes.nBase.getChild(cYears.getSelectedItem().toString()); + nTable = new noeud("Table"); + nTable.setAttribut("defaut_Year", defautYear); + if(nYears!=null) { noeud nFormation = nYears.getChild(cFormations.getSelectedItem().toString()); + nTable.setAttribut("Formation", cFormations.getSelectedItem().toString()); + nTable.setAttribut("GroupeTD", " - "); String[] head = new String[31] ; String[][] data = new String[nFormation.getChildren().size()-1][31] ; @@ -227,6 +238,11 @@ public class gestionnaire extends JFrame { indexCol++; } indexRow++; + try { + nTable.addChild(nStudent.clone()); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } } @@ -274,10 +290,23 @@ public class gestionnaire extends JFrame { - private void majTableGroupes() { + public void majTableGroupes() { + String GroupeTD = (String) cGroupeTD.getSelectedItem(); + + nTable = new noeud("Table"); + nTable.setAttribut("defaut_Year", defautYear); + if(cGroupeTD.getSelectedItem()!=null) { + nTable.setAttribut("GroupeTD", cGroupeTD.getSelectedItem().toString()); + }else { + nTable.setAttribut("GroupeTD", " - "); + } + + if(GroupeTD!=null) { noeud nYears = commandes.nBase.getChild(cYears.getSelectedItem().toString()); + nTable.setAttribut("Formation", cFormations.getSelectedItem().toString()); + if(nYears!=null) { noeud nFormation = nYears.getChild(cFormations.getSelectedItem().toString()); @@ -310,7 +339,15 @@ public class gestionnaire extends JFrame { } } } - if(trouve)indexRow++; + if(trouve) { + indexRow++; + try { + nTable.addChild(nStudent.clone()); + } catch (CloneNotSupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } table.setModel(new DefaultTableModel(data, head)); @@ -322,6 +359,7 @@ public class gestionnaire extends JFrame { table.revalidate(); table.repaint(); + } } diff --git a/src/baseUFRHG/importAllBaseToExcel.java b/src/baseUFRHG/importAllBaseToExcel.java index a2b087a..5def495 100644 --- a/src/baseUFRHG/importAllBaseToExcel.java +++ b/src/baseUFRHG/importAllBaseToExcel.java @@ -44,7 +44,7 @@ public class importAllBaseToExcel { if(indexCol==0) { // Colonne formation if(cell.getCellType() == CellType.STRING) { - nBF = commandes.nBase.getChild(cell.getStringCellValue()); + nBF = commandes.nBase.getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(cell.getStringCellValue())); } } diff --git a/src/baseUFRHG/noeud.java b/src/baseUFRHG/noeud.java index 657c0d2..3c6bb0f 100644 --- a/src/baseUFRHG/noeud.java +++ b/src/baseUFRHG/noeud.java @@ -14,7 +14,7 @@ import java.util.regex.Pattern; * @author pabr6 * */ -public class noeud { +public class noeud implements Cloneable{ private String name; private String content; private SortedMap attributes = new TreeMap<>(); @@ -92,6 +92,15 @@ public class noeud { } return sb.toString(); } + + /** + * Retourne le premier enfant ou retourne un null. + * @return + */ + public noeud getFirstChild() { + if(this.children.size()>0) return this.children.get(0); + return null; + } /** * Place le contenu textuel content à ce noeud.
@@ -204,6 +213,24 @@ public class noeud { return false; } + /** + * Clone de l'objet. + */ + public noeud clone() throws CloneNotSupportedException { + noeud cloned = (noeud) super.clone(); + + // Copie profonde des objets privés si nécessaire + if(this.name!=null) cloned.name = new String(this.name); + if(this.content!=null) cloned.content = new String(this.content); + cloned.attributes = new TreeMap(this.attributes); + cloned.children = new ArrayList(this.children); +// if(this.Parent!=null) cloned.Parent = this.Parent.clone(); + + + return cloned; + } + + /** * Retourne le premier enfant ou enfant d'enfant qui contient un attribut nameAttribut.
* Sinon retourne un null. diff --git a/src/baseUFRHG/sauvegardeXMLBase.java b/src/baseUFRHG/sauvegardeXMLBase.java index dce330b..742ac7d 100644 --- a/src/baseUFRHG/sauvegardeXMLBase.java +++ b/src/baseUFRHG/sauvegardeXMLBase.java @@ -32,7 +32,13 @@ public class sauvegardeXMLBase { try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(directoryName), StandardCharsets.UTF_8))) { writer.write(nBase.toWrite()); - JOptionPane.showMessageDialog(null, "Les " + nbreModif +" modifications ont été enregistrées dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE); + + + if(nbreModif>0) { + JOptionPane.showMessageDialog(null, "Les " + nbreModif +" modifications ont été enregistrées dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE); + }else { + JOptionPane.showMessageDialog(null, "Il n'y a pas eu de modification dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE); + } } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la méthode save", JOptionPane.ERROR_MESSAGE);