Ajoute de la class CreateUpdateZipArchive.
This commit is contained in:
parent
85887a5f4c
commit
8d8c07d802
File diff suppressed because one or more lines are too long
@ -27,6 +27,7 @@ import javax.swing.UIManager;
|
||||
|
||||
import Inscriptions.importInscriptionCSV;
|
||||
import Inscriptions.importInscriptionXLS;
|
||||
import baseUFRHG.CreateUpdateZipArchive;
|
||||
import baseUFRHG.FileChooserXLSX;
|
||||
import baseUFRHG.VersionChecker;
|
||||
import baseUFRHG.commandes;
|
||||
@ -44,7 +45,16 @@ public class Window_demarre extends JFrame {
|
||||
private JFrame frmEvalwriter;
|
||||
JButton btnExporterTouteLaBase;
|
||||
JButton actImporterInscriptionDepuisCSV;
|
||||
|
||||
|
||||
JButton btnAideImportationInscriptionXLSX = new JButton("Aide à l'importation des inscriptions depuis Ms Excel");
|
||||
JButton btnHelpDownload = new JButton("Aide au téléchargement et à l'installation");
|
||||
JButton btnNewVersion = new JButton("<html>Nouvelle version disponible</html>");
|
||||
JButton btnNAideMiseAJour = new JButton("Aide à la mise en jour depuis classeur Ms Excel");
|
||||
JButton btnMiseAJourDepuisClasseur = new JButton("<html>Mise à jour de la base depuis<br>un classeur Ms Excel</html>");
|
||||
JButton btnGestionnaire = new JButton("");
|
||||
JButton btnimporterDesInscriptionsdepuisClasseur = new JButton("<html>Importer des inscriptions<br>depuis un classeur Ms Excel</html>");
|
||||
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
@ -86,6 +96,7 @@ public class Window_demarre extends JFrame {
|
||||
public void run() {
|
||||
// Appeler la méthode de sauvegarde ici
|
||||
sauvegardeXMLBase.saveSauvegarde(commandes.nBase);
|
||||
CreateUpdateZipArchive.save();
|
||||
}
|
||||
};
|
||||
|
||||
@ -104,14 +115,10 @@ public class Window_demarre extends JFrame {
|
||||
}
|
||||
|
||||
public Window_demarre() {
|
||||
// commandes.nBase = recupeBases.recupeLaBase();
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
private void initialize() {
|
||||
@ -139,28 +146,13 @@ public class Window_demarre extends JFrame {
|
||||
btnExporterTouteLaBase = new JButton("<html>Exporter toute la base dans<br>un classeur MS Excel</html>");
|
||||
btnExporterTouteLaBase.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnExporterTouteLaBase.setIcon(new ImageIcon(Window_demarre.class.getResource("/resources/exportbasetoexcel.png")));
|
||||
btnExporterTouteLaBase.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(commandes.nBase==null) {
|
||||
commandes.nBase = recupeBases.recupeLaBase();
|
||||
}
|
||||
//Exporte la base dans un classeur Excel.
|
||||
exportBaseToExcel.exportBase();
|
||||
}
|
||||
});
|
||||
btnExporterTouteLaBase.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
// btnCreate.addActionListener(this);
|
||||
|
||||
btnExporterTouteLaBase.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
btnExporterTouteLaBase.setBounds(10, 416, 377, 78);
|
||||
|
||||
frmEvalwriter.getContentPane().add(btnExporterTouteLaBase);
|
||||
|
||||
actImporterInscriptionDepuisCSV = new JButton("<html>Importer des inscriptions<br>depuis CSV (UTF-8, point-virgule)</html>");
|
||||
actImporterInscriptionDepuisCSV.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
actImporterInscriptionDepuisCSV.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
importInscriptionCSV.importe();
|
||||
}
|
||||
});
|
||||
actImporterInscriptionDepuisCSV.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
actImporterInscriptionDepuisCSV.setIcon(new ImageIcon(Window_demarre.class.getResource("/resources/importationcsv.png")));
|
||||
actImporterInscriptionDepuisCSV.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 16));
|
||||
actImporterInscriptionDepuisCSV.setBounds(10, 323, 377, 60);
|
||||
@ -175,53 +167,22 @@ public class Window_demarre extends JFrame {
|
||||
lblTitre.setBounds(10, 35, 753, 202);
|
||||
frmEvalwriter.getContentPane().add(lblTitre);
|
||||
|
||||
JButton btnMiseAJourDepuisClasseur = new JButton("<html>Mise à jour de la base depuis<br>un classeur Ms Excel</html>");
|
||||
btnMiseAJourDepuisClasseur.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnMiseAJourDepuisClasseur.setIcon(new ImageIcon(Window_demarre.class.getResource("/resources/majInscriptionToBase.png")));
|
||||
btnMiseAJourDepuisClasseur.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(VersionChecker.matchVersion(commandes.nBase)) {
|
||||
File f = FileChooserXLSX.retourneFileXLSX();
|
||||
if(f!=null) {
|
||||
importAllBaseToExcel.lecture(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnMiseAJourDepuisClasseur.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
btnMiseAJourDepuisClasseur.setBounds(10, 502, 377, 60);
|
||||
frmEvalwriter.getContentPane().add(btnMiseAJourDepuisClasseur);
|
||||
|
||||
JButton btnGestionnaire = new JButton("");
|
||||
|
||||
btnGestionnaire.setIcon(new ImageIcon(Window_demarre.class.getResource("/resources/gestionnaire_bouton.png")));
|
||||
btnGestionnaire.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(commandes.nBase==null) {
|
||||
commandes.nBase = recupeBases.recupeLaBase();
|
||||
}
|
||||
if(VersionChecker.matchVersion(commandes.nBase)) {
|
||||
afficheGestionnaire();
|
||||
}
|
||||
}
|
||||
});
|
||||
btnGestionnaire.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
btnGestionnaire.setBounds(397, 416, 366, 175);
|
||||
frmEvalwriter.getContentPane().add(btnGestionnaire);
|
||||
|
||||
JButton btnimporterDesInscriptionsdepuisClasseur = new JButton("<html>Importer des inscriptions<br>depuis un classeur Ms Excel</html>");
|
||||
btnimporterDesInscriptionsdepuisClasseur.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnimporterDesInscriptionsdepuisClasseur.setIcon(new ImageIcon(Window_demarre.class.getResource("/resources/bouton_inscription_excel.png")));
|
||||
btnimporterDesInscriptionsdepuisClasseur.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
btnimporterDesInscriptionsdepuisClasseur.setBounds(397, 323, 366, 60);
|
||||
btnimporterDesInscriptionsdepuisClasseur.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File f = FileChooserXLSX.retourneFileXLSX();
|
||||
if(f!=null) {
|
||||
importInscriptionXLS.importe(f);
|
||||
}
|
||||
}
|
||||
});
|
||||
frmEvalwriter.getContentPane().add(btnimporterDesInscriptionsdepuisClasseur);
|
||||
|
||||
JLabel lblAuteurVersion = new JLabel("<html>Pablo Rodriguez - 2023<br>Version "+ commandes.version+"</html>");
|
||||
@ -232,13 +193,7 @@ public class Window_demarre extends JFrame {
|
||||
lblAuteurVersion.setBounds(22, 11, 307, 55);
|
||||
frmEvalwriter.getContentPane().add(lblAuteurVersion);
|
||||
|
||||
JButton btnNAideMiseAJour = new JButton("Aide à la mise en jour depuis classeur Ms Excel");
|
||||
btnNAideMiseAJour.setForeground(Color.GRAY);
|
||||
btnNAideMiseAJour.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Window_Help_maj_data();
|
||||
}
|
||||
});
|
||||
btnNAideMiseAJour.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 12));
|
||||
btnNAideMiseAJour.setBounds(10, 561, 377, 30);
|
||||
frmEvalwriter.getContentPane().add(btnNAideMiseAJour);
|
||||
@ -259,41 +214,19 @@ public class Window_demarre extends JFrame {
|
||||
lblFondImage.setBounds(10, -48, 753, 365);
|
||||
frmEvalwriter.getContentPane().add(lblFondImage);
|
||||
|
||||
JButton btnNewVersion = new JButton("<html>Nouvelle version disponible</html>");
|
||||
|
||||
btnNewVersion.setIcon(new ImageIcon(Window_demarre.class.getResource("/resources/newVersion.png")));
|
||||
btnNewVersion.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||
btnNewVersion.setBounds(10, 602, 753, 63);
|
||||
frmEvalwriter.getContentPane().add(btnNewVersion);
|
||||
btnNewVersion.setVisible(commandes.newVersion);
|
||||
|
||||
btnNewVersion.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String url = "https://forge.chapril.org/pablo/GestionDesInscriptions/releases"; // Remplacez cette URL par celle que vous souhaitez afficher
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
} catch (IOException | URISyntaxException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JButton btnHelpDownload = new JButton("Aide au téléchargement et à l'installation");
|
||||
|
||||
btnHelpDownload.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 12));
|
||||
btnHelpDownload.setForeground(Color.GRAY);
|
||||
btnHelpDownload.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Window_Help_download_and_install();
|
||||
}
|
||||
});
|
||||
btnHelpDownload.setBounds(10, 665, 753, 30);
|
||||
frmEvalwriter.getContentPane().add(btnHelpDownload);
|
||||
|
||||
JButton btnAideImportationInscriptionXLSX = new JButton("Aide à l'importation des inscriptions depuis Ms Excel");
|
||||
btnAideImportationInscriptionXLSX.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Window_Help_inscriptionXLSX();
|
||||
}
|
||||
});
|
||||
|
||||
btnAideImportationInscriptionXLSX.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 12));
|
||||
btnAideImportationInscriptionXLSX.setBounds(397, 381, 366, 30);
|
||||
frmEvalwriter.getContentPane().add(btnAideImportationInscriptionXLSX);
|
||||
@ -309,8 +242,19 @@ public class Window_demarre extends JFrame {
|
||||
|
||||
btnHelpDownload.setVisible(commandes.newVersion);
|
||||
|
||||
ListenerAction();
|
||||
|
||||
// Ajoutez un WindowListener à la fenêtre principale
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ListenerAction() {
|
||||
|
||||
|
||||
// Ajoutez un WindowListener à la fenêtre principale.
|
||||
// Permet de fermer la fenêtre.
|
||||
frmEvalwriter.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
@ -324,7 +268,88 @@ public class Window_demarre extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Bouton gestionnaire de la base.
|
||||
btnGestionnaire.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(commandes.nBase==null) {
|
||||
commandes.nBase = recupeBases.recupeLaBase();
|
||||
}
|
||||
if(VersionChecker.matchVersion(commandes.nBase)) {
|
||||
afficheGestionnaire();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton exporter toute la base dans un classeur Ms Excel
|
||||
btnExporterTouteLaBase.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(commandes.nBase==null) commandes.nBase = recupeBases.recupeLaBase();
|
||||
//Exporte la base dans un classeur Excel.
|
||||
exportBaseToExcel.exportBase();
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton importer des inscription depuis un classeur Ms Excel.
|
||||
btnimporterDesInscriptionsdepuisClasseur.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File f = FileChooserXLSX.retourneFileXLSX();
|
||||
if(f!=null) {
|
||||
importInscriptionXLS.importe(f);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton Aide à la mise à jour de la base depuis un classeur Ms Excel.
|
||||
btnMiseAJourDepuisClasseur.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(VersionChecker.matchVersion(commandes.nBase)) {
|
||||
File f = FileChooserXLSX.retourneFileXLSX();
|
||||
if(f!=null) {
|
||||
importAllBaseToExcel.lecture(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton importer des inscriptions depuis un fichier CSV.
|
||||
actImporterInscriptionDepuisCSV.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
importInscriptionCSV.importe();
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton Aide à l'importation des inscription depuis un classeur Ms Excel
|
||||
btnAideImportationInscriptionXLSX.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Window_Help_inscriptionXLSX();
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton Aide au téléchargement et à l'installation de l'application.
|
||||
btnHelpDownload.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Window_Help_download_and_install();
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton nouvelle version disponible.
|
||||
btnNewVersion.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String url = "https://forge.chapril.org/pablo/GestionDesInscriptions/releases"; // Remplacez cette URL par celle que vous souhaitez afficher
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
} catch (IOException | URISyntaxException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bouton aide à la mise à jour de la base depuis un classeur Ms Excel
|
||||
btnNAideMiseAJour.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Window_Help_maj_data();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -513,6 +513,7 @@ public class Window_gestionnaire extends JFrame {
|
||||
menuFile.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
|
||||
JMenuItem saveBaseItem = menuFile.add(new saveTable(this));
|
||||
saveBaseItem.setText("Archive (Zip) et sauvegarde les modifications");
|
||||
menuFile.add(saveBaseItem);
|
||||
menuFile.addSeparator();
|
||||
JMenuItem exitItem = new JMenuItem("Quitter");
|
||||
|
173
src/baseUFRHG/CreateUpdateZipArchive.java
Normal file
173
src/baseUFRHG/CreateUpdateZipArchive.java
Normal file
@ -0,0 +1,173 @@
|
||||
package baseUFRHG;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class CreateUpdateZipArchive {
|
||||
|
||||
|
||||
public static void save() {
|
||||
String archiveFilePath = Paths.get("").toAbsolutePath().toString()+ "/base/archiveBase.zip";
|
||||
String texteIntoString = commandes.nBase.toWrite();
|
||||
|
||||
// Vérifier si l'archive existe, sinon la créer
|
||||
if (!archiveExists(archiveFilePath)) {
|
||||
createEmptyArchive(archiveFilePath);
|
||||
}
|
||||
|
||||
// Vérifier le nombre de fichiers dans l'archive
|
||||
int numFilesInArchive = countFilesInArchive(archiveFilePath);
|
||||
|
||||
// Si l'archive contient déjà 5 fichiers, supprimer le plus ancien
|
||||
if (numFilesInArchive >= 100) {
|
||||
removeOldestFileFromArchive(archiveFilePath);
|
||||
}
|
||||
|
||||
|
||||
// Créer le fichier XML avec le contenu de la chaîne
|
||||
String xmlContent = texteIntoString;
|
||||
String fileName = createFileNameWithDateTime("sauvbase", ".xml");
|
||||
String filePath = Paths.get("").toAbsolutePath().toString() + "/base/" + fileName;
|
||||
createFile(filePath, xmlContent);
|
||||
|
||||
// Ajouter le fichier XML à l'archive
|
||||
addFileToArchive(archiveFilePath, filePath);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static boolean archiveExists(String archiveFilePath) {
|
||||
File file = new File(archiveFilePath);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
private static void createEmptyArchive(String archiveFilePath) {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(archiveFilePath);
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
zos.close();
|
||||
System.out.println("Archive created successfully.");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String createFileNameWithDateTime(String prefix, String extension) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
String dateTimeString = now.format(formatter);
|
||||
return prefix + "_" + dateTimeString + extension;
|
||||
}
|
||||
|
||||
private static void createFile(String filePath, String content) {
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter(filePath);
|
||||
fileWriter.write(content);
|
||||
fileWriter.close();
|
||||
System.out.println("File created successfully: " + filePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void addFileToArchive(String archiveFilePath, String filePath) {
|
||||
try {
|
||||
File archiveFile = new File(archiveFilePath);
|
||||
File fileToAdd = new File(filePath);
|
||||
|
||||
Path archivePath = archiveFile.toPath();
|
||||
Path fileToAddPath = fileToAdd.toPath();
|
||||
|
||||
String fileToAddName = fileToAdd.getName();
|
||||
|
||||
try (FileSystem fs = FileSystems.newFileSystem(archivePath, null)) {
|
||||
Path fileInArchive = fs.getPath(fileToAddName);
|
||||
Files.copy(fileToAddPath, fileInArchive, StandardCopyOption.REPLACE_EXISTING);
|
||||
System.out.println("File added to the archive successfully.");
|
||||
|
||||
// Suppression du fichier après ajout à l'archive
|
||||
Files.deleteIfExists(fileToAddPath);
|
||||
System.out.println("File deleted successfully: " + filePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int countFilesInArchive(String archiveFilePath) {
|
||||
int count = 0;
|
||||
try (FileSystem fs = FileSystems.newFileSystem(Paths.get(archiveFilePath), null)) {
|
||||
for (Path rootDirectory : fs.getRootDirectories()) {
|
||||
count += countFilesRecursive(rootDirectory);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private static int countFilesRecursive(Path directory) {
|
||||
int count = 0;
|
||||
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(directory)) {
|
||||
for (Path path : directoryStream) {
|
||||
if (Files.isDirectory(path)) {
|
||||
count += countFilesRecursive(path);
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
private static void removeOldestFileFromArchive(String archiveFilePath) {
|
||||
try (FileSystem fs = FileSystems.newFileSystem(Paths.get(archiveFilePath), null)) {
|
||||
Path archivePath = fs.getPath("/");
|
||||
DirectoryStream<Path> directoryStream = Files.newDirectoryStream(archivePath, "sauvbase_*.xml");
|
||||
List<Path> files = new ArrayList<>();
|
||||
for (Path file : directoryStream) {
|
||||
files.add(file);
|
||||
}
|
||||
|
||||
if (!files.isEmpty()) {
|
||||
files.sort(Comparator.comparingLong(path -> getTimestampFromFileName(path)));
|
||||
Path oldestFile = files.get(0);
|
||||
Files.deleteIfExists(oldestFile);
|
||||
System.out.println("Oldest file deleted from the archive: " + oldestFile.getFileName());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static long getTimestampFromFileName(Path filePath) {
|
||||
String fileName = filePath.getFileName().toString();
|
||||
String timestampString = fileName.substring(fileName.lastIndexOf('_') + 1, fileName.lastIndexOf('.'));
|
||||
return Long.parseLong(timestampString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ public class VersionChecker {
|
||||
|
||||
/**
|
||||
* Vérification de la présence d'une nouvelle version dans la forge de Chapril.
|
||||
* Réupération des messages ou blocage de l'application.
|
||||
*/
|
||||
public static void verificationNewVersion() {
|
||||
|
||||
@ -64,6 +65,8 @@ public class VersionChecker {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// aide moi 1 = compléter mon service annuel
|
||||
pattern ="helpme1";
|
||||
regex = Pattern.compile(pattern);
|
||||
@ -73,13 +76,14 @@ public class VersionChecker {
|
||||
commandes.helpme1 = true;
|
||||
}
|
||||
|
||||
// blocage de l'application suite à des comportements malhonnête.
|
||||
// blocage de l'application suite à des comportements malhonnêtes.
|
||||
// Le message affiché contient mon prénom et nom comme signature.
|
||||
pattern ="blocageapplication";
|
||||
regex = Pattern.compile(pattern);
|
||||
matcher = regex.matcher(content);
|
||||
|
||||
matcher = regex.matcher(content);
|
||||
if(matcher.find()) {
|
||||
commandes.blocageApplication = true;
|
||||
commandes.newVersion = false;
|
||||
}
|
||||
|
||||
|
||||
@ -127,11 +131,22 @@ public class VersionChecker {
|
||||
|
||||
String[] VersionApplicationSplit = commandes.version.split("\\.");
|
||||
String[] VersionBaseSplit = versionDeLaBase.split("\\.");
|
||||
int versionIntegerApplication = Integer.valueOf( VersionApplicationSplit[0] + VersionApplicationSplit[1] + VersionApplicationSplit[2]);
|
||||
int versionIntegerBase = Integer.valueOf( VersionBaseSplit[0] + VersionBaseSplit[1] + VersionBaseSplit[2]);
|
||||
|
||||
boolean newV = false;
|
||||
|
||||
if( Integer.valueOf(VersionBaseSplit[0]) < Integer.valueOf(VersionApplicationSplit[0]) ) {
|
||||
newV=true;
|
||||
}else if ((Integer.valueOf(VersionBaseSplit[0])==Integer.valueOf(VersionApplicationSplit[0]))
|
||||
&& (Integer.valueOf(VersionBaseSplit[1]) < Integer.valueOf(VersionApplicationSplit[1]))) {
|
||||
newV=true;
|
||||
}else if ((Integer.valueOf(VersionBaseSplit[0])==Integer.valueOf(VersionApplicationSplit[0]))
|
||||
&& (Integer.valueOf(VersionBaseSplit[1]) == Integer.valueOf(VersionApplicationSplit[1]))
|
||||
&& (Integer.valueOf(VersionBaseSplit[2])<Integer.valueOf(VersionApplicationSplit[2])) ){
|
||||
newV=true;
|
||||
}
|
||||
|
||||
|
||||
if(versionIntegerBase < versionIntegerApplication) {
|
||||
if(newV) {
|
||||
nBase.setAttribut("version", commandes.version);
|
||||
|
||||
//Modification de la base si elle est de la version 1.0.1 ou 1.0.2
|
||||
|
@ -10,6 +10,7 @@ import javax.swing.ImageIcon;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import Windows.Window_gestionnaire;
|
||||
import baseUFRHG.CreateUpdateZipArchive;
|
||||
import baseUFRHG.commandes;
|
||||
import baseUFRHG.sauvegardeXMLBase;
|
||||
import baseUFRHG.sauvegardeXMLBase.saveType;
|
||||
@ -39,6 +40,7 @@ public class saveTable extends AbstractAction{
|
||||
|
||||
// Sauvegarde de la base
|
||||
sauvegardeXMLBase.save(commandes.nBase,saveType.WITH_DEFAULT_MESSAGE,"");
|
||||
CreateUpdateZipArchive.save();
|
||||
|
||||
instance.majTableFormation();
|
||||
instance.majTableGroupes();
|
||||
|
@ -38,8 +38,9 @@ public class base {
|
||||
if (matcher.matches()) {
|
||||
int firstNumber = Integer.parseInt(matcher.group(1));
|
||||
int secondNumber = Integer.parseInt(matcher.group(2));
|
||||
|
||||
if (firstNumber < secondNumber) {
|
||||
|
||||
// les deux nombres entiers doivent se suivre
|
||||
if (secondNumber==(firstNumber+1)) {
|
||||
|
||||
if(!userInput.isEmpty()) {
|
||||
userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput);
|
||||
|
@ -3,11 +3,13 @@ package baseUFRHG;
|
||||
public class commandes {
|
||||
|
||||
public static noeud nBase = null; // La base de données sous forme de noeud.
|
||||
public static String version = "1.0.3"; // La version actuelle
|
||||
public static String version = "1.0.4"; // La version actuelle
|
||||
|
||||
// Messages et sécurité
|
||||
public static Boolean newVersion = false; //Permet de vérifier l'existance d'un nouvelle version.
|
||||
public static Boolean helpme1 = false; //M'aider à compléter mon service annuel.
|
||||
public static Boolean blocageApplication = false; //Blocage total de l'application.
|
||||
public static String messageAlerte = ""; //Message alerte
|
||||
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 3.2 KiB |
Loading…
Reference in New Issue
Block a user