89 lines
2.8 KiB
Java
89 lines
2.8 KiB
Java
package action;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
import java.io.BufferedReader;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.InputStreamReader;
|
|
|
|
import javax.swing.AbstractAction;
|
|
import javax.swing.Action;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.filechooser.FileSystemView;
|
|
|
|
import MEPTL.commandes;
|
|
import cXML.node;
|
|
import fenetres.SimpleTableDemo;
|
|
import fenetres.chargeEvaluations;
|
|
import fenetres.create;
|
|
|
|
public class actOpenHistoriqueEvaluation extends AbstractAction{
|
|
{
|
|
putValue( Action.NAME, "Charger une évaluation" );
|
|
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/chargehistoriqueevaluationmini.png")) );
|
|
putValue( Action.SHORT_DESCRIPTION, "Charger une évaluation" );
|
|
}
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
nodeEvaluations();
|
|
if(commandes.evaluationsBase!=null) {
|
|
// chargeEvaluations.getInstance();
|
|
new SimpleTableDemo();
|
|
}else {
|
|
commandes.evaluationsBase = new node();
|
|
commandes.evaluationsBase.setNomElt("evaluations");
|
|
chargeEvaluations.getInstance();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Récupération du node base_evaluations_analyseWriter.xml.</br>
|
|
*/
|
|
private void nodeEvaluations() {
|
|
|
|
File directory = new File(FileSystemView.getFileSystemView().getDefaultDirectory().getPath());
|
|
if (directory.exists()){
|
|
File file = null;
|
|
if(commandes.os.contains("Win")) {
|
|
file = new File(directory.getAbsolutePath() + "\\" + "base_evaluations_analyseWriter.xml");
|
|
}else {
|
|
file = new File(directory.getAbsolutePath() + "/" + "base_evaluations_analyseWriter.xml");
|
|
}
|
|
|
|
if(file!=null) {
|
|
BufferedReader br;
|
|
try {
|
|
br = new BufferedReader(
|
|
new InputStreamReader(
|
|
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
|
String line;
|
|
StringBuilder targetString = new StringBuilder();
|
|
while ((line = br.readLine()) != null) {
|
|
targetString.append(line);
|
|
}
|
|
node evaluations = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
|
if(evaluations!=null) {
|
|
if(evaluations.getNodes().size()>0) {
|
|
if(evaluations.getNomElt().equals("evaluations")) {
|
|
commandes.evaluationsBase = evaluations;
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception e) {
|
|
JFrame frame = new JFrame();
|
|
JLabel texte = new JLabel("<html><p>Il y a une erreur avec le fichier <b>base_evaluations_analyseWriter.xml</b></p>"
|
|
+ "<p>Probablement, il a été renommé ou supprimé.</p>"
|
|
+ "Ou bien encore, il ne contient aucune évaluation.</html>");
|
|
JOptionPane.showMessageDialog(frame, texte);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|