analyseWriter/src/app/afficheText.java

291 lines
15 KiB
Java

package app;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.swing.JEditorPane;
import MEPTL.commandes;
import MEPTL.outils;
import cXML.node;
import calcul.calculIntervalleBaremeABCDE;
import calcul.calculNotesProgression;
import calcul.listeAttributsAnalyseWriter;
public class afficheText extends JEditorPane {
/**
*
*/
private static final long serialVersionUID = 1L;
public void refreshAffichage(node nod) {
if(nod!=null) {
setContentType("text/html");
node nodeParent = nod.getParent();
String imageAllContent = "<img src="+afficheText.class.getResource("/resources/allcontentmini.png").toString()+">";
String imageTitre = "<img src="+afficheText.class.getResource("/resources/titremini.png").toString()+">";
String imageSaut = "<img src="+afficheText.class.getResource("/resources/sautmini.png").toString()+">";
String imageaddmenu = "<img src="+afficheText.class.getResource("/resources/addmenumini.png").toString()+">";
String imagerechercheIndex = "<img src="+afficheText.class.getResource("/resources/rechercheindexmini.png").toString()+">";
String imagerechercheContenuExact = "<img src="+afficheText.class.getResource("/resources/recherchecontenumini.png").toString()+">";
String imagereanalyseStyle = "<img src="+afficheText.class.getResource("/resources/evaluerstylemini.png").toString()+">";
String imagereEvaleNode = "<img src="+afficheText.class.getResource("/resources/evalnodemini.png").toString()+">";
String imagereRechercheAncragePage= "<img src="+afficheText.class.getResource("/resources/rechercheancragepagemini.png").toString()+">";
String imagereRecherchePlusProcheVoisin= "<img src="+afficheText.class.getResource("/resources/recherchecontenuplusprochevoisinmini.png").toString()+">";
String imagerePremierAuteur= "<img src="+afficheText.class.getResource("/resources/auteurcreateurmini.png").toString()+">";
String imagereDernierEditeur= "<img src="+afficheText.class.getResource("/resources/auteurediteurmini.png").toString()+">";
StringBuilder sb = new StringBuilder();
sb.append(baliseStyle.balise());
sb.append("<p class=\"p1\">Parent = " + nodeParent.getNomElt() + "</p><br>");
sb.append("<hr><br><h1>Nom du node : " + nod.getNomElt() + "</h1><br><hr>");
//sous titre pour identifier les éléments
if(nod.getNomElt().equals("style:style")) {
sb.append("<h2>Nom du style : " + nod.getAttributs().get("style:name")+ "</h2><br>");
}
if(nod.getNomElt().equals("draw:frame")) {
sb.append("<h2>Nom du frame : " + outils.withoutCodeAndPointPourRechercheContenuExact(nod.getAttributs().get("draw:name"))+ "</h2><br>");
}
if(nod.getNomElt().equals("style:master-page")) {
sb.append("<h2>Nom du style de page : " + nod.getAttributs().get("style:display-name")+ "</h2><br>");
}
if(nod.getNomElt().equals("page")) {
sb.append("<h2>Numero absolue de la page : " + outils.withoutCodeAndPointPourRechercheContenuExact(nod.getAttributs().get("numeroabsolue"))
+ " - Numerotation de la page : " + outils.withoutCodeAndPointPourRechercheContenuExact(nod.getAttributs().get("numero"))+ "</h2><br>");
}
if(nod.getAttributs().get("evaluer")!=null) if(nod.getAttributs().get("evaluer").equalsIgnoreCase("true")) {
sb.append("<p><img src="+afficheText.class.getResource("/resources/evalwriter.png").toString()+"> Ce node est évalué.</p>");
}
if(nod.getAttributs().size()>0) {
if(nod.getAttributs().size()==1) sb.append("<br><h4><u>L'ATTRIBUT DU NODE</u></h4>");
if(nod.getAttributs().size()>1) sb.append("<br><h4><u>LES ATTRIBUTS DU NODE</u></h4>");
}
if(nod.getAttributs().size()<=0) {
if(nod.getAttributs().size()==1) sb.append("<br><h4><u>PAS D'ATTRIBUT DANS CE NODE</u></h4>");
}
Enumeration<String> key = nod.getAttributs().keys();
List<String> Lesattributsdunode = new ArrayList<String>();
while(key.hasMoreElements()) {
String K = key.nextElement();
Lesattributsdunode.add(K);
}
//permet le tri par ordre alphabétique des clés du dictionnaire
Lesattributsdunode = Lesattributsdunode.stream().sorted().collect(Collectors.toList());
if(nod.getAttributs().get("evaluer")!=null) if(nod.getAttributs().get("evaluer").equalsIgnoreCase("true")) {
sb.append("<br>");
sb.append("<ul>");
sb.append("<li class=\"p4\"><b><u>Les attributs d'analyseWriter</u></b></li>");
for(int i=0; i < Lesattributsdunode.size();i++) {
if(listeAttributsAnalyseWriter.isAttributAnalyseWriter(Lesattributsdunode.get(i))) {
if(Lesattributsdunode.get(i).equals("allContent")) {
Pattern p = Pattern.compile("[1-9]$|[0-9]{2,}$");
Matcher m = p.matcher(nod.getAttributs().get(Lesattributsdunode.get(i)));
if(m.find()) {
sb.append("<li class=\"p4\">"+imageAllContent + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
if(Lesattributsdunode.get(i).equals("titre")||Lesattributsdunode.get(i).equals("titre1")||Lesattributsdunode.get(i).equals("titre2")||Lesattributsdunode.get(i).equals("titre3")) {
if(nod.getAttributs().get(Lesattributsdunode.get(i)).length()>0) {
sb.append("<li class=\"p4\">"+imageTitre + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
if(Lesattributsdunode.get(i).equals("saut") && nod.getAttributs().get(Lesattributsdunode.get(i)).equals("true")) {
sb.append("<li class=\"p4\">"+imageSaut + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("addmenu") && nod.getAttributs().get(Lesattributsdunode.get(i)).equals("true")) {
sb.append("<li class=\"p4\">"+imageaddmenu + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("recherche_index") && nod.getAttributs().get(Lesattributsdunode.get(i)).equals("true")) {
sb.append("<li class=\"p4\">"+imagerechercheIndex + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("recherche_contenu_exact") && nod.getAttributs().get(Lesattributsdunode.get(i)).equals("true")) {
sb.append("<li class=\"p4\">"+imagerechercheContenuExact + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("analyseStyle") && nod.getAttributs().get(Lesattributsdunode.get(i)).equals("true")) {
sb.append("<li class=\"p4\">"+imagereanalyseStyle + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("evalNameNode") && !nod.getAttributs().get(Lesattributsdunode.get(i)).equals("0")) {
sb.append("<li class=\"p4\">"+imagereEvaleNode + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("recherche_anchor-page-number") && nod.getAttributs().get(Lesattributsdunode.get(i)).equals("true")) {
sb.append("<li class=\"p4\">"+imagereRechercheAncragePage + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("recherche_contenu_plus_proche_voisin") && nod.getAttributs().get(Lesattributsdunode.get(i)).equals("true")) {
sb.append("<li class=\"p4\">"+imagereRecherchePlusProcheVoisin + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("evalNameInitialCreator") && !nod.getAttributs().get(Lesattributsdunode.get(i)).equals("0")) {
sb.append("<li class=\"p4\">"+imagerePremierAuteur + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
if(Lesattributsdunode.get(i).equals("evalNameCreator") && !nod.getAttributs().get(Lesattributsdunode.get(i)).equals("0")) {
sb.append("<li class=\"p4\">"+imagereDernierEditeur + " <b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
// sb.append("<li class=\"p4\"><b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
sb.append("</ul>");
sb.append("<br>");
sb.append("<ul>");
sb.append("<li class=\"p2\"><b><u>Les attributs de Writer</u></b></li>");
for(int i=0; i < Lesattributsdunode.size();i++) {
if(!listeAttributsAnalyseWriter.isAttributAnalyseWriter(Lesattributsdunode.get(i))) {
sb.append("<li class=\"p2\"><b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
sb.append("</ul>");
}
if(nod.getAttributs().get("evaluer")!=null) if(!nod.getAttributs().get("evaluer").equalsIgnoreCase("true")) {
sb.append("<br>");
sb.append("<ul>");
sb.append("<li class=\"p3\"><b><u>Les attributs d'analyseWriter</u></b></li>");
for(int i=0; i < Lesattributsdunode.size();i++) {
if(listeAttributsAnalyseWriter.isAttributAnalyseWriter(Lesattributsdunode.get(i))) {
sb.append("<li class=\"p3\"><b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
sb.append("</ul>");
sb.append("<br>");
sb.append("<ul>");
sb.append("<li class=\"p3\"><b><u>Les attributs de Writer</u></b></li>");
for(int i=0; i < Lesattributsdunode.size();i++) {
if(!listeAttributsAnalyseWriter.isAttributAnalyseWriter(Lesattributsdunode.get(i))) {
sb.append("<li class=\"p3\"><b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
sb.append("</ul>");
}
if(nod.getAttributs().size()>0) {
if(nod.getAttributs().get("evaluer")==null) {
sb.append("<br>");
sb.append("<ul>");
sb.append("<li class=\"p3\"><b><u>Les attributs d'analyseWriter</u></b></li>");
for(int i=0; i < Lesattributsdunode.size();i++) {
if(listeAttributsAnalyseWriter.isAttributAnalyseWriter(Lesattributsdunode.get(i))) {
sb.append("<li class=\"p3\"><b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
sb.append("</ul>");
sb.append("<br>");
sb.append("<ul>");
sb.append("<li class=\"p3\"><b><u>Les attributs de Writer</u></b></li>");
for(int i=0; i < Lesattributsdunode.size();i++) {
if(!listeAttributsAnalyseWriter.isAttributAnalyseWriter(Lesattributsdunode.get(i))) {
sb.append("<li class=\"p3\"><b>" + Lesattributsdunode.get(i) + "=\"" + nod.getAttributs().get(Lesattributsdunode.get(i))+"\"</b></li>");
}
}
sb.append("</ul>");
}
}
if(!nod.retourneLesContenusEnfants("").trim().isEmpty()) {
sb.append("<br><br><h4><u>Contenu</u></h4><br>" + nod.retourneLesContenusEnfants("") );
}
setText("<html>"+sb.toString()+"</html>");
}
if(nod==null) {
setText("");
}
}
public void AfficheTotalPoint(node nod, int pointTotalNode) {
setContentType("text/html");
node nodeParent = nod.getParent();
StringBuilder sb = new StringBuilder();
sb.append(baliseStyle.balise());
if(nodeParent!=null) {
sb.append("<p class=\"p1\">Parent = " + nodeParent.getNomElt() + "</p><br>");
}
sb.append("<hr><br><h1>Total des points dans le node : " + nod.getNomElt() + "</h1><br><hr>");
sb.append("<p class=\"p5\">Uniquement les nodes évalués</p>");
sb.append("<p class=\"p5\">TOTAL POINT = " + String.valueOf(pointTotalNode) + "</p>");
setText("<html>"+sb.toString()+"</html>");
}
public void afficheChargementFichierAnalyse(){
StringBuilder text = new StringBuilder();
text.append(baliseStyle.balise());
text.append("<hr><h1><u>INFORMATIONS</u><h1><hr><br>");
text.append("<h3>Le titre de l'exercice est : <u>" + commandes.analyse_titre+"</u></h3>");
text.append("<p>Le sujet (metaSujet) est : <b>" + commandes.analyse_metaSujet+"</b></p>");
text.append("<p>L'auteur de l'exercice est : <b>" + commandes.analyse_auteur+"</b></p>");
if(commandes.analyse_baremeABC==true) {
text.append("<br><p>La notation est sous la forme d'une <b><u>note alphabétique ABCDE</u></b>.</p>");
text.append("<p>La progression est de <b>" + String.valueOf(commandes.analyse_progression)+ "</b></p>");
calcul.calculIntervalleBaremeABCDE C = new calculIntervalleBaremeABCDE(commandes.analyse_progression);
text.append("<p>" + C.getMessageLigne() + "</p>");
}else {
text.append("<p>La notation est sous la forme d'une <b><u>note numérique</u></b>.</p>");
text.append("<p>Le barème est sur <b>" + String.valueOf(commandes.analyse_notefrom)+ "</b></p>");
text.append("<p>La progression est de <b>" + String.valueOf(commandes.analyse_progression) + "</b></p>");
calculNotesProgression C = new calculNotesProgression(commandes.analyse_progression, commandes.analyse_notefrom);
text.append("<p>" + C.getMessageLigne() + "</p>");
}
text.append("<br>");
text.append("<p>Le nom du fichier : <b>" + commandes.analysis_filename + "</b></p>");
text.append("<p>Le hash de l'évaluation est : <b>" + commandes.hash + "<b></p>");
text.append("<br>");
text.append("<p>Historiques des modifications present : <b>" + commandes.analyse_historiquePresent + "</b></p>");
text.append("<br>");
text.append("<p>Verification de la presence metaSujet : <b>" + commandes.analyse_presenceMetaSujet + "</b></p>");
text.append("<br>");
text.append("<p>Contrôle la date de céation : <b>" + commandes.analyse_controleDateCreation+ "</b></p>");
text.append("<br>");
text.append("<p>Contrôle l'auteur initial du fichier : <b>" + commandes.analyse_controle_Initial_Creator + "</b></p>");
text.append("<br>");
text.append("<p>Dossier de l'analyse contenant les fichiers des étudiants :</p>");
text.append("<p class=\"city\"><b>"+commandes.path+"</b></p>");
text.append("<br>");
text.append("<br><p>Fichier d'analyse :</p>");
text.append("<p class=\"city\"><b>"+commandes.PathFilenameAnalysis+"</b></p>");
setContentType("text/html");
setText(text.toString());
}
}