2022-05-28 19:13:25 +02:00
package app ;
import java.awt.BorderLayout ;
import java.awt.Color ;
2022-06-01 21:38:37 +02:00
import java.awt.Desktop ;
2022-05-28 19:13:25 +02:00
import java.awt.Dimension ;
import java.awt.Font ;
import java.awt.event.ActionEvent ;
import java.awt.event.KeyEvent ;
import java.awt.event.MouseAdapter ;
import java.awt.event.MouseEvent ;
import java.io.File ;
import java.io.IOException ;
import java.util.Enumeration ;
import java.util.regex.Matcher ;
import java.util.regex.Pattern ;
import javax.swing.AbstractAction ;
import javax.swing.Action ;
import javax.swing.ImageIcon ;
import javax.swing.JButton ;
import javax.swing.JFileChooser ;
import javax.swing.JFrame ;
import javax.swing.JMenu ;
import javax.swing.JMenuBar ;
import javax.swing.JOptionPane ;
import javax.swing.JPanel ;
2022-06-01 21:38:37 +02:00
import javax.swing.JPopupMenu ;
2022-05-28 19:13:25 +02:00
import javax.swing.JScrollPane ;
import javax.swing.JSplitPane ;
import javax.swing.JToolBar ;
import javax.swing.JTree ;
import javax.swing.KeyStroke ;
import javax.swing.UnsupportedLookAndFeelException ;
2022-06-02 15:47:54 +02:00
import javax.swing.filechooser.FileNameExtensionFilter ;
2022-05-28 19:13:25 +02:00
import javax.swing.tree.DefaultMutableTreeNode ;
import javax.swing.tree.DefaultTreeCellRenderer ;
2022-06-01 21:38:37 +02:00
import javax.swing.tree.TreeNode ;
import javax.swing.tree.TreePath ;
2022-05-28 19:13:25 +02:00
import javax.swing.tree.TreeSelectionModel ;
2022-06-02 15:47:54 +02:00
import javax.xml.parsers.ParserConfigurationException ;
import org.xml.sax.SAXException ;
2022-05-28 19:13:25 +02:00
import MEPTL.commandes ;
2022-06-02 15:47:54 +02:00
import MEPTL.ecritureSujet ;
import MEPTL.meptl ;
import MEPTL.verificationFichierAnalyse ;
2022-05-28 19:13:25 +02:00
import cXML.Run ;
2022-06-01 21:38:37 +02:00
import cXML.node ;
2022-06-11 12:10:28 +02:00
import calcul.listeAttributsAnalyseWriter ;
2022-06-13 17:43:41 +02:00
import calcul.listeNodeFormatageDirectDeWriter ;
2022-06-11 12:10:28 +02:00
2022-05-28 19:13:25 +02:00
import java.awt.event.InputEvent ;
2022-06-09 09:13:46 +02:00
import javax.swing.JToggleButton ;
2022-06-09 17:49:22 +02:00
import java.awt.event.ActionListener ;
2022-06-09 09:13:46 +02:00
2022-05-28 19:13:25 +02:00
public class create extends JFrame {
private static final long serialVersionUID = 1L ;
// les élément de create
private JTree tree = new JTree ( ) ;
2022-06-05 18:42:06 +02:00
private afficheText textNodeSelect = new afficheText ( ) ;
2022-06-09 09:13:46 +02:00
private JToolBar toolBar_1 ;
2022-05-28 19:13:25 +02:00
private JMenuBar menuBar = new JMenuBar ( ) ;
2022-06-09 20:35:59 +02:00
JButton buttonEvaluate ;
2022-06-06 18:59:42 +02:00
TreePath cheminVersLeNode ;
2022-06-09 09:13:46 +02:00
JToggleButton tglbtnTousLesNodes ;
2022-05-28 19:13:25 +02:00
/ * *
* Create the application .
* /
public create ( ) {
try {
initialize ( ) ;
} catch ( UnsupportedLookAndFeelException e ) {
e . printStackTrace ( ) ;
}
setVisible ( true ) ;
}
2022-06-03 21:30:14 +02:00
2022-05-28 19:13:25 +02:00
/ * *
* Initialize the contents of the frame .
* @throws UnsupportedLookAndFeelException
* /
private void initialize ( ) throws UnsupportedLookAndFeelException {
2022-06-09 09:13:46 +02:00
setSize ( 1200 , 800 ) ;
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-05-28 19:13:25 +02:00
//setExtendedState(getExtendedState()|JFrame.MAXIMIZED_BOTH );
ImageIcon img = new ImageIcon ( getClass ( ) . getResource ( " /evalwriter.png " ) ) ;
2022-06-06 18:59:42 +02:00
setTitle ( commandes . Titre + " " + commandes . version + " " + commandes . branch ) ;
2022-05-28 19:13:25 +02:00
setIconImage ( img . getImage ( ) ) ;
setLocationRelativeTo ( null ) ;
setDefaultCloseOperation ( JFrame . DISPOSE_ON_CLOSE ) ;
// Construction et injection de la barre de menu
setJMenuBar ( this . createMenuBar ( ) ) ;
2022-06-01 21:38:37 +02:00
tree . setVisibleRowCount ( 30 ) ;
// Ajoute le menu contextuel de la tree
2022-06-02 17:48:14 +02:00
tree . setComponentPopupMenu ( null ) ;
2022-05-28 19:13:25 +02:00
// Construction et injection de la barre d'outils
JPanel contentPane = ( JPanel ) getContentPane ( ) ;
this . createToolBar ( ) ;
2022-06-02 17:48:14 +02:00
this . createPopupMenuTree ( null ) ;
2022-05-28 19:13:25 +02:00
getContentPane ( ) . setLayout ( new BorderLayout ( 2 , 2 ) ) ;
2022-06-09 09:13:46 +02:00
contentPane . add ( toolBar_1 , BorderLayout . NORTH ) ;
2022-06-04 15:43:08 +02:00
2022-05-28 19:13:25 +02:00
// The content of the window
if ( commandes . fichierAnalyseValide ) tree = commandes . tree ;
JScrollPane leftScrollPane = new JScrollPane ( ) ;
2022-06-13 17:43:41 +02:00
leftScrollPane . setPreferredSize ( new Dimension ( 400 , 0 ) ) ;
2022-05-28 19:13:25 +02:00
JScrollPane rightScrollPane = new JScrollPane ( ) ;
JSplitPane splitPane = new JSplitPane ( JSplitPane . HORIZONTAL_SPLIT , leftScrollPane , rightScrollPane ) ;
2022-06-04 15:43:08 +02:00
splitPane . setBounds ( 10 , 10 , 1364 , 783 ) ;
2022-05-28 19:13:25 +02:00
rightScrollPane . setViewportView ( textNodeSelect ) ;
textNodeSelect . setFont ( new Font ( " Monospaced " , Font . PLAIN , 15 ) ) ;
leftScrollPane . setViewportView ( tree ) ;
tree . setFont ( new Font ( " Tahoma " , Font . PLAIN , 14 ) ) ;
2022-06-06 09:50:45 +02:00
getContentPane ( ) . add ( splitPane , BorderLayout . CENTER ) ;
2022-06-01 21:38:37 +02:00
2022-06-02 15:47:54 +02:00
if ( commandes . fichierAnalyseValide ) constructionTree ( ) ;
2022-06-06 09:50:45 +02:00
this . setExtendedState ( MAXIMIZED_BOTH ) ;
2022-05-28 19:13:25 +02:00
ListenerAction ( ) ;
}
private void ListenerAction ( ) {
tree . addMouseListener ( new MouseAdapter ( ) {
@Override
public void mouseClicked ( MouseEvent e ) {
2022-06-01 21:38:37 +02:00
if ( tree . getSelectionPath ( ) ! = null ) {
2022-06-05 18:42:06 +02:00
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
createPopupMenuTree ( nod ) ;
textNodeSelect . refreshAffichage ( nod ) ;
2022-05-28 19:13:25 +02:00
}
2022-06-01 21:38:37 +02:00
}
} ) ;
2022-06-02 15:47:54 +02:00
2022-06-13 17:43:41 +02:00
2022-06-01 21:38:37 +02:00
}
2022-06-04 15:43:08 +02:00
2022-06-06 18:59:42 +02:00
/ * *
* Calcul le total des points dans le node et les nodes enfants .
* @param nod
* @param point
* @return
* /
private int calculNombreDepoint ( node nod , int point ) {
System . out . println ( " début du calcul du nombre de point du node " + nod . getNomElt ( ) ) ;
if ( nod . getAttributs ( ) . get ( " evaluer " ) ! = null ) if ( nod . getAttributs ( ) . get ( " evaluer " ) . equalsIgnoreCase ( " true " ) ) {
if ( nod . getAttributs ( ) . get ( " allContent " ) ! = null ) {
Pattern pt = Pattern . compile ( " [0-9]{1,}$ " ) ;
Matcher match = pt . matcher ( nod . getAttributs ( ) . get ( " allContent " ) ) ;
if ( match . find ( ) ) {
String s = match . group ( ) ;
try {
point = point + Integer . valueOf ( s ) ;
} catch ( Exception e ) {
JOptionPane . showInternalMessageDialog ( null , " Erreur dans la valeur de l'attribut allContent " ) ;
}
System . out . println ( " match point pour allcontent = " + s ) ;
}
}
if ( nod . getAttributs ( ) . get ( " evalNameInitialCreator " ) ! = null ) {
try {
point = point + Integer . valueOf ( nod . getAttributs ( ) . get ( " evalNameInitialCreator " ) ) ;
} catch ( Exception e ) {
JOptionPane . showInternalMessageDialog ( null , " Erreur dans la valeur de l'attribut evalNameInitialCreator " ) ;
}
}
if ( nod . getAttributs ( ) . get ( " evalNameCreator " ) ! = null ) {
try {
point = point + Integer . valueOf ( nod . getAttributs ( ) . get ( " evalNameCreator " ) ) ;
} catch ( Exception e ) {
2022-06-10 12:24:43 +02:00
JOptionPane . showInternalMessageDialog ( null , " Erreur dans la valeur de l'attribut evalNameCreator " ) ;
}
}
if ( nod . getAttributs ( ) . get ( " evalNameNode " ) ! = null ) {
try {
point = point + Integer . valueOf ( nod . getAttributs ( ) . get ( " evalNameNode " ) ) ;
} catch ( Exception e ) {
2022-06-06 18:59:42 +02:00
JOptionPane . showInternalMessageDialog ( null , " Erreur dans la valeur de l'attribut evalNameCreator " ) ;
}
}
Enumeration < String > key = nod . getAttributs ( ) . keys ( ) ;
while ( key . hasMoreElements ( ) ) {
String k = key . nextElement ( ) ;
if ( nod . getAttributs ( ) . get ( k ) . contains ( " ‽ " ) | | nod . getAttributs ( ) . get ( k ) . contains ( " ‼ " ) ) {
Pattern pt = Pattern . compile ( " [0-9]{1,}$ " ) ;
Matcher match = pt . matcher ( nod . getAttributs ( ) . get ( k ) ) ;
if ( match . find ( ) ) {
String s = match . group ( ) ;
try {
point = point + Integer . valueOf ( s ) ;
} catch ( Exception e ) {
JOptionPane . showInternalMessageDialog ( null , " Erreur dans la valeur de l'attribut " + k ) ;
}
}
}
}
for ( int i = 0 ; i < nod . getNodes ( ) . size ( ) ; i + + ) {
if ( nod . getNodes ( ) . get ( i ) ! = null ) {
point = calculNombreDepoint ( nod . getNodes ( ) . get ( i ) , point ) ;
}
}
}
return point ;
}
2022-06-01 21:38:37 +02:00
/ * *
* Création du menu contextuel du tree
* @return
* /
2022-06-02 17:48:14 +02:00
private void createPopupMenuTree ( node nod ) {
2022-06-04 21:12:59 +02:00
2022-06-02 17:48:14 +02:00
if ( nod ! = null ) {
2022-06-02 22:19:32 +02:00
2022-06-05 11:19:09 +02:00
boolean nodeSetting = false ;
2022-06-10 09:36:23 +02:00
boolean nodeFormatageDirectePasDeTitrePasAddMenu = false ;
2022-06-04 21:12:59 +02:00
2022-06-05 11:19:09 +02:00
if ( nod . chemin ( ) . contains ( " setting " ) ) nodeSetting = true ;
2022-06-02 22:19:32 +02:00
2022-06-10 09:36:23 +02:00
node nodStyleParent = nod . retourneParentAyantLAttribut ( " style:name " ) ;
if ( nodStyleParent ! = null ) {
String nomDuStle = nodStyleParent . getAttributs ( ) . get ( " style:name " ) ;
Pattern p = Pattern . compile ( " ^P[0-9]{1,}$|^T[0-9]{1,}$ " ) ;
Matcher m = p . matcher ( nomDuStle ) ;
if ( m . find ( ) ) {
nodeFormatageDirectePasDeTitrePasAddMenu = true ;
}
}
2022-06-05 11:19:09 +02:00
//Menu Evaluer
2022-06-02 17:48:14 +02:00
JMenu mnEvaluer = new JMenu ( " Evaluer " ) ;
mnEvaluer . add ( actEvalueTrue ) ;
mnEvaluer . add ( actEvalueFalse ) ;
2022-06-05 11:19:09 +02:00
//Menu arbre
2022-06-02 17:48:14 +02:00
JMenu mnManageTree = new JMenu ( " Arbre " ) ;
2022-06-04 21:12:59 +02:00
mnManageTree . add ( actUpNode ) ;
mnManageTree . add ( actDownNode ) ;
mnManageTree . addSeparator ( ) ;
2022-06-02 17:48:14 +02:00
mnManageTree . add ( actExpandAll ) ;
mnManageTree . add ( actExpandNode ) ;
mnManageTree . addSeparator ( ) ;
mnManageTree . add ( actCollapseAll ) ;
mnManageTree . add ( actCollapseNode ) ;
2022-06-06 18:59:42 +02:00
//Menu Saut niveau >1
2022-06-02 22:19:32 +02:00
JMenu mnSaut = new JMenu ( " Saut de ligne avant " ) ;
mnSaut . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/sautmini.png " ) ) ) ;
mnSaut . add ( actsauttrue ) ;
mnSaut . add ( actsautfalse ) ;
2022-06-02 17:48:14 +02:00
2022-06-06 18:59:42 +02:00
//Menu saut niveau = 1
2022-06-05 11:19:09 +02:00
//Menu Saut
JMenu mnSautNiveau1 = new JMenu ( " Saut de ligne avant " ) ;
mnSautNiveau1 . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/sautmini.png " ) ) ) ;
mnSautNiveau1 . add ( actsauttrue ) ;
mnSautNiveau1 . add ( actsautfalse ) ;
2022-06-06 18:59:42 +02:00
//Menu Titre niveau > 1
2022-06-02 22:19:32 +02:00
JMenu mnTitre = new JMenu ( " Titre " ) ;
mnTitre . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/titremini.png " ) ) ) ;
mnTitre . add ( actTitrePrincipal ) ;
mnTitre . add ( actTitre1 ) ;
mnTitre . add ( actTitre2 ) ;
mnTitre . add ( actTitre3 ) ;
2022-06-04 21:12:59 +02:00
mnTitre . addSeparator ( ) ;
mnTitre . add ( actSupprimeTitre ) ;
2022-06-02 17:48:14 +02:00
2022-06-06 18:59:42 +02:00
//Menu Titre niveau = 1
2022-06-05 11:19:09 +02:00
JMenu mnTitreNiveau1 = new JMenu ( " Titre " ) ;
mnTitreNiveau1 . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/titremini.png " ) ) ) ;
mnTitreNiveau1 . add ( actTitrePrincipal ) ;
mnTitreNiveau1 . add ( actTitre1 ) ;
mnTitreNiveau1 . add ( actTitre2 ) ;
mnTitreNiveau1 . add ( actTitre3 ) ;
mnTitreNiveau1 . addSeparator ( ) ;
mnTitreNiveau1 . add ( actSupprimeTitre ) ;
2022-06-02 22:19:32 +02:00
2022-06-06 18:59:42 +02:00
//Menu ajoute un lien de menu niveau 1
JMenu mnAddMenuNiveau1 = new JMenu ( " Lien " ) ; //addMenu
mnAddMenuNiveau1 . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/addmenumini.png " ) ) ) ;
mnAddMenuNiveau1 . add ( actAddMenuTrue ) ;
mnAddMenuNiveau1 . add ( actAddMenuFalse ) ;
2022-06-02 22:19:32 +02:00
2022-06-06 18:59:42 +02:00
//Menu ajoute un lien de menu niveau sup 1
JMenu mnAddMenuNiveauSup1 = new JMenu ( " Lien " ) ; //addMenu
mnAddMenuNiveauSup1 . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/addmenumini.png " ) ) ) ;
mnAddMenuNiveauSup1 . add ( actAddMenuTrue ) ;
mnAddMenuNiveauSup1 . add ( actAddMenuFalse ) ;
//Menu recherche par l'index
JMenu mnRechercheIndex = new JMenu ( " Recherche par l'index " ) ;
mnRechercheIndex . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/rechercheindexmini.png " ) ) ) ;
mnRechercheIndex . add ( actRechercheIndextrue ) ;
mnRechercheIndex . addSeparator ( ) ;
mnRechercheIndex . add ( actRechercheIndexfalse ) ;
2022-06-09 20:35:59 +02:00
//Menu recherche par le contenu Exact
JMenu mnRechercheContenu = new JMenu ( " Recherche par le contenu exact " ) ;
2022-06-06 18:59:42 +02:00
mnRechercheContenu . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/recherchecontenumini.png " ) ) ) ;
mnRechercheContenu . add ( actRechercheContenutrue ) ;
mnRechercheContenu . addSeparator ( ) ;
mnRechercheContenu . add ( actRechercheContenufalse ) ;
2022-06-09 20:35:59 +02:00
//Menu recherche par le contenu plus proche voisin
2022-06-11 12:10:28 +02:00
JMenu mnRechercheContenuPlusProcheVoisin = new JMenu ( " Recherche par le plus proche voisin " ) ;
2022-06-09 20:35:59 +02:00
mnRechercheContenuPlusProcheVoisin . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/recherchecontenuplusprochevoisin.png " ) ) ) ;
mnRechercheContenuPlusProcheVoisin . add ( actRechercheContenuPlusProcheVoisintrue ) ;
mnRechercheContenuPlusProcheVoisin . addSeparator ( ) ;
mnRechercheContenuPlusProcheVoisin . add ( actRechercheContenuPlusProcheVoisinfalse ) ;
2022-06-09 09:13:46 +02:00
//Menu analyseStyle (évaluer le style du paragraphe)
2022-06-06 18:59:42 +02:00
JMenu mnAnalyseStyle = new JMenu ( " Evaluer le style " ) ;
mnAnalyseStyle . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evaluerstylemini.png " ) ) ) ;
mnAnalyseStyle . add ( actEvaluerStyleTrue ) ;
mnAnalyseStyle . addSeparator ( ) ;
mnAnalyseStyle . add ( actEvaluerStyleFalse ) ;
//Menu Evaluer présence d'un node pour les nodes de niveau > 1
2022-06-04 21:12:59 +02:00
JMenu mnEvalNameNode = new JMenu ( " Evaluer la présence du node " ) ;
mnEvalNameNode . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evalnodemini.png " ) ) ) ;
mnEvalNameNode . add ( actEvalNameNodeOui ) ;
mnEvalNameNode . add ( actEvalNameNodeNon ) ;
2022-06-02 22:19:32 +02:00
2022-06-09 09:13:46 +02:00
//Menue Recherche par le numéro de la page ancrer
JMenu mnRechercheParNumeroPageAncrer = new JMenu ( " Recherche par le numéro de la page " ) ;
mnRechercheParNumeroPageAncrer . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/rechercheancragepagemini.png " ) ) ) ;
mnRechercheParNumeroPageAncrer . add ( actRechercheAnchorPageNumberTrue ) ;
mnRechercheParNumeroPageAncrer . addSeparator ( ) ;
mnRechercheParNumeroPageAncrer . add ( actRechercheAnchorPageNumberFalse ) ;
2022-06-06 18:59:42 +02:00
//***************************
//** Menu node niveau = 1 ***
//***************************
2022-06-05 11:19:09 +02:00
JMenu mnNiveau1 = new JMenu ( " Attributs aW, niveau 1 " ) ;
2022-06-09 09:13:46 +02:00
mnNiveau1 . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/attributanalysewritermini.png " ) ) ) ;
2022-06-05 11:19:09 +02:00
mnNiveau1 . add ( actCoefficient ) ;
mnNiveau1 . addSeparator ( ) ;
mnNiveau1 . add ( mnSautNiveau1 ) ;
mnNiveau1 . addSeparator ( ) ;
mnNiveau1 . add ( mnTitreNiveau1 ) ;
2022-06-06 18:59:42 +02:00
mnNiveau1 . addSeparator ( ) ;
mnNiveau1 . add ( mnAddMenuNiveau1 ) ;
2022-06-05 11:19:09 +02:00
2022-06-06 18:59:42 +02:00
//***************************
//** Menu node niveau > 1 ***
//***************************
2022-06-05 11:19:09 +02:00
JMenu mnNiveauSup1 = new JMenu ( " Attributs aW, niveau " + String . valueOf ( nod . getLevel ( ) + " " ) ) ;
2022-06-06 18:59:42 +02:00
mnNiveauSup1 . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/attributanalysewritermini.png " ) ) ) ;
JMenu mnPourFeedback = new JMenu ( " Pour représentation feedback " ) ;
mnPourFeedback . add ( mnSaut ) ;
2022-06-10 09:36:23 +02:00
if ( ! nodeFormatageDirectePasDeTitrePasAddMenu ) {
mnPourFeedback . addSeparator ( ) ;
mnPourFeedback . add ( mnTitre ) ;
mnPourFeedback . addSeparator ( ) ;
mnPourFeedback . add ( mnAddMenuNiveauSup1 ) ;
}
2022-06-06 18:59:42 +02:00
mnNiveauSup1 . add ( mnPourFeedback ) ;
2022-06-05 11:19:09 +02:00
if ( ! nod . getNomElt ( ) . equals ( " page " ) ) {
mnNiveauSup1 . addSeparator ( ) ;
mnNiveauSup1 . add ( mnEvalNameNode ) ;
2022-06-02 22:19:32 +02:00
}
2022-06-05 11:19:09 +02:00
mnNiveauSup1 . addSeparator ( ) ;
mnNiveauSup1 . add ( actAllContent ) ;
2022-06-02 22:19:32 +02:00
if ( nod . getNomElt ( ) . equals ( " meta:initial-creator " ) ) {
2022-06-05 11:19:09 +02:00
mnNiveauSup1 . addSeparator ( ) ;
mnNiveauSup1 . add ( actEvalInitialCreator ) ;
2022-06-02 22:19:32 +02:00
}
2022-06-06 09:50:45 +02:00
if ( nod . getNomElt ( ) . equals ( " dc:creator " ) ) {
mnNiveauSup1 . addSeparator ( ) ;
mnNiveauSup1 . add ( actevalNameCreator ) ;
}
2022-06-10 09:36:23 +02:00
if ( ecritureSujet . listeDesNodesByRecherche ( nod . getNomElt ( ) ) ) {
2022-06-06 18:59:42 +02:00
mnNiveauSup1 . addSeparator ( ) ;
mnNiveauSup1 . add ( mnRechercheIndex ) ;
mnNiveauSup1 . addSeparator ( ) ;
mnNiveauSup1 . add ( mnRechercheContenu ) ;
mnNiveauSup1 . addSeparator ( ) ;
2022-06-09 20:35:59 +02:00
mnNiveauSup1 . add ( mnRechercheContenuPlusProcheVoisin ) ;
mnNiveauSup1 . addSeparator ( ) ;
2022-06-06 18:59:42 +02:00
mnNiveauSup1 . add ( mnAnalyseStyle ) ;
}
2022-06-09 09:13:46 +02:00
if ( ecritureSujet . listeDesRechercheAnchorPageNumber ( nod . getNomElt ( ) ) ) {
mnNiveauSup1 . addSeparator ( ) ;
mnNiveauSup1 . add ( mnRechercheParNumeroPageAncrer ) ;
}
2022-06-05 11:19:09 +02:00
2022-06-02 22:19:32 +02:00
2022-06-05 11:19:09 +02:00
//**Menu setting
JMenu mnSetting = new JMenu ( " Les paramètres " ) ;
mnSetting . add ( " CSV " ) ;
mnSetting . add ( " ZIP feedback " ) ;
mnSetting . add ( " plagiarism " ) ;
mnSetting . add ( " text:similarity " ) ;
mnSetting . add ( " translation " ) ;
//La popupMenu qui s'affiche sur le tree
2022-06-02 22:19:32 +02:00
JPopupMenu mnPopupTree = new JPopupMenu ( ) ;
2022-06-05 11:19:09 +02:00
if ( ! nodeSetting ) {
mnPopupTree . add ( mnEvaluer ) ;
}
if ( nod . getLevel ( ) = = 1 & & ! nodeSetting ) {
2022-06-02 17:48:14 +02:00
mnPopupTree . addSeparator ( ) ;
2022-06-05 11:19:09 +02:00
mnPopupTree . add ( mnNiveau1 ) ;
2022-06-02 17:48:14 +02:00
}
2022-06-05 11:19:09 +02:00
if ( nod . getLevel ( ) > 1 & & ! nodeSetting ) {
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( mnNiveauSup1 ) ;
2022-06-02 22:19:32 +02:00
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( actAttribut ) ;
}
2022-06-05 11:19:09 +02:00
if ( nodeSetting ) {
mnPopupTree . add ( mnSetting ) ;
}
2022-06-02 17:48:14 +02:00
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( mnManageTree ) ;
2022-06-05 11:19:09 +02:00
if ( ! nodeSetting ) {
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( actDeleteNode ) ;
}
2022-06-02 17:48:14 +02:00
tree . setComponentPopupMenu ( mnPopupTree ) ;
2022-06-05 18:42:06 +02:00
}
2022-05-28 19:13:25 +02:00
}
2022-06-01 21:38:37 +02:00
2022-05-28 19:13:25 +02:00
/* Methode de construction de la barre de menu */
private JMenuBar createMenuBar ( ) {
// La barre de menu à proprement parler
menuBar = new JMenuBar ( ) ;
// Définition du menu déroulant "File" et de son contenu
JMenu mnuFile = new JMenu ( " Fichier " ) ;
mnuFile . setMnemonic ( 'F' ) ;
/*JMenuItem mnuNewFile =*/
2022-06-06 09:50:45 +02:00
mnuFile . add ( actOpen ) ;
mnuFile . add ( actNewFichierAnalyse ) ;
mnuFile . addSeparator ( ) ;
2022-05-28 19:13:25 +02:00
mnuFile . add ( actSave ) ;
mnuFile . add ( actSaveAs ) ;
mnuFile . addSeparator ( ) ;
mnuFile . add ( actExit ) ;
menuBar . add ( mnuFile ) ;
// Définition du menu déroulant "Edit" et de son contenu
JMenu mnuEdit = new JMenu ( " Edition " ) ;
mnuEdit . setMnemonic ( 'E' ) ;
mnuEdit . add ( actUndo ) ;
mnuEdit . add ( actRedo ) ;
mnuEdit . addSeparator ( ) ;
mnuEdit . add ( actCopy ) ;
mnuEdit . add ( actCut ) ;
mnuEdit . add ( actPaste ) ;
menuBar . add ( mnuEdit ) ;
2022-06-06 09:50:45 +02:00
// Définition du menu Node
JMenu mnNode = new JMenu ( " Modifier " ) ;
mnNode . add ( actNodeFichier ) ;
mnNode . addSeparator ( ) ;
menuBar . add ( mnNode ) ;
//Menu arbre
JMenu mnManageTree = new JMenu ( " Arbre " ) ;
mnManageTree . add ( actUpNode ) ;
mnManageTree . add ( actDownNode ) ;
mnManageTree . addSeparator ( ) ;
mnManageTree . add ( actExpandAll ) ;
mnManageTree . add ( actExpandNode ) ;
mnManageTree . addSeparator ( ) ;
mnManageTree . add ( actCollapseAll ) ;
mnManageTree . add ( actCollapseNode ) ;
mnNode . add ( mnManageTree ) ;
mnNode . addSeparator ( ) ;
//Définition Evaluer
JMenu mnEvaluer = new JMenu ( " Evaluer " ) ;
mnEvaluer . add ( actEvalueTrue ) ;
mnEvaluer . add ( actEvalueFalse ) ;
mnNode . add ( mnEvaluer ) ;
2022-06-01 21:38:37 +02:00
2022-06-06 09:50:45 +02:00
// Définition du menu déroulant "Création évaluation" et de son contenu
2022-05-28 19:13:25 +02:00
JMenu mnuExercice = new JMenu ( " Création évaluation " ) ;
mnuExercice . setMnemonic ( 'N' ) ;
mnuExercice . add ( actEvaluer ) ;
menuBar . add ( mnuExercice ) ;
// Définition du menu déroulant "Help" et de son contenu
JMenu mnuHelp = new JMenu ( " Aide " ) ;
mnuHelp . setMnemonic ( 'H' ) ;
mnuHelp . add ( actAPropos ) ;
2022-06-01 21:38:37 +02:00
mnuHelp . add ( actDocumentation ) ;
2022-05-28 19:13:25 +02:00
menuBar . add ( mnuHelp ) ;
return menuBar ;
}
/* Methode de construction de la barre d'outils */
private void createToolBar ( ) {
2022-06-09 09:13:46 +02:00
toolBar_1 = new JToolBar ( ) ;
2022-05-28 19:13:25 +02:00
2022-06-09 09:13:46 +02:00
JButton buttonLoadFile = toolBar_1 . add ( actOpen ) ;
2022-05-28 19:13:25 +02:00
buttonLoadFile . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/fichierAnalyse.png " ) ) ) ;
2022-06-01 21:38:37 +02:00
buttonLoadFile . setHideActionText ( true ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( buttonLoadFile ) ;
2022-06-02 15:47:54 +02:00
2022-06-09 09:13:46 +02:00
JButton btnNewFichierAnalyse = toolBar_1 . add ( actNewFichierAnalyse ) ;
2022-06-02 15:47:54 +02:00
btnNewFichierAnalyse . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/fichierODF.png " ) ) ) ;
btnNewFichierAnalyse . setHideActionText ( true ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnNewFichierAnalyse ) ;
toolBar_1 . addSeparator ( ) ;
2022-05-28 19:13:25 +02:00
2022-06-09 20:35:59 +02:00
buttonEvaluate = toolBar_1 . add ( actEvaluer ) ;
buttonEvaluate . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
}
} ) ;
buttonEvaluate . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evaluate.png " ) ) ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . addSeparator ( ) ;
JButton btnAfficheInformationFichierAnalyse = toolBar_1 . add ( actAfficheInformationFichierAnalyse ) ;
btnAfficheInformationFichierAnalyse . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/fichierAnalyseInfo.png " ) ) ) ;
btnAfficheInformationFichierAnalyse . setHideActionText ( true ) ;
toolBar_1 . add ( btnAfficheInformationFichierAnalyse ) ;
JButton btnNodeFichier = toolBar_1 . add ( actNodeFichier ) ;
2022-06-01 21:38:37 +02:00
btnNodeFichier . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/nodeFichier.png " ) ) ) ;
btnNodeFichier . setHideActionText ( true ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnNodeFichier ) ;
2022-05-28 19:13:25 +02:00
2022-06-11 12:10:28 +02:00
JButton btnSetting = new JButton ( " " ) ;
btnSetting . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/setting.png " ) ) ) ;
toolBar_1 . add ( btnSetting ) ;
2022-05-28 19:13:25 +02:00
2022-06-09 09:13:46 +02:00
toolBar_1 . addSeparator ( ) ;
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
JButton btnEvaluerTrue = toolBar_1 . add ( actEvalueTrue ) ;
2022-06-06 18:59:42 +02:00
btnEvaluerTrue . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evaluertrue.png " ) ) ) ;
btnEvaluerTrue . setHideActionText ( true ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnEvaluerTrue ) ;
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
JButton btnEvaluerFalse = toolBar_1 . add ( actEvalueFalse ) ;
2022-06-06 18:59:42 +02:00
btnEvaluerFalse . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evaluerfalse.png " ) ) ) ;
btnEvaluerFalse . setHideActionText ( true ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnEvaluerFalse ) ;
JButton btnEvaluerTouteLaBrancheEtLesEnfantTrue = toolBar_1 . add ( actEvaluerTousEnfantsTrue ) ;
btnEvaluerTouteLaBrancheEtLesEnfantTrue . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evaluertouslesenfants.png " ) ) ) ;
btnEvaluerTouteLaBrancheEtLesEnfantTrue . setHideActionText ( true ) ;
toolBar_1 . add ( btnEvaluerTouteLaBrancheEtLesEnfantTrue ) ;
JButton btnEvaluerTouteLaBrancheEtLesEnfantFalse = toolBar_1 . add ( actEvaluerTousEnfantsFalse ) ;
btnEvaluerTouteLaBrancheEtLesEnfantFalse . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evaluertouslesenfantsfaux.png " ) ) ) ;
btnEvaluerTouteLaBrancheEtLesEnfantTrue . setHideActionText ( true ) ;
toolBar_1 . add ( btnEvaluerTouteLaBrancheEtLesEnfantFalse ) ;
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
toolBar_1 . addSeparator ( ) ;
2022-06-06 18:59:42 +02:00
JButton btnAttribut = new JButton ( actAttribut ) ;
btnAttribut . setText ( " " ) ;
btnAttribut . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/attribut.png " ) ) ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnAttribut ) ;
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
toolBar_1 . addSeparator ( ) ;
2022-06-06 18:59:42 +02:00
JButton btnTotalPoint = new JButton ( actTotalPoint ) ;
btnTotalPoint . setToolTipText ( " " ) ;
btnTotalPoint . setText ( " " ) ;
btnTotalPoint . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/totalpoint.png " ) ) ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnTotalPoint ) ;
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
JButton btnTotalPointNode = toolBar_1 . add ( actTotalPointNode ) ;
2022-06-06 18:59:42 +02:00
btnTotalPointNode . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/totalpointnode.png " ) ) ) ;
btnTotalPointNode . setHideActionText ( true ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnTotalPointNode ) ;
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
toolBar_1 . addSeparator ( ) ;
tglbtnTousLesNodes = new JToggleButton ( " " ) ;
tglbtnTousLesNodes . setAction ( actTousLesNodesEvaluer ) ;
tglbtnTousLesNodes . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/lesnodesevaluer.png " ) ) ) ;
toolBar_1 . add ( tglbtnTousLesNodes ) ;
toolBar_1 . addSeparator ( ) ;
2022-06-04 15:43:08 +02:00
2022-06-09 09:13:46 +02:00
JButton btnAbout = toolBar_1 . add ( actAbout ) ;
2022-05-28 19:13:25 +02:00
btnAbout . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/apropos.png " ) ) ) ;
btnAbout . setHideActionText ( true ) ;
2022-06-09 09:13:46 +02:00
toolBar_1 . add ( btnAbout ) ;
2022-05-28 19:13:25 +02:00
2022-06-01 21:38:37 +02:00
2022-06-09 09:13:46 +02:00
JButton btnNewButton = toolBar_1 . add ( actTutoriels ) ;
btnNewButton . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/tutoriel.png " ) ) ) ;
btnNewButton . setHideActionText ( true ) ;
toolBar_1 . add ( btnNewButton ) ;
toolBar_1 . addSeparator ( ) ;
JButton button_2 = toolBar_1 . add ( actExit ) ;
button_2 . setHideActionText ( true ) ;
2022-06-05 18:42:06 +02:00
2022-05-28 19:13:25 +02:00
}
2022-06-02 17:48:14 +02:00
2022-05-28 19:13:25 +02:00
/ * *
2022-06-01 21:38:37 +02:00
* Ouvre et affiche le fichier d ' analyse
2022-05-28 19:13:25 +02:00
* /
private AbstractAction actOpen = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-01 21:38:37 +02:00
putValue ( Action . NAME , " Ouvrir un fichier d'analyse " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/fichierAnalysemini.png " ) ) ) ;
2022-05-28 19:13:25 +02:00
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_O ) ;
putValue ( Action . SHORT_DESCRIPTION , " Ouvrir un nouveau fichier d'analyse (CTRL+O) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_O , InputEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
new filechooserXML ( ) ;
if ( commandes . fichierAnalyseValide ) {
constructionTree ( ) ;
2022-06-11 12:10:28 +02:00
textNodeSelect . afficheChargementFichierAnalyse ( ) ;
2022-06-02 15:47:54 +02:00
} else {
constructionTree ( ) ;
2022-06-04 21:12:59 +02:00
textNodeSelect . setContentType ( " text/plain " ) ;
2022-06-02 15:47:54 +02:00
textNodeSelect . setText ( commandes . message . toString ( ) ) ;
2022-05-28 19:13:25 +02:00
}
System . out . println ( " Open " ) ;
}
} ;
2022-06-09 09:13:46 +02:00
/ * *
* Affiche le tree contenant tous les nodes
* /
private AbstractAction actTousLesNodesEvaluer = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/touslesnodesmini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Affiche tous les nodes " ) ;
}
@Override
public void actionPerformed ( ActionEvent e ) {
if ( tglbtnTousLesNodes . isSelected ( ) ) {
try {
commandes . sujetSauvegarde = commandes . sujet . clone ( ) ;
commandes . sujet . supprimeTousLesNodesEvaluerFalseOuNull ( ) ;
commandes . fichierAnalyseValide = false ;
2022-06-09 20:35:59 +02:00
textNodeSelect . setContentType ( " text/html " ) ;
2022-06-09 09:13:46 +02:00
textNodeSelect . setText ( " <hr><h1>Affiche uniquement les nodes évalués par l'application.</h1><hr> "
+ " <br><h2><u>Le chemin vers chaque node évalué est constitué de node évalué.</u><br> "
+ " Si vous enregistrez maintenant, vous enregistrez le fichier d'analyse avec <u>uniquement</u> les nodes évalués.</h2> " ) ;
2022-06-09 20:35:59 +02:00
buttonEvaluate . setEnabled ( false ) ;
2022-06-09 09:13:46 +02:00
constructionTree ( ) ;
} catch ( CloneNotSupportedException e1 ) {
e1 . printStackTrace ( ) ;
}
} else {
try {
commandes . sujet = commandes . sujetSauvegarde . clone ( ) ;
2022-06-09 20:35:59 +02:00
buttonEvaluate . setEnabled ( true ) ;
2022-06-09 09:13:46 +02:00
} catch ( CloneNotSupportedException e1 ) {
e1 . printStackTrace ( ) ;
}
2022-06-09 20:35:59 +02:00
textNodeSelect . setContentType ( " text/html " ) ;
2022-06-09 09:13:46 +02:00
textNodeSelect . setText ( " <hr><h1>Affiche tous les nodes évalués ou pas.</h1><hr> " ) ;
commandes . fichierAnalyseValide = true ;
constructionTree ( ) ;
}
}
} ;
2022-06-01 21:38:37 +02:00
/ * *
*
* /
private AbstractAction actNodeFichier = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Modifier les paramètres de l'évaluation " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/nodeFichiermini.png " ) ) ) ;
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( create . class . getResource ( " /resources/nodeFichier.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Modifier les paramètres de l'évaluation " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
2022-06-02 15:47:54 +02:00
if ( commandes . sujet . getNomElt ( ) . equals ( " fichier " ) ) {
2022-06-11 12:10:28 +02:00
new proprieteFichierAnalyse ( textNodeSelect ) ;
2022-06-02 15:47:54 +02:00
2022-06-01 21:38:37 +02:00
}
2022-06-02 15:47:54 +02:00
System . out . println ( " ouvre la fenêtre propriété du fichier d'analyse " ) ;
2022-06-01 21:38:37 +02:00
}
} ;
2022-06-02 22:19:32 +02:00
/ * *
*
* /
private AbstractAction actAttribut = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-05 11:19:09 +02:00
putValue ( Action . NAME , " Evaluer les attributs Writer " ) ;
2022-06-02 22:19:32 +02:00
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/attributmini.png " ) ) ) ;
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( create . class . getResource ( " /resources/attributmini.png " ) ) ) ;
2022-06-09 17:49:22 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Evaluer les attributs du traitement de texte Writer " ) ;
2022-06-02 22:19:32 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
2022-06-03 21:30:14 +02:00
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-06 18:59:42 +02:00
int nbrAttribut = nod . getAttributs ( ) . size ( ) ;
System . out . println ( " Nbr attribut brut = " + nbrAttribut ) ;
Enumeration < String > k = nod . getAttributs ( ) . keys ( ) ;
while ( k . hasMoreElements ( ) ) {
String key = k . nextElement ( ) ;
if ( listeAttributsAnalyseWriter . isAttributAnalyseWriter ( key ) ) {
nbrAttribut - - ;
}
}
System . out . println ( " Nbr attribut writer = " + nbrAttribut ) ;
if ( nbrAttribut > 0 ) {
if ( nod . getLevel ( ) > 1 & & ! nod . chemin ( ) . contains ( " setting " ) ) {
new attributs ( nod , textNodeSelect ) ;
} else {
JOptionPane . showMessageDialog ( null , " Vous ne pouvez pas modifier les attributs de ce node. " ) ;
}
} else {
JOptionPane . showMessageDialog ( null , " Ce node ne contient pas d'attribut Writer. " ) ;
}
2022-06-03 21:30:14 +02:00
System . out . println ( " ouvre la fenêtre attributs " ) ;
2022-06-02 22:19:32 +02:00
}
} ;
2022-05-28 19:13:25 +02:00
/ * *
* Affiche la fenêtre d ' information sur analyseWriter
* /
private AbstractAction actAbout = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-01 21:38:37 +02:00
putValue ( Action . NAME , " Informations " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/aproposmini.png " ) ) ) ;
2022-05-28 19:13:25 +02:00
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_I ) ;
putValue ( Action . SHORT_DESCRIPTION , " Informations (CTRL+I) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_I , InputEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
new about ( ) ;
System . out . println ( " About " ) ;
}
} ;
2022-06-03 21:30:14 +02:00
2022-05-28 19:13:25 +02:00
/ * *
2022-06-06 09:50:45 +02:00
* Enregistrer
2022-05-28 19:13:25 +02:00
* /
private AbstractAction actSave = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Enregister " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /save.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_S ) ;
2022-06-01 21:38:37 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Enregistrer (CTRL+S) " ) ;
2022-05-28 19:13:25 +02:00
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_S , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
Pattern p = Pattern . compile ( " [.xml] \\ b " ) ;
Matcher m = p . matcher ( commandes . nameSujet ) ;
2022-06-02 15:47:54 +02:00
String message = " " ;
2022-05-28 19:13:25 +02:00
if ( m . find ( ) ) {
message = " \" Voulez-vous enregistrer le fichier \" " + commandes . nameSujet + " \" \ n "
2022-06-09 17:49:22 +02:00
+ " Dans le dossier " + commandes . PathFilenameAnalysis ;
2022-06-02 15:47:54 +02:00
} else {
message = " \" Voulez-vous enregistrer le fichier \" " + commandes . nameSujet + " .xml \" \ n "
2022-06-09 17:49:22 +02:00
+ " Dans le dossier " + commandes . PathFilenameAnalysis ;
2022-06-02 15:47:54 +02:00
commandes . nameSujet = commandes . nameSujet + " .xml " ;
2022-05-28 19:13:25 +02:00
}
int input = JOptionPane . showConfirmDialog ( null , message ) ;
if ( input = = 0 ) {
try {
2022-06-02 15:47:54 +02:00
verificationFichierAnalyse . MiseAJourHashNomFichierAnalyse ( commandes . nameSujet ) ;
2022-06-09 17:49:22 +02:00
Run . ecritureNodeEnXML ( commandes . sujet , commandes . nameSujet , commandes . PathFilenameAnalysis , " sujet " ) ;
2022-05-28 19:13:25 +02:00
if ( m . find ( ) ) {
2022-06-09 20:35:59 +02:00
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " a été réenregistré. \ n \ n "
+ " Il se trouve dans le dossier " + commandes . PathFilenameAnalysis ) ;
2022-05-28 19:13:25 +02:00
} else {
2022-06-09 20:35:59 +02:00
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " .xml \" a été réenregistré. \ n \ n "
+ " Il se trouve dans le dossier " + commandes . PathFilenameAnalysis ) ;
2022-05-28 19:13:25 +02:00
}
System . out . println ( input + " Save " ) ;
2022-06-02 15:47:54 +02:00
} catch ( IOException | CloneNotSupportedException e1 ) {
2022-05-28 19:13:25 +02:00
e1 . printStackTrace ( ) ;
}
}
}
} ;
/ * *
2022-06-06 09:50:45 +02:00
* Enregistrer sous . . .
2022-05-28 19:13:25 +02:00
* /
private AbstractAction actSaveAs = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Enregistrer sous... " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /save_as.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_A ) ;
2022-06-01 21:38:37 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Enregistrer sous... " ) ;
2022-05-28 19:13:25 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
JFileChooser fileChooser = new JFileChooser ( ) ;
fileChooser . setDialogTitle ( " Enregistrer sous... " ) ;
File file = null ;
if ( ! commandes . nameSujet . isEmpty ( ) ) {
2022-06-09 17:49:22 +02:00
file = new File ( commandes . PathFilenameAnalysis ) ; //+ "\\" + utils.filename + ".xml"
2022-05-28 19:13:25 +02:00
}
2022-06-02 15:47:54 +02:00
2022-05-28 19:13:25 +02:00
fileChooser . setCurrentDirectory ( file ) ;
int userSelection = fileChooser . showSaveDialog ( null ) ;
if ( userSelection = = JFileChooser . APPROVE_OPTION ) {
File fileToSave = fileChooser . getSelectedFile ( ) ;
try {
2022-06-02 15:47:54 +02:00
verificationFichierAnalyse . MiseAJourHashNomFichierAnalyse ( fileToSave . getName ( ) ) ;
2022-05-28 19:13:25 +02:00
Run . ecritureNodeEnXML ( commandes . sujet , fileToSave . getName ( ) , fileToSave . getPath ( ) . substring ( 0 , fileToSave . getPath ( ) . lastIndexOf ( " \\ " ) ) , " sujet " ) ;
commandes . nameSujet = fileToSave . getName ( ) ;
2022-06-09 17:49:22 +02:00
commandes . PathFilenameAnalysis = fileToSave . getPath ( ) . substring ( 0 , fileToSave . getPath ( ) . lastIndexOf ( " \\ " ) ) ;
2022-05-28 19:13:25 +02:00
Pattern p = Pattern . compile ( " [.xml] \\ b " ) ;
Matcher m = p . matcher ( commandes . nameSujet ) ;
if ( m . find ( ) ) {
2022-06-09 17:49:22 +02:00
file = new File ( commandes . PathFilenameAnalysis + " \\ " + commandes . nameSujet ) ;
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " a été renregistré. \ n \ nIl se trouve dans le dossier " + commandes . PathFilenameAnalysis ) ;
2022-05-28 19:13:25 +02:00
} else {
2022-06-09 17:49:22 +02:00
file = new File ( commandes . PathFilenameAnalysis + " \\ " + commandes . nameSujet + " .xml " ) ;
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " .xml \" a été renregistré. \ n \ nIl se trouve dans le dossier " + commandes . PathFilenameAnalysis ) ;
2022-05-28 19:13:25 +02:00
}
} catch ( IOException e1 ) {
e1 . printStackTrace ( ) ;
2022-06-02 15:47:54 +02:00
} catch ( CloneNotSupportedException e1 ) {
e1 . printStackTrace ( ) ;
}
2022-05-28 19:13:25 +02:00
System . out . println ( " Save as file: " + fileToSave . getAbsolutePath ( ) ) ;
}
System . out . println ( " Save as " ) ;
}
} ;
/ * *
* Quitter l ' application
* /
private AbstractAction actExit = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-01 21:38:37 +02:00
putValue ( Action . NAME , " Quitter " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/exitmini.png " ) ) ) ;
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( create . class . getResource ( " /resources/exit.png " ) ) ) ;
2022-05-28 19:13:25 +02:00
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_Q ) ;
putValue ( Action . SHORT_DESCRIPTION , " Quitter (CRTL+Q) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_Q , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
int a = JOptionPane . showConfirmDialog ( null , " Voulez-vous quitter l'application? " , " Sélectionner un choix " , JOptionPane . YES_NO_OPTION ) ;
if ( a = = JOptionPane . YES_NO_OPTION ) {
System . out . println ( " Le choix : " + a ) ;
System . out . println ( " Exit " + e . getSource ( ) . toString ( ) ) ;
create . this . dispose ( ) ;
}
}
} ;
2022-06-01 21:38:37 +02:00
2022-05-28 19:13:25 +02:00
/ * *
*
* /
private AbstractAction actUndo = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Annuler " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /undo.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_U ) ;
putValue ( Action . SHORT_DESCRIPTION , " Annuler (CTRL+Z) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_Z , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
System . out . println ( " Undo " ) ;
}
} ;
/ * *
*
* /
private AbstractAction actRedo = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Refaire " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /redo.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_R ) ;
putValue ( Action . SHORT_DESCRIPTION , " Refaire (CTRL+U) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_U , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
System . out . println ( " Redo " ) ;
}
} ;
/ * *
*
* /
private AbstractAction actCopy = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Copier " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /copy.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_C ) ;
putValue ( Action . SHORT_DESCRIPTION , " Copier (CTRL+C) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_C , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
System . out . println ( " Copy " ) ;
}
} ;
2022-06-09 09:13:46 +02:00
/ * *
*
* /
private AbstractAction actAfficheInformationFichierAnalyse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Affiche informations " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Affiche les informations du fichier d'analyse. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
textNodeSelect . afficheChargementFichierAnalyse ( ) ;
}
} ;
2022-05-28 19:13:25 +02:00
/ * *
*
* /
private AbstractAction actCut = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Couper " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /cut.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_T ) ;
putValue ( Action . SHORT_DESCRIPTION , " Couper (CTRL+X) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_X , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
System . out . println ( " Cut " ) ;
}
} ;
2022-06-02 17:48:14 +02:00
/ * *
2022-06-02 22:19:32 +02:00
* Ajoute ou modifie le poid d ' un node
2022-06-02 17:48:14 +02:00
* /
private AbstractAction actCoefficient = new 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 ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-05 11:19:09 +02:00
double poids = 1 . 00 ;
2022-06-02 17:48:14 +02:00
if ( nod . getAttributs ( ) . get ( " poids " ) ! = null ) {
2022-06-05 11:19:09 +02:00
try {
poids = Double . valueOf ( nod . getAttributs ( ) . get ( " poids " ) ) ;
} catch ( Exception e2 ) {
System . out . println ( e2 . toString ( ) ) ;
}
2022-06-02 17:48:14 +02:00
}
String a = JOptionPane . showInputDialog ( null , " Quel est le coefficient de cette partie de l'évaluation? " , poids ) ;
if ( ! a . isEmpty ( ) ) {
try {
2022-06-05 11:19:09 +02:00
poids = Double . valueOf ( a ) ;
2022-06-02 17:48:14 +02:00
if ( poids < = 0 ) {
2022-06-05 11:19:09 +02:00
nod . poids ( Double . valueOf ( 1 ) ) ;
2022-06-02 17:48:14 +02:00
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . 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 {
2022-06-05 11:19:09 +02:00
nod . poids ( Double . valueOf ( poids ) ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
2022-06-02 17:48:14 +02:00
}
} catch ( Exception e2 ) {
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . setText ( " <h2>Erreur la valeur doit être un nombre entier.<br>La valeur n'a pas été modifiée.</h2> " ) ;
}
}
}
} ;
2022-06-02 22:19:32 +02:00
2022-06-04 21:12:59 +02:00
/ * *
* Evalue la présence de ce node
* /
private AbstractAction actEvalNameNodeOui = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Oui, combien de point? " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer la présence de ce node " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
int point = 0 ;
if ( nod . getAttributs ( ) . get ( " evalNameNode " ) ! = null ) {
point = Integer . valueOf ( nod . getAttributs ( ) . get ( " evalNameNode " ) ) ;
}
String a = JOptionPane . showInputDialog ( null , " Quel est le nombre de point? " , point ) ;
if ( ! a . isEmpty ( ) ) {
try {
point = Integer . valueOf ( a ) ;
if ( point < = 0 ) {
nod . getAttributs ( ) . put ( " evalNameNode " , String . valueOf ( 0 ) ) ;
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . setText ( " <h2>Erreur la valeur doit être un nombre entier POSITIF supérieur à zéro.<br>Cependant,la valeur a été modifiée.<br>evalNameNode=0.</h2> " ) ;
} else {
nod . getAttributs ( ) . put ( " evalNameNode " , String . valueOf ( point ) ) ;
}
} catch ( Exception e2 ) {
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . setText ( " <h2>Erreur la valeur doit être un nombre entier.<br>L'attribut n'a pas été modifiée.</h2> " ) ;
}
}
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
2022-06-04 21:12:59 +02:00
}
} ;
2022-06-05 11:19:09 +02:00
/ * *
2022-06-06 09:50:45 +02:00
* Evalue la présence du node meta : initial - creator
2022-06-05 11:19:09 +02:00
* /
private AbstractAction actEvalInitialCreator = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer la présence du premier auteur (créateur) " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer la présence du premier auteur (créateur) " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/auteurcreateurmini.png " ) ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
int point = 0 ;
if ( nod . getAttributs ( ) . get ( " evalNameInitialCreator " ) ! = null ) {
point = Integer . valueOf ( nod . getAttributs ( ) . get ( " evalNameInitialCreator " ) ) ;
}
String a = JOptionPane . showInputDialog ( null , " Quel est le nombre de point? " , point ) ;
if ( ! a . isEmpty ( ) ) {
try {
point = Integer . valueOf ( a ) ;
if ( point < = 0 ) {
nod . getAttributs ( ) . put ( " evalNameInitialCreator " , String . valueOf ( 0 ) ) ;
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . setText ( " <h2>Erreur la valeur doit être un nombre entier POSITIF supérieur à zéro.<br>Cependant,la valeur a été modifiée.<br>evalNameInitialCreator=0.</h2> " ) ;
} else {
nod . getAttributs ( ) . put ( " evalNameInitialCreator " , String . valueOf ( point ) ) ;
}
} catch ( Exception e2 ) {
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . setText ( " <h2>Erreur la valeur doit être un nombre entier.<br>L'attribut n'a pas été modifiée.</h2> " ) ;
}
}
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
2022-06-05 11:19:09 +02:00
}
} ;
2022-06-06 09:50:45 +02:00
/ * *
* Evalue la présence du node dc : creator
* /
private AbstractAction actevalNameCreator = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer la présence du dernier éditeur " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer la présence du dernier éditeur " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/auteurediteurmini.png " ) ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
int point = 0 ;
if ( nod . getAttributs ( ) . get ( " evalNameCreator " ) ! = null ) {
point = Integer . valueOf ( nod . getAttributs ( ) . get ( " evalNameCreator " ) ) ;
}
String a = JOptionPane . showInputDialog ( null , " Quel est le nombre de point? " , point ) ;
if ( ! a . isEmpty ( ) ) {
try {
point = Integer . valueOf ( a ) ;
if ( point < = 0 ) {
nod . getAttributs ( ) . put ( " evalNameCreator " , String . valueOf ( 0 ) ) ;
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . setText ( " <h2>Erreur la valeur doit être un nombre entier POSITIF supérieur à zéro.<br>Cependant,la valeur a été modifiée.<br>evalNameCreator=0.</h2> " ) ;
} else {
nod . getAttributs ( ) . put ( " evalNameCreator " , String . valueOf ( point ) ) ;
}
} catch ( Exception e2 ) {
textNodeSelect . setText ( balisestyles ( ) ) ;
textNodeSelect . setText ( " <h2>Erreur la valeur doit être un nombre entier.<br>L'attribut n'a pas été modifiée.</h2> " ) ;
}
}
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
2022-06-05 11:19:09 +02:00
/ * *
* Evalue la présence de ce node
* /
private AbstractAction actAllContent = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer le contenu du node " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer le contenu du node " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/allcontentmini.png " ) ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-05 18:42:06 +02:00
new allContent ( nod , textNodeSelect ) ;
2022-06-05 11:19:09 +02:00
}
} ;
2022-06-04 21:12:59 +02:00
/ * *
* Evalue la présence de ce node
* /
private AbstractAction actEvalNameNodeNon = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Supprime l'évaluation de la présence du node " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Supprime l'évaluation de la présence du node " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . supprimeAttribut ( " evalNameNode " ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-04 21:12:59 +02:00
}
} ;
2022-06-02 22:19:32 +02:00
/ * *
* Ajoute ou modifie le titre principal
* /
private AbstractAction actTitrePrincipal = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Titre principal " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Titre principal " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
String titre = " " ;
if ( nod . getAttributs ( ) . get ( " titre " ) ! = null ) {
titre = nod . getAttributs ( ) . get ( " titre " ) ;
}
String a = JOptionPane . showInputDialog ( null , " Quel est le titre? " , titre ) ;
nod . titre ( a ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-02 22:19:32 +02:00
}
} ;
2022-06-06 18:59:42 +02:00
2022-06-04 21:12:59 +02:00
/ * *
* Ajoute ou modifie le titre principal
* /
private AbstractAction actSupprimeTitre = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-11 12:10:28 +02:00
putValue ( Action . NAME , " Supprimer le titre " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Supprime le titre " ) ;
2022-06-04 21:12:59 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
if ( nod . getAttributs ( ) . get ( " titre " ) ! = null ) {
nod . supprimeAttribut ( " titre " ) ;
}
if ( nod . getAttributs ( ) . get ( " titre1 " ) ! = null ) {
nod . supprimeAttribut ( " titre1 " ) ;
}
if ( nod . getAttributs ( ) . get ( " titre2 " ) ! = null ) {
nod . supprimeAttribut ( " titre2 " ) ;
}
if ( nod . getAttributs ( ) . get ( " titre3 " ) ! = null ) {
nod . supprimeAttribut ( " titre3 " ) ;
}
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-04 21:12:59 +02:00
}
} ;
2022-06-02 22:19:32 +02:00
/ * *
* Ajoute ou modifie le titre 1
* /
private AbstractAction actTitre1 = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Titre 1 " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Titre 1 " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
String titre = " " ;
if ( nod . getAttributs ( ) . get ( " titre1 " ) ! = null ) {
titre = nod . getAttributs ( ) . get ( " titre1 " ) ;
}
String a = JOptionPane . showInputDialog ( null , " Quel est le titre? " , titre ) ;
nod . titre1 ( a ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-02 22:19:32 +02:00
}
} ;
/ * *
* Ajoute ou modifie le titre 2
* /
private AbstractAction actTitre2 = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Titre 2 " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Titre 2 " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
String titre = " " ;
if ( nod . getAttributs ( ) . get ( " titre2 " ) ! = null ) {
titre = nod . getAttributs ( ) . get ( " titre2 " ) ;
}
String a = JOptionPane . showInputDialog ( null , " Quel est le titre? " , titre ) ;
nod . titre2 ( a ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-02 22:19:32 +02:00
}
} ;
/ * *
* Ajoute ou modifie le titre 3
* /
private AbstractAction actTitre3 = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Titre 3 " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Titre 3 " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
String titre = " " ;
if ( nod . getAttributs ( ) . get ( " titre3 " ) ! = null ) {
titre = nod . getAttributs ( ) . get ( " titre3 " ) ;
}
String a = JOptionPane . showInputDialog ( null , " Quel est le titre? " , titre ) ;
nod . titre3 ( a ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-02 22:19:32 +02:00
}
} ;
2022-06-06 18:59:42 +02:00
private AbstractAction actTotalPoint = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Nombre de point " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Nombre de points dans le node " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/totalpointmini.png " ) ) ) ;
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( create . class . getResource ( " /resources/totalpoint.png " ) ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
System . out . println ( " Calcul le nombre de point dans le sujet " ) ;
textNodeSelect . AfficheTotalPoint ( commandes . sujet , calculNombreDepoint ( commandes . sujet , 0 ) ) ;
}
} ;
private AbstractAction actTotalPointNode = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Nombre de point " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Nombre de points dans le node " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/totalpointnodemini.png " ) ) ) ;
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( create . class . getResource ( " /resources/totalpointnode.png " ) ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
System . out . println ( " Calcul le nombre de point dans le node " ) ;
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
textNodeSelect . AfficheTotalPoint ( nod , calculNombreDepoint ( nod , 0 ) ) ;
}
} ;
/ * *
* Recherche par l ' index true
* /
private AbstractAction actRechercheIndextrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Recherche par l'index du node : true " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Recherche par index le node dans le fichier de l'étudiant. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " recherche_index " , " true " ) ;
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
/ * *
* Evalue le style : name true
* /
private AbstractAction actEvaluerStyleTrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer le style. " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer le style:name de ce node dans le fichier de l'étudiant " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " analyseStyle " , " true " ) ;
2022-06-13 17:43:41 +02:00
//***************************************************************************************************************
//** Place l'attribut EvaluerATraversAnalyseStyle=true au style qui doit être évaluer à travers d'analyseStyle **
//** S'il y a des attributs évaluer avec ‽ alors change par ‼ **
//***************************************************************************************************************
node nodStyle = commandes . sujet . retourneFirstNodeByNameAndAttributValueExactStrict ( " style:style " , " style:name " , nod . getAttributs ( ) . get ( " text:style-name " ) ) ;
if ( nodStyle ! = null ) {
nodStyle . getAttributs ( ) . put ( " EvaluerATraversAnalyseStyle " , " true " ) ;
nodStyle . evaluerTrue ( ) ;
nodStyle . changeLesCodesEvaluateursVersCodeATraversAnalyseStyle ( ) ;
}
2022-06-06 18:59:42 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
/ * *
* Evalue le style : name true
* /
private AbstractAction actEvaluerStyleFalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " N'évaluer pas le style. " ) ;
putValue ( Action . SHORT_DESCRIPTION , " N'évaluer pas le style:name de ce node dans le fichier de l'étudiant " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " analyseStyle " , " false " ) ;
2022-06-13 17:43:41 +02:00
//***************************************************************************************************************
//** Place l'attribut EvaluerATraversAnalyseStyle=false au style qui doit être évaluer à travers d'analyseStyle **
//** S'il y a des attribut évaluer avec ‼ alors change par ‽ **
//***************************************************************************************************************
node nodStyle = commandes . sujet . retourneFirstNodeByNameAndAttributValueExactStrict ( " style:style " , " style:name " , nod . getAttributs ( ) . get ( " text:style-name " ) ) ;
if ( nodStyle ! = null ) {
nodStyle . getAttributs ( ) . put ( " EvaluerATraversAnalyseStyle " , " false " ) ;
nodStyle . evaluerAllChildFalse ( ) ;
if ( ! listeNodeFormatageDirectDeWriter . isFormatageDirect ( nodStyle ) ) {
nodStyle . changeLesCodesEvaluateursVersCodeEvaluateurDirect ( ) ;
}
}
2022-06-06 18:59:42 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
/ * *
* Recherche le node par l ' index false
* /
private AbstractAction actRechercheIndexfalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Ne recherche par l'index du node : false " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Ne recherche pas par l'index le node dans le fichier de l'étudiant. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " recherche_index " , " false " ) ;
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
2022-06-09 20:35:59 +02:00
/ * *
* Recherche le node par le contenu true
* /
private AbstractAction actRechercheContenutrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Recherche par le contenu du node : true " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Recherche par le contenu le node dans le fichier de l'étudiant. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " recherche_contenu_exact " , " true " ) ;
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
2022-06-06 18:59:42 +02:00
/ * *
* Recherche le node par le contenu true
* /
2022-06-09 20:35:59 +02:00
private AbstractAction actRechercheContenuPlusProcheVoisintrue = new AbstractAction ( ) {
2022-06-06 18:59:42 +02:00
private static final long serialVersionUID = 1L ;
{
2022-06-11 12:10:28 +02:00
putValue ( Action . NAME , " true " ) ;
2022-06-09 20:35:59 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Recherche par le contenu du plus proche voisin. " ) ;
2022-06-06 18:59:42 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-09 20:35:59 +02:00
nod . getAttributs ( ) . put ( " recherche_contenu_plus_proche_voisin " , " true " ) ;
2022-06-06 18:59:42 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
2022-06-09 09:13:46 +02:00
/ * *
* Recherche le node par le contenu false
* /
private AbstractAction actRechercheContenufalse = new AbstractAction ( ) {
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
private static final long serialVersionUID = 1L ;
2022-06-06 18:59:42 +02:00
2022-06-09 09:13:46 +02:00
{
2022-06-11 12:10:28 +02:00
putValue ( Action . NAME , " false " ) ;
2022-06-09 09:13:46 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Ne recherche pas par le contenu le node dans le fichier de l'étudiant. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " recherche_contenu_exact " , " false " ) ;
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
2022-06-09 20:35:59 +02:00
/ * *
* Recherche le node par le contenu true
* /
private AbstractAction actRechercheContenuPlusProcheVoisinfalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Plus proche voisin : false " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Ne recherche pas par le contenu du plus proche voisin. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-10 09:36:23 +02:00
nod . getAttributs ( ) . put ( " recherche_contenu_plus_proche_voisin " , " false " ) ;
2022-06-09 20:35:59 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
2022-06-09 09:13:46 +02:00
/ * *
* Recherche par le numéro de la page true
* /
private AbstractAction actRechercheAnchorPageNumberTrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " true " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Recherche l'image par le numéro de la page dans le node dans le fichier de l'étudiant. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " recherche_anchor-page-number " , " true " ) ;
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
/ * *
* Recherche par le numéro de la page true
* /
private AbstractAction actRechercheAnchorPageNumberFalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " false " ) ;
putValue ( Action . SHORT_DESCRIPTION , " Ne recherche pas l'image par le numéro de la page. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . getAttributs ( ) . put ( " recherche_anchor-page-number " , " false " ) ;
textNodeSelect . refreshAffichage ( nod ) ;
}
} ;
2022-06-06 18:59:42 +02:00
2022-06-02 22:19:32 +02:00
/ * *
* Ajoute ou modifie un saut de ligne à true .
* /
private AbstractAction actsauttrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " true " ) ;
putValue ( Action . SHORT_DESCRIPTION , " true " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
TreeNode [ ] chemin = selectNode . getPath ( ) ;
boolean avertissement = false ;
for ( int i = 0 ; i < chemin . length ; i + + ) {
if ( chemin [ i ] . toString ( ) . contains ( " setting " ) ) avertissement = true ;
System . out . println ( chemin [ i ] . toString ( ) ) ;
}
if ( ! avertissement ) {
nod . saut ( true ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-02 22:19:32 +02:00
} else {
JOptionPane . showMessageDialog ( null , " Ce node ne peut pas être évaluer. " ) ;
}
}
} ;
/ * *
* Ajoute ou modifie un saut de ligne à true .
* /
private AbstractAction actsautfalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " false " ) ;
putValue ( Action . SHORT_DESCRIPTION , " false " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
TreeNode [ ] chemin = selectNode . getPath ( ) ;
boolean avertissement = false ;
for ( int i = 0 ; i < chemin . length ; i + + ) {
if ( chemin [ i ] . toString ( ) . contains ( " setting " ) ) avertissement = true ;
System . out . println ( chemin [ i ] . toString ( ) ) ;
}
if ( ! avertissement ) {
nod . saut ( false ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
// refeshNodeSelected();
2022-06-02 22:19:32 +02:00
} else {
JOptionPane . showMessageDialog ( null , " Ce node ne peut pas être évaluer. " ) ;
}
}
} ;
2022-06-02 17:48:14 +02:00
2022-05-28 19:13:25 +02:00
/ * *
*
* /
private AbstractAction actPaste = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Coller " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /paste.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_P ) ;
putValue ( Action . SHORT_DESCRIPTION , " Coller (CTRL+V) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_V , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
System . out . println ( " Paste " ) ;
}
} ;
/ * *
2022-06-01 21:38:37 +02:00
* Affiche la fenêtre informaton sur la version
2022-05-28 19:13:25 +02:00
* /
private AbstractAction actAPropos = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-01 21:38:37 +02:00
putValue ( Action . NAME , " Informations " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/aproposmini.png " ) ) ) ;
2022-05-28 19:13:25 +02:00
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_M ) ;
putValue ( Action . SHORT_DESCRIPTION , " Informations (CTRL+I) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_I , InputEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
new about ( ) ;
System . out . println ( " A propos " ) ;
}
} ;
2022-06-01 21:38:37 +02:00
2022-06-09 09:13:46 +02:00
2022-06-01 21:38:37 +02:00
/ * *
* Supprime un node
* /
2022-06-04 21:12:59 +02:00
private AbstractAction actDeleteNode = new AbstractAction ( ) {
2022-06-01 21:38:37 +02:00
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Supprime " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/supprimemini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Supprime " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
if ( tree . getSelectionPath ( ) ! = null ) {
int a = JOptionPane . showConfirmDialog ( null , " Voulez-vous supprimer le node " + selectNode . toString ( ) + " ? " , " Sélectionner un choix " , JOptionPane . YES_NO_OPTION ) ;
if ( a = = JOptionPane . YES_NO_OPTION ) {
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-02 15:47:54 +02:00
if ( ! ( nod . getNomElt ( ) . equals ( " setting " ) | | nod . getNomElt ( ) . equals ( " csv " ) | | nod . getNomElt ( ) . equals ( " import_moodle " ) | | nod . getNomElt ( ) . equals ( " zip " )
| | nod . getNomElt ( ) . equals ( " plagiarism " ) | | nod . getNomElt ( ) . equals ( " text:similarity " ) | | nod . getNomElt ( ) . equals ( " color " ) | | nod . getNomElt ( ) . equals ( " translation " ) ) ) {
2022-06-06 18:59:42 +02:00
2022-06-02 15:47:54 +02:00
nod . getParent ( ) . supprimeNodeEnfant ( nod ) ;
constructionTree ( ) ;
2022-06-06 18:59:42 +02:00
2022-06-02 15:47:54 +02:00
} else {
JOptionPane . showMessageDialog ( null , " Vous ne devez pas supprimer ce node ! " , " Oh non!!! " , JOptionPane . INFORMATION_MESSAGE ) ;
}
2022-06-01 21:38:37 +02:00
}
}
}
} ;
/ * *
2022-06-02 22:19:32 +02:00
* evaluer = true
2022-06-01 21:38:37 +02:00
* /
private AbstractAction actEvalueTrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-04 21:12:59 +02:00
putValue ( ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_E , InputEvent . ALT_DOWN_MASK ) ) ;
2022-06-01 21:38:37 +02:00
putValue ( Action . NAME , " Evaluer true " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/evaluertruemini.png " ) ) ) ;
2022-06-06 18:59:42 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Evaluer ce node par l'application " ) ;
2022-06-01 21:38:37 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
2022-06-02 17:48:14 +02:00
2022-06-01 21:38:37 +02:00
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-06 18:59:42 +02:00
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
2022-06-02 17:48:14 +02:00
nod . evaluerTrue ( ) ;
if ( nod . getLevel ( ) = = 1 ) {
nod . addMenu ( true ) ;
}
2022-06-06 18:59:42 +02:00
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
2022-06-06 18:59:42 +02:00
2022-06-02 17:48:14 +02:00
} else {
JOptionPane . showMessageDialog ( null , " Ce node ne peut pas être évaluer. " ) ;
}
2022-06-01 21:38:37 +02:00
}
} ;
2022-06-02 22:19:32 +02:00
/ * *
/ * *
* addMenu = true
* /
private AbstractAction actAddMenuTrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " true " ) ;
putValue ( Action . SHORT_DESCRIPTION , " true " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-06 18:59:42 +02:00
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
2022-06-02 22:19:32 +02:00
nod . addMenu ( true ) ;
2022-06-06 18:59:42 +02:00
textNodeSelect . refreshAffichage ( nod ) ; ;
2022-06-02 22:19:32 +02:00
} else {
2022-06-06 18:59:42 +02:00
JOptionPane . showMessageDialog ( null , " Ce node ne peut pas contenir de lien de menu. " ) ;
2022-06-02 22:19:32 +02:00
}
}
} ;
/ * *
* addMenu = false
* /
private AbstractAction actAddMenuFalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " false " ) ;
putValue ( Action . SHORT_DESCRIPTION , " false " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
2022-06-06 18:59:42 +02:00
2022-06-02 22:19:32 +02:00
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-06 18:59:42 +02:00
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
2022-06-02 22:19:32 +02:00
nod . addMenu ( false ) ;
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( nod ) ;
2022-06-02 22:19:32 +02:00
} else {
2022-06-06 18:59:42 +02:00
JOptionPane . showMessageDialog ( null , " Ce node ne peut pas contenir de lien de menu. " ) ;
2022-06-02 22:19:32 +02:00
}
}
} ;
2022-06-01 21:38:37 +02:00
// public static void expandOrCollapsePath (JTree tree,TreePath treePath,int level,int currentLevel,boolean expand) {
// System.out.println("Exp level="+currentLevel+", exp="+expand + ", level=" + level);
// if (expand && level<=currentLevel && level>0) return;
//
// TreeNode treeNode = ( TreeNode ) treePath.getLastPathComponent();
// TreeModel treeModel=tree.getModel();
// if ( treeModel.getChildCount(treeNode) >= 0 ) {
// for ( int i = 0; i < treeModel.getChildCount(treeNode); i++ ) {
// TreeNode n = ( TreeNode )treeModel.getChild(treeNode, i);
// TreePath path = treePath.pathByAddingChild( n );
// expandOrCollapsePath(tree,path,level,currentLevel+1,expand);
// }
// if (!expand && currentLevel<level) return;
// }
// if (expand) {
// tree.expandPath( treePath );
//// System.err.println("Path expanded at level "+currentLevel+"-"+treePath);
// } else {
// tree.collapsePath(treePath);
//// System.err.println("Path collapsed at level "+currentLevel+"-"+treePath);
// }
// }
/ * *
*
* /
private AbstractAction actDocumentation = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Documentation " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/documentationmini.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_D ) ;
putValue ( Action . SHORT_DESCRIPTION , " Documentation (CTRL+D) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_D , InputEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
Desktop d = Desktop . getDesktop ( ) ;
try {
2022-06-09 09:13:46 +02:00
d . open ( new File ( create . class . getResource ( " /resources/documentation.pdf " ) . getPath ( ) ) ) ;
2022-06-01 21:38:37 +02:00
} catch ( IOException e1 ) {
e1 . printStackTrace ( ) ;
}
System . out . println ( " Affiche la documentation. " ) ;
}
} ;
2022-06-09 09:13:46 +02:00
private AbstractAction actTutoriels = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Tutoriels " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/tutorielmini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Tutoriels " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
try {
String url = " https://www.youtube.com/channel/UCBSfItcCVnbRJdQbVE9ppjQ " ;
java . awt . Desktop . getDesktop ( ) . browse ( java . net . URI . create ( url ) ) ;
}
catch ( java . io . IOException e1 ) {
System . out . println ( e1 . getMessage ( ) ) ;
}
System . out . println ( " Affiche les tutoriels. " ) ;
}
} ;
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
/ * *
* N ' évalue pas le node evaluer = false
* /
2022-06-01 21:38:37 +02:00
private AbstractAction actEvalueFalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
2022-06-04 21:12:59 +02:00
putValue ( ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_E , InputEvent . ALT_DOWN_MASK | InputEvent . SHIFT_DOWN_MASK ) ) ;
2022-06-01 21:38:37 +02:00
putValue ( Action . NAME , " Evaluer false " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/evaluerfalsemini.png " ) ) ) ;
2022-06-06 18:59:42 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Ne pas évaluer ce node par l'application. " ) ;
2022-06-01 21:38:37 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
2022-06-06 18:59:42 +02:00
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
nod . evaluerFalse ( ) ;
textNodeSelect . refreshAffichage ( nod ) ;
} else {
JOptionPane . showMessageDialog ( null , " Ce node ne peut être évalué. " ) ;
}
2022-06-01 21:38:37 +02:00
}
} ;
2022-06-09 09:13:46 +02:00
/ * *
* Evalue le node est les enfants suivant c ' est tout
* /
private AbstractAction actEvaluerTousEnfantsTrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer toute la branche " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/evaluertouslesenfantsmini.png " ) ) ) ;
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( create . class . getResource ( " /resources/evaluertouslesenfants.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer toute la branche de la racine à la feuille. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
nod . evaluerAllChildTrue ( ) ;
textNodeSelect . refreshAffichage ( nod ) ;
} else {
JOptionPane . showMessageDialog ( null , " Ce node ne peut être évalué. " ) ;
}
}
} ;
/ * *
* N ' évalue pas le node est les enfants suivant c ' est tout
* /
private AbstractAction actEvaluerTousEnfantsFalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer toute la branche " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/evaluertouslesenfantsmini.png " ) ) ) ;
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( create . class . getResource ( " /resources/evaluertouslesenfants.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer toute la branche de la racine à la feuille. " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
nod . evaluerAllChildFalse ( ) ;
textNodeSelect . refreshAffichage ( nod ) ;
} else {
JOptionPane . showMessageDialog ( null , " Ce node ne peut être évalué. " ) ;
}
}
} ;
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
/ * *
* Expand all
* /
private AbstractAction actExpandAll = new AbstractAction ( ) {
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
private static final long serialVersionUID = 1L ;
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
{
putValue ( Action . NAME , " Tout étendre " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/expandallmini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Tout étendre " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
expandAll ( ) ;
2022-06-05 18:42:06 +02:00
// refeshNodeSelected();
2022-06-04 21:12:59 +02:00
}
} ;
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
/ * *
* Calloapse all
* /
private AbstractAction actCollapseAll = new AbstractAction ( ) {
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
private static final long serialVersionUID = 1L ;
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
{
putValue ( Action . NAME , " Tout réduire " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/collapseallmini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Tout réduire " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
collapseAll ( ) ;
2022-06-05 18:42:06 +02:00
// refeshNodeSelected();
2022-06-04 21:12:59 +02:00
}
} ;
2022-06-01 21:38:37 +02:00
2022-06-04 21:12:59 +02:00
/ * *
* Expand node
* /
private AbstractAction actExpandNode = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Etendre ce node " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/expandnodemini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Etendre ce node " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
if ( tree . getSelectionPath ( ) ! = null ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
expandNode ( selectNode ) ;
2022-06-05 18:42:06 +02:00
// refeshNodeSelected();
2022-06-04 21:12:59 +02:00
}
}
} ;
/ * *
* Collapse node
* /
private AbstractAction actCollapseNode = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Réduire ce node " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/collapsenodemini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Réduire ce node " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
if ( tree . getSelectionPath ( ) ! = null ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
collapseNode ( selectNode ) ;
2022-06-05 18:42:06 +02:00
// refeshNodeSelected();
2022-06-04 21:12:59 +02:00
}
}
} ;
/ * *
* Up node
* /
private AbstractAction actUpNode = new AbstractAction ( ) {
2022-06-01 21:38:37 +02:00
private static final long serialVersionUID = 1L ;
{
2022-06-04 21:12:59 +02:00
putValue ( Action . NAME , " Monter le node " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/upnodemini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Monter le node " ) ;
2022-06-01 21:38:37 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
if ( tree . getSelectionPath ( ) ! = null ) {
2022-06-04 21:12:59 +02:00
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
int a = JOptionPane . showConfirmDialog ( null , " Voulez-vous monter le node " + selectNode . toString ( ) + " ? " , " Sélectionner un choix " , JOptionPane . YES_NO_OPTION ) ;
if ( a = = JOptionPane . YES_NO_OPTION ) {
node nod = ( node ) selectNode . getUserObject ( ) ;
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
nod . getParent ( ) . upNodeEnfant ( nod ) ;
constructionTree ( ) ;
} else {
JOptionPane . showMessageDialog ( null , " Vous ne devez pas déplacer ce node ! " , " Oh non!!! " , JOptionPane . INFORMATION_MESSAGE ) ;
}
}
}
2022-06-01 21:38:37 +02:00
}
2022-06-04 21:12:59 +02:00
} ;
2022-06-09 09:13:46 +02:00
/ * *
*
* /
2022-06-04 21:12:59 +02:00
private AbstractAction actDownNode = new AbstractAction ( ) {
2022-06-01 21:38:37 +02:00
private static final long serialVersionUID = 1L ;
{
2022-06-04 21:12:59 +02:00
putValue ( Action . NAME , " Descendre le node " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/downnodemini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Descendre le node " ) ;
2022-06-01 21:38:37 +02:00
}
@Override public void actionPerformed ( ActionEvent e ) {
if ( tree . getSelectionPath ( ) ! = null ) {
2022-06-04 21:12:59 +02:00
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
int a = JOptionPane . showConfirmDialog ( null , " Voulez-vous descendre le node " + selectNode . toString ( ) + " ? " , " Sélectionner un choix " , JOptionPane . YES_NO_OPTION ) ;
if ( a = = JOptionPane . YES_NO_OPTION ) {
node nod = ( node ) selectNode . getUserObject ( ) ;
if ( ! nod . chemin ( ) . contains ( " setting " ) ) {
nod . getParent ( ) . downNodeEnfant ( nod ) ;
constructionTree ( ) ;
} else {
JOptionPane . showMessageDialog ( null , " Vous ne devez pas déplacer ce node ! " , " Oh non!!! " , JOptionPane . INFORMATION_MESSAGE ) ;
}
}
}
2022-06-01 21:38:37 +02:00
}
2022-06-04 21:12:59 +02:00
} ;
2022-06-04 15:43:08 +02:00
2022-06-02 15:47:54 +02:00
/ * *
* Gènère un nouveau fichier d ' analyse à partir d ' un fichier ODF
* /
private AbstractAction actNewFichierAnalyse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . LARGE_ICON_KEY , new ImageIcon ( evaluate . class . getResource ( " /resources/fichierODF.png " ) ) ) ;
putValue ( Action . NAME , " Génère un nouveau fichier d'analyse " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( evaluate . class . getResource ( " /resources/fichierODFmini.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_N ) ;
putValue ( Action . SHORT_DESCRIPTION , " Générer un nouveau fichier d'analyse (CTRL+N) " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_N , InputEvent . CTRL_DOWN_MASK ) ) ;
}
@Override
public void actionPerformed ( ActionEvent e ) {
JFileChooser chooser = new JFileChooser ( ) ;
chooser . setDialogTitle ( " Choisir un fichier ODF " ) ;
chooser . setCurrentDirectory ( new java . io . File ( commandes . path ) ) ;
chooser . setFileSelectionMode ( JFileChooser . FILES_ONLY ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( " Format ODF " , " odt " ) ;
chooser . setFileFilter ( filter ) ;
chooser . setAcceptAllFileFilterUsed ( true ) ;
if ( chooser . showOpenDialog ( null ) = = JFileChooser . APPROVE_OPTION ) {
System . out . println ( " getCurrentDirectory(): " + chooser . getCurrentDirectory ( ) ) ;
System . out . println ( " getSelectedFile() : " + chooser . getSelectedFile ( ) . getAbsolutePath ( ) ) ;
2022-06-12 09:39:22 +02:00
2022-06-02 15:47:54 +02:00
commandes . path = chooser . getCurrentDirectory ( ) . getAbsolutePath ( ) ;
2022-06-12 09:39:22 +02:00
commandes . PathFilenameAnalysis = chooser . getCurrentDirectory ( ) . getAbsolutePath ( ) ;
String cheminVersFichier = chooser . getSelectedFile ( ) . getAbsolutePath ( ) ;
2022-06-02 15:47:54 +02:00
commandes . nameSujet = chooser . getSelectedFile ( ) . getName ( ) ;
Run b = null ;
try {
2022-06-12 09:39:22 +02:00
b = new Run ( cheminVersFichier ) ;
commandes . sujet = Run . XMLContent ( b . getLectDossiers ( ) . getEC ( ) . getListeContentWriter ( ) . get ( 0 ) ) ;
commandes . sujet = meptl . LectureFichierEtudiantSousFormeDeNode ( commandes . sujet , b , 0 ) ;
commandes . sujet . getAttributs ( ) . put ( " analysis_filename " , " sujet.xml " ) ;
commandes . sujet = ecritureSujet . nodePourEcritureSujet ( commandes . sujet , b , 0 ) ;
2022-06-06 18:59:42 +02:00
commandes . sujet . supprimeTousLesNodesEnfantWithThisName ( " text:change-start " ) ;
commandes . sujet . supprimeTousLesNodesEnfantWithThisName ( " text:change-end " ) ;
2022-06-09 09:13:46 +02:00
commandes . sujetSauvegarde = commandes . sujet . clone ( ) ;
2022-06-02 15:47:54 +02:00
new verificationFichierAnalyse ( ) ;
2022-06-09 20:35:59 +02:00
2022-06-12 09:39:22 +02:00
2022-06-02 15:47:54 +02:00
if ( commandes . fichierAnalyseValide ) {
constructionTree ( ) ;
2022-06-12 09:39:22 +02:00
textNodeSelect . afficheChargementFichierAnalyse ( ) ;
2022-06-02 15:47:54 +02:00
} else {
textNodeSelect . setText ( " <h1>Le fichier n'est pas valise</h1> " ) ;
}
} catch ( ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1 ) {
e1 . printStackTrace ( ) ;
}
} else {
2022-06-05 18:42:06 +02:00
textNodeSelect . refreshAffichage ( null ) ;
2022-06-02 15:47:54 +02:00
}
commandes . ecritCode = true ;
}
} ;
2022-05-28 19:13:25 +02:00
/ * *
*
* /
private AbstractAction actEvaluer = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /evaluate.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_E ) ;
2022-06-01 21:38:37 +02:00
putValue ( Action . SHORT_DESCRIPTION , " Evaluer un node (CTRL+E) " ) ;
2022-05-28 19:13:25 +02:00
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_E , KeyEvent . CTRL_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
new evaluate ( ) ;
dispose ( ) ;
}
} ;
/ * *
* Construction du Tree avec le node sujet .
* /
public void constructionTree ( ) {
2022-06-01 21:38:37 +02:00
Run . parentAndLevel ( commandes . sujet , commandes . sujet , 0 ) ;
2022-06-12 09:39:22 +02:00
DefaultMutableTreeNode root = null ;
2022-05-28 19:13:25 +02:00
commandes . tree . getSelectionModel ( ) . setSelectionMode ( TreeSelectionModel . SINGLE_TREE_SELECTION ) ;
commandes . tree . setExpandsSelectedPaths ( true ) ;
commandes . tree . setInvokesStopCellEditing ( true ) ;
2022-06-01 21:38:37 +02:00
tree . setExpandsSelectedPaths ( true ) ;
tree . setInvokesStopCellEditing ( true ) ;
2022-06-13 17:43:41 +02:00
//Construction si c'est un fichier d'analyse
2022-06-02 15:47:54 +02:00
if ( commandes . sujet . getNomElt ( ) . equals ( " fichier " ) ) {
2022-06-13 17:43:41 +02:00
root = new DefaultMutableTreeNode ( commandes . sujet , true ) ;
2022-06-12 09:39:22 +02:00
root = addNodeMutable ( commandes . sujet , root ) ;
2022-06-13 17:43:41 +02:00
commandes . tree = new JTree ( root ) ;
DefaultTreeCellRenderer cellRenderer = ( DefaultTreeCellRenderer ) commandes . tree . getCellRenderer ( ) ;
cellRenderer . setOpenIcon ( new ImageIcon ( create . class . getResource ( " /resources/treeOpen.png " ) ) ) ;
cellRenderer . setClosedIcon ( new ImageIcon ( create . class . getResource ( " /resources/treeClose.png " ) ) ) ;
cellRenderer . setLeafIcon ( new ImageIcon ( create . class . getResource ( " /resources/treeLeaf.png " ) ) ) ;
cellRenderer . setBackgroundNonSelectionColor ( new Color ( 255 , 255 , 221 ) ) ;
cellRenderer . setBackgroundSelectionColor ( new Color ( 0 , 0 , 128 ) ) ;
cellRenderer . setBorderSelectionColor ( Color . black ) ;
cellRenderer . setTextSelectionColor ( Color . white ) ;
cellRenderer . setTextNonSelectionColor ( Color . blue ) ;
tree . setCellRenderer ( cellRenderer ) ;
// tree.setCellRenderer(new MyTreeCellRenderer());
tree . setModel ( commandes . tree . getModel ( ) ) ;
2022-05-28 19:13:25 +02:00
}
}
2022-06-09 09:13:46 +02:00
2022-06-12 09:39:22 +02:00
/ * *
* Permet la construction du tree .
* @param nod
* @param parent
* @return
* /
private DefaultMutableTreeNode addNodeMutable ( node nod , DefaultMutableTreeNode parent ) {
if ( nod ! = null ) {
DefaultMutableTreeNode node1 = null ;
for ( int i = 0 ; i < nod . getNodes ( ) . size ( ) ; i + + ) {
2022-06-13 17:43:41 +02:00
if ( ! nod . getNodes ( ) . get ( i ) . getNomElt ( ) . equals ( " setting " ) ) {
node1 = new DefaultMutableTreeNode ( nod . getNodes ( ) . get ( i ) ) ;
addNodeMutable ( nod . getNodes ( ) . get ( i ) , node1 ) ;
parent . add ( node1 ) ;
}
2022-06-12 09:39:22 +02:00
}
}
return parent ;
}
2022-06-09 09:13:46 +02:00
2022-05-28 19:13:25 +02:00
/ * *
* La balise de style pour le code HTML
* @return
* /
private static String balisestyles ( ) {
return " <style type= \" text/css \" > "
+ " h1 {margin-bottom: 0.25cm;font-size: 18pt;font-family: \" Arial \" ;text-align:center;font-weight: bold;} "
2022-06-02 17:48:14 +02:00
+ " h2 {color:red;margin-bottom: 0.25cm;font-size: 18pt;font-family: \" Arial \" ;text-align:center;font-weight: bold;} "
2022-05-28 19:13:25 +02:00
+ " h4 {text-align:left;font-family: \" Arial \" ; font-size: 16pt; font-weight: bold; line-height: 110%;} "
+ " hr { display: block; margin-top: 0.5em; margin-bottom: 8em; margin-left: 2em; margin-right: 2em; border-style: inset; border-width: 4px;} "
+ " spanpablo { float: right; width: 8em; font-size: 250%; font-family: algerian, courier; line-height: 80%; margin-right: 1%; color: red; text-align: center} "
+ " p.p1{color:blue;font-family: \" Arial \" ;font-size: 14pt;margin-bottom: 0cm; margin-top: 0cm; line-height: 0%; background: transparent; margin-left: 0cm; white-space: pre;} "
+ " li.p2{color:green;font-family: \" Arial \" ;font-size: 14pt;margin-bottom: 0cm; margin-top: 0cm; line-height: 0%; background: transparent; margin-left: 0cm; white-space: pre;} "
+ " li.p3{color:red;font-family: \" Arial \" ;font-size: 14pt;margin-bottom: 0cm; margin-top: 0cm; line-height: 0%; background: transparent; margin-left: 0cm; white-space: pre;} "
+ " p.p4{margin-left: 0px; margin-bottom: 0cm; margin-top: 4px; line-height: 115%} "
+ " </style> " ;
}
2022-06-01 21:38:37 +02:00
private void expandAll ( ) {
Enumeration < ? > topLevelNodes = ( ( TreeNode ) tree . getModel ( ) . getRoot ( ) ) . children ( ) ;
while ( topLevelNodes . hasMoreElements ( ) ) {
DefaultMutableTreeNode N = ( DefaultMutableTreeNode ) topLevelNodes . nextElement ( ) ;
tree . expandPath ( new TreePath ( N . getPath ( ) ) ) ;
expandNode ( N ) ;
}
}
private void collapseAll ( ) {
Enumeration < ? > topLevelNodes = ( ( TreeNode ) tree . getModel ( ) . getRoot ( ) ) . children ( ) ;
while ( topLevelNodes . hasMoreElements ( ) ) {
DefaultMutableTreeNode N = ( DefaultMutableTreeNode ) topLevelNodes . nextElement ( ) ;
tree . collapsePath ( new TreePath ( N . getPath ( ) ) ) ;
collapseNode ( N ) ;
}
}
private void expandNode ( DefaultMutableTreeNode N ) {
Enumeration < ? > topLevelNodes = ( ( TreeNode ) N ) . children ( ) ;
while ( topLevelNodes . hasMoreElements ( ) ) {
DefaultMutableTreeNode N1 = ( DefaultMutableTreeNode ) topLevelNodes . nextElement ( ) ;
tree . expandPath ( new TreePath ( N1 . getPath ( ) ) ) ;
expandNode ( N1 ) ;
}
}
private void collapseNode ( DefaultMutableTreeNode N ) {
Enumeration < ? > topLevelNodes = ( ( TreeNode ) N ) . children ( ) ;
while ( topLevelNodes . hasMoreElements ( ) ) {
DefaultMutableTreeNode N1 = ( DefaultMutableTreeNode ) topLevelNodes . nextElement ( ) ;
tree . collapsePath ( new TreePath ( N1 . getPath ( ) ) ) ;
collapseNode ( N1 ) ;
}
tree . collapsePath ( new TreePath ( N . getPath ( ) ) ) ;
}
2022-06-13 17:43:41 +02:00
2022-06-02 15:47:54 +02:00
// void saySomething(String eventDescription, TreeExpansionEvent e) {
// System.out.println(eventDescription + "; " + "path = " + e.getPath());
// }
//
//
// // Required by TreeExpansionListener interface.
// public void treeExpanded(TreeExpansionEvent e) {
// saySomething("Tree-expanded event detected", e);
// }
//
// // Required by TreeExpansionListener interface.
// public void treeCollapsed(TreeExpansionEvent e) {
// saySomething("Tree-collapsed event detected", e);
// }
2022-05-28 19:13:25 +02:00
}
2022-06-02 15:47:54 +02:00
//class MyTreeWillExpandListener implements TreeWillExpandListener {
//
//
// public void treeWillExpand(TreeExpansionEvent evt) throws ExpandVetoException {
// JTree tree = (JTree) evt.getSource();
//
// TreePath path = evt.getPath();
// boolean veto = false;
// if (veto) {
// throw new ExpandVetoException(evt);
// }
// }
//
// public void treeWillCollapse(TreeExpansionEvent evt) throws ExpandVetoException {
// JTree tree = (JTree) evt.getSource();
//
// TreePath path = evt.getPath();
// boolean veto = false;
// if (veto) {
// throw new ExpandVetoException(evt);
// }
// }
//}
//class MyTreeExpansionListener implements TreeExpansionListener {
//
// public ArrayList<TreePath> Chemin = new ArrayList<TreePath>();
//
// public ArrayList<TreePath> getChemin() {
// return Chemin;
// }
//
// public void setChemin(ArrayList<TreePath> chemin) {
// Chemin = chemin;
// }
//
// public void treeExpanded(TreeExpansionEvent evt) {
// TreePath path = evt.getPath();
// Chemin.add(path);
// System.out.println("treeExpanded");
// }
//
// public void treeCollapsed(TreeExpansionEvent evt) {
// TreePath path = evt.getPath();
// Chemin.remove(path);
// System.out.println("treeCollapsed");
//
// }
//}