2022-06-19 21:01:30 +02:00
|
|
|
package fenetres.create_act;
|
|
|
|
|
2022-12-07 20:44:00 +01:00
|
|
|
import java.awt.Component;
|
|
|
|
import java.awt.HeadlessException;
|
|
|
|
import java.awt.Image;
|
2022-06-19 21:01:30 +02:00
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.InputEvent;
|
|
|
|
import java.awt.event.KeyEvent;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
|
import javax.swing.Action;
|
|
|
|
import javax.swing.ImageIcon;
|
2022-12-07 20:44:00 +01:00
|
|
|
import javax.swing.JDialog;
|
2022-06-19 21:01:30 +02:00
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
import javax.swing.KeyStroke;
|
|
|
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
|
|
|
import MEPTL.commandes;
|
|
|
|
import MEPTL.ecritureSujet;
|
|
|
|
import MEPTL.meptl;
|
|
|
|
import MEPTL.verificationFichierAnalyse;
|
|
|
|
import cXML.Run;
|
|
|
|
import fenetres.evaluate;
|
|
|
|
|
|
|
|
public class actNewFichierAnalyse extends AbstractAction{
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
{
|
|
|
|
putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierODF.png")));
|
|
|
|
putValue( Action.NAME, "Génère un nouveau fichier d'analyse" );
|
|
|
|
putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierODFmini.png")) );
|
|
|
|
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_N );
|
|
|
|
putValue( Action.SHORT_DESCRIPTION, "Générer un nouveau fichier d'analyse (CTRL+N)" );
|
|
|
|
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK) );
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2022-12-07 20:44:00 +01:00
|
|
|
JFileChooser chooser = new JFileChooser(){
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Override
|
|
|
|
protected JDialog createDialog( Component parent ) throws HeadlessException {
|
|
|
|
JDialog dialog = super.createDialog( parent );
|
|
|
|
Image img = new ImageIcon(getClass().getResource("/evalwriter.png") ).getImage();
|
|
|
|
dialog.setIconImage(img);
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-06-19 21:01:30 +02:00
|
|
|
chooser.setDialogTitle("Choisir un fichier ODF");
|
|
|
|
|
|
|
|
chooser.setCurrentDirectory(new java.io.File(commandes.path));
|
|
|
|
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
|
|
|
FileNameExtensionFilter filter = new FileNameExtensionFilter("Format ODF", "odt");
|
|
|
|
chooser.setFileFilter(filter);
|
|
|
|
chooser.setAcceptAllFileFilterUsed(true);
|
|
|
|
|
|
|
|
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
|
|
|
System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
|
|
|
|
System.out.println("getSelectedFile() : " + chooser.getSelectedFile().getAbsolutePath());
|
2022-07-08 11:13:46 +02:00
|
|
|
commandes.initialiseParametresSettingProprietes();;
|
2022-07-10 11:42:47 +02:00
|
|
|
commandes.fichierAnalyseValide=true;
|
2022-06-19 21:01:30 +02:00
|
|
|
commandes.path = chooser.getCurrentDirectory().getAbsolutePath();
|
|
|
|
commandes.PathFilenameAnalysis = chooser.getCurrentDirectory().getAbsolutePath();
|
|
|
|
String cheminVersFichier = chooser.getSelectedFile().getAbsolutePath();
|
|
|
|
commandes.nameSujet = chooser.getSelectedFile().getName();
|
|
|
|
|
|
|
|
Run b = null;
|
|
|
|
try {
|
|
|
|
b = new Run(cheminVersFichier);
|
|
|
|
commandes.sujet = Run.XMLContent(b.getLectDossiers().getEC().getListeContentWriter().get(0));
|
|
|
|
|
2022-12-07 08:43:07 +01:00
|
|
|
//Supprime l'historique des modifications
|
|
|
|
commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:tracked-changes");
|
2022-12-15 08:52:32 +01:00
|
|
|
commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:deletion");
|
|
|
|
commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:change-start");
|
|
|
|
commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:change-end");
|
|
|
|
commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:tracked-changes");
|
|
|
|
commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:change");
|
2022-12-07 08:43:07 +01:00
|
|
|
|
|
|
|
|
2022-06-19 21:01:30 +02:00
|
|
|
commandes.sujet = meptl.LectureFichierEtudiantSousFormeDeNode(commandes.sujet,b,0);
|
|
|
|
commandes.sujet.getAttributs().put("analysis_filename","sujet.xml");
|
|
|
|
|
|
|
|
commandes.sujet = ecritureSujet.nodePourEcritureSujet(commandes.sujet,b,0);
|
2022-12-07 08:43:07 +01:00
|
|
|
|
2022-06-19 21:01:30 +02:00
|
|
|
|
2022-11-15 09:00:37 +01:00
|
|
|
// try {
|
|
|
|
// Run.ecritureNodeEnXML(commandes.sujet , commandes.nameSujet+".xml",commandes.path,"Sujet");
|
|
|
|
// } catch (IOException e1) {
|
|
|
|
// // TODO Auto-generated catch block
|
|
|
|
// e1.printStackTrace();
|
|
|
|
// }
|
|
|
|
|
2022-12-07 08:43:07 +01:00
|
|
|
|
2022-06-19 21:01:30 +02:00
|
|
|
|
|
|
|
new verificationFichierAnalyse();
|
|
|
|
|
|
|
|
|
|
|
|
if(commandes.fichierAnalyseValide) {
|
2022-07-10 11:42:47 +02:00
|
|
|
commandes.sujetSauvegarde = commandes.sujet.clone();
|
2022-12-13 08:27:40 +01:00
|
|
|
fenetres.create.getTree().setVisible(true);
|
2022-06-19 21:01:30 +02:00
|
|
|
fenetres.create.constructionTree();
|
|
|
|
fenetres.create.getTextNodeSelect().afficheChargementFichierAnalyse();
|
|
|
|
}else {
|
2022-11-13 08:58:51 +01:00
|
|
|
fenetres.create.getTextNodeSelect().setText("<h1>Le fichier n'est pas valide</h1>");
|
2022-06-19 21:01:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} catch (ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1) {
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fenetres.create.getTextNodeSelect().refreshAffichage(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
commandes.ecritCode = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|