MAJ V4.4.3
Base de données des évaluations. Possibilité de changer le chemin vers la base de données; Par défaut la base de données se trouve dans le répertoire de l'application.
This commit is contained in:
parent
7522ddb274
commit
9747d57bf4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
package MEPTL;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.JTree;
|
||||
@ -127,7 +128,12 @@ public class commandes {
|
||||
public static int analyse_Nbre_Fichier_Student = 0;
|
||||
public static int analyse_index_Fichier_Student = 0;
|
||||
public static StringBuilder message = new StringBuilder();
|
||||
|
||||
|
||||
//** base de données des évaluations
|
||||
public static String PathBaseEvaluations = Paths.get("").toAbsolutePath().toString(); //Chemin vers la base de données
|
||||
public static boolean PathBaseEvalationDefaut = true; //Flag si ce n'est pas le chemin par défaut vers la base de données
|
||||
public static String NameBaseEvaluations="base_evaluations_analyseWriter.xml"; //Nom par défaut de la base de données
|
||||
|
||||
public static void initialiseParametresSettingProprietes() {
|
||||
//** setting valeur par défaut
|
||||
culture = "FR";
|
||||
|
@ -5,6 +5,8 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
@ -12,12 +14,10 @@ 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.baseDonneesEvaluations;
|
||||
import fenetres.create;
|
||||
|
||||
public class actOpenHistoriqueEvaluation extends AbstractAction{
|
||||
@ -30,59 +30,78 @@ public class actOpenHistoriqueEvaluation extends AbstractAction{
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
nodeEvaluations();
|
||||
recupeNodeBaseEvaluations();
|
||||
if(commandes.evaluationsBase!=null) {
|
||||
// chargeEvaluations.getInstance();
|
||||
new SimpleTableDemo();
|
||||
baseDonneesEvaluations.getInstance();
|
||||
}else {
|
||||
commandes.evaluationsBase = new node();
|
||||
commandes.evaluationsBase.setNomElt("evaluations");
|
||||
chargeEvaluations.getInstance();
|
||||
creationNewNodeBaseEvaluation();
|
||||
baseDonneesEvaluations.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupération du node base_evaluations_analyseWriter.xml.</br>
|
||||
*/
|
||||
private void nodeEvaluations() {
|
||||
private void recupeNodeBaseEvaluations() {
|
||||
|
||||
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;
|
||||
}
|
||||
// File directory = new File(FileSystemView.getFileSystemView().getDefaultDirectory().getPath());
|
||||
|
||||
String directoryName = "";
|
||||
File file = null;
|
||||
if(commandes.PathBaseEvalationDefaut) {
|
||||
directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
}else {
|
||||
directoryName = commandes.PathBaseEvaluations;
|
||||
}
|
||||
|
||||
if(commandes.os.contains("Win")) {
|
||||
file = new File(directoryName + "\\" + commandes.NameBaseEvaluations);
|
||||
}else {
|
||||
file = new File(directoryName + "/" + commandes.NameBaseEvaluations);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}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><br>"
|
||||
+ "<p>Une nouvelle base sera créé.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Création du node evaluationBase.<br>
|
||||
*/
|
||||
private void creationNewNodeBaseEvaluation() {
|
||||
commandes.evaluationsBase = new node();
|
||||
commandes.evaluationsBase.setNomElt("evaluations");
|
||||
try {
|
||||
commandes.evaluationsBase.getAttributs().put("date", calcul.formatDateWriter.dateTodayLibreOffice());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
26
src/action/actPathBaseEvaluations.java
Normal file
26
src/action/actPathBaseEvaluations.java
Normal file
@ -0,0 +1,26 @@
|
||||
package action;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import fenetres.ChargePathBaseEvaluation;
|
||||
import fenetres.create;
|
||||
|
||||
public class actPathBaseEvaluations extends AbstractAction{
|
||||
{
|
||||
putValue( Action.NAME, "Indiquer le chemin vers la base des évaluations" );
|
||||
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/sauvegardehistoriqueevaluationmini.png")) );
|
||||
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_O );
|
||||
putValue( Action.SHORT_DESCRIPTION, "Indiquer le chemin vers la base des évaluation" );
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new ChargePathBaseEvaluation();
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
package action;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import MEPTL.commandes;
|
||||
import cXML.Run;
|
||||
import cXML.node;
|
||||
import fenetres.create;
|
||||
|
||||
public class actSaveHistoriqueEvaluation extends AbstractAction{
|
||||
{
|
||||
putValue( Action.NAME, "Sauvegarder l'évaluation" );
|
||||
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/sauvegardehistoriqueevaluationmini.png")) );
|
||||
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_O );
|
||||
putValue( Action.SHORT_DESCRIPTION, "Sauvegarder l'évaluation" );
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(commandes.fichierAnalyseValide) {
|
||||
|
||||
|
||||
String name = JOptionPane.showInputDialog(null,"Donner un nom à cette évaluation ?","Nom de l'évaluation");
|
||||
|
||||
if(!name.isBlank()) {
|
||||
node evaluations = nodeEvaluations();
|
||||
if(!isEvaluationExist(evaluations, name)) {
|
||||
evaluations.getNodes().add(0, creationNodeEvaluation(new node(), name));
|
||||
// evaluations.getNodes().add(creationNodeEvaluation(new node(), name));
|
||||
}else {
|
||||
evaluations.getNodes().add(creationNodeEvaluation(evaluations.retourneFirstNodeByNameAndAttributValueExactStrict("evaluation", "name", name), name));
|
||||
}
|
||||
|
||||
//Mise à jour de la base de données
|
||||
Date aujourdhui = new Date();
|
||||
evaluations.getAttributs().put("version", commandes.version);
|
||||
try {
|
||||
evaluations.getAttributs().put("date", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
|
||||
ecritureBaseEvaluation(evaluations);
|
||||
} catch (ParseException | IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEvaluationExist(node evaluations, String nameEvaluation) {
|
||||
if(evaluations!=null) {
|
||||
if(evaluations.retourneFirstNodeByNameAndAttributValueExactStrict("evaluation", "name", nameEvaluation)!=null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private node nodeEvaluations() {
|
||||
node evaluations = new node();
|
||||
evaluations.setNomElt("evaluations");
|
||||
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);
|
||||
}
|
||||
evaluations = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
||||
}catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return evaluations;
|
||||
}
|
||||
|
||||
private node creationNodeEvaluation(node evaluation, String name) {
|
||||
evaluation.setNomElt("evaluation");
|
||||
Date aujourdhui = new Date();
|
||||
evaluation.getAttributs().put("version", commandes.version);
|
||||
evaluation.getAttributs().put("name", name);
|
||||
evaluation.getAttributs().put("PathFilenameAnalysis", commandes.PathFilenameAnalysis);
|
||||
evaluation.getAttributs().put("path", commandes.path);
|
||||
evaluation.getAttributs().put("fichierStudentMoodle", String.valueOf(commandes.fichierStudentMoodle));
|
||||
evaluation.getAttributs().put("sansFeeback", String.valueOf(commandes.sansFeeback) );
|
||||
evaluation.getAttributs().put("noDetail", String.valueOf(commandes.noDetail) );
|
||||
evaluation.getAttributs().put("noNote", String.valueOf(commandes.noNote) );
|
||||
evaluation.getAttributs().put("zipfeedback", String.valueOf(commandes.zipfeedback) );
|
||||
evaluation.getAttributs().put("verifHisto2", String.valueOf(commandes.verifHisto2) );
|
||||
evaluation.getAttributs().put("ecritNoteCSV", String.valueOf(commandes.ecritNoteCSV) );
|
||||
evaluation.getAttributs().put("newLogo", String.valueOf(commandes.newLogo) );
|
||||
evaluation.getAttributs().put("noLogo", String.valueOf(commandes.noLogo) );
|
||||
|
||||
evaluation.getNodes().add(commandes.sujet);
|
||||
if(commandes.sujet.getAttributs().get("analysis_filename").contains(".xml")) {
|
||||
evaluation.getAttributs().put("analysis_filename",commandes.sujet.getAttributs().get("analysis_filename"));
|
||||
}else {
|
||||
evaluation.getAttributs().put("analysis_filename",commandes.nameSujet);
|
||||
}
|
||||
|
||||
|
||||
evaluation.getAttributs().put("fourniCSV", String.valueOf(commandes.fourniCSV) );
|
||||
if(commandes.nameCSV!=null) {
|
||||
evaluation.getAttributs().put("nameCSV", commandes.nameCSV );
|
||||
}else {
|
||||
evaluation.getAttributs().put("nameCSV", "");
|
||||
}
|
||||
|
||||
evaluation.getAttributs().put("fourniCSV", String.valueOf(commandes.fourniCSV) );
|
||||
if(commandes.nameSVG!=null) {
|
||||
evaluation.getAttributs().put("nameSVG", commandes.nameSVG );
|
||||
}else {
|
||||
evaluation.getAttributs().put("nameSVG", "" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
evaluation.getNodes().add(commandes.nodeCSV);
|
||||
|
||||
try {
|
||||
evaluation.getAttributs().put("date", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(commandes.nameSVG!=null) {
|
||||
if(!commandes.nameSVG.isBlank() && !commandes.contenuFichierSVG.isBlank()) {
|
||||
node SVG = new node();
|
||||
SVG.setNomElt("nodSVG");
|
||||
SVG.setContenu(commandes.contenuFichierSVG);
|
||||
evaluation.getNodes().add(SVG);
|
||||
}
|
||||
}
|
||||
|
||||
return evaluation;
|
||||
|
||||
}
|
||||
|
||||
private void ecritureBaseEvaluation(node evaluations) throws IOException {
|
||||
File directory = new File(FileSystemView.getFileSystemView().getDefaultDirectory().getPath());
|
||||
Run.ecritureNodeEnXML(evaluations, "base_evaluations_analyseWriter.xml", directory.getAbsolutePath(), Run.TypeFile.Evaluation);
|
||||
}
|
||||
}
|
@ -76,7 +76,15 @@ public class formatDateWriter {
|
||||
return d1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne sous la forme d'un string au format LibreOffice la date d'aujourd'hui.<br>
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static String dateTodayLibreOffice() throws ParseException {
|
||||
Date aujourdhui = new Date();
|
||||
return DateLibreOffice(aujourdhui);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
117
src/fenetres/ChargePathBaseEvaluation.java
Normal file
117
src/fenetres/ChargePathBaseEvaluation.java
Normal file
@ -0,0 +1,117 @@
|
||||
package fenetres;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Image;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
import MEPTL.commandes;
|
||||
import cXML.node;
|
||||
|
||||
public class ChargePathBaseEvaluation extends JFileChooser {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public ChargePathBaseEvaluation() {
|
||||
|
||||
setDialogTitle("Sélectionner la base de données des évaluations.");
|
||||
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Base de données des évaluations", "xml");
|
||||
setFileFilter(filter);
|
||||
setPreferredSize(new Dimension(550, 420));
|
||||
|
||||
int response = showOpenDialog(null);
|
||||
if(response == JFileChooser.APPROVE_OPTION) {
|
||||
|
||||
|
||||
File file = new File(getSelectedFile().getAbsolutePath());
|
||||
String ext = file.getName().substring(file.getName().lastIndexOf("."));
|
||||
|
||||
if(ext.equals(".xml")){
|
||||
openFileXML(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
private void openFileXML(File file) {
|
||||
|
||||
|
||||
if(commandes.os.contains("Win")) {
|
||||
commandes.path = file.getPath().substring(0,file.getPath().lastIndexOf("\\")); // Sur Windows
|
||||
}else {
|
||||
commandes.path = file.getPath().substring(0,file.getPath().lastIndexOf("/")); // Sur mac & Linux
|
||||
}
|
||||
|
||||
String PathFilenameAnalysis = getCurrentDirectory().getPath();
|
||||
String nameSujet = file.getName().toString();
|
||||
|
||||
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 nodeEvaluation = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
||||
|
||||
if(nodeEvaluation.getNomElt().equals("evaluations")) {
|
||||
commandes.NameBaseEvaluations=nameSujet;
|
||||
commandes.PathBaseEvaluations=PathFilenameAnalysis;
|
||||
commandes.PathBaseEvalationDefaut=false;
|
||||
if(!create.isDispose) create.getTextNodeSelect().afficheChargementCheminVersLaBase();
|
||||
if(!evaluate.isDispose) evaluate.getTxtpnmessages().afficheChargementCheminVersLaBase();
|
||||
}else {
|
||||
commandes.PathBaseEvalationDefaut=false;
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><p>Ce n'est pas une base de données des évaluations.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
}
|
||||
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -475,12 +475,28 @@ public class afficheText extends JEditorPane {
|
||||
text.append("<br><hr><br>");
|
||||
text.append("<p><b><u>Fichier d'analyse</u></b> :</p>");
|
||||
text.append("<p class=\"city\"><b>"+commandes.analysis_filename+"</b></p>");
|
||||
|
||||
text.append("<br><hr><br>");
|
||||
text.append("<p><b><u>La base de données des évaluations</u></b> :</p>");
|
||||
text.append("<p>La base de données des évaluations se trouve : <b>" + commandes.PathBaseEvaluations +"</b></p>"
|
||||
+ "<p>La base de données se nomme : <b>" + commandes.NameBaseEvaluations +"</b></p>");
|
||||
|
||||
|
||||
setContentType("text/html");
|
||||
setText(text.toString());
|
||||
}
|
||||
|
||||
|
||||
public void afficheChargementCheminVersLaBase() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append(baliseStyle.balise());
|
||||
text.append("<hr><h1><u>INFORMATIONS</u></h1><br>"
|
||||
+ "<p>La base de données des évaluations se trouve : " + commandes.PathBaseEvaluations +" </p>"
|
||||
+ "<p>La base de données se nomme : " + commandes.NameBaseEvaluations +"</p>");
|
||||
setContentType("text/html");
|
||||
setText(text.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param TextErreur
|
||||
|
@ -15,6 +15,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
@ -30,7 +31,6 @@ import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import MEPTL.commandes;
|
||||
import MEPTL.meptl;
|
||||
@ -38,11 +38,11 @@ import MEPTL.verificationFichierAnalyse;
|
||||
import cXML.Run;
|
||||
import cXML.node;
|
||||
|
||||
public class SimpleTableDemo extends JFrame { /**
|
||||
public class baseDonneesEvaluations extends JFrame { /**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static SimpleTableDemo instance;
|
||||
private static baseDonneesEvaluations instance;
|
||||
JTable table = new JTable();
|
||||
private JPanel panelHaut = new JPanel();
|
||||
private JPanel panelBas = new JPanel();
|
||||
@ -57,7 +57,7 @@ public class SimpleTableDemo extends JFrame { /**
|
||||
String[] columnNames = {"Nom de l'évaluation","Date d'enregistrement","Titre de l'exercice","Propriété personnalisé Sujet","Nom du fichier d'analyse"};
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
|
||||
public SimpleTableDemo() {
|
||||
public baseDonneesEvaluations() {
|
||||
|
||||
|
||||
super();
|
||||
@ -126,7 +126,7 @@ public SimpleTableDemo() {
|
||||
|
||||
//*Le haut
|
||||
String nombreEvluation = String.valueOf(commandes.evaluationsBase.getNodes().size());
|
||||
lblInformationBaseEvluation.setText("<html>Date dernière modification : " +calcul.formatDateWriter.DateEnClairFR( calcul.formatDateWriter.DateLibreOffice(commandes.evaluationsBase.getAttributs().get("date"))) + " -- Nombre d'évaluation : " + nombreEvluation);
|
||||
lblInformationBaseEvluation.setText("<html>Date dernière modification : " + calcul.formatDateWriter.DateEnClairFR( calcul.formatDateWriter.DateLibreOffice(commandes.evaluationsBase.getAttributs().get("date"))) + " -- Nombre d'évaluation : " + nombreEvluation);
|
||||
add(panelHaut, BorderLayout.NORTH);
|
||||
lblInformationBaseEvluation.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelHaut.add(lblInformationBaseEvluation);
|
||||
@ -159,10 +159,9 @@ public SimpleTableDemo() {
|
||||
}
|
||||
|
||||
|
||||
public static SimpleTableDemo getInstance() {
|
||||
if(chargeEvaluations.isDispose) instance = null;
|
||||
if (instance == null) {
|
||||
instance = new SimpleTableDemo();
|
||||
public static baseDonneesEvaluations getInstance() {
|
||||
if (isDispose) {
|
||||
instance = new baseDonneesEvaluations();
|
||||
}
|
||||
instance.setVisible(true);
|
||||
isDispose=false;
|
||||
@ -393,8 +392,17 @@ private void chargeLeNodeSujet(File file) {
|
||||
|
||||
|
||||
private void ecritureBaseEvaluation(node evaluations) throws IOException {
|
||||
File directory = new File(FileSystemView.getFileSystemView().getDefaultDirectory().getPath());
|
||||
Run.ecritureNodeEnXML(evaluations, "base_evaluations_analyseWriter.xml", directory.getAbsolutePath(), Run.TypeFile.Evaluation);
|
||||
// File directory = new File(FileSystemView.getFileSystemView().getDefaultDirectory().getPath());
|
||||
// Run.ecritureNodeEnXML(evaluations, "base_evaluations_analyseWriter.xml", directory.getAbsolutePath(), Run.TypeFile.Evaluation);
|
||||
|
||||
String directoryName = "";
|
||||
if(commandes.PathBaseEvalationDefaut) {
|
||||
directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
}else {
|
||||
directoryName = commandes.PathBaseEvaluations;
|
||||
}
|
||||
Run.ecritureNodeEnXML(evaluations, commandes.NameBaseEvaluations, directoryName, Run.TypeFile.Evaluation);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,638 +0,0 @@
|
||||
package fenetres;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.FocusManager;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import MEPTL.commandes;
|
||||
import MEPTL.meptl;
|
||||
import MEPTL.verificationFichierAnalyse;
|
||||
import action.actSaveHistoriqueEvaluation;
|
||||
import cXML.Run;
|
||||
import cXML.node;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
public class chargeEvaluations extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static chargeEvaluations instance;
|
||||
private JPanel contentPane = new JPanel();
|
||||
JPanel panelCentre = new JPanel();
|
||||
ArrayList<JLabel> LeslabelsTitre = new ArrayList<JLabel>();
|
||||
ArrayList<JLabel> LeslabelsMeta = new ArrayList<JLabel>();
|
||||
ArrayList<JLabel> LeslabelsDate = new ArrayList<JLabel>();
|
||||
ArrayList<JLabel> LeslabelsFileNameAnalysis = new ArrayList<JLabel>();
|
||||
ArrayList<JRadioButton> LesRadioButtons = new ArrayList<JRadioButton>();
|
||||
JLabel lblInformationBaseEvluation = new JLabel("");
|
||||
public static boolean isDispose = true;
|
||||
int indexSelect=0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public static chargeEvaluations getInstance() {
|
||||
if(chargeEvaluations.isDispose) instance = null;
|
||||
if (instance == null) {
|
||||
instance = new chargeEvaluations();
|
||||
}
|
||||
instance.setVisible(true);
|
||||
isDispose=false;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
public chargeEvaluations() {
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
setBounds(100, 100, 1300, 600);
|
||||
int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth();
|
||||
int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight();
|
||||
setLocation(( (screenWidth) - getWidth()) / 2, (screenHeight - getHeight()) / 2);
|
||||
|
||||
ImageIcon img = new ImageIcon(getClass().getResource("/evalwriter.png") );
|
||||
setIconImage(img.getImage());
|
||||
setTitle(commandes.Titre + " - La base de données des évaluations");
|
||||
|
||||
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(new BorderLayout(2, 2));
|
||||
|
||||
JPanel panelGauche = new JPanel();
|
||||
contentPane.add(panelGauche, BorderLayout.WEST);
|
||||
panelGauche.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2));
|
||||
|
||||
JPanel panelHaut = new JPanel();
|
||||
contentPane.add(panelHaut, BorderLayout.NORTH);
|
||||
|
||||
|
||||
lblInformationBaseEvluation.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelHaut.add(lblInformationBaseEvluation);
|
||||
|
||||
JPanel panelBas = new JPanel();
|
||||
contentPane.add(panelBas, BorderLayout.SOUTH);
|
||||
panelBas.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 10));
|
||||
|
||||
JButton btnSupprimeEvaluation = new JButton("Supprimer une évaluation");
|
||||
btnSupprimeEvaluation.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnSupprimeEvaluation.setForeground(new Color(255, 0, 0));
|
||||
btnSupprimeEvaluation.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||
panelBas.add(btnSupprimeEvaluation);
|
||||
|
||||
Component horizontalGlue = Box.createHorizontalGlue();
|
||||
panelBas.add(horizontalGlue);
|
||||
|
||||
Component horizontalGlue_1 = Box.createHorizontalGlue();
|
||||
panelBas.add(horizontalGlue_1);
|
||||
|
||||
JButton btnSaveEvaluation = new JButton("Enregistre l'évaluation actuelle");
|
||||
btnSaveEvaluation.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new actSaveHistoriqueEvaluation();
|
||||
}
|
||||
});
|
||||
btnSaveEvaluation.setForeground(new Color(0, 64, 128));
|
||||
btnSaveEvaluation.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||
panelBas.add(btnSaveEvaluation);
|
||||
|
||||
JButton btnValide = new JButton("Charger l'évaluation");
|
||||
btnValide.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||
btnValide.setForeground(new Color(0, 128, 0));
|
||||
panelBas.add(btnValide);
|
||||
|
||||
JScrollPane scrollPaneCentre = new JScrollPane();
|
||||
contentPane.add(scrollPaneCentre, BorderLayout.CENTER);
|
||||
|
||||
|
||||
scrollPaneCentre.setViewportView(panelCentre);
|
||||
panelCentre.setLayout(new MigLayout("gap rel 4", "[100px:n,grow][50px:n,grow][150px:n,grow 150][150px:n,grow 150][150px:n,grow 150]", "[20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0]"));
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Nom de l'évaluation");
|
||||
lblNewLabel.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel, "cell 0 0");
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Date d'enregistrement");
|
||||
lblNewLabel_1.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_1, "cell 1 0");
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("Nom du fichier d'analyse");
|
||||
lblNewLabel_2.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_2, "cell 2 0");
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("Titre de l'exercice");
|
||||
lblNewLabel_3.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_3, "cell 3 0");
|
||||
|
||||
JLabel lblNewLabel_4 = new JLabel("Propriété personnalisé Sujet");
|
||||
lblNewLabel_4.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_4.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_4, "cell 4 0");
|
||||
|
||||
|
||||
// String dateDernierEnregistrement = commandes.evaluationsBase.getAttributs().get("date");
|
||||
|
||||
String nombreEvluation = String.valueOf(commandes.evaluationsBase.getNodes().size());
|
||||
|
||||
lblInformationBaseEvluation.setText("<html>Date dernière modification : " +calcul.formatDateWriter.DateEnClairFR( calcul.formatDateWriter.DateLibreOffice(commandes.evaluationsBase.getAttributs().get("date"))) + " -- Nombre d'évaluation : " + nombreEvluation);
|
||||
|
||||
for(int i = 0 ; i<commandes.evaluationsBase.getNodes().size(); i++ ) {
|
||||
LesRadioButtons.add(new JRadioButton(commandes.evaluationsBase.getNodes().get(i).getAttributs().get("name")));
|
||||
LeslabelsDate.add(new JLabel( calcul.formatDateWriter.DateEnClairFR( calcul.formatDateWriter.DateLibreOffice(commandes.evaluationsBase.getNodes().get(i).getAttributs().get("date") ) )));
|
||||
|
||||
node fichier = commandes.evaluationsBase.getNodes().get(i).retourneFirstEnfantsByName("fichier");
|
||||
|
||||
String Titre = fichier.getAttributs().get("titre");
|
||||
String MetatSujet = fichier.getAttributs().get("metaSujet");
|
||||
String nameFileAnalysis = fichier.getAttributs().get("filenameAnalyse");
|
||||
|
||||
|
||||
LeslabelsTitre.add(new JLabel(Titre));
|
||||
LeslabelsMeta.add(new JLabel(MetatSujet));
|
||||
LeslabelsFileNameAnalysis.add(new JLabel(nameFileAnalysis));
|
||||
}
|
||||
|
||||
|
||||
int j = 0;
|
||||
for(int i = 0 ; i<LesRadioButtons.size(); i++ ) {
|
||||
j=i+1;
|
||||
panelCentre.add(LesRadioButtons.get(i), "cell 0 "+j);
|
||||
panelCentre.add(LeslabelsDate.get(i), "cell 1 "+j);
|
||||
panelCentre.add(LeslabelsFileNameAnalysis.get(i), "cell 2 "+j);
|
||||
panelCentre.add(LeslabelsTitre.get(i), "cell 3 "+j);
|
||||
panelCentre.add(LeslabelsMeta.get(i), "cell 4 "+j);
|
||||
|
||||
LesRadioButtons.get(i).addMouseListener(new MyMouseListener());
|
||||
|
||||
}
|
||||
|
||||
|
||||
btnValide.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int compteur = 0;
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
if(LesRadioButtons.get(i).isSelected()) compteur++;
|
||||
}
|
||||
if(compteur>1) {
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
LesRadioButtons.get(i).setSelected(false);
|
||||
}
|
||||
}else {
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
if(LesRadioButtons.get(i).isSelected()) {
|
||||
chargeEvaluationSelected(commandes.evaluationsBase.getNodes().get(i));
|
||||
isDispose=true;
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
btnSupprimeEvaluation.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int compteur = 0;
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
if(LesRadioButtons.get(i).isSelected()) compteur++;
|
||||
}
|
||||
if(compteur>1) {
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
LesRadioButtons.get(i).setSelected(false);
|
||||
}
|
||||
}else {
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
if(LesRadioButtons.get(i).isSelected()) {
|
||||
commandes.evaluationsBase.getNodes().remove(i);
|
||||
try {
|
||||
ecritureBaseEvaluation(commandes.evaluationsBase);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
actualise();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Bouton Sauvegarde de l'évaluation.</br>
|
||||
*/
|
||||
btnSaveEvaluation.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(commandes.fichierAnalyseValide) {
|
||||
|
||||
int compteur = 0;
|
||||
String name ="Nom de l'évaluation";
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
if(LesRadioButtons.get(i).isSelected()) compteur++;
|
||||
}
|
||||
if(compteur>1) {
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
LesRadioButtons.get(i).setSelected(false);
|
||||
}
|
||||
}else {
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
if(LesRadioButtons.get(i).isSelected()) {
|
||||
name = LesRadioButtons.get(i).getText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
name = JOptionPane.showInputDialog(null,"Donner un nom à cette évaluation ?",name);
|
||||
|
||||
if(!name.isBlank()) {
|
||||
if(!isEvaluationExist(name)) {
|
||||
commandes.evaluationsBase.getNodes().add(0, creationNodeEvaluation(new node(), name));;
|
||||
}else {
|
||||
creationNodeEvaluation(commandes.evaluationsBase.retourneFirstNodeByNameAndAttributValueExactStrict("evaluation", "name", name), name);
|
||||
}
|
||||
|
||||
//Mise à jour de la base de données
|
||||
Date aujourdhui = new Date();
|
||||
commandes.evaluationsBase.getAttributs().put("version", commandes.version);
|
||||
try {
|
||||
commandes.evaluationsBase.getAttributs().put("date", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
|
||||
ecritureBaseEvaluation(commandes.evaluationsBase);
|
||||
actualise();
|
||||
} catch (ParseException | IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ListenerAction();
|
||||
}
|
||||
|
||||
//Quitte la fenêtre.</br>
|
||||
private void ListenerAction() {
|
||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
|
||||
isDispose=true;
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class MyMouseListener extends MouseAdapter {
|
||||
public void mouseClicked(MouseEvent evt) {
|
||||
|
||||
Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
|
||||
indexSelect = LesRadioButtons.indexOf(focusOwner);
|
||||
|
||||
if (evt.getClickCount() == 3) {
|
||||
System.out.println("triple-click");
|
||||
LesRadioButtons.get(indexSelect).setSelected(true);
|
||||
} else if (evt.getClickCount() == 2) {
|
||||
System.out.println("double-click");
|
||||
LesRadioButtons.get(indexSelect).setSelected(true);
|
||||
}
|
||||
else if (evt.getClickCount() == 1) {
|
||||
System.out.println("click");
|
||||
LesRadioButtons.get(indexSelect).setSelected(true);
|
||||
}
|
||||
|
||||
|
||||
System.out.println("indexSelect = " + indexSelect);
|
||||
|
||||
for(int i = 0; i < LesRadioButtons.size();i++) {
|
||||
if(i!=indexSelect) LesRadioButtons.get(i).setSelected(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* charge en mémoire l'évaluation sélectionnée.<br>
|
||||
* @param evaluation
|
||||
*/
|
||||
private void chargeEvaluationSelected(node evaluation) {
|
||||
|
||||
//* Charge le node sujet provisoirement
|
||||
commandes.path = evaluation.getAttributs().get("path"); //Dossier des fichiers des étudiants
|
||||
commandes.sujet = evaluation.retourneFirstEnfantsByName("fichier"); // Chargement provisoire du node sujet depuis la base
|
||||
commandes.nameSujet = evaluation.getAttributs().get("analysis_filename");
|
||||
commandes.PathFilenameAnalysis = evaluation.getAttributs().get("PathFilenameAnalysis");
|
||||
|
||||
//** Les paramètres
|
||||
commandes.version = evaluation.getAttributs().get("version");
|
||||
commandes.fichierStudentMoodle = Boolean.valueOf(evaluation.getAttributs().get("fichierStudentMoodle"));
|
||||
commandes.sansFeeback = Boolean.valueOf(evaluation.getAttributs().get("sansFeeback"));
|
||||
commandes.noDetail = Boolean.valueOf(evaluation.getAttributs().get("noDetail"));
|
||||
commandes.noNote = Boolean.valueOf(evaluation.getAttributs().get("noNote"));
|
||||
commandes.zipfeedback = Boolean.valueOf(evaluation.getAttributs().get("zipfeedback"));
|
||||
commandes.verifHisto2 = Boolean.valueOf(evaluation.getAttributs().get("verifHisto2"));
|
||||
commandes.ecritNoteCSV = Boolean.valueOf(evaluation.getAttributs().get("ecritNoteCSV"));
|
||||
commandes.newLogo = Boolean.valueOf(evaluation.getAttributs().get("newLogo"));
|
||||
commandes.noLogo = Boolean.valueOf(evaluation.getAttributs().get("noLogo"));
|
||||
|
||||
commandes.fourniCSV = Boolean.valueOf(evaluation.getAttributs().get("fourniCSV"));
|
||||
commandes.nameCSV = evaluation.getAttributs().get("nameCSV");
|
||||
|
||||
commandes.fourniCSV = Boolean.valueOf(evaluation.getAttributs().get("fourniCSV"));
|
||||
commandes.nameSVG = evaluation.getAttributs().get("nameSVG");
|
||||
|
||||
|
||||
commandes.nodeCSV = evaluation.retourneFirstEnfantsByName("fileCSV");
|
||||
|
||||
commandes.contenuFichierSVG = evaluation.retourneFirstEnfantsByName("nodSVG").retourneLesContenusEnfants("");
|
||||
|
||||
commandes.fichierAnalyseValide = true;
|
||||
|
||||
|
||||
|
||||
//* Rechercher la source
|
||||
String CheminVersFileXML = "";
|
||||
if(commandes.os.contains("Win")) {
|
||||
commandes.PathFilenameAnalysis.replaceAll("/", "\\"); // Sur Windows
|
||||
CheminVersFileXML = commandes.PathFilenameAnalysis + "\\" + commandes.nameSujet;
|
||||
|
||||
}else {
|
||||
commandes.PathFilenameAnalysis.replaceAll("\\", "/"); // Sur Windows // Sur mac & Linux
|
||||
CheminVersFileXML = commandes.PathFilenameAnalysis + "/" + commandes.nameSujet;
|
||||
}
|
||||
|
||||
File file = new File(CheminVersFileXML);
|
||||
if(file.exists()) {
|
||||
chargeLeNodeSujet(file);
|
||||
commandes.path = evaluation.getAttributs().get("path"); //Recharge le chemin vers le dossier contenant les fichiers des étudiants
|
||||
}else {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><p>Le fichier d'analyse de l'évaluation, " + commandes.nameSujet + ", <b>a été renommé ou supprimé</b>.</p><br>"
|
||||
+ "<p>Le fichier d'analyse de l'évaluation <b><u>est récupéré</u></b> depuis la base de données des évaluations.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
}
|
||||
|
||||
|
||||
//** Remise à zéro de la base dans la mémoire de l'application
|
||||
commandes.evaluationsBase = null;
|
||||
|
||||
//** Affichage de la fenêtre
|
||||
if(!evaluate.isDispose) {
|
||||
evaluate.getInstance();
|
||||
};
|
||||
if(!create.isDispose) {
|
||||
create.getInstance();
|
||||
};
|
||||
|
||||
isDispose=true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Charge le fichier d'analyse de l'évaluation.<br>
|
||||
* @param file
|
||||
*/
|
||||
private void chargeLeNodeSujet(File file) {
|
||||
|
||||
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.node2(targetString);
|
||||
node sujetLoad = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
||||
|
||||
// Vérification de la conformité du fichier d'analyse
|
||||
if(!ChargeFichierXML.fichierSujetValide(sujetLoad)) {
|
||||
JOptionPane.showMessageDialog(null, "Le fichier d'analyse n'est pas valide.");
|
||||
}else {
|
||||
commandes.initialiseParametresSettingProprietes();
|
||||
commandes.sujet = sujetLoad;
|
||||
commandes.sujetSauvegarde = commandes.sujet.clone();
|
||||
//Chargement des paramètres du fichier d'analyse
|
||||
System.out.println( "Chargement des paramètres du fichier d'analyse");
|
||||
meptl.chargementParametresFichierAnalyse();
|
||||
|
||||
// Rechercher des erreurs dans le fichier d'analyse
|
||||
System.out.println( "Vérification du fichier d'analyse" );
|
||||
new verificationFichierAnalyse();
|
||||
}
|
||||
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void ecritureBaseEvaluation(node evaluations) throws IOException {
|
||||
File directory = new File(FileSystemView.getFileSystemView().getDefaultDirectory().getPath());
|
||||
Run.ecritureNodeEnXML(evaluations, "base_evaluations_analyseWriter.xml", directory.getAbsolutePath(), Run.TypeFile.Evaluation);
|
||||
}
|
||||
|
||||
|
||||
private boolean isEvaluationExist(String nameEvaluation) {
|
||||
if(commandes.evaluationsBase.retourneFirstNodeByNameAndAttributValueExactStrict("evaluation", "name", nameEvaluation)!=null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private node creationNodeEvaluation(node evaluation, String name) {
|
||||
evaluation.setNomElt("evaluation");
|
||||
Date aujourdhui = new Date();
|
||||
evaluation.getAttributs().put("version", commandes.version);
|
||||
evaluation.getAttributs().put("name", name);
|
||||
evaluation.getAttributs().put("PathFilenameAnalysis", commandes.PathFilenameAnalysis);
|
||||
evaluation.getAttributs().put("path", commandes.path);
|
||||
evaluation.getAttributs().put("fichierStudentMoodle", String.valueOf(commandes.fichierStudentMoodle));
|
||||
evaluation.getAttributs().put("sansFeeback", String.valueOf(commandes.sansFeeback) );
|
||||
evaluation.getAttributs().put("noDetail", String.valueOf(commandes.noDetail) );
|
||||
evaluation.getAttributs().put("noNote", String.valueOf(commandes.noNote) );
|
||||
evaluation.getAttributs().put("zipfeedback", String.valueOf(commandes.zipfeedback) );
|
||||
evaluation.getAttributs().put("verifHisto2", String.valueOf(commandes.verifHisto2) );
|
||||
evaluation.getAttributs().put("ecritNoteCSV", String.valueOf(commandes.ecritNoteCSV) );
|
||||
evaluation.getAttributs().put("newLogo", String.valueOf(commandes.newLogo) );
|
||||
evaluation.getAttributs().put("noLogo", String.valueOf(commandes.noLogo) );
|
||||
|
||||
//Supprime le node fichier s'il existe.
|
||||
node nodremove = evaluation.retourneFirstEnfantsByName("fichier");
|
||||
if(!nodremove.isVide()) evaluation.getNodes().remove(nodremove);
|
||||
|
||||
evaluation.getNodes().add(commandes.sujet);
|
||||
|
||||
if(commandes.sujet.getAttributs().get("analysis_filename").contains(".xml")) {
|
||||
evaluation.getAttributs().put("analysis_filename",commandes.sujet.getAttributs().get("analysis_filename"));
|
||||
}else {
|
||||
evaluation.getAttributs().put("analysis_filename",commandes.nameSujet);
|
||||
}
|
||||
|
||||
|
||||
evaluation.getAttributs().put("fourniCSV", String.valueOf(commandes.fourniCSV) );
|
||||
if(commandes.nameCSV!=null) {
|
||||
evaluation.getAttributs().put("nameCSV", commandes.nameCSV );
|
||||
}else {
|
||||
evaluation.getAttributs().put("nameCSV", "");
|
||||
}
|
||||
|
||||
evaluation.getAttributs().put("fourniCSV", String.valueOf(commandes.fourniCSV) );
|
||||
if(commandes.nameSVG!=null) {
|
||||
evaluation.getAttributs().put("nameSVG", commandes.nameSVG );
|
||||
}else {
|
||||
evaluation.getAttributs().put("nameSVG", "" );
|
||||
}
|
||||
|
||||
|
||||
//Supprime le node fichier s'il existe.
|
||||
nodremove = evaluation.retourneFirstEnfantsByName("fileCSV");
|
||||
if(!nodremove.isVide()) evaluation.getNodes().remove(nodremove);
|
||||
|
||||
evaluation.getNodes().add(commandes.nodeCSV);
|
||||
|
||||
try {
|
||||
evaluation.getAttributs().put("date", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(commandes.nameSVG!=null) {
|
||||
if(!commandes.nameSVG.isBlank() && !commandes.contenuFichierSVG.isBlank()) {
|
||||
node SVG = new node();
|
||||
SVG.setNomElt("nodSVG");
|
||||
SVG.setContenu(commandes.contenuFichierSVG);
|
||||
evaluation.getNodes().add(SVG);
|
||||
}
|
||||
}
|
||||
|
||||
return evaluation;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void actualise() {
|
||||
|
||||
LesRadioButtons.clear();
|
||||
LeslabelsDate.clear();
|
||||
LeslabelsTitre.clear();
|
||||
LeslabelsFileNameAnalysis.clear();
|
||||
LeslabelsMeta.clear();
|
||||
|
||||
panelCentre.removeAll();
|
||||
panelCentre.setLayout(new MigLayout("gap rel 4", "[100px:n,grow][50px:n,grow][150px:n,grow 150][150px:n,grow 150][150px:n,grow 150]", "[20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0][20px:20px:20px,shrinkprio 0,shrink 0]"));
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Nom de l'évaluation");
|
||||
lblNewLabel.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel, "cell 0 0");
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Date d'enregistrement");
|
||||
lblNewLabel_1.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_1, "cell 1 0");
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("Nom du fichier d'analyse");
|
||||
lblNewLabel_2.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_2, "cell 2 0");
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("Titre de l'exercice");
|
||||
lblNewLabel_3.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_3.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_3, "cell 3 0");
|
||||
|
||||
JLabel lblNewLabel_4 = new JLabel("Propriété personnalisé Sujet");
|
||||
lblNewLabel_4.setForeground(new Color(0, 0, 255));
|
||||
lblNewLabel_4.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||
panelCentre.add(lblNewLabel_4, "cell 4 0");
|
||||
|
||||
|
||||
String dateDernierEnregistrement = commandes.evaluationsBase.getAttributs().get("date");
|
||||
|
||||
String nombreEvluation = String.valueOf(commandes.evaluationsBase.getNodes().size());
|
||||
|
||||
lblInformationBaseEvluation.setText("<html>Date dernière modification : " + dateDernierEnregistrement + " -- Nombre d'évaluation : " + nombreEvluation);
|
||||
|
||||
for(int i = 0 ; i<commandes.evaluationsBase.getNodes().size(); i++ ) {
|
||||
LesRadioButtons.add(new JRadioButton(commandes.evaluationsBase.getNodes().get(i).getAttributs().get("name")));
|
||||
LeslabelsDate.add(new JLabel(commandes.evaluationsBase.getNodes().get(i).getAttributs().get("date")));
|
||||
|
||||
node fichier = commandes.evaluationsBase.getNodes().get(i).retourneFirstEnfantsByName("fichier");
|
||||
|
||||
String Titre = fichier.getAttributs().get("titre");
|
||||
String MetatSujet = fichier.getAttributs().get("metaSujet");
|
||||
String nameFileAnalysis = fichier.getAttributs().get("filenameAnalyse");
|
||||
|
||||
|
||||
LeslabelsTitre.add(new JLabel(Titre));
|
||||
LeslabelsMeta.add(new JLabel(MetatSujet));
|
||||
LeslabelsFileNameAnalysis.add(new JLabel(nameFileAnalysis));
|
||||
}
|
||||
|
||||
|
||||
int j = 0;
|
||||
for(int i = 0 ; i<LesRadioButtons.size(); i++ ) {
|
||||
j=i+1;
|
||||
panelCentre.add(LesRadioButtons.get(i), "cell 0 "+j);
|
||||
panelCentre.add(LeslabelsDate.get(i), "cell 1 "+j);
|
||||
panelCentre.add(LeslabelsFileNameAnalysis.get(i), "cell 2 "+j);
|
||||
panelCentre.add(LeslabelsTitre.get(i), "cell 3 "+j);
|
||||
panelCentre.add(LeslabelsMeta.get(i), "cell 4 "+j);
|
||||
|
||||
LesRadioButtons.get(i).addMouseListener(new MyMouseListener());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -61,6 +61,7 @@ import action.actNodeFichier;
|
||||
import action.actOpen;
|
||||
import action.actOpenHistoriqueEvaluation;
|
||||
import action.actPaste;
|
||||
import action.actPathBaseEvaluations;
|
||||
import action.actSave;
|
||||
import action.actSaveAs;
|
||||
import action.actSetting;
|
||||
@ -257,7 +258,7 @@ public final class create extends JFrame {
|
||||
mnuFile.add( new actOpen() );
|
||||
mnuFile.add( new actNewFichierAnalyse() );
|
||||
mnuFile.addSeparator();
|
||||
// mnuFile.add( new actSaveHistoriqueEvaluation() );
|
||||
mnuFile.add( new actPathBaseEvaluations() );
|
||||
mnuFile.add( new actOpenHistoriqueEvaluation() );
|
||||
mnuFile.addSeparator();
|
||||
mnuFile.add( new actSave() );
|
||||
@ -347,6 +348,10 @@ public final class create extends JFrame {
|
||||
toolBarPrincipal.setName("outils principaux");
|
||||
|
||||
JButton btnChargeEvaluation = toolBarPrincipal.add( new actOpenHistoriqueEvaluation() );
|
||||
btnChargeEvaluation.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
btnChargeEvaluation.setIcon(new ImageIcon(create.class.getResource("/resources/chargehistoriqueevaluation.png")));
|
||||
btnChargeEvaluation.setHideActionText(true);
|
||||
toolBarPrincipal.add(btnChargeEvaluation);
|
||||
|
@ -41,6 +41,7 @@ import action.actAbout;
|
||||
import action.actDocumentation;
|
||||
import action.actLicence;
|
||||
import action.actOpenHistoriqueEvaluation;
|
||||
import action.actPathBaseEvaluations;
|
||||
import action.actTutoriels;
|
||||
import cXML.Run;
|
||||
import cXML.node;
|
||||
@ -435,7 +436,7 @@ public class evaluate extends JFrame {
|
||||
JMenu mnNewMenu = new JMenu("Fichier");
|
||||
mnNewMenu.setMnemonic( 'F' );
|
||||
menuBar.add(mnNewMenu);
|
||||
// mnNewMenu.add( new actSaveHistoriqueEvaluation() );
|
||||
mnNewMenu.add( new actPathBaseEvaluations() );
|
||||
mnNewMenu.add( new actOpenHistoriqueEvaluation() );
|
||||
mnNewMenu.addSeparator();
|
||||
mnNewMenu.add( actSave );
|
||||
@ -644,10 +645,9 @@ public class evaluate extends JFrame {
|
||||
chckbxfichiersEtudiants.setSelected(commandes.fichierStudentMoodle);
|
||||
chckbxZipfeedback.setSelected(commandes.zipfeedback);
|
||||
chckbxnoFeedback.setSelected(commandes.sansFeeback);
|
||||
chckbxnoFeedback.setSelected(commandes.noNote);
|
||||
chckCSVNotes.setSelected(commandes.ecritNoteCSV);
|
||||
chckbxNewLogo.setSelected(commandes.newLogo);
|
||||
chckbxNoLogo.setSelected(commandes.noLogo);
|
||||
chckbxNoNote.setSelected(commandes.noNote);
|
||||
chckbxVerif.setSelected(commandes.verifHisto2);
|
||||
chckbxNoDetail.setSelected(commandes.noDetail);
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
package fenetres;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
|
||||
public class savePreferences {
|
||||
@SuppressWarnings("unused")
|
||||
private JEditorPane txt;
|
||||
|
||||
savePreferences(JEditorPane txt){
|
||||
this.txt=txt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user