110 lines
4.6 KiB
Java
110 lines
4.6 KiB
Java
package fenetres;
|
|
|
|
import java.awt.Color;
|
|
import java.awt.Font;
|
|
import java.util.ArrayList;
|
|
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JCheckBox;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
|
|
import MEPTL.commandes;
|
|
import cXML.node;
|
|
|
|
|
|
public class CustomInputDialogActivateStyle {
|
|
public static void showCustominputDialog(node nod) {
|
|
|
|
JLabel lblTitre = new JLabel("<html><h2>AnalyseStyle<h2></html>");
|
|
lblTitre.setForeground(new Color(50,50,200));
|
|
|
|
JLabel lblExpliaction = new JLabel("<html><p>Si la méthode est activée alors le style de ce texte est analysé <br>"
|
|
+ "dans la structure du document. Cette méthode convient pour <br>"
|
|
+ "les formatages directs (surcharges) des paragraphes ou des <br>"
|
|
+ "caractères.</p>");
|
|
lblExpliaction.setFont(new Font("Tahoma", Font.BOLD, 12));
|
|
lblExpliaction.setForeground(Color.blue);
|
|
ImageIcon icon = new ImageIcon(create.class.getResource("/resources/evaluerstyle.png"));
|
|
JCheckBox chckbxAllBrother = new JCheckBox("<html>Placer la méthode sur tous les nodes frères.</html>");
|
|
|
|
|
|
Object[] message = {
|
|
lblTitre,
|
|
lblExpliaction,
|
|
chckbxAllBrother
|
|
};
|
|
|
|
String[] options = {"Active", "Désactive"};
|
|
|
|
int optionSelected = JOptionPane.showOptionDialog(
|
|
null,
|
|
message,
|
|
"Ajouter ou supprimer la méthode AnalyseStyle",
|
|
JOptionPane.DEFAULT_OPTION,
|
|
JOptionPane.INFORMATION_MESSAGE,
|
|
icon,
|
|
options,
|
|
options[0]);
|
|
|
|
if (optionSelected == 0) { // Bouton "Ajouter" sélectionné
|
|
placeLaMethodeActive(nod);
|
|
if(chckbxAllBrother.isSelected()) {
|
|
ArrayList<node> nods = nod.retourneTousLesFreres();
|
|
for(int i = 0 ; i < nods.size(); i ++) {
|
|
placeLaMethodeActive(nods.get(i));
|
|
}
|
|
}
|
|
} else if (optionSelected == 1) { // Bouton "Supprimer" sélectionné
|
|
supprimeLaMethode(nod);
|
|
if(chckbxAllBrother.isSelected()) {
|
|
if(chckbxAllBrother.isSelected()) {
|
|
ArrayList<node> nods = nod.retourneTousLesFreres();
|
|
for(int i = 0 ; i < nods.size(); i ++) {
|
|
supprimeLaMethode(nods.get(i));
|
|
}
|
|
}
|
|
}
|
|
}else { // Si la boîte de dialogue est annulée ou fermée
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private static void placeLaMethodeActive(node nod) {
|
|
nod.getAttributs().put("analyseStyle", "true");
|
|
//***************************************************************************************************************
|
|
//** Place l'attribut EvaluerATraversAnalyseStyle=true au style qui doit être évaluer à travers d'analyseStyle **
|
|
//** S'il y a des attributs évaluer avec ‽ alors change par ‼ **
|
|
//***************************************************************************************************************
|
|
String nameStyle = nod.getAttributs().get("text:style-name");
|
|
ArrayList<node> nodP = commandes.sujet.retourneEnfantsContainAttribut("style:name");
|
|
for(int i = 0 ; i < nodP.size();i++) {
|
|
if(nodP.get(i).getAttributs().get("style:name").equals(nameStyle)) {
|
|
nodP.get(i).getAttributs().put("EvaluerATraversAnalyseStyle", "true");
|
|
nodP.get(i).evaluerTrue();
|
|
nodP.get(i).changeLesCodesEvaluateursVersCodeATraversAnalyseStyle();
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void supprimeLaMethode(node nod) {
|
|
nod.supprimeAttribut("analyseStyle");
|
|
//***************************************************************************************************************
|
|
//** Place l'attribut EvaluerATraversAnalyseStyle=true au style qui doit être évaluer à travers d'analyseStyle **
|
|
//** S'il y a des attributs évaluer avec ‽ alors change par ‼ **
|
|
//***************************************************************************************************************
|
|
String nameStyle = nod.getAttributs().get("text:style-name");
|
|
ArrayList<node> nodP = commandes.sujet.retourneEnfantsContainAttribut("style:name");
|
|
for(int i = 0 ; i < nodP.size();i++) {
|
|
if(nodP.get(i).getAttributs().get("style:name").equals(nameStyle)) {
|
|
nodP.get(i).getAttributs().put("EvaluerATraversAnalyseStyle", "false");
|
|
nodP.get(i).changeLesCodesEvaluateursVersCodeATraversAnalyseStyle();
|
|
nodP.get(i).evaluerFalse();
|
|
}
|
|
}
|
|
}
|
|
}
|