MAJ V1.0.1 (JRE 1.8 with JDK 1.8.0_271)

This commit is contained in:
pablo rodriguez 2023-07-03 14:31:54 +02:00
parent 837bbeac2b
commit 63a399cf48
21 changed files with 90 additions and 101 deletions

BIN
Base.xlsx Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

1
base/base.xml Normal file

File diff suppressed because one or more lines are too long

1
base/base_sauvegarde.xml Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -150,9 +150,8 @@ public class CreateCalcWorkbook extends JFrame{
JOptionPane.showMessageDialog(null, "Le classeur a été créé avec succès.");
}catch (IOException e) {
System.out.println(e.toString());
// e.printStackTrace();
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la class CreateCalcWorkbook", JOptionPane.ERROR_MESSAGE);
System.out.println(e.toString());
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la class CreateCalcWorkbook", JOptionPane.ERROR_MESSAGE);
}
return null;
}

View File

@ -23,12 +23,12 @@ public class ExempleMAJ extends JFrame{
public void init() {
frame = new JFrame();
frame.setTitle("Gestion des inscriptions et des groupes - langues - informatique - stage - rentrée");
frame.setBounds(100, 100, 1000, 600);
frame.setBounds(0, 0, 1300, 100);
int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth();
int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight();
frame.setLocation(( (screenWidth) - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2);
// frame.setLocation(( (screenWidth) - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2);
frame.setSize(screenWidth, screenHeight);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);

View File

@ -10,38 +10,7 @@ public class FileSaveXLSX {
String Formation = "";
JFrame frame = new JFrame("Enregistrer le classeur Ms Excel");
// public void chooseDestination2(Object[][] data, String Formation, exportBaseToExcel.exportType type) {
// this.data = data;
// this.Formation = Formation;
//
// // Créer une boîte de dialogue de sélection de fichier
// JFileChooser fileChooser = new JFileChooser();
//
// // Afficher uniquement les dossiers (et non les fichiers)
// fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
//
// // Afficher la boîte de dialogue de sélection de fichier
// int result = fileChooser.showSaveDialog(null);
//
// // Vérifier si l'utilisateur a sélectionné un dossier de destination
// if (result == JFileChooser.APPROVE_OPTION) {
// // Récupérer le dossier sélectionné par l'utilisateur
// File selectedFolder = fileChooser.getSelectedFile();
//
// // Récupérer le nom du fichier à partir d'une boîte de dialogue
// String fileName = JOptionPane.showInputDialog(null, "Nom du fichier :", Formation);
//
// // Créer le chemin complet du fichier en combinant le dossier et le nom du fichier
// String filePath = selectedFolder.getAbsolutePath() + File.separator + fileName + ".xlsx";
//
// if(type.equals(exportBaseToExcel.exportType.TABLE)) new CreateCalcWorkbook(data,filePath);
// if(type.equals(exportBaseToExcel.exportType.EMARGEMENT)) new createEmargement(data, filePath);
// }
//
//
//
//
// }
public void save(Object[][] data, String Formation, exportBaseToExcel.exportType type) {
@ -55,8 +24,10 @@ public class FileSaveXLSX {
// Spécifiez le nom de fichier par défaut
if(type == exportBaseToExcel.exportType.EMARGEMENT) {
nameFile = "emargement_" + Formation + ".xlsx";
}else {
}else if(type == exportBaseToExcel.exportType.TABLE){
nameFile = "table_" + Formation + ".xlsx";
}else {
nameFile = "base" + Formation + ".xlsx";
}
fileChooser.setSelectedFile(new File(nameFile));
@ -72,10 +43,9 @@ public class FileSaveXLSX {
new CreateCalcWorkbook(data, selectedFile.getAbsolutePath());
if (type.equals(exportBaseToExcel.exportType.EMARGEMENT))
new createEmargement(data, selectedFile.getAbsolutePath());
if (type.equals(exportBaseToExcel.exportType.BASE))
new CreateCalcWorkbook(data, selectedFile.getAbsolutePath());
}
}
}

View File

@ -1,21 +1,17 @@
package baseUFRHG;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import baseUFRHG.sauvegardeXMLBase.saveType;
public class base {
/**
@ -33,12 +29,6 @@ public class base {
String defaultValue = "2022-2023";
String userInput = JOptionPane.showInputDialog("Quelle est l'année universitaire ? ",defaultValue);
String regex = "(\\d{4})-(\\d{4})";
Pattern pattern = Pattern.compile(regex);
@ -54,23 +44,9 @@ public class base {
userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput);
nBase.addChild(new noeud(userInput));
nBase.setAttribut("defaut_Year", userInput);
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
Path outputFilePath = Paths.get(directoryName);
try {
BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
fichier.write(nBase.toWrite());
fichier.close();
JFrame frame = new JFrame();
JLabel texte = new JLabel("<html><p>La base de données a été créée.</p></html>");
JOptionPane.showMessageDialog(frame, texte);
} catch (IOException e) {
e.printStackTrace();
}
return nBase;
sauvegardeXMLBase.save(nBase, saveType.WITH_MESSAGE);
commandes.nBase = nBase;
return commandes.nBase;
}
@ -93,13 +69,7 @@ public class base {
}
return null;
}

View File

@ -84,7 +84,7 @@ public class demarre extends JFrame {
frmEvalwriter.setResizable(false);
btnCreate = new JButton("<html>Exporter toute la base dans<br>un classeur MS Excel (base.xlsx)</html>");
btnCreate = new JButton("<html>Exporter toute la base dans<br>un classeur MS Excel</html>");
btnCreate.setHorizontalAlignment(SwingConstants.LEFT);
btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")));
btnCreate.addActionListener(new ActionListener() {
@ -119,10 +119,10 @@ public class demarre extends JFrame {
// lblNewLabel.setIcon(new ImageIcon(demarre.class.getResource("/resources/accueilanalysecalc.png")));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Pacifico", Font.PLAIN, 26));
lblNewLabel.setBounds(10, 82, 753, 106);
lblNewLabel.setBounds(10, 104, 753, 106);
frmEvalwriter.getContentPane().add(lblNewLabel);
JButton btnNewButton = new JButton("<html>Mise à jour de la base<br>depuis classeur MS Excel</html>");
JButton btnNewButton = new JButton("<html>Mise à jour de la base depuis<br>un classeur Ms Excel</html>");
btnNewButton.setHorizontalAlignment(SwingConstants.LEFT);
btnNewButton.setIcon(new ImageIcon(demarre.class.getResource("/resources/majInscriptionToBase.png")));
btnNewButton.addActionListener(new ActionListener() {
@ -154,9 +154,9 @@ public class demarre extends JFrame {
btnTutoriels.setBounds(397, 394, 366, 175);
frmEvalwriter.getContentPane().add(btnTutoriels);
JButton btnimporterDesInscriptionsdepuis = new JButton("<html>Importer des inscriptions<br>depuis tableur MS Excel</html>");
JButton btnimporterDesInscriptionsdepuis = new JButton("<html>Importer des inscriptions<br>depuis un classeur Ms Excel</html>");
btnimporterDesInscriptionsdepuis.setHorizontalAlignment(SwingConstants.LEFT);
btnimporterDesInscriptionsdepuis.setIcon(new ImageIcon(demarre.class.getResource("/resources/importationexcel.png")));
btnimporterDesInscriptionsdepuis.setIcon(new ImageIcon(demarre.class.getResource("/resources/bouton_inscription_excel.png")));
btnimporterDesInscriptionsdepuis.setFont(new Font("Arial", Font.BOLD, 16));
btnimporterDesInscriptionsdepuis.setBounds(397, 323, 366, 60);
btnimporterDesInscriptionsdepuis.addActionListener(new ActionListener() {
@ -172,7 +172,7 @@ public class demarre extends JFrame {
JLabel lblNewLabel_3 = new JLabel("<html>pablo rodriguez - 2023<br>Version 1.0.1</html>");
lblNewLabel_3.setVerticalAlignment(SwingConstants.TOP);
lblNewLabel_3.setHorizontalAlignment(SwingConstants.LEFT);
lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 14));
lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 15));
lblNewLabel_3.setForeground(new Color(255, 255, 255));
lblNewLabel_3.setBounds(22, 11, 265, 40);
frmEvalwriter.getContentPane().add(lblNewLabel_3);

View File

@ -1,6 +1,5 @@
package baseUFRHG;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
@ -13,6 +12,7 @@ public class exportBaseToExcel {
public static enum exportType {
TABLE,
EMARGEMENT,
BASE
}
@ -102,7 +102,12 @@ public class exportBaseToExcel {
}
if(data.length>0) {
new CreateCalcWorkbook(data, Paths.get("").toAbsolutePath().toString()+ "/Base.xlsx");
FileSaveXLSX s = new FileSaveXLSX();
s.save(data, "", exportType.BASE);
// new CreateCalcWorkbook(data, Paths.get("").toAbsolutePath().toString()+ "/Base.xlsx");
}else {
JPanel panel = new JPanel();
JLabel message = new JLabel("<html><p>La base de données est nulle.</p></html>");

View File

@ -335,7 +335,7 @@ public class gestionnaire extends JFrame {
}
});
JMenu menuExport = new JMenu("Export");
JMenu menuExport = new JMenu("Exportation");
menuExport.setFont(new Font("Tahoma", Font.BOLD, 14));
JMenuItem exportItem = menuExport.add(new exportTable(this));
menuExport.add(exportItem);
@ -1126,7 +1126,7 @@ public class gestionnaire extends JFrame {
}
}
lblInformation.setText("Informations : Nombre d'étudaint = " + compteur);
lblInformation.setText("Informations : Nombre d'étudiant = " + compteur);
// Obtenir les entrées du dictionnaire sous forme de liste
List<Map.Entry<String, Integer>> entryList = new ArrayList<>(dictionary.entrySet());

View File

@ -100,6 +100,7 @@ public class importInscriptionXLS {
nStudent = new noeud(nameNoeudStudent);
nFormation.addChild(nStudent);
}
for (Map.Entry<String, String> entry : Student.entrySet()) {
if(entry.getKey().equals("Individu - Nom")
|| entry.getKey().equals("Individu - Prénom")
@ -113,6 +114,7 @@ public class importInscriptionXLS {
nStudent.setAttribut(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(entry.getKey()), entry.getValue());
}
}
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","");
@ -144,7 +146,6 @@ public class importInscriptionXLS {
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

View File

@ -13,14 +13,16 @@ public class recupeBases {
* Récupère la base des évaluations qui se trouve indiqué par commandes.PathBaseEvaluationDefaut ou commandes.PathBaseEvaluations.
*/
public static noeud recupeLaBase() {
String filePath = "base.xml";
String filePath = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml";
File file = new File(filePath);
noeud nBase = null;
if (file.exists()) {
//lecture du fichier base.xml
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml";
String xmlString = lectureFileToString.lecture(directoryName);
nBase = lectureXML.lectureStringToNoeud(xmlString);

View File

@ -1,11 +1,13 @@
package baseUFRHG;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Date;
import javax.swing.JOptionPane;
@ -20,9 +22,23 @@ public class sauvegardeXMLBase {
public static void save(noeud nBase, saveType type) {
// 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))) {
String pathToFile = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml";
String PathToDirector = Paths.get("").toAbsolutePath() + "/base";
File directory11 = new File(PathToDirector);
if (!directory11.exists()) {
boolean created = directory11.mkdirs();
if (created) {
System.out.println("Répertoire base créé avec succès");
} else {
System.out.println("Échec de la création du répertoire base");
}
}
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(pathToFile), StandardCharsets.UTF_8))) {
writer.write(nBase.toWrite());
if(type==saveType.WITH_MESSAGE) JOptionPane.showMessageDialog(null, "La base a été sauvegardée.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE);
} catch (IOException e) {
@ -34,10 +50,29 @@ public class sauvegardeXMLBase {
public static void saveSauvegarde(noeud nBase) {
String PathToDirector = Paths.get("").toAbsolutePath() + "/base";
File directory11 = new File(PathToDirector);
if (!directory11.exists()) {
boolean created = directory11.mkdirs();
if (created) {
System.out.println("Répertoire base créé avec succès");
} else {
System.out.println("Échec de la création du répertoire base");
}
}
// Sauvegarde de la base
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base_sauvegarde.xml";
String pathToFile = Paths.get("").toAbsolutePath().toString()+ "/base/base_sauvegarde.xml";
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
new FileOutputStream(pathToFile), StandardCharsets.UTF_8))) {
Date aujourdhui = new Date();
nBase.setAttribut("date_derniere_modification",base.DateEnClairFR(aujourdhui));
writer.write(nBase.toWrite());
} catch (IOException e) {
e.printStackTrace();
@ -54,6 +89,9 @@ public class sauvegardeXMLBase {
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(path), StandardCharsets.UTF_8))) {
Date aujourdhui = new Date();
nBase.setAttribut("date_derniere_modification",base.DateEnClairFR(aujourdhui));
writer.write(nBase.toWrite());
JOptionPane.showMessageDialog(null, "Sauvegarde réussi.","Message",JOptionPane.OK_OPTION);
} catch (IOException e) {
@ -66,13 +104,17 @@ public class sauvegardeXMLBase {
public static void saveModif(noeud nBase, Integer nbreModif) {
// Sauvegarde de la base
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base/base.xml";
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
Date aujourdhui = new Date();
nBase.setAttribut("date_derniere_modification",base.DateEnClairFR(aujourdhui));
writer.write(nBase.toWrite());
if(nbreModif>0) {
JOptionPane.showMessageDialog(null, "Les " + nbreModif +" modifications ont été enregistrées dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE);
}else {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 328 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB