78 lines
2.7 KiB
Java
78 lines
2.7 KiB
Java
package action;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import javax.swing.AbstractAction;
|
|
import javax.swing.Action;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JOptionPane;
|
|
|
|
import cXML.node;
|
|
import fenetres.baliseStyle;
|
|
import fenetres.create;
|
|
import list.listeDesNodesAnalyseStyle;
|
|
|
|
public class actEvalFormatageDirectTousLesNodesTrue extends AbstractAction{
|
|
{
|
|
putValue( Action.NAME, "Oui, combien de point?" );
|
|
putValue( Action.SHORT_DESCRIPTION, "Evaluer la présence ou l'absence du formatage direct." );
|
|
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/truemini.png")) );
|
|
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/truemini.png")) );
|
|
}
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
node nod = (node) fenetres.create.getSelectNode().getUserObject();
|
|
int point = 0;
|
|
if(nod.getAttributs().get("evalFormatageDirect")!=null) {
|
|
point = Integer.valueOf(nod.getAttributs().get("evalFormatageDirect"));
|
|
}
|
|
|
|
String a = JOptionPane.showInputDialog(null,"Quel est le nombre de point?",point);
|
|
|
|
if(a!=null)if(!a.isEmpty()) {
|
|
try {
|
|
point = Integer.valueOf(a);
|
|
if(point<=0) {
|
|
nod.supprimeAttribut("evalFormatageDirect");
|
|
fenetres.create.getTextNodeSelect().setText(baliseStyle.balise());
|
|
fenetres.create.getTextNodeSelect().setText("<h2>Erreur la valeur doit être un nombre entier POSITIF SUPÉRIEUR à zéro.<br>Cependant,l'attribut <b>evalFormatageDirect</b> a été supprimé.</h2>");
|
|
}else {
|
|
if(nod.getNomElt().equals("page")) {
|
|
ajouteAttribut(nod,point);
|
|
}
|
|
if(nod.getNomElt().equals("structurepage")) {
|
|
for(int i = 0 ; i < nod.getNodes().size(); i++) {
|
|
if(nod.getNodes().get(i).getNomElt().equals("page")) {
|
|
ajouteAttribut(nod.getNodes().get(i),point);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e2) {
|
|
fenetres.create.getTextNodeSelect().setText(baliseStyle.balise());
|
|
fenetres.create.getTextNodeSelect().setText("<h2>Erreur la valeur doit être un nombre entier.<br>L'attribut n'a pas été modifiée.</h2>");
|
|
}
|
|
}
|
|
fenetres.create.getTextNodeSelect().refreshAffichage(nod);
|
|
}
|
|
|
|
|
|
private void ajouteAttribut(node nodePage, Integer point) {
|
|
for(int i = 0 ; i < nodePage.getNodes().size(); i++) {
|
|
if(listeDesNodesAnalyseStyle.isAnalyseStyle(nodePage.getNodes().get(i))) {
|
|
if(point>0) {
|
|
nodePage.getNodes().get(i).getAttributs().put("evalFormatageDirect", String.valueOf(point));
|
|
}else {
|
|
nodePage.getNodes().get(i).supprimeAttribut("evalFormatageDirect");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|