2022-06-19 21:01:30 +02:00
package fenetres ;
2022-06-05 18:42:06 +02:00
2024-04-18 13:54:25 +02:00
import java.awt.Color ;
2022-06-05 18:42:06 +02:00
import java.awt.Font ;
import java.awt.event.ActionEvent ;
2022-12-10 11:16:34 +01:00
import java.awt.event.ActionListener ;
2022-06-05 18:42:06 +02:00
2022-12-10 11:16:34 +01:00
import javax.swing.DefaultComboBoxModel ;
import javax.swing.ImageIcon ;
import javax.swing.JButton ;
2024-04-18 13:54:25 +02:00
import javax.swing.JCheckBox ;
2022-06-05 18:42:06 +02:00
import javax.swing.JComboBox ;
2022-12-10 11:16:34 +01:00
import javax.swing.JFrame ;
import javax.swing.JLabel ;
import javax.swing.JOptionPane ;
import javax.swing.JPanel ;
2022-06-05 18:42:06 +02:00
import javax.swing.JTextField ;
import javax.swing.SwingConstants ;
2022-12-10 11:16:34 +01:00
import javax.swing.border.EmptyBorder ;
2022-12-24 11:57:29 +01:00
import javax.swing.tree.DefaultMutableTreeNode ;
import javax.swing.tree.DefaultTreeModel ;
import javax.swing.tree.TreePath ;
2022-06-20 11:25:08 +02:00
2022-12-10 11:16:34 +01:00
import MEPTL.commandes ;
import cXML.node ;
import list.listeDesNodesAllContent ;
2022-06-05 18:42:06 +02:00
public class allContent extends JFrame {
/ * *
*
* /
private static final long serialVersionUID = 1L ;
private JPanel contentPane ;
private JTextField textFieldPoint ;
private JLabel lblExplication ;
2024-04-18 13:54:25 +02:00
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 ;
2022-06-05 18:42:06 +02:00
String valeur = " strict " ;
int point = 0 ;
/ * *
2024-04-18 13:54:25 +02:00
* 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 .
2022-06-05 18:42:06 +02:00
* /
2024-04-18 13:54:25 +02:00
public allContent ( node nod , afficheText J ) {
2022-06-05 18:42:06 +02:00
this . nod = nod ;
this . J = J ;
2022-12-10 11:16:34 +01:00
2022-06-05 18:42:06 +02:00
if ( nod . getAttributs ( ) . get ( " allContent " ) ! = null ) {
String value = nod . getAttributs ( ) . get ( " allContent " ) ;
2024-03-23 10:28:11 +01:00
if ( value . contains ( " SansCasseEspaceChiffre " ) ) { value = value . replace ( " SansCasseEspaceChiffre " , " " ) ; valeur = " SansCasseEspaceChiffre " ; }
2022-06-05 18:42:06 +02:00
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 ) ;
2024-04-18 13:54:25 +02:00
setBounds ( 100 , 100 , 700 , 354 ) ;
2022-06-20 11:25:08 +02:00
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 ) ;
2024-03-24 14:48:24 +01:00
setTitle ( " Méthode allContent - " + commandes . Titre + " " + commandes . version + " " + commandes . branch ) ;
2022-06-20 11:25:08 +02:00
setIconImage ( img . getImage ( ) ) ;
2022-06-05 18:42:06 +02:00
contentPane = new JPanel ( ) ;
contentPane . setBorder ( new EmptyBorder ( 5 , 5 , 5 , 5 ) ) ;
setContentPane ( contentPane ) ;
contentPane . setLayout ( null ) ;
2024-04-18 13:54:25 +02:00
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 ) ;
2022-06-05 18:42:06 +02:00
2024-03-23 10:28:11 +01:00
JLabel lblValeurDeLattribut = new JLabel ( " Algorithme d'évaluation " ) ;
lblValeurDeLattribut . setFont ( new Font ( " Tahoma " , Font . BOLD | Font . ITALIC , 13 ) ) ;
2024-04-18 13:54:25 +02:00
lblValeurDeLattribut . setBounds ( 26 , 124 , 165 , 23 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( lblValeurDeLattribut ) ;
2024-03-23 10:28:11 +01:00
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> " ) ;
2022-06-05 18:42:06 +02:00
lblDescription . setLabelFor ( this ) ;
2024-04-18 13:54:25 +02:00
lblDescription . setFont ( new Font ( " Tahoma " , Font . BOLD , 13 ) ) ;
lblDescription . setBounds ( 10 , 11 , 633 , 50 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( lblDescription ) ;
comboBoxValeur = new JComboBox < String > ( ) ;
2024-03-23 10:28:11 +01:00
comboBoxValeur . setFont ( new Font ( " Tahoma " , Font . BOLD | Font . ITALIC , 14 ) ) ;
comboBoxValeur . setModel ( new DefaultComboBoxModel < String > ( new String [ ] { " strict " , " strictSansEspace " , " SansCasseEspaceChiffre " , " environ " } ) ) ;
2022-06-05 18:42:06 +02:00
comboBoxValeur . setSelectedItem ( valeur ) ;
2024-04-18 13:54:25 +02:00
comboBoxValeur . setBounds ( 201 , 119 , 216 , 30 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( comboBoxValeur ) ;
2024-03-23 10:28:11 +01:00
JLabel lblPoint = new JLabel ( " Combien de point ? " ) ;
lblPoint . setFont ( new Font ( " Tahoma " , Font . BOLD , 13 ) ) ;
2024-04-18 13:54:25 +02:00
lblPoint . setBounds ( 26 , 72 , 171 , 22 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( lblPoint ) ;
textFieldPoint = new JTextField ( ) ;
2024-03-23 10:28:11 +01:00
textFieldPoint . setFont ( new Font ( " Tahoma " , Font . BOLD , 14 ) ) ;
2022-06-05 18:42:06 +02:00
textFieldPoint . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textFieldPoint . setText ( " 0 " ) ;
2024-04-18 13:54:25 +02:00
textFieldPoint . setBounds ( 201 , 72 , 72 , 23 ) ;
2022-06-05 18:42:06 +02:00
textFieldPoint . setColumns ( 6 ) ;
textFieldPoint . setText ( String . valueOf ( point ) ) ;
contentPane . add ( textFieldPoint ) ;
2024-03-23 10:28:11 +01:00
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 ) ;
2022-06-05 18:42:06 +02:00
if ( comboBoxValeur . getSelectedItem ( ) . equals ( " strict " ) ) {
2024-03-23 10:28:11 +01:00
lblExplication . setText ( " <html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASSE comprise.</html> " ) ;
2022-06-05 18:42:06 +02:00
}
if ( comboBoxValeur . getSelectedItem ( ) . equals ( " strictSansEspace " ) ) {
2024-03-23 10:28:11 +01:00
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> " ) ;
2022-06-05 18:42:06 +02:00
}
if ( comboBoxValeur . getSelectedItem ( ) . equals ( " environ " ) ) {
2024-03-23 10:28:11 +01:00
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> " ) ;
2022-06-05 18:42:06 +02:00
}
2024-04-18 13:54:25 +02:00
lblExplication . setBounds ( 26 , 170 , 633 , 80 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( lblExplication ) ;
2024-04-18 13:54:25 +02:00
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 ) ;
2022-12-25 18:00:02 +01:00
2024-04-18 13:54:25 +02:00
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. " ) ;
}
}
} ) ;
2022-06-05 18:42:06 +02:00
2024-04-18 13:54:25 +02:00
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 ( ) ;
}
} ) ;
2022-06-05 18:42:06 +02:00
comboBoxValeur . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
if ( comboBoxValeur . getSelectedItem ( ) . equals ( " strict " ) ) {
2024-03-23 10:28:11 +01:00
lblExplication . setText ( " <html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASSE comprise.</html> " ) ;
2022-06-05 18:42:06 +02:00
}
if ( comboBoxValeur . getSelectedItem ( ) . equals ( " strictSansEspace " ) ) {
2024-03-23 10:28:11 +01:00
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> " ) ;
2022-06-05 18:42:06 +02:00
}
if ( comboBoxValeur . getSelectedItem ( ) . equals ( " environ " ) ) {
2024-03-23 10:28:11 +01:00
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> " ) ;
2022-06-05 18:42:06 +02:00
}
}
} ) ;
}
}