2022-06-19 21:01:30 +02:00
package fenetres ;
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 ;
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 ;
2022-12-10 11:16:34 +01:00
2022-06-05 18:42:06 +02:00
node nod ;
afficheText J ;
JComboBox < String > comboBoxValeur ;
String valeur = " strict " ;
int point = 0 ;
/ * *
2022-12-24 11:57:29 +01:00
* Evaluation de tous les contenu d ' un node .
* @param nod : Le node à évaluer .
* @param J : Affichage du texte
2023-01-24 21:11:01 +01:00
* @param Childs : Si TRUE alors évaluation de tous les contenus des nodes enfants .
2022-06-05 18:42:06 +02:00
* /
2022-12-10 11:16:34 +01:00
public allContent ( node nod , afficheText J , boolean Childs ) {
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 " ) ;
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 ) ;
2022-06-20 11:25:08 +02:00
setBounds ( 100 , 100 , 556 , 326 ) ;
setTitle ( " allContent " ) ;
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 ) ;
2022-12-25 18:00:02 +01:00
setTitle ( " 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 ) ;
2022-12-25 18:00:02 +01:00
JButton btnNewButton = new JButton ( " Valider " ) ;
btnNewButton . setIcon ( new ImageIcon ( allContent . class . getResource ( " /resources/truemini.png " ) ) ) ;
2022-06-20 11:25:08 +02:00
btnNewButton . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
btnNewButton . setBounds ( 394 , 237 , 121 , 39 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( btnNewButton ) ;
JLabel lblValeurDeLattribut = new JLabel ( " Type d'évaluation " ) ;
lblValeurDeLattribut . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
2022-06-20 11:25:08 +02:00
lblValeurDeLattribut . setBounds ( 10 , 105 , 130 , 23 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( lblValeurDeLattribut ) ;
2022-06-20 09:45:00 +02:00
JLabel lblDescription = new JLabel ( " <html>Cet attribut permet d'évaluer le contenu du node et de celui des nodes enfants de ce node.<br> "
+ " Par conséquent, tous les nodes enfants seront évalués.</html> " ) ;
2022-06-05 18:42:06 +02:00
lblDescription . setLabelFor ( this ) ;
lblDescription . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
2022-06-20 11:25:08 +02:00
lblDescription . setBounds ( 10 , 11 , 520 , 50 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( lblDescription ) ;
comboBoxValeur = new JComboBox < String > ( ) ;
comboBoxValeur . setModel ( new DefaultComboBoxModel < String > ( new String [ ] { " strict " , " strictSansEspace " , " environ " } ) ) ;
comboBoxValeur . setSelectedItem ( valeur ) ;
comboBoxValeur . setBounds ( 150 , 106 , 130 , 22 ) ;
contentPane . add ( comboBoxValeur ) ;
JLabel lblPoint = new JLabel ( " Combien de point? " ) ;
lblPoint . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
lblPoint . setBounds ( 10 , 72 , 130 , 22 ) ;
contentPane . add ( lblPoint ) ;
textFieldPoint = new JTextField ( ) ;
textFieldPoint . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textFieldPoint . setText ( " 0 " ) ;
textFieldPoint . setBounds ( 150 , 72 , 43 , 20 ) ;
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, CASE comprise.</html> " ) ;
if ( comboBoxValeur . getSelectedItem ( ) . equals ( " strict " ) ) {
lblExplication . setText ( " <html>Dans le fichier de l'étudiants.<br>Le contenu du node doit être rigoureusement identique, CASE 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, CASE comprise, mais ignore les espaces en début et fin.</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 CASE est ignorée.</html> " ) ;
}
2022-06-20 11:25:08 +02:00
lblExplication . setBounds ( 10 , 158 , 520 , 56 ) ;
2022-06-05 18:42:06 +02:00
contentPane . add ( lblExplication ) ;
2022-12-25 18:00:02 +01:00
JLabel lblNewLabel = new JLabel ( " Pour annuler la méthode, saisissez 0 point. " ) ;
lblNewLabel . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
lblNewLabel . setIcon ( new ImageIcon ( allContent . class . getResource ( " /resources/falsemini.png " ) ) ) ;
lblNewLabel . setBounds ( 240 , 69 , 275 , 23 ) ;
contentPane . add ( lblNewLabel ) ;
2022-06-05 18:42:06 +02:00
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, CASE 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, CASE comprise, mais ignore les espaces en début et fin.</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 CASE est ignorée.</html> " ) ;
}
}
} ) ;
btnNewButton . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
try {
int point = Integer . valueOf ( textFieldPoint . getText ( ) ) ;
if ( point < 0 ) point = 0 ;
2022-12-10 11:16:34 +01:00
if ( ! Childs ) {
2023-01-24 21:11:01 +01:00
nod . getAttributs ( ) . put ( " allContent " , comboBoxValeur . getSelectedItem ( ) . toString ( ) + String . valueOf ( point ) ) ;
2022-12-10 11:16:34 +01:00
nod . evaluerAllChildTrue ( ) ;
J . refreshAffichage ( nod ) ;
} else {
2023-01-24 21:11:01 +01:00
if ( nod . getNomElt ( ) . equals ( " page " ) ) {
placeAtrtibutAllContentDansLesNodesDeLaPage ( nod , comboBoxValeur . getSelectedItem ( ) . toString ( ) , point ) ;
2022-12-10 11:16:34 +01:00
}
2023-01-24 21:11:01 +01:00
if ( nod . getNomElt ( ) . equals ( " structurepage " ) ) {
for ( int i = 0 ; i < nod . getNodes ( ) . size ( ) ; i + + ) {
if ( nod . getNodes ( ) . get ( i ) . getNomElt ( ) . equals ( " page " ) ) {
placeAtrtibutAllContentDansLesNodesDeLaPage ( nod . getNodes ( ) . get ( i ) , comboBoxValeur . getSelectedItem ( ) . toString ( ) , point ) ;
}
}
}
2022-12-10 11:16:34 +01:00
J . refreshAffichage ( nod ) ;
}
dispose ( ) ;
2022-06-05 18:42:06 +02:00
} catch ( Exception e2 ) {
JOptionPane . showMessageDialog ( null , " Le nombre de point doit être un entier. " ) ;
}
2022-12-24 11:57:29 +01:00
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 ) ;
2022-06-05 18:42:06 +02:00
}
2022-12-24 11:57:29 +01:00
2022-06-05 18:42:06 +02:00
} ) ;
setVisible ( true ) ;
}
2023-01-24 21:11:01 +01:00
private void placeAtrtibutAllContentDansLesNodesDeLaPage ( node nodePage , String methode , Integer point ) {
for ( int i = 0 ; i < nodePage . getNodes ( ) . size ( ) ; i + + ) {
if ( listeDesNodesAllContent . isAllContent ( nodePage . getNodes ( ) . get ( i ) ) ) {
nodePage . getNodes ( ) . get ( i ) . getAttributs ( ) . put ( " allContent " , methode + String . valueOf ( point ) ) ;
nodePage . getNodes ( ) . get ( i ) . evaluerAllChildTrue ( ) ; }
}
}
2022-06-05 18:42:06 +02:00
}