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.SystemColor ;
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 ;
2022-06-02 15:47:54 +02:00
import java.util.ArrayList ;
2022-05-28 19:13:25 +02:00
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.JCheckBox ;
import javax.swing.JComboBox ;
import javax.swing.JEditorPane ;
import javax.swing.JFileChooser ;
import javax.swing.JFrame ;
import javax.swing.JLabel ;
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.JSeparator ;
import javax.swing.JSplitPane ;
import javax.swing.JTabbedPane ;
import javax.swing.JTextField ;
import javax.swing.JToolBar ;
import javax.swing.JTree ;
import javax.swing.KeyStroke ;
import javax.swing.SwingConstants ;
import javax.swing.UnsupportedLookAndFeelException ;
2022-06-02 15:47:54 +02:00
import javax.swing.event.TreeExpansionEvent ;
import javax.swing.event.TreeExpansionListener ;
import javax.swing.event.TreeWillExpandListener ;
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-02 15:47:54 +02:00
import javax.swing.tree.ExpandVetoException ;
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-05-28 19:13:25 +02:00
import java.awt.event.InputEvent ;
2022-06-02 15:47:54 +02:00
import java.awt.event.ActionListener ;
2022-05-28 19:13:25 +02:00
2022-06-01 21:38:37 +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 ( ) ;
private JEditorPane textNodeSelect = new JEditorPane ( ) ;
private JToolBar toolBar = new JToolBar ( ) ;
private JMenuBar menuBar = new JMenuBar ( ) ;
2022-06-02 15:47:54 +02:00
2022-05-28 19:13:25 +02:00
private JTabbedPane tabbedPane = new JTabbedPane ( JTabbedPane . TOP ) ;
// les éléments de l'évaluation
private JTextField textFieldTitreAvantLeSaut = new JTextField ( ) ;
private JComboBox < String > comboBoxAttribut = new JComboBox < String > ( ) ;
private JEditorPane editorPaneInformationNode = new JEditorPane ( ) ;
private JEditorPane editorPaneInfosAttribut = new JEditorPane ( ) ;
private JEditorPane editorPaneInfosNode = new JEditorPane ( ) ;
private JCheckBox chckbxEvaluerNode = new JCheckBox ( " Evaluer un ou des éléments de ce node. " ) ;
private JCheckBox chckbxSautApresTitre = new JCheckBox ( " Insérer un titre puis un saut avant l'évaluation de ce node. " ) ;
private JCheckBox chckbxEvaluerPresenceDeCeNode = new JCheckBox ( " Evaluer la présence de ce node. " ) ;
private JTextField textField_NombrePointEvalThisNode = new JTextField ( ) ;
private JCheckBox chckbxEvaluerAttribut = new JCheckBox ( " Evaluer l'attribut " ) ;
private JTextField textField_NombrePointAttribut = new JTextField ( ) ;
private JEditorPane editorPaneAttribut = new JEditorPane ( ) ;
private JEditorPane editorPaneContenuNode = new JEditorPane ( ) ;
private JCheckBox chckbxEvaluerContenuDuNode = new JCheckBox ( " Evaluer le contenu du node ci-dessous " ) ;
private JTextField textFieldNombrePointContenuNode = new JTextField ( ) ;
private JButton btnEtendu = new JButton ( " → Tolérance " ) ;
private JButton btnOuExact = new JButton ( " ¦ OU " ) ;
private JButton btnContient = new JButton ( " { Contient } " ) ;
private JButton btnColor = new JButton ( " # Couleur " ) ;
private JButton btnBordure = new JButton ( " Bordure " ) ;
private String messg = " Valeur de l'attribut - fonctions - évaluateur et point " ;
private JLabel lblType = new JLabel ( messg ) ;
private JEditorPane editorPaneContenuEnfant = new JEditorPane ( ) ;
private JTextField textField_DistanceSimilitude = new JTextField ( ) ;
private JTextField textFieldNbrPointContenuEnfant = new JTextField ( ) ;
private JCheckBox chckbxEvaluerSimilitude = new JCheckBox ( " Evaluer le contenu complet avec les nodes enfants (Similitude) " ) ;
private JCheckBox chckbxIgnoreValeurNumerique = new JCheckBox ( " Ignorer les valeurs numériques " ) ;
private JCheckBox chckbxIgnoreLaCasse = new JCheckBox ( " Ignore la casse " ) ;
private JCheckBox chckbxIgnoreLesCaracteresSpeciaux = new JCheckBox ( " Ignore les caractères spéciaux " ) ;
private final JPanel panelStyleStructure = new JPanel ( ) ;
private String messg2 = " Le style du paragraphe est : " ;
private JLabel lblLeStyleDeParagrapheDuParagraphe = new JLabel ( messg2 ) ;
private final JLabel lblAttribut_analyseStyle = new JLabel ( " Sélectionner l'attribut " ) ;
private final JComboBox < String > comboBoxAttribut_analyseStyle = new JComboBox < String > ( ) ;
private JCheckBox chckbx_EvaluateStyleDeParagraphe = new JCheckBox ( " Evaluer le style de paragraphe " ) ;
private JTextField textField_evaluateStyleParagrapheAttributNbrPoint = new JTextField ( ) ;
private JEditorPane editorPane_evaluateStyleParagrapheAttribut = new JEditorPane ( ) ;
private JLabel lbl_NombrePointAttributEvaluationStyleParagraphe = new JLabel ( " Nombre point " ) ;
private JScrollPane scrollPane_evaluationAttributStyleParagraphe = new JScrollPane ( ) ;
/ * *
* Create the application .
* /
public create ( ) {
try {
initialize ( ) ;
} catch ( UnsupportedLookAndFeelException e ) {
e . printStackTrace ( ) ;
}
setVisible ( true ) ;
}
/ * *
* Initialize the contents of the frame .
* @throws UnsupportedLookAndFeelException
* /
private void initialize ( ) throws UnsupportedLookAndFeelException {
// UIManager.setLookAndFeel(new NimbusLookAndFeel());
/*Chargement des images*/
ImageIcon img1 = new ImageIcon ( getClass ( ) . getResource ( " /attribut.png " ) ) ;
ImageIcon img3 = new ImageIcon ( getClass ( ) . getResource ( " /property.png " ) ) ;
ImageIcon img4 = new ImageIcon ( getClass ( ) . getResource ( " /content.png " ) ) ;
ImageIcon img2 = new ImageIcon ( getClass ( ) . getResource ( " /structurepage.png " ) ) ;
//frame = new JFrame();
2022-05-31 19:37:46 +02:00
// System.out.println(this.getClass());
// this.setExtendedState(MAXIMIZED_BOTH);
setSize ( 1400 , 920 ) ;
2022-05-28 19:13:25 +02:00
//setExtendedState(getExtendedState()|JFrame.MAXIMIZED_BOTH );
2022-06-01 21:38:37 +02:00
// setTitle("analyseWriter - Evaluer les fichiers des étudiants");
2022-05-28 19:13:25 +02:00
ImageIcon img = new ImageIcon ( getClass ( ) . getResource ( " /evalwriter.png " ) ) ;
setIconImage ( img . getImage ( ) ) ;
setLocationRelativeTo ( null ) ;
// frame.setBounds(0, 0, 860, 500);
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
tree . setComponentPopupMenu ( createPopupMenuTree ( ) ) ;
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 15:47:54 +02:00
this . createPopupMenuTree ( ) ;
2022-05-28 19:13:25 +02:00
getContentPane ( ) . setLayout ( new BorderLayout ( 2 , 2 ) ) ;
contentPane . add ( toolBar , BorderLayout . NORTH ) ;
// The content of the window
if ( commandes . fichierAnalyseValide ) tree = commandes . tree ;
// JTextArea J = new JTextArea();
// contentPane.add(J,BorderLayout.EAST);
JPanel panel = new JPanel ( ) ;
getContentPane ( ) . add ( panel , BorderLayout . CENTER ) ;
panel . setLayout ( null ) ;
2022-05-31 19:37:46 +02:00
tabbedPane . setBounds ( 816 , 10 , 600 , 785 ) ;
2022-05-28 19:13:25 +02:00
panel . add ( tabbedPane ) ;
JPanel panelProperties = new JPanel ( ) ;
panelProperties . setLayout ( null ) ;
tabbedPane . addTab ( " Propriétés " , img3 , panelProperties , null ) ;
chckbxEvaluerNode . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxEvaluerNode . setBounds ( 6 , 144 , 285 , 23 ) ;
panelProperties . add ( chckbxEvaluerNode ) ;
chckbxSautApresTitre . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxSautApresTitre . setBounds ( 6 , 342 , 461 , 23 ) ;
panelProperties . add ( chckbxSautApresTitre ) ;
textFieldTitreAvantLeSaut . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
textFieldTitreAvantLeSaut . setColumns ( 10 ) ;
textFieldTitreAvantLeSaut . setBounds ( 10 , 395 , 536 , 33 ) ;
panelProperties . add ( textFieldTitreAvantLeSaut ) ;
JLabel lblNewLabel_1 = new JLabel ( " Texte à insérer avant l'évaluation de ce node. (Si un saut est inséré) " ) ;
lblNewLabel_1 . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
lblNewLabel_1 . setBounds ( 6 , 372 , 511 , 23 ) ;
panelProperties . add ( lblNewLabel_1 ) ;
chckbxEvaluerPresenceDeCeNode . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxEvaluerPresenceDeCeNode . setBounds ( 6 , 458 , 226 , 23 ) ;
panelProperties . add ( chckbxEvaluerPresenceDeCeNode ) ;
JScrollPane scrollPane_1 = new JScrollPane ( ) ;
scrollPane_1 . setBounds ( 10 , 11 , 536 , 125 ) ;
panelProperties . add ( scrollPane_1 ) ;
editorPaneInfosNode . setEditable ( false ) ;
scrollPane_1 . setViewportView ( editorPaneInfosNode ) ;
editorPaneInfosNode . setText ( ( String ) null ) ;
JScrollPane scrollPane_2 = new JScrollPane ( ) ;
scrollPane_2 . setBounds ( 10 , 235 , 536 , 100 ) ;
panelProperties . add ( scrollPane_2 ) ;
scrollPane_2 . setViewportView ( editorPaneInformationNode ) ;
editorPaneInformationNode . setText ( ( String ) null ) ;
editorPaneInformationNode . setEditable ( false ) ;
textField_NombrePointEvalThisNode . setText ( " 1 " ) ;
textField_NombrePointEvalThisNode . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textField_NombrePointEvalThisNode . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
textField_NombrePointEvalThisNode . setColumns ( 10 ) ;
textField_NombrePointEvalThisNode . setBounds ( 360 , 459 , 45 , 20 ) ;
panelProperties . add ( textField_NombrePointEvalThisNode ) ;
JLabel lblNbrePointsPourEvaluerCeNode = new JLabel ( " Nbre point " ) ;
lblNbrePointsPourEvaluerCeNode . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
lblNbrePointsPourEvaluerCeNode . setBounds ( 271 , 462 , 79 , 14 ) ;
panelProperties . add ( lblNbrePointsPourEvaluerCeNode ) ;
JPanel panelAttributs = new JPanel ( ) ;
panelAttributs . setLayout ( null ) ;
tabbedPane . addTab ( " Attributs " , img1 , panelAttributs , null ) ;
comboBoxAttribut . setToolTipText ( " Les attributs présents dans ce node. " ) ;
comboBoxAttribut . setMaximumRowCount ( 10 ) ;
comboBoxAttribut . setFont ( new Font ( " Tahoma " , Font . PLAIN , 14 ) ) ;
comboBoxAttribut . setBounds ( 10 , 31 , 510 , 31 ) ;
panelAttributs . add ( comboBoxAttribut ) ;
JScrollPane scrollPane_3 = new JScrollPane ( ) ;
scrollPane_3 . setBounds ( 10 , 201 , 536 , 135 ) ;
panelAttributs . add ( scrollPane_3 ) ;
scrollPane_3 . setViewportView ( editorPaneAttribut ) ;
editorPaneAttribut . setFont ( new Font ( " Tahoma " , Font . BOLD , 16 ) ) ;
JLabel lblAttribut = new JLabel ( " Sélectionner l'attribut " ) ;
lblAttribut . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
lblAttribut . setBounds ( 10 , 11 , 149 , 22 ) ;
panelAttributs . add ( lblAttribut ) ;
textField_NombrePointAttribut . setText ( " 0 " ) ;
textField_NombrePointAttribut . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textField_NombrePointAttribut . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
textField_NombrePointAttribut . setColumns ( 10 ) ;
textField_NombrePointAttribut . setBounds ( 114 , 126 , 57 , 31 ) ;
panelAttributs . add ( textField_NombrePointAttribut ) ;
JLabel lblNewLabel = new JLabel ( " Nombre point " ) ;
lblNewLabel . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
lblNewLabel . setBounds ( 16 , 134 , 94 , 14 ) ;
panelAttributs . add ( lblNewLabel ) ;
chckbxEvaluerAttribut . setFont ( new Font ( " Tahoma " , Font . BOLD , 14 ) ) ;
chckbxEvaluerAttribut . setBounds ( 10 , 97 , 269 , 23 ) ;
panelAttributs . add ( chckbxEvaluerAttribut ) ;
JLabel lblAvertissement = new JLabel ( " " ) ;
lblAvertissement . setVerticalAlignment ( SwingConstants . TOP ) ;
lblAvertissement . setForeground ( Color . RED ) ;
lblAvertissement . setBounds ( 153 , 11 , 393 , 22 ) ;
panelAttributs . add ( lblAvertissement ) ;
lblType . setVerticalAlignment ( SwingConstants . TOP ) ;
lblType . setHorizontalAlignment ( SwingConstants . LEFT ) ;
lblType . setBounds ( 10 , 168 , 547 , 22 ) ;
panelAttributs . add ( lblType ) ;
JScrollPane scrollPane_3_1 = new JScrollPane ( ) ;
scrollPane_3_1 . setBounds ( 10 , 389 , 536 , 323 ) ;
panelAttributs . add ( scrollPane_3_1 ) ;
scrollPane_3_1 . setViewportView ( editorPaneInfosAttribut ) ;
btnEtendu . setBounds ( 10 , 347 , 100 , 31 ) ;
panelAttributs . add ( btnEtendu ) ;
btnOuExact . setBounds ( 120 , 347 , 90 , 30 ) ;
panelAttributs . add ( btnOuExact ) ;
btnContient . setBounds ( 220 , 347 , 100 , 30 ) ;
panelAttributs . add ( btnContient ) ;
btnColor . setBounds ( 330 , 347 , 90 , 30 ) ;
panelAttributs . add ( btnColor ) ;
btnBordure . setBounds ( 430 , 347 , 90 , 30 ) ;
panelAttributs . add ( btnBordure ) ;
JPanel panelContenu = new JPanel ( ) ;
panelContenu . setLayout ( null ) ;
tabbedPane . addTab ( " Contenu " , img4 , panelContenu , null ) ;
JScrollPane scrollPane = new JScrollPane ( ) ;
scrollPane . setBounds ( 10 , 67 , 530 , 86 ) ;
panelContenu . add ( scrollPane ) ;
editorPaneContenuNode . setEditable ( false ) ;
scrollPane . setViewportView ( editorPaneContenuNode ) ;
chckbxEvaluerContenuDuNode . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxEvaluerContenuDuNode . setBounds ( 6 , 25 , 304 , 23 ) ;
panelContenu . add ( chckbxEvaluerContenuDuNode ) ;
JLabel lblNbrPointContenuNode = new JLabel ( " Nbre point contenu node " ) ;
lblNbrPointContenuNode . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
lblNbrPointContenuNode . setBounds ( 316 , 27 , 155 , 19 ) ;
panelContenu . add ( lblNbrPointContenuNode ) ;
textFieldNombrePointContenuNode . setText ( " 0 " ) ;
textFieldNombrePointContenuNode . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textFieldNombrePointContenuNode . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
textFieldNombrePointContenuNode . setColumns ( 10 ) ;
textFieldNombrePointContenuNode . setBounds ( 481 , 22 , 59 , 30 ) ;
panelContenu . add ( textFieldNombrePointContenuNode ) ;
JScrollPane scrollPane_4 = new JScrollPane ( ) ;
scrollPane_4 . setBounds ( 10 , 258 , 530 , 242 ) ;
panelContenu . add ( scrollPane_4 ) ;
editorPaneContenuEnfant . setEditable ( false ) ;
scrollPane_4 . setViewportView ( editorPaneContenuEnfant ) ;
JLabel lblNbrePointContenu = new JLabel ( " Nbre point contenu complet avec ceux des nodes enfants " ) ;
lblNbrePointContenu . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
lblNbrePointContenu . setBounds ( 10 , 222 , 389 , 19 ) ;
panelContenu . add ( lblNbrePointContenu ) ;
textFieldNbrPointContenuEnfant . setToolTipText ( " <html>Nombre de point si le contenu est similaire<br>(distance Levenshtein inférieure ou égale)</html> " ) ;
textFieldNbrPointContenuEnfant . setText ( " 0 " ) ;
textFieldNbrPointContenuEnfant . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textFieldNbrPointContenuEnfant . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
textFieldNbrPointContenuEnfant . setColumns ( 10 ) ;
textFieldNbrPointContenuEnfant . setBounds ( 481 , 217 , 59 , 30 ) ;
panelContenu . add ( textFieldNbrPointContenuEnfant ) ;
textField_DistanceSimilitude . setToolTipText ( " Distance de Levenshtein " ) ;
textField_DistanceSimilitude . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textField_DistanceSimilitude . setText ( " 2 " ) ;
textField_DistanceSimilitude . setBounds ( 490 , 183 , 50 , 23 ) ;
panelContenu . add ( textField_DistanceSimilitude ) ;
textField_DistanceSimilitude . setColumns ( 10 ) ;
chckbxEvaluerSimilitude . setToolTipText ( " Comparaison des différents mots du contenu. " ) ;
chckbxEvaluerSimilitude . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxEvaluerSimilitude . setBounds ( 10 , 182 , 474 , 23 ) ;
panelContenu . add ( chckbxEvaluerSimilitude ) ;
chckbxIgnoreValeurNumerique . setToolTipText ( " <html>Le texte sera nettoyé de toutes les valeurs numériques<br>avant la comparaison avec le fichier de l'étudiant.</html> " ) ;
chckbxIgnoreValeurNumerique . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxIgnoreValeurNumerique . setBounds ( 10 , 532 , 285 , 23 ) ;
panelContenu . add ( chckbxIgnoreValeurNumerique ) ;
JSeparator separator = new JSeparator ( ) ;
separator . setForeground ( SystemColor . activeCaption ) ;
separator . setBounds ( 10 , 164 , 530 , 11 ) ;
panelContenu . add ( separator ) ;
chckbxIgnoreLaCasse . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxIgnoreLaCasse . setBounds ( 10 , 568 , 228 , 23 ) ;
panelContenu . add ( chckbxIgnoreLaCasse ) ;
JSeparator separator_1 = new JSeparator ( ) ;
separator_1 . setForeground ( SystemColor . activeCaption ) ;
separator_1 . setBounds ( 10 , 511 , 530 , 2 ) ;
panelContenu . add ( separator_1 ) ;
chckbxIgnoreLesCaracteresSpeciaux . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
chckbxIgnoreLesCaracteresSpeciaux . setBounds ( 302 , 533 , 238 , 23 ) ;
panelContenu . add ( chckbxIgnoreLesCaracteresSpeciaux ) ;
tabbedPane . addTab ( " Style " , img2 , panelStyleStructure , null ) ;
panelStyleStructure . setLayout ( null ) ;
lblAttribut_analyseStyle . setBounds ( 10 , 96 , 135 , 15 ) ;
lblAttribut_analyseStyle . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
panelStyleStructure . add ( lblAttribut_analyseStyle ) ;
comboBoxAttribut_analyseStyle . setToolTipText ( " Les attributs présents dans ce node. " ) ;
comboBoxAttribut_analyseStyle . setMaximumRowCount ( 10 ) ;
comboBoxAttribut_analyseStyle . setFont ( new Font ( " Tahoma " , Font . PLAIN , 14 ) ) ;
comboBoxAttribut_analyseStyle . setBounds ( 10 , 122 , 519 , 31 ) ;
panelStyleStructure . add ( comboBoxAttribut_analyseStyle ) ;
lblLeStyleDeParagrapheDuParagraphe . setHorizontalAlignment ( SwingConstants . LEFT ) ;
lblLeStyleDeParagrapheDuParagraphe . setVerticalAlignment ( SwingConstants . TOP ) ;
lblLeStyleDeParagrapheDuParagraphe . setBounds ( 10 , 11 , 536 , 24 ) ;
panelStyleStructure . add ( lblLeStyleDeParagrapheDuParagraphe ) ;
chckbx_EvaluateStyleDeParagraphe . setFont ( new Font ( " Tahoma " , Font . BOLD , 14 ) ) ;
chckbx_EvaluateStyleDeParagraphe . setBounds ( 6 , 42 , 540 , 23 ) ;
panelStyleStructure . add ( chckbx_EvaluateStyleDeParagraphe ) ;
scrollPane_evaluationAttributStyleParagraphe . setBounds ( 10 , 192 , 519 , 97 ) ;
panelStyleStructure . add ( scrollPane_evaluationAttributStyleParagraphe ) ;
scrollPane_evaluationAttributStyleParagraphe . setViewportView ( editorPane_evaluateStyleParagrapheAttribut ) ;
lbl_NombrePointAttributEvaluationStyleParagraphe . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
lbl_NombrePointAttributEvaluationStyleParagraphe . setBounds ( 10 , 164 , 94 , 14 ) ;
panelStyleStructure . add ( lbl_NombrePointAttributEvaluationStyleParagraphe ) ;
textField_evaluateStyleParagrapheAttributNbrPoint . setText ( " 0 " ) ;
textField_evaluateStyleParagrapheAttributNbrPoint . setHorizontalAlignment ( SwingConstants . CENTER ) ;
textField_evaluateStyleParagrapheAttributNbrPoint . setFont ( new Font ( " Tahoma " , Font . BOLD , 12 ) ) ;
textField_evaluateStyleParagrapheAttributNbrPoint . setColumns ( 10 ) ;
textField_evaluateStyleParagrapheAttributNbrPoint . setBounds ( 114 , 156 , 57 , 31 ) ;
panelStyleStructure . add ( textField_evaluateStyleParagrapheAttributNbrPoint ) ;
JScrollPane leftScrollPane = new JScrollPane ( ) ;
leftScrollPane . setPreferredSize ( new Dimension ( 200 , 0 ) ) ;
JScrollPane rightScrollPane = new JScrollPane ( ) ;
JSplitPane splitPane = new JSplitPane ( JSplitPane . HORIZONTAL_SPLIT , leftScrollPane , rightScrollPane ) ;
2022-05-31 19:37:46 +02:00
splitPane . setBounds ( 10 , 10 , 800 , 783 ) ;
2022-05-28 19:13:25 +02:00
panel . add ( splitPane ) ;
rightScrollPane . setViewportView ( textNodeSelect ) ;
textNodeSelect . setFont ( new Font ( " Monospaced " , Font . PLAIN , 15 ) ) ;
leftScrollPane . setViewportView ( tree ) ;
tree . setFont ( new Font ( " Tahoma " , Font . PLAIN , 14 ) ) ;
2022-06-01 21:38:37 +02:00
2022-06-02 15:47:54 +02:00
if ( commandes . fichierAnalyseValide ) constructionTree ( ) ;
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 ) {
refeshNodeSelected ( ) ;
2022-05-28 19:13:25 +02:00
}
2022-06-01 21:38:37 +02:00
}
} ) ;
2022-06-02 15:47:54 +02:00
// tree.addTreeWillExpandListener(new MyTreeWillExpandListener());
// tree.addTreeExpansionListener(new MyTreeExpansionListener());
2022-06-01 21:38:37 +02:00
}
public void refeshNodeSelected ( ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
if ( tree . getSelectionPath ( ) ! = null ) {
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
node nodeParent = nod . getParent ( ) ;
StringBuilder sb = new StringBuilder ( ) ;
sb . append ( balisestyles ( ) ) ;
sb . append ( " <p class= \" p1 \" >Parent = " + nodeParent . getNomElt ( ) + " </p><br> " ) ;
sb . append ( " <hr> " ) ;
sb . append ( " <br><h1>Nom du node : " + nod . getNomElt ( ) + " </h1><br> " ) ;
sb . append ( " <hr> " ) ;
Enumeration < String > key = nod . getAttributs ( ) . keys ( ) ;
if ( nod . getAttributs ( ) . size ( ) > 0 ) sb . append ( " <br><h4><u>Attribut(s)</u></h4> " ) ;
sb . append ( " <ul> " ) ;
while ( key . hasMoreElements ( ) ) {
String k = key . nextElement ( ) ;
boolean ecrit = false ;
if ( nod . getAttributs ( ) . get ( " evaluer " ) ! = null ) {
if ( nod . getAttributs ( ) . get ( " evaluer " ) . equals ( " true " ) ) {
switch ( k ) {
case ( " evalContenu " ) :
sb . append ( " <li class= \" p2 \" ><b> " + k + " = \" " + nod . getAttributs ( ) . get ( k ) + " \" </b></li> " ) ;
ecrit = true ;
break ;
case ( " evaluer " ) :
sb . append ( " <li class= \" p2 \" ><b> " + k + " = \" " + nod . getAttributs ( ) . get ( k ) + " \" </b></li> " ) ;
ecrit = true ;
break ;
}
if ( nod . getAttributs ( ) . get ( k ) . contains ( " ‽ " ) & & ! ecrit ) {
sb . append ( " <li class= \" p2 \" ><b> " + k + " = \" " + nod . getAttributs ( ) . get ( k ) + " \" </b></li> " ) ;
ecrit = true ;
2022-05-28 19:13:25 +02:00
} else {
2022-06-01 21:38:37 +02:00
sb . append ( " <li class= \" p2 \" > " + k + " = \" " + nod . getAttributs ( ) . get ( k ) + " \" </li> " ) ;
ecrit = true ;
2022-05-28 19:13:25 +02:00
}
2022-06-01 21:38:37 +02:00
2022-05-28 19:13:25 +02:00
} else {
sb . append ( " <li class= \" p3 \" > " + k + " = \" " + nod . getAttributs ( ) . get ( k ) + " \" </li> " ) ;
2022-06-01 21:38:37 +02:00
if ( nod . getAttributs ( ) . get ( k ) . contains ( " ‽ " ) ) sb . append ( " <li class= \" p3 \" ><b> " + k + " = \" " + nod . getAttributs ( ) . get ( k ) + " \" </b></li> " ) ;
2022-05-28 19:13:25 +02:00
}
2022-06-01 21:38:37 +02:00
} else {
sb . append ( " <li class= \" p3 \" > " + k + " = \" " + nod . getAttributs ( ) . get ( k ) + " \" </li> " ) ;
2022-05-28 19:13:25 +02:00
}
2022-06-01 21:38:37 +02:00
2022-05-28 19:13:25 +02:00
}
2022-06-01 21:38:37 +02:00
sb . append ( " </ul> " ) ;
2022-05-28 19:13:25 +02:00
2022-06-01 21:38:37 +02:00
if ( ! nod . retourneLesContenusEnfants ( " " ) . trim ( ) . isEmpty ( ) ) {
sb . append ( " <br><br><h4><u>Contenu</u></h4><br> " + nod . retourneLesContenusEnfants ( " " ) ) ;
}
textNodeSelect . setText ( " <html> " + sb . toString ( ) + " </html> " ) ;
}
}
/ * *
* Création du menu contextuel du tree
* @return
* /
private JPopupMenu createPopupMenuTree ( ) {
2022-06-02 15:47:54 +02:00
JMenu mnEvaluer = new JMenu ( " Evaluer " ) ;
mnEvaluer . add ( actEvalueTrue ) ;
mnEvaluer . add ( actEvalueFalse ) ;
2022-06-01 21:38:37 +02:00
JMenu mnManageTree = new JMenu ( " Arbre " ) ;
mnManageTree . add ( actExpandAll ) ;
mnManageTree . add ( actExpandNode ) ;
mnManageTree . addSeparator ( ) ;
mnManageTree . add ( actCollapseAll ) ;
mnManageTree . add ( actCollapseNode ) ;
2022-06-02 15:47:54 +02:00
JMenu mnNiveauPrincipal = new JMenu ( " Node niveau 1 " ) ;
mnNiveauPrincipal . add ( " Ajoute une lien de menu " ) ;
mnNiveauPrincipal . add ( " Ajoute un titre de menu " ) ;
mnNiveauPrincipal . add ( " Coefficient " ) ;
2022-06-01 21:38:37 +02:00
JPopupMenu mnPopupTree = new JPopupMenu ( ) ;
2022-06-02 15:47:54 +02:00
mnPopupTree . add ( mnEvaluer ) ;
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( mnNiveauPrincipal ) ;
2022-06-01 21:38:37 +02:00
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( actNodeFichier ) ;
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( mnManageTree ) ;
mnPopupTree . addSeparator ( ) ;
mnPopupTree . add ( actDelete ) ;
return mnPopupTree ;
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 =*/
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-01 21:38:37 +02:00
// menu Modifier
JMenu mnuModif = new JMenu ( " Modifier " ) ;
mnuModif . setMnemonic ( 'M' ) ;
mnuModif . add ( actOpen ) ;
mnuModif . add ( actNodeFichier ) ;
2022-06-02 15:47:54 +02:00
mnuModif . addSeparator ( ) ;
mnuModif . add ( actNewFichierAnalyse ) ;
2022-06-01 21:38:37 +02:00
menuBar . add ( mnuModif ) ;
2022-05-28 19:13:25 +02:00
// Définition du menu déroulant "Edit" et de son contenu
JMenu mnuExercice = new JMenu ( " Création évaluation " ) ;
mnuExercice . setMnemonic ( 'N' ) ;
mnuExercice . add ( actConfiguration ) ;
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 ( ) {
toolBar = new JToolBar ( ) ;
JButton buttonLoadFile = toolBar . add ( actOpen ) ;
buttonLoadFile . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/fichierAnalyse.png " ) ) ) ;
2022-06-01 21:38:37 +02:00
buttonLoadFile . setHideActionText ( true ) ;
2022-06-02 15:47:54 +02:00
toolBar . add ( buttonLoadFile ) ;
JButton btnNewFichierAnalyse = toolBar . add ( actNewFichierAnalyse ) ;
btnNewFichierAnalyse . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/fichierODF.png " ) ) ) ;
btnNewFichierAnalyse . setHideActionText ( true ) ;
toolBar . add ( btnNewFichierAnalyse ) ;
2022-05-28 19:13:25 +02:00
2022-06-01 21:38:37 +02:00
JButton btnNodeFichier = toolBar . add ( actNodeFichier ) ;
btnNodeFichier . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/nodeFichier.png " ) ) ) ;
btnNodeFichier . setHideActionText ( true ) ;
toolBar . add ( btnNodeFichier ) ;
2022-05-28 19:13:25 +02:00
toolBar . addSeparator ( ) ;
JButton btnAbout = toolBar . add ( actAbout ) ;
btnAbout . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/apropos.png " ) ) ) ;
btnAbout . setHideActionText ( true ) ;
toolBar . add ( btnAbout ) ;
2022-06-01 21:38:37 +02:00
JButton btnDocumentation = toolBar . add ( actDocumentation ) ;
btnDocumentation . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/documentation.png " ) ) ) ;
btnDocumentation . setHideActionText ( true ) ;
toolBar . add ( btnDocumentation ) ;
2022-05-28 19:13:25 +02:00
toolBar . addSeparator ( ) ;
toolBar . add ( actExit ) . setHideActionText ( true ) ;
toolBar . addSeparator ( ) ;
toolBar . add ( actConfiguration ) ;
2022-06-01 21:38:37 +02:00
JButton button = toolBar . add ( actEvaluer ) ;
button . setIcon ( new ImageIcon ( create . class . getResource ( " /resources/evaluate.png " ) ) ) ;
2022-05-28 19:13:25 +02:00
// if(commandes.fichierAnalyseValide) {
// toolBar.add( actConfiguration ).setEnabled(true);
// toolBar.add( actEvaluer ).setEnabled(true);
// }else {
// toolBar.add( actConfiguration ).setEnabled( false );
// toolBar.add( actEvaluer ).setEnabled(false);
// }
}
/*Mise à jour de la toolbar*/
private void MAJToolBar ( ) {
// if(commandes.fichierAnalyseValide) {
// toolBar.getComponent(6).setEnabled(true);
// toolBar.getComponent(7).setEnabled(true);
// menuBar.getComponent(3).setEnabled(true);
// }else {
// toolBar.getComponent(6).setEnabled(false);
// toolBar.getComponent(7).setEnabled(false);
// menuBar.getComponent(3).setEnabled(false);
// }
}
/ * *
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 ( ) ;
textNodeSelect . setText ( " Le chargement de la nouvelle structure est réussi. " ) ;
MAJToolBar ( ) ;
2022-06-02 15:47:54 +02:00
} else {
constructionTree ( ) ;
textNodeSelect . setText ( commandes . message . toString ( ) ) ;
MAJToolBar ( ) ;
2022-05-28 19:13:25 +02:00
}
System . out . println ( " Open " ) ;
}
} ;
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 " ) ) {
new proprieteFichierAnalyse ( ) ;
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-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 " ) ;
}
} ;
/ * *
*
* /
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 "
+ " Dans le dossier " + commandes . path ;
2022-06-02 15:47:54 +02:00
} else {
message = " \" Voulez-vous enregistrer le fichier \" " + commandes . nameSujet + " .xml \" \ n "
+ " Dans le dossier " + commandes . path ;
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-05-28 19:13:25 +02:00
Run . ecritureNodeEnXML ( commandes . sujet , commandes . nameSujet , commandes . path , " sujet " ) ;
if ( m . find ( ) ) {
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " a été renregistré. \ n \ n "
+ " Il se trouve dans le dossier " + commandes . path ) ;
} else {
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " .xml \" a été renregistré. \ n \ n "
+ " Il se trouve dans le dossier " + commandes . path ) ;
}
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 ( ) ;
}
}
}
} ;
/ * *
*
* /
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 ( ) ) {
file = new File ( commandes . path ) ; //+ "\\" + utils.filename + ".xml"
}
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 ( ) ;
commandes . path = fileToSave . getPath ( ) . substring ( 0 , fileToSave . getPath ( ) . lastIndexOf ( " \\ " ) ) ;
Pattern p = Pattern . compile ( " [.xml] \\ b " ) ;
Matcher m = p . matcher ( commandes . nameSujet ) ;
if ( m . find ( ) ) {
file = new File ( commandes . path + " \\ " + commandes . nameSujet ) ;
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " a été renregistré. \ n \ nIl se trouve dans le dossier " + commandes . path ) ;
} else {
file = new File ( commandes . path + " \\ " + commandes . nameSujet + " .xml " ) ;
textNodeSelect . setText ( " Le fichier \" " + commandes . nameSujet + " .xml \" a été renregistré. \ n \ nIl se trouve dans le dossier " + commandes . path ) ;
}
} catch ( IOException e1 ) {
e1 . printStackTrace ( ) ;
2022-06-02 15:47:54 +02:00
} catch ( CloneNotSupportedException e1 ) {
// TODO Auto-generated catch block
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 " ) ;
}
} ;
/ * *
*
* /
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 " ) ;
}
} ;
/ * *
*
* /
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
/ * *
* Supprime un node
* /
private AbstractAction actDelete = new AbstractAction ( ) {
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 " ) ) ) {
nod . getParent ( ) . supprimeNodeEnfant ( nod ) ;
constructionTree ( ) ;
} else {
JOptionPane . showMessageDialog ( null , " Vous ne devez pas supprimer ce node ! " , " Oh non!!! " , JOptionPane . INFORMATION_MESSAGE ) ;
}
2022-06-01 21:38:37 +02:00
}
}
}
} ;
/ * *
* Evalue le node est tous ces enfants
* /
private AbstractAction actEvalueTrue = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer true " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/evaluertruemini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer true " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
// TreePath p = tree.getSelectionPath();
// int level = p.getPathCount();
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . evaluerTrue ( ) ;
refeshNodeSelected ( ) ;
// tree.setModel(commandes.tree.getModel()) ;
// constructionTree();
// try {
// expandOrCollapsePath(tree,p,level,1,true);
// }catch(Exception e1) {
// e1.printStackTrace();
// //do nothing
// }
// System.out.println(p.toString());
// System.out.println(tree.getExpandsSelectedPaths());
// tree.setSelectionPath(p);
// tree.expandPath(p);
}
} ;
// 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 {
d . open ( new File ( evaluate . class . getResource ( " /resources/documentation.pdf " ) . getPath ( ) ) ) ;
} catch ( IOException e1 ) {
// TODO Auto-generated catch block
e1 . printStackTrace ( ) ;
}
System . out . println ( " Affiche la documentation. " ) ;
}
} ;
private AbstractAction actEvalueFalse = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Evaluer false " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( create . class . getResource ( " /resources/evaluerfalsemini.png " ) ) ) ;
putValue ( Action . SHORT_DESCRIPTION , " Evaluer false " ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
DefaultMutableTreeNode selectNode = ( DefaultMutableTreeNode ) tree . getSelectionPath ( ) . getLastPathComponent ( ) ;
textNodeSelect . setContentType ( " text/html " ) ;
node nod = ( node ) selectNode . getUserObject ( ) ;
nod . evaluerFalse ( ) ;
refeshNodeSelected ( ) ;
}
} ;
private AbstractAction actExpandAll = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
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 ( ) ;
refeshNodeSelected ( ) ;
}
} ;
private AbstractAction actCollapseAll = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
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 ( ) ;
refeshNodeSelected ( ) ;
}
} ;
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 ) ;
refeshNodeSelected ( ) ;
}
}
} ;
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 ) ;
refeshNodeSelected ( ) ;
}
}
} ;
2022-05-28 19:13:25 +02:00
/ * *
*
* /
private AbstractAction actConfiguration = new AbstractAction ( ) {
private static final long serialVersionUID = 1L ;
{
putValue ( Action . NAME , " Configuration " ) ;
putValue ( Action . SMALL_ICON , new ImageIcon ( getClass ( ) . getResource ( " /configuration.png " ) ) ) ;
putValue ( Action . MNEMONIC_KEY , KeyEvent . VK_W ) ;
putValue ( Action . SHORT_DESCRIPTION , " Configurer le fichier pour l'évaluation " ) ;
putValue ( Action . ACCELERATOR_KEY , KeyStroke . getKeyStroke ( KeyEvent . VK_W , KeyEvent . ALT_DOWN_MASK ) ) ;
}
@Override public void actionPerformed ( ActionEvent e ) {
if ( commandes . fichierAnalyseValide ) {
} else {
JOptionPane . showMessageDialog ( null , " Charger un fichier Writer (.odt) ou un fichier d'évaluaton (.xml). " ) ;
}
System . out . println ( " Configuration " ) ;
}
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 ( ) ) ;
commandes . path = chooser . getCurrentDirectory ( ) . getAbsolutePath ( ) ;
commandes . PathFilenameAnalysis = chooser . getSelectedFile ( ) . getAbsolutePath ( ) ;
commandes . nameSujet = chooser . getSelectedFile ( ) . getName ( ) ;
Run b = null ;
try {
b = new Run ( commandes . PathFilenameAnalysis ) ;
node nodSujet = Run . XMLContent ( b . getLectDossiers ( ) . getEC ( ) . getListeContentWriter ( ) . get ( 0 ) ) ;
nodSujet = meptl . LectureFichierEtudiantSousFormeDeNode ( nodSujet , b , 0 ) ;
nodSujet . getAttributs ( ) . put ( " analysis_filename " , " sujet.xml " ) ;
commandes . sujet = ecritureSujet . nodePourEcritureSujet ( nodSujet , b , 0 ) ;
new verificationFichierAnalyse ( ) ;
if ( commandes . fichierAnalyseValide ) {
constructionTree ( ) ;
} else {
textNodeSelect . setText ( " <h1>Le fichier n'est pas valise</h1> " ) ;
}
} catch ( ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1 ) {
e1 . printStackTrace ( ) ;
}
} else {
refeshNodeSelected ( ) ;
}
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-05-28 19:13:25 +02:00
DefaultMutableTreeNode node0 = null ;
DefaultMutableTreeNode node1 = null ;
DefaultMutableTreeNode node2 = null ;
DefaultMutableTreeNode node3 = null ;
DefaultMutableTreeNode node4 = null ;
DefaultMutableTreeNode node5 = null ;
DefaultMutableTreeNode node6 = null ;
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-05-28 19:13:25 +02:00
2022-06-02 15:47:54 +02:00
if ( commandes . sujet . getNomElt ( ) . equals ( " fichier " ) ) {
2022-05-28 19:13:25 +02:00
node0 = new DefaultMutableTreeNode ( commandes . sujet . getNomElt ( ) , true ) ;
2022-06-01 21:38:37 +02:00
2022-06-02 15:47:54 +02:00
if ( commandes . sujet ! = null ) for ( int i = 0 ; i < commandes . sujet . getNodes ( ) . size ( ) ; i + + ) {
2022-05-28 19:13:25 +02:00
node1 = new DefaultMutableTreeNode ( commandes . sujet . getNodes ( ) . get ( i ) ) ;
2022-06-02 15:47:54 +02:00
if ( commandes . sujet . getNodes ( ) . get ( i ) ! = null ) for ( int j = 0 ; j < commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . size ( ) ; j + + ) {
node2 = new DefaultMutableTreeNode ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) ) ;
if ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) ! = null ) for ( int k = 0 ; k < commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . size ( ) ; k + + ) {
2022-05-28 19:13:25 +02:00
node3 = new DefaultMutableTreeNode ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) ) ;
2022-06-02 15:47:54 +02:00
if ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) ! = null ) for ( int l = 0 ; l < commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . size ( ) ; l + + ) {
2022-05-28 19:13:25 +02:00
node4 = new DefaultMutableTreeNode ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . get ( l ) ) ;
2022-06-02 15:47:54 +02:00
if ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . get ( l ) ! = null ) for ( int m = 0 ; m < commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . get ( l ) . getNodes ( ) . size ( ) ; m + + ) {
2022-05-28 19:13:25 +02:00
node5 = new DefaultMutableTreeNode ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . get ( l ) . getNodes ( ) . get ( m ) ) ;
2022-06-02 15:47:54 +02:00
if ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . get ( l ) . getNodes ( ) . get ( m ) ! = null ) for ( int n = 0 ; n < commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . get ( l ) . getNodes ( ) . get ( m ) . getNodes ( ) . size ( ) ; n + + ) {
2022-05-28 19:13:25 +02:00
node6 = new DefaultMutableTreeNode ( commandes . sujet . getNodes ( ) . get ( i ) . getNodes ( ) . get ( j ) . getNodes ( ) . get ( k ) . getNodes ( ) . get ( l ) . getNodes ( ) . get ( m ) . getNodes ( ) . get ( n ) ) ;
2022-06-01 21:38:37 +02:00
node5 . add ( node6 ) ;
2022-05-28 19:13:25 +02:00
}
node4 . add ( node5 ) ;
}
node3 . add ( node4 ) ;
}
node2 . add ( node3 ) ;
}
node1 . add ( node2 ) ;
}
node0 . add ( node1 ) ;
}
}
commandes . tree = new JTree ( node0 ) ;
DefaultTreeCellRenderer cellRenderer = ( DefaultTreeCellRenderer ) commandes . tree . getCellRenderer ( ) ;
cellRenderer . setOpenIcon ( new ImageIcon ( create . class . getResource ( " /resources/treeOpen.png " ) ) ) ;
cellRenderer . setClosedIcon ( new ImageIcon ( create . class . getResource ( " /resources/treeOpen.png " ) ) ) ;
cellRenderer . setLeafIcon ( new ImageIcon ( create . class . getResource ( " /resources/treeOpen.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 . setModel ( commandes . tree . getModel ( ) ) ;
}
/ * *
* 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;} "
+ " 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-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");
//
// }
//}