2022-06-19 21:01:30 +02:00
|
|
|
package fenetres.create_act;
|
|
|
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.KeyEvent;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
|
import javax.swing.Action;
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
import javax.swing.KeyStroke;
|
|
|
|
|
|
|
|
import MEPTL.commandes;
|
|
|
|
import MEPTL.verificationFichierAnalyse;
|
|
|
|
import cXML.Run;
|
|
|
|
|
|
|
|
public class actSave extends AbstractAction{
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
{
|
|
|
|
putValue( Action.NAME, "Enregister" );
|
|
|
|
putValue( Action.SMALL_ICON, new ImageIcon( getClass().getResource("/save.png")) );
|
|
|
|
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_S );
|
|
|
|
putValue( Action.SHORT_DESCRIPTION, "Enregistrer (CTRL+S)" );
|
|
|
|
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK ) );
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
Pattern p = Pattern.compile("[.xml]\\b");
|
|
|
|
Matcher m = p.matcher(commandes.nameSujet);
|
|
|
|
|
|
|
|
String message="";
|
|
|
|
|
|
|
|
if(m.find()) {
|
2022-12-22 14:21:29 +01:00
|
|
|
message="\"Voulez-vous enregistrer le fichier \"" + commandes.nameSujet + ".xml\"\n"
|
2022-06-19 21:01:30 +02:00
|
|
|
+ "Dans le dossier " + commandes.PathFilenameAnalysis;
|
|
|
|
}else {
|
|
|
|
message="\"Voulez-vous enregistrer le fichier \"" + commandes.nameSujet + ".xml\"\n"
|
|
|
|
+ "Dans le dossier " + commandes.PathFilenameAnalysis;
|
|
|
|
commandes.nameSujet = commandes.nameSujet + ".xml";
|
|
|
|
}
|
|
|
|
|
2022-12-22 14:21:29 +01:00
|
|
|
int input = JOptionPane.showConfirmDialog(null, message);
|
|
|
|
|
|
|
|
if(input==0) {
|
|
|
|
try {
|
|
|
|
verificationFichierAnalyse.MiseAJourHashNomFichierAnalyse(commandes.nameSujet);
|
|
|
|
|
2022-12-23 19:24:59 +01:00
|
|
|
Run.ecritureNodeEnXML(commandes.sujet, commandes.nameSujet,commandes.PathFilenameAnalysis,Run.TypeFile.Sujet);
|
2022-12-22 14:21:29 +01:00
|
|
|
|
|
|
|
if(m.find()) {
|
|
|
|
fenetres.create.getTextNodeSelect().setText("Le fichier \"" + commandes.nameSujet + " a été réenregistré.\n\n"
|
|
|
|
+ "Il se trouve dans le dossier " + commandes.PathFilenameAnalysis);
|
|
|
|
}else {
|
|
|
|
fenetres.create.getTextNodeSelect().setText("Le fichier \"" + commandes.nameSujet + ".xml\" a été réenregistré.\n\n"
|
|
|
|
+ "Il se trouve dans le dossier " + commandes.PathFilenameAnalysis);
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println( input + "Save" );
|
|
|
|
} catch (IOException | CloneNotSupportedException e1) {
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-19 21:01:30 +02:00
|
|
|
|
2022-12-22 14:21:29 +01:00
|
|
|
|
2022-06-19 21:01:30 +02:00
|
|
|
|
|
|
|
}
|