b40b6edb05
Ajout dans le menu structure de l'évaluation dans toutes les page de l'absence ou la présence de paragraphe vide
70 lines
2.3 KiB
Java
70 lines
2.3 KiB
Java
package action;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import javax.swing.AbstractAction;
|
|
import javax.swing.Action;
|
|
import javax.swing.Box;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
|
|
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());
|
|
}
|
|
}
|
|
|
|
|
|
JTextField poidsField = new JTextField(8);
|
|
poidsField.setText(String.valueOf(poids));
|
|
JPanel myPanel = new JPanel();
|
|
myPanel.add(new JLabel("Coef. :"));
|
|
myPanel.add(Box.createHorizontalStrut(2)); // a spacer
|
|
myPanel.add(poidsField);
|
|
|
|
|
|
int result = JOptionPane.showConfirmDialog(null, myPanel, "Saisissez le coefficient", JOptionPane.OK_CANCEL_OPTION);
|
|
if (result == JOptionPane.OK_OPTION) {
|
|
try {
|
|
poids = Double.valueOf(poidsField.getText());
|
|
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 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>");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|