analyseWriter/src/action/actEvalTabAlignementGaucheO...

65 lines
2.2 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;
public class actEvalTabAlignementGaucheOui extends AbstractAction{
/**
*
*/
private static final long serialVersionUID = 1L;
{
putValue( Action.NAME, "Oui, combien de point?" );
putValue( Action.SHORT_DESCRIPTION, "Evaluer l'alignement à gauche de la tabulation" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/evaltabalgngauchetruemini.png")) );
}
@Override
public void actionPerformed(ActionEvent e) {
node nod = (node) fenetres.create.getSelectNode().getUserObject();
int point = 0;
if(nod.getAttributs().get("evalTABAlignementAGauche")!=null) {
point = Integer.valueOf(nod.getAttributs().get("evalTABAlignementAGauche"));
}
if(nod.getAttributs().get("style:type")==null) {
String a = JOptionPane.showInputDialog(null,"Quel est le nombre de point?",point);
if(a!=null)if(!a.isBlank()) {
try {
point = Integer.valueOf(a);
if(point<0) {
nod.getAttributs().put("evalTABAlignementAGauche", String.valueOf(0));
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,la valeur a été modifiée.<br>evalTABAlignementAGauche=0.</h2>");
}else {
if(point>0) {
nod.getAttributs().put("evalTABAlignementAGauche", String.valueOf(point));
}else {
nod.supprimeAttribut("evalTABAlignementAGauche");
}
}
} 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);
}else {
JOptionPane.showMessageDialog(null,"Il y a un autre alignement dans cette tabulation.");
}
}
}