256 lines
11 KiB
Java
256 lines
11 KiB
Java
package fenetres;
|
|
|
|
|
|
import java.awt.Color;
|
|
import java.awt.Font;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
import javax.swing.DefaultComboBoxModel;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JCheckBox;
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
import javax.swing.SwingConstants;
|
|
import javax.swing.border.EmptyBorder;
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
import javax.swing.tree.TreePath;
|
|
|
|
import MEPTL.commandes;
|
|
import cXML.node;
|
|
import list.listeDesNodesAllContent;
|
|
|
|
public class allContent extends JFrame {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
private JPanel contentPane;
|
|
private JTextField textFieldPoint;
|
|
private JLabel lblExplication;
|
|
private JButton btnAdd = new JButton("Ajouter");
|
|
private JButton btnRemove = new JButton("Supprimer");
|
|
private JCheckBox chckbxPlaceMethodeChildren = new JCheckBox("<html>Place la méthode sur tous<br>les nodes enfants</html>");
|
|
|
|
private node nod;
|
|
private afficheText J;
|
|
private JComboBox<String> comboBoxValeur;
|
|
String valeur="strict";
|
|
int point=0;
|
|
|
|
|
|
/**
|
|
* La méthode allContent permet d'évaluer tous les contenus textuel d'un node<br>
|
|
* avec les contenus des nodes enfants.
|
|
* @param nod : Le node
|
|
* @param J : Affichage du texte dans la fenêtre.
|
|
*/
|
|
public allContent(node nod, afficheText J) {
|
|
this.nod=nod;
|
|
this.J=J;
|
|
|
|
|
|
if(nod.getAttributs().get("allContent")!=null) {
|
|
String value = nod.getAttributs().get("allContent");
|
|
if(value.contains("SansCasseEspaceChiffre")) { value=value.replace("SansCasseEspaceChiffre", "");valeur="SansCasseEspaceChiffre";}
|
|
if(value.contains("strictSansEspace")) { value=value.replace("strictSansEspace", "");valeur="strictSansEspace";}
|
|
if(value.contains("strict")) {value=value.replace("strict", "");valeur="strict";}
|
|
if(value.contains("environ")) {value=value.replace("environ", "");valeur="environ";}
|
|
|
|
point = Integer.valueOf(value);
|
|
}
|
|
|
|
setResizable(false);
|
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
setBounds(100, 100, 700, 354);
|
|
|
|
ImageIcon img = new ImageIcon(getClass().getResource("/evalwriter.png") );
|
|
int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth();
|
|
int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight();
|
|
setLocation(( (screenWidth) - getWidth()) / 2, (screenHeight - getHeight()) / 2);
|
|
|
|
setTitle("Méthode allContent - " + commandes.Titre + " " + commandes.version + " " + commandes.branch);
|
|
setIconImage(img.getImage());
|
|
|
|
|
|
contentPane = new JPanel();
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
setContentPane(contentPane);
|
|
contentPane.setLayout(null);
|
|
|
|
btnAdd.setIcon(new ImageIcon(allContent.class.getResource("/resources/true.png")));
|
|
btnAdd.setFont(new Font("Tahoma", Font.BOLD, 18));
|
|
btnAdd.setBounds(458, 261, 216, 50);
|
|
contentPane.add(btnAdd);
|
|
|
|
JLabel lblValeurDeLattribut = new JLabel("Algorithme d'évaluation");
|
|
lblValeurDeLattribut.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13));
|
|
lblValeurDeLattribut.setBounds(26, 124, 165, 23);
|
|
contentPane.add(lblValeurDeLattribut);
|
|
|
|
JLabel lblDescription = new JLabel("<html>Cet attribut permet d'évaluer le contenu du node et de celui des nodes enfants.<br>Par conséquent, tous les nodes enfants seront évalués.</html>");
|
|
lblDescription.setLabelFor(this);
|
|
lblDescription.setFont(new Font("Tahoma", Font.BOLD, 13));
|
|
lblDescription.setBounds(10, 11, 633, 50);
|
|
contentPane.add(lblDescription);
|
|
|
|
comboBoxValeur = new JComboBox<String>();
|
|
comboBoxValeur.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 14));
|
|
comboBoxValeur.setModel(new DefaultComboBoxModel<String>(new String[] {"strict", "strictSansEspace", "SansCasseEspaceChiffre", "environ"}));
|
|
comboBoxValeur.setSelectedItem(valeur);
|
|
comboBoxValeur.setBounds(201, 119, 216, 30);
|
|
contentPane.add(comboBoxValeur);
|
|
|
|
JLabel lblPoint = new JLabel("Combien de point ?");
|
|
lblPoint.setFont(new Font("Tahoma", Font.BOLD, 13));
|
|
lblPoint.setBounds(26, 72, 171, 22);
|
|
contentPane.add(lblPoint);
|
|
|
|
textFieldPoint = new JTextField();
|
|
textFieldPoint.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
textFieldPoint.setHorizontalAlignment(SwingConstants.CENTER);
|
|
textFieldPoint.setText("0");
|
|
textFieldPoint.setBounds(201, 72, 72, 23);
|
|
textFieldPoint.setColumns(6);
|
|
textFieldPoint.setText(String.valueOf(point));
|
|
contentPane.add(textFieldPoint);
|
|
|
|
|
|
lblExplication = new JLabel("<html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASSE comprise.</html>");
|
|
lblExplication.setFont(new Font("Tahoma", Font.PLAIN, 13));
|
|
lblExplication.setForeground(new Color(0, 0, 205));
|
|
lblExplication.setVerticalAlignment(SwingConstants.TOP);
|
|
|
|
if(comboBoxValeur.getSelectedItem().equals("strict")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASSE comprise.</html>");
|
|
}
|
|
if(comboBoxValeur.getSelectedItem().equals("strictSansEspace")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASSE comprise, mais ignore les espaces en début et fin.</html>");
|
|
}
|
|
if(comboBoxValeur.getSelectedItem().equals("SansCasseEspaceChiffre")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>La CASSE, les espaces, les chiffres et les caractères accentués sont ignorés.</html>");
|
|
}
|
|
if(comboBoxValeur.getSelectedItem().equals("environ")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>Le contenu du node peut être plus ou moins proche (voir le paramètre similude), la CASSE est ignorée.</html>");
|
|
}
|
|
|
|
lblExplication.setBounds(26, 170, 633, 80);
|
|
contentPane.add(lblExplication);
|
|
|
|
btnRemove.setIcon(new ImageIcon(allContent.class.getResource("/resources/false.png")));
|
|
btnRemove.setFont(new Font("Tahoma", Font.BOLD, 18));
|
|
btnRemove.setBounds(232, 261, 216, 50);
|
|
contentPane.add(btnRemove);
|
|
|
|
if(nod.isHasEnfant()) {
|
|
boolean EnableChckBox = false;
|
|
for(int i = 0 ; i < nod.getNodes().size();i++) {
|
|
if( listeDesNodesAllContent.isAllContent(nod.getNodes().get(i))){
|
|
EnableChckBox=true;
|
|
}
|
|
}
|
|
chckbxPlaceMethodeChildren.setEnabled(EnableChckBox);
|
|
}else {
|
|
chckbxPlaceMethodeChildren.setEnabled(false);
|
|
}
|
|
chckbxPlaceMethodeChildren.setFont(new Font("Tahoma", Font.PLAIN, 12));
|
|
chckbxPlaceMethodeChildren.setBounds(458, 68, 216, 30);
|
|
contentPane.add(chckbxPlaceMethodeChildren);
|
|
|
|
|
|
Listener();
|
|
setVisible(true);
|
|
}
|
|
|
|
|
|
private void placeAtrtibutAllContentDansLesNodesChildren(node nod,String methode, Integer point) {
|
|
for(int i = 0 ; i < nod.getNodes().size(); i++) {
|
|
if( listeDesNodesAllContent.isAllContent(nod.getNodes().get(i))){
|
|
nod.getNodes().get(i).getAttributs().put("allContent", methode+String.valueOf(point));
|
|
nod.getNodes().get(i).evaluerAllChildTrue(); }
|
|
}
|
|
}
|
|
|
|
private void supprimeAttributAllConetnetDansLesNodesChildren(node nod) {
|
|
for(int i = 0 ; i < nod.getNodes().size(); i++) {
|
|
if( listeDesNodesAllContent.isAllContent(nod.getNodes().get(i))){
|
|
nod.getNodes().get(i).supprimeAttribut("allContent"); }
|
|
}
|
|
}
|
|
|
|
|
|
private void Listener() {
|
|
|
|
btnAdd.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
try {
|
|
int point = Integer.parseInt(textFieldPoint.getText());
|
|
if(point<0) point =0;
|
|
|
|
if(!chckbxPlaceMethodeChildren.isSelected()) {
|
|
nod.getAttributs().put("allContent", comboBoxValeur.getSelectedItem().toString() + String.valueOf(point));
|
|
nod.evaluerAllChildTrue();
|
|
}else {
|
|
placeAtrtibutAllContentDansLesNodesChildren(nod,comboBoxValeur.getSelectedItem().toString(),point);
|
|
}
|
|
J.refreshAffichage(nod);
|
|
TreePath path = fenetres.create.getTree().getSelectionPath();
|
|
DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
|
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
|
|
model.reload(root);
|
|
fenetres.create.getTree().setSelectionPath(path);
|
|
fenetres.create.getTree().expandPath(path);
|
|
fenetres.create.getTextNodeSelect().refreshAffichage(nod);
|
|
dispose();
|
|
} catch (Exception e2) {
|
|
JOptionPane.showMessageDialog(null, "Le nombre de point doit être un entier.");
|
|
}
|
|
}
|
|
});
|
|
|
|
btnRemove.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
if(!chckbxPlaceMethodeChildren.isSelected()) {
|
|
nod.supprimeAttribut("allContent");
|
|
}else {
|
|
supprimeAttributAllConetnetDansLesNodesChildren(nod);
|
|
}
|
|
J.refreshAffichage(nod);
|
|
TreePath path = fenetres.create.getTree().getSelectionPath();
|
|
DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
|
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
|
|
model.reload(root);
|
|
fenetres.create.getTree().setSelectionPath(path);
|
|
fenetres.create.getTree().expandPath(path);
|
|
fenetres.create.getTextNodeSelect().refreshAffichage(nod);
|
|
dispose();
|
|
}
|
|
});
|
|
|
|
comboBoxValeur.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
if(comboBoxValeur.getSelectedItem().equals("strict")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASSE comprise.</html>");
|
|
}
|
|
if(comboBoxValeur.getSelectedItem().equals("strictSansEspace")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASSE comprise, mais ignore les espaces en début et fin.</html>");
|
|
}
|
|
if(comboBoxValeur.getSelectedItem().equals("SansCasseEspaceChiffre")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>La CASSE, les espaces, les chiffres et les caractères accentués sont ignorés.</html>");
|
|
}
|
|
if(comboBoxValeur.getSelectedItem().equals("environ")) {
|
|
lblExplication.setText("<html>Dans le fichier de l'étudiants.<br>Le contenu du node peut être plus ou moins proche (voir le paramètre similude), la CASSE est ignorée.</html>");
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|