77 lines
2.8 KiB
Java
77 lines
2.8 KiB
Java
package action;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
import java.io.IOException;
|
|
import java.text.ParseException;
|
|
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 MEPTL.commandes;
|
|
import MEPTL.verificationFichierAnalyse_node_commandesSujet;
|
|
import cXML.Run;
|
|
|
|
public class actSaveFileAnalysis extends AbstractAction{
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
{
|
|
putValue( Action.NAME, "Enregister le fichier d'analyse" );
|
|
putValue( Action.SMALL_ICON, new ImageIcon( getClass().getResource("/fichierAnalysemini.png")) );
|
|
putValue( Action.SHORT_DESCRIPTION, "Enregistrer le fichier d'analyse. (CTRL+S)" );
|
|
}
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
Pattern p = Pattern.compile("[.xml]\\b");
|
|
Matcher m = p.matcher(commandes.nameSujet);
|
|
|
|
String message="";
|
|
|
|
if(m.find()) {
|
|
message="\"Voulez-vous enregistrer le fichier d'analyse \"" + commandes.nameSujet + ".xml\"\n"
|
|
+ "Dans le dossier " + commandes.PathFilenameAnalysis;
|
|
}else {
|
|
message="\"Voulez-vous enregistrer le fichier d'analyse \"" + commandes.nameSujet + ".xml\"\n"
|
|
+ "Dans le dossier " + commandes.PathFilenameAnalysis;
|
|
commandes.nameSujet = commandes.nameSujet + ".xml";
|
|
}
|
|
|
|
int input = JOptionPane.showConfirmDialog(null, message);
|
|
|
|
if(input==0) {
|
|
try {
|
|
verificationFichierAnalyse_node_commandesSujet.MiseAJourHashNomFichierAnalyse(commandes.nameSujet);
|
|
//Mise à jour de la date d'enregistrement du fichier d'analyse
|
|
try {
|
|
commandes.sujet.getAttributs().put("date", calcul.formatDateWriter.dateTodayLibreOffice());
|
|
} catch (ParseException e1) {
|
|
e1.printStackTrace();
|
|
}
|
|
|
|
Run.ecritureNodeEnXML(commandes.sujet, commandes.nameSujet,commandes.PathFilenameAnalysis,Run.TypeFile.Sujet);
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|