58 lines
1.9 KiB
Java
58 lines
1.9 KiB
Java
|
package fenetres.create_act;
|
||
|
|
||
|
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 actCoefficient extends AbstractAction{
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
private static final long serialVersionUID = 1L;
|
||
|
{
|
||
|
putValue( Action.NAME, "Coefficient (poids)" );
|
||
|
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/poidsmini.png")) );
|
||
|
putValue( Action.SHORT_DESCRIPTION, "Coefficient (poids)" );
|
||
|
}
|
||
|
@Override
|
||
|
public void actionPerformed(ActionEvent e) {
|
||
|
node nod = (node) fenetres.create.getSelectNode().getUserObject();
|
||
|
double poids = 1.00;
|
||
|
if(nod.getAttributs().get("poids")!=null) {
|
||
|
try {
|
||
|
poids = Double.valueOf(nod.getAttributs().get("poids"));
|
||
|
} catch (Exception e2) {
|
||
|
System.out.println(e2.toString());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
String a = JOptionPane.showInputDialog(null,"Quel est le coefficient de cette partie de l'évaluation?",poids);
|
||
|
|
||
|
if(!a.isEmpty()) {
|
||
|
try {
|
||
|
poids = Double.valueOf(a);
|
||
|
if(poids<=0) {
|
||
|
nod.poids(Double.valueOf(1));
|
||
|
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>poids=1.</h2>");
|
||
|
}else {
|
||
|
nod.poids(Double.valueOf(poids));
|
||
|
fenetres.create.getTextNodeSelect().refreshAffichage(nod);
|
||
|
}
|
||
|
} catch (Exception e2) {
|
||
|
fenetres.create.getTextNodeSelect().setText(baliseStyle.balise());
|
||
|
fenetres.create.getTextNodeSelect().setText("<h2>Erreur la valeur doit être un nombre entier.<br>La valeur n'a pas été modifiée.</h2>");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|