package fenetres; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.io.IOException; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; 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; import javax.swing.JScrollPane; import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.SwingConstants; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.filechooser.FileNameExtensionFilter; import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.SAXException; import MEPTL.commandes; import MEPTL.meptl; import cXML.Run; import cXML.node; import fenetres.create_act.actAbout; import fenetres.create_act.actDocumentation; import fenetres.create_act.actLicence; import fenetres.create_act.actTutoriels; import net.miginfocom.swing.MigLayout; /** * * @author pablo rodriguez * */ public class evaluate extends JFrame { /** * */ private static final long serialVersionUID = 1L; /** * */ private JToolBar toolBar; private JPanel contentPane; private JLabel lblPath; private JLabel lblFileAnalyse; private JLabel lblFichierCSV; private JLabel lblFichierSVG; private JLabel lblChargementFichierCSV; private JCheckBox chckbxfichiersEtudiants; private JCheckBox chckbxZipfeedback; private JCheckBox chckbxnoFeedback; private JCheckBox chckbxNoNote; private JCheckBox chckCSVNotes; private JCheckBox chckbxNoLogo; private JCheckBox chckbxVerif; private JCheckBox chckbxNewLogo; private JCheckBox chckbxNoDetail; private static afficheText txtpnmessages; private static evaluate instance; /** * Create the frame. */ public void initialize() throws UnsupportedLookAndFeelException{ setSize(1200,800); ImageIcon img = new ImageIcon(getClass().getResource("/evalwriter.png") ); this.setIconImage(img.getImage()); setTitle(commandes.Titre + " " + commandes.version + " " + commandes.branch); setLocationRelativeTo( null ); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // setBounds(100, 100, 980, 700); 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); createMenu(); createToolBar(); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); contentPane.add(toolBar, BorderLayout.NORTH); JPanel panelWest = new JPanel(); contentPane.add(panelWest, BorderLayout.WEST); panelWest.setLayout(new MigLayout("", "[24px][260px]", "[71px][71px][36px][24px][24px][24px][24px][24px][24px][36px][24px][24px][24px][24px][][]")); ImageIcon imgDossierEtudaint = new ImageIcon(getClass().getResource("/dossieretudiantmini.png") ); lblFileAnalyse = new JLabel("Fichier de l'analyse : "); lblFileAnalyse.setHorizontalAlignment(SwingConstants.LEFT); lblFileAnalyse.setFont(new Font("Tahoma", Font.BOLD, 14)); panelWest.add(lblFileAnalyse, "cell 1 0,alignx left,aligny top"); JLabel lblImageDossierEtudiant = new JLabel(imgDossierEtudaint); panelWest.add(lblImageDossierEtudiant, "flowx,cell 0 2,alignx center,aligny center"); chckbxVerif = new JCheckBox("Vérification des historiques avant analyse"); chckbxVerif.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxVerif.isSelected()) { commandes.verifHisto2=true; }else { commandes.verifHisto2=false; } } }); chckbxfichiersEtudiants = new JCheckBox("Les fichiers des étudiants
ne sont pas dans des dossiers nominatifs"); chckbxfichiersEtudiants.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxfichiersEtudiants.isSelected()) { commandes.fichierStudentMoodle=true; }else { commandes.fichierStudentMoodle=false; } } }); chckbxfichiersEtudiants.setFont(new Font("Tahoma", Font.PLAIN, 12)); chckbxfichiersEtudiants.setToolTipText("Cochez si les fichiers des étudiants ne sont pas dans des dossier nominatifs"); panelWest.add(chckbxfichiersEtudiants, "cell 1 2,growx,aligny center"); chckbxfichiersEtudiants.setSelected(commandes.fichierStudentMoodle); chckbxnoFeedback = new JCheckBox("Pas de feedback"); chckbxnoFeedback.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxnoFeedback.isSelected()) { commandes.sansFeeback=true; }else { commandes.sansFeeback=false; } } }); ImageIcon imgDNoFeedBack = new ImageIcon(getClass().getResource("/nofeedbackmini.png") ); JLabel lblNoFeedBack = new JLabel(imgDNoFeedBack); panelWest.add(lblNoFeedBack, "cell 0 3"); chckbxnoFeedback.setToolTipText("Cochez si vous ne voulez pas générer des feedbacks"); chckbxnoFeedback.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxnoFeedback, "cell 1 3,growx,aligny top"); chckbxnoFeedback.setSelected(commandes.sansFeeback); chckbxNoDetail = new JCheckBox("Pas de détails dans les feedbacks"); chckbxNoDetail.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxNoDetail.isSelected()) { commandes.noDetail=true; }else { commandes.noDetail=false; } } }); ImageIcon imgDNoDetail = new ImageIcon(getClass().getResource("/nodetailmini.png") ); JLabel lblNoDeatail = new JLabel(imgDNoDetail); panelWest.add(lblNoDeatail, "cell 0 4"); chckbxNoDetail.setToolTipText("Cochez si vous voulez que la table synthèse dans les feedbacks"); chckbxNoDetail.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxNoDetail, "cell 1 4,growx,aligny top"); chckbxNoDetail.setSelected(commandes.noDetail); chckbxNoNote = new JCheckBox("Pas de note dans les feedbacks"); chckbxNoNote.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxNoNote.isSelected()) { commandes.noNote=true; }else { commandes.noNote=false; } } }); chckbxNoNote.setToolTipText("Cochez si vous voulez pas faire apparaître les notes dans les feedbacks"); chckbxNoNote.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxNoNote, "cell 1 5,grow"); chckbxNoNote.setSelected(commandes.noNote); chckbxZipfeedback = new JCheckBox("Zip les feedbacks"); chckbxZipfeedback.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxZipfeedback.isSelected()) { commandes.zipfeedback=true; }else { commandes.zipfeedback=false; } } }); chckbxZipfeedback.setToolTipText("Cochez si vous voulez placer tous les feedbacks dans une archive ZIP"); chckbxZipfeedback.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxZipfeedback, "cell 1 6,grow"); chckbxZipfeedback.setSelected(commandes.zipfeedback); chckbxVerif.setToolTipText("Cochez si vous voulez vérifier les échanges de fichiers entre les étudiants."); chckbxVerif.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxVerif, "flowy,cell 1 7,growx,aligny top"); chckbxVerif.setSelected(commandes.verifHisto2); lblChargementFichierCSV = new JLabel("Chargement de la liste des étudiants"); panelWest.add(lblChargementFichierCSV, "cell 1 8,alignx left,aligny center"); lblFichierCSV = new JLabel("Fichier CSV liste des étudiants :"); lblFichierCSV.setFont(new Font("Tahoma", Font.BOLD, 14)); panelWest.add(lblFichierCSV, "cell 1 9,grow"); chckCSVNotes = new JCheckBox("Créer un fichier CSV des notes"); chckCSVNotes.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckCSVNotes.isSelected()) { commandes.ecritNoteCSV=true; }else { commandes.ecritNoteCSV=false; } } }); chckCSVNotes.setToolTipText("Cochez si vous voulez importer les notes dans un fichier CSV."); panelWest.add(chckCSVNotes, "flowx,cell 1 10,grow"); chckCSVNotes.setSelected(commandes.ecritNoteCSV); lblFichierSVG = new JLabel("Fichier SVG :"); lblFichierSVG.setFont(new Font("Tahoma", Font.BOLD, 14)); panelWest.add(lblFichierSVG, "cell 1 11,growx"); chckbxNoLogo = new JCheckBox("Pas de logo"); chckbxNoLogo.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxNoLogo.isSelected()) { commandes.noLogo=true; }else { commandes.noLogo=false; } } }); chckbxNewLogo = new JCheckBox("Nouveau logo"); chckbxNewLogo.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if(chckbxNewLogo.isSelected()) { commandes.newLogo=true; }else { commandes.newLogo=false; } } }); chckbxNewLogo.setToolTipText("Cochez si vous voulez remplacer le logo par celui au-dessus."); chckbxNewLogo.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxNewLogo, "cell 1 12"); chckbxNewLogo.setSelected(commandes.newLogo); chckbxNoLogo.setToolTipText("Cochez si vous voulez pas de logo dans les feedbacks."); chckbxNoLogo.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxNoLogo, "cell 1 13"); chckbxNoLogo.setSelected(commandes.noLogo); lblPath = new JLabel(); lblPath.setHorizontalAlignment(SwingConstants.LEFT); lblPath.setFont(new Font("Tahoma", Font.BOLD, 14)); lblPath.setText("Dossier de l'analyse : " + commandes.path.substring(commandes.path.lastIndexOf("\\")+1,commandes.path.length()) + ""); panelWest.add(lblPath, "cell 1 1,growx,aligny top"); JPanel panelCentre = new JPanel(); contentPane.add(panelCentre, BorderLayout.CENTER); panelCentre.setLayout(new BorderLayout(0, 0)); JScrollPane scrollPane = new JScrollPane(); panelCentre.add(scrollPane); txtpnmessages = new afficheText(); txtpnmessages.setFont(new Font("Tahoma", Font.PLAIN, 16)); txtpnmessages.setContentType("text/html"); txtpnmessages.setText(baliseStyle.balise() + "

*** Charger un fichier d'analyse. ***


"); scrollPane.setViewportView(txtpnmessages); if(commandes.fourniCSV) { lblChargementFichierCSV.setBackground(new Color(40,180,40)); lblChargementFichierCSV.setOpaque(true); lblFichierCSV.setText("Fichier CSV : " + commandes.nameCSV + ""); }else { lblChargementFichierCSV.setOpaque(false); lblFichierCSV.setText("Fichier CSV"); } this.setExtendedState(MAXIMIZED_BOTH); ListenerAction(); refreshLabel(); setVisible(true); } private void ListenerAction() { /*Some piece of code*/ addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { if(JOptionPane.showConfirmDialog(null,"Voulez-vous quitter analyseWriter?", "Quitter", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION) { dispose(); } } }); } public static evaluate getInstance() { if (instance == null) { instance = new evaluate(); } instance.setVisible(true); if(commandes.fichierAnalyseValide) { txtpnmessages.afficheChargementFichierAnalyse(); }else { txtpnmessages.setText(baliseStyle.balise() + "

*** Veuillez charger un fichier d'analyse ***


"); } return instance; } /** * Create the application. */ public evaluate() { try { initialize(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } setVisible(true); } private void createMenu() { JMenuBar menuBar = new JMenuBar(); menuBar.setFont(new Font("Segoe UI", Font.BOLD, 14)); setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu("Fichier"); mnNewMenu.setMnemonic( 'F' ); menuBar.add(mnNewMenu); mnNewMenu.add( actSave ); mnNewMenu.add( actSaveas ); mnNewMenu.addSeparator(); mnNewMenu.add( actExit ); JMenu mnMenu_Fichier = new JMenu("Fichier d'analyse"); menuBar.add(mnMenu_Fichier); mnMenu_Fichier.add( actOpen ); mnMenu_Fichier.addSeparator(); mnMenu_Fichier.add( actAboutFichierAnalyse ); mnMenu_Fichier.add( actCodeFichierAnalyse ); mnMenu_Fichier.add( actModifierFichierAnalyse ); JMenu mnMenu_Liste_Etudiant = new JMenu("Liste des étudiants"); menuBar.add(mnMenu_Liste_Etudiant); mnMenu_Liste_Etudiant.add(actChargeListeEtudiantCSV); mnMenu_Liste_Etudiant.addSeparator(); mnMenu_Liste_Etudiant.add(actAfficheListeEtudiant ); mnMenu_Liste_Etudiant.add(actVerifCSV ); JMenu mnMenu_Logo = new JMenu("Logo"); menuBar.add(mnMenu_Logo); mnMenu_Logo.add(actChargeLogo); JMenu mnMenu_Evaluation = new JMenu("Evaluation des étudiants"); menuBar.add(mnMenu_Evaluation); mnMenu_Evaluation.add(actSelectFolder); mnMenu_Evaluation.addSeparator(); mnMenu_Evaluation.add(actEvaluate); mnMenu_Evaluation.addSeparator(); mnMenu_Evaluation.add(actVerifHistorique); JMenu mnMenu_Informations = new JMenu("Aides"); menuBar.add(mnMenu_Informations); mnMenu_Informations.add( new actAbout() ); mnMenu_Informations.addSeparator(); mnMenu_Informations.add(new actDocumentation()); mnMenu_Informations.addSeparator(); mnMenu_Informations.add(new actTutoriels()); mnMenu_Informations.addSeparator(); mnMenu_Informations.add( new actLicence()); } private void createToolBar() { toolBar = new JToolBar(); JButton btnSelectFileAnalyse = toolBar.add( actOpen ); btnSelectFileAnalyse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnSelectFileAnalyse.setHideActionText( true ); btnSelectFileAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyse.png"))); JButton btnInformationAnalyse = toolBar.add( actCodeFichierAnalyse ); btnInformationAnalyse.setHideActionText(true); btnInformationAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfo2.png"))); JButton btnAfficheCodeFichierAnalyse = toolBar.add( actAboutFichierAnalyse ); btnAfficheCodeFichierAnalyse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnAfficheCodeFichierAnalyse.setHideActionText(true); btnAfficheCodeFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfo.png"))); toolBar.add(btnAfficheCodeFichierAnalyse); JButton btnModifierFichierAnalyse = toolBar.add(actModifierFichierAnalyse); btnModifierFichierAnalyse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnModifierFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/versfichierAnalyse.png"))); btnModifierFichierAnalyse.setHideActionText(true); toolBar.add(btnModifierFichierAnalyse); toolBar.addSeparator(); JButton btnEvaluerLesFichiers = toolBar.add(actEvaluate); btnEvaluerLesFichiers.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnEvaluerLesFichiers.setHideActionText(true); JButton btnFichierCSV = toolBar.add(actChargeListeEtudiantCSV ); btnFichierCSV.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnFichierCSV.setHideActionText(true); btnFichierCSV.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSV.png"))); toolBar.add(btnFichierCSV); JButton btnInfoListeEtudiant = toolBar.add(actAfficheListeEtudiant); btnInfoListeEtudiant.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnInfoListeEtudiant.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfo.png"))); btnInfoListeEtudiant.setHideActionText(true); toolBar.add(btnInfoListeEtudiant); JButton btnVerificationCSVavecFichierAnalyse = toolBar.add( actVerifCSV ); btnVerificationCSVavecFichierAnalyse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnVerificationCSVavecFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfoXML.png"))); btnVerificationCSVavecFichierAnalyse.setHideActionText(true); toolBar.add(btnVerificationCSVavecFichierAnalyse); toolBar.addSeparator(); JButton btnFichierSVG = toolBar.add(actChargeLogo); btnFichierSVG.setHideActionText(true); btnFichierSVG.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierSVG.png"))); toolBar.add(btnFichierSVG); toolBar.addSeparator(); JButton btnSelectFolder = toolBar.add(actSelectFolder); btnSelectFolder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnSelectFolder.setIcon(new ImageIcon(evaluate.class.getResource("/resources/open.png"))); btnSelectFolder.setHideActionText(true); toolBar.add(btnSelectFolder); btnEvaluerLesFichiers.setIcon(new ImageIcon(evaluate.class.getResource("/resources/evaluate.png"))); toolBar.add(btnEvaluerLesFichiers); JButton btnVerifHistorique = toolBar.add(actVerifHistorique); btnVerifHistorique.setIcon(new ImageIcon(evaluate.class.getResource("/resources/verifhistorique.png"))); btnVerifHistorique.setHideActionText(true); toolBar.add(btnVerifHistorique); toolBar.addSeparator(); JButton btnAbout = toolBar.add(new actAbout()); btnAbout.setIcon(new ImageIcon(evaluate.class.getResource("/resources/apropos.png"))); btnAbout.setHideActionText(true); toolBar.add(btnAbout); JButton btnTutoriels = toolBar.add(new actDocumentation()); btnTutoriels.setIcon(new ImageIcon(evaluate.class.getResource("/resources/documentation.png"))); toolBar.add(btnTutoriels); toolBar.addSeparator(); JButton btnExit = toolBar.add(actExit); btnExit.setIcon(new ImageIcon(evaluate.class.getResource("/resources/exit.png"))); btnExit.setHideActionText(true); toolBar.add(btnExit); } /** * Raffraichi les informations.
*/ private void refreshLabel() { if(!commandes.fichierAnalyseValide) { System.out.println( "Erreur du fichier d'analyse" ); if(!MEPTL.verificationFichierAnalyse.messageErreur.toString().isEmpty()) txtpnmessages.setText(MEPTL.verificationFichierAnalyse.messageErreur.toString()); chckbxfichiersEtudiants.setEnabled(false); chckbxZipfeedback.setEnabled(false); chckbxnoFeedback.setEnabled(false); chckbxNoNote.setEnabled(false); chckCSVNotes.setEnabled(false); chckbxNewLogo.setEnabled(false); chckbxNoLogo.setEnabled(false); chckbxVerif.setEnabled(false); chckbxNoDetail.setEnabled(false); }else { chckbxfichiersEtudiants.setEnabled(true); chckbxZipfeedback.setEnabled(true); chckbxnoFeedback.setEnabled(true); chckbxNoNote.setEnabled(true); chckCSVNotes.setEnabled(true); chckbxNewLogo.setEnabled(true); chckbxNoLogo.setEnabled(true); chckbxVerif.setEnabled(true); chckbxNoDetail.setEnabled(true); txtpnmessages.afficheChargementFichierAnalyse(); } lblPath.setText("Dossier de l'analyse :
" + commandes.path.substring(commandes.path.lastIndexOf("\\")+1,commandes.path.length()) + ""); lblFileAnalyse.setText("Fichier de l'analyse :
" + commandes.analysis_filename + ""); lblFichierSVG.setText("Fichier SVG :
" + commandes.nameSVG.substring(commandes.nameSVG.lastIndexOf("\\")+1,commandes.nameSVG.length()) + ""); lblFichierCSV.setText("Fichier CSV :
" + commandes.nameCSV + ""); } /** * * Evaluer l'ensemble des fichiers des étudiants.
*/ private AbstractAction actEvaluate = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/evaluate.png"))); putValue( Action.NAME, "Evaluer les fichiers" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/evaluatemini.png")) ); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_E ); putValue( Action.SHORT_DESCRIPTION, "Evaluer les fichiers (CTRL+E)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed(ActionEvent e) { Thread t2 = new Thread(new evaluerLesFichiersEtudiants(txtpnmessages)); t2.start(); } }; /** * Ouvre et affiche un fichier d'analyse au format XML.
*/ private AbstractAction actOpen = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue(LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyse.png"))); putValue( Action.NAME, "Ouvrir un nouveau fichier d'analyse" ); putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/fichierAnalysemini.png")) ); 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 ) { System.out.println( "Open" ); new filechooserXML(); System.out.println( "Rafraichissement du label informations" ); refreshLabel(); System.out.println( "Open close" ); } }; /** * Chargement d'un logo SVG.
*/ private AbstractAction actChargeLogo = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierSVG.png"))); putValue( Action.NAME, "Charge un logo SVG" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierSVGmini.png"))); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_G ); putValue( Action.SHORT_DESCRIPTION, "Charge un logo SVG (CTRL+G)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Choisir un fichier SVG"); chooser.setCurrentDirectory(new java.io.File(commandes.path)); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter filter = new FileNameExtensionFilter("Format SVG", "svg"); 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.nameSVG = chooser.getSelectedFile().getAbsolutePath(); commandes.contenuFichierSVG= meptl.chargementFichierSVG(); txtpnmessages.setContentType("text/plain"); txtpnmessages.setText(commandes.contenuFichierSVG); } else { commandes.nameSVG = ""; commandes.contenuFichierSVG=""; System.out.println("No Selection "); } refreshLabel(); } }; /** * Sélectionne le dossier courant contenant les fichiers des étudiants */ private AbstractAction actSelectFolder = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue(LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/open.png"))); putValue( Action.NAME, "Dossier d'analyse" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/openmini.png")) ); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_U ); putValue( Action.SHORT_DESCRIPTION, "Dossier d'analyse (CTRL+U)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(commandes.path)); chooser.setDialogTitle("Sélectionner le dossier contenant les fichiers des étudiants."); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); System.out.println("getSelectedFile() : " + chooser.getSelectedFile().getAbsolutePath()); commandes.path = chooser.getSelectedFile().getAbsolutePath(); } else { System.out.println("No Selection "); } refreshLabel(); } }; /** /** * Verification de l'historique.
*/ private AbstractAction actVerifHistorique = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/verifhistorique.png"))); putValue( Action.NAME, "Evaluer l'historique des modification" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/verifhistoriquemini.png"))); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_H ); putValue( Action.SHORT_DESCRIPTION, "Evaluer l'historique des modification (CTRL+H)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { commandes.verifHisto = true; commandes.analyse = false; if(!commandes.path.isEmpty()) { try { msgBox V = new msgBox("Je travaille dure.",false,false,"Attendez"); Thread.sleep(100); meptl.analyseVerifieHistoriqueLesFichiersEtudiantsEtExportNoteCSV(); txtpnmessages.setContentType("text/plain"); txtpnmessages.setText(commandes.message.toString()); V.close(); } catch (ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1) { e1.printStackTrace(); } catch (InterruptedException e1) { e1.printStackTrace(); } }else { txtpnmessages.setText("*** Veuillez sélectionner un dossier d'analyse. ***"); } commandes.verifHisto = false; } }; private AbstractAction actVerifCSV = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfoXML.png"))); putValue( Action.NAME, "Vérification des champs du CSV" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfoXMLmini.png")) ); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_U ); putValue( Action.SHORT_DESCRIPTION, "Vérification des champs du CSV (CTRL+B)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { if(commandes.fichierAnalyseValide) { if(commandes.fourniCSV) { node settingCSV = commandes.sujet.retourneFirstEnfantsByName("import_moodle"); if(settingCSV.isHasAttributs()) { String email ="inconnu"; String name = "inconnu"; String firstname = "inconnu"; String id = "inconnu"; txtpnmessages.setContentType("text/plain"); boolean avertissement = false; if(settingCSV.getAttributs().get("email")!=null) { email = settingCSV.getAttributs().get("email"); } if(settingCSV.getAttributs().get("name")!=null) { name = settingCSV.getAttributs().get("name"); } if(settingCSV.getAttributs().get("firstname")!=null) { firstname = settingCSV.getAttributs().get("firstname"); } if(settingCSV.getAttributs().get("id")!=null) { id = settingCSV.getAttributs().get("id"); } if(commandes.nodeCSV.getNodes().get(0).getAttributs().get(firstname)==null) { txtpnmessages.setText("*** AVERTISSEMENT - Il n'y a pas le champ " + firstname + " dans le fichier CSV. ***"); avertissement=true; } if(commandes.nodeCSV.getNodes().get(0).getAttributs().get(name)==null) { txtpnmessages.setText("*** AVERTISSEMENT - Il n'y a pas le champ " + name + " dans le fichier CSV. ***"); avertissement=true; } if(commandes.nodeCSV.getNodes().get(0).getAttributs().get(id)==null) { txtpnmessages.setText("*** AVERTISSEMENT - Il n'y a pas le champ " + id + " dans le fichier CSV. ***"); avertissement=true; } if(commandes.nodeCSV.getNodes().get(0).getAttributs().get(email)==null) { txtpnmessages.setText("*** AVERTISSEMENT - Il n'y a pas le champ " + email + " dans le fichier CSV. ***"); avertissement=true; } if(!avertissement) { txtpnmessages.setText("*** Le fichier CSV contenant la liste des étudiants peut être utilisé avec les paramètres du fichier d'analyse ***"); } }else { txtpnmessages.setText("*** Le fichier CSV contenant la liste des étudiants est vide ***"); } }else { txtpnmessages.setText("*** Veuillez charger un fichier CSV contenant la liste des étudiants ***"); new msgBox("Le fichier CSV contenant la liste des étudiants n'est pas chargé.",true,false,"Avertissement"); } }else { txtpnmessages.setText("*** Veuillez charger un fichier d'analyse ***"); new msgBox("Le fichier d'analyse n'est pas valide.",true,false,"Avertissement"); } } }; /** * Information sur le fichier d'analyse.
*/ private AbstractAction actAboutFichierAnalyse = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Informations du fichier d'analyse" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfo2mini.png"))); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_K ); putValue( Action.SHORT_DESCRIPTION, "Informations du fichier d'analyse (CTRL+K)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { if(commandes.fichierAnalyseValide) { txtpnmessages.afficheChargementFichierAnalyse(); }else { txtpnmessages.setText(baliseStyle.balise() + "

*** Veuillez charger un fichier d'analyse ***


"); } } }; /** * Quitter l'application */ private AbstractAction actExit = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Quitter" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/exitmini.png"))); putValue( Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/exit.png")) ); 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 ) { if(JOptionPane.showConfirmDialog(null,"Voulez-vous quitter analyseWriter?", "Quitter", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION) { dispose(); } } }; /** * Enregistre l'évaluation.
*/ private AbstractAction actSave = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Enregistrer la zone de texte" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/savemini.png"))); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_S ); putValue( Action.SHORT_DESCRIPTION, "Enregistrer la zone de texte (CRTL+S)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK ) ); } @Override public void actionPerformed( ActionEvent e ) { } }; /** * Enregistre sous l'évaluation.
*/ private AbstractAction actSaveas = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Enregistrer la zone de texte sous ..." ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/saveasmini.png"))); putValue( Action.SHORT_DESCRIPTION, "Enregistrer la zone de texte sous ..." ); } @Override public void actionPerformed( ActionEvent e ) { } }; /** * */ @SuppressWarnings("unused") private AbstractAction actSavePreference = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Enregistrer prefrences" ); putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/savepreferencemini.png")) ); putValue( Action.LARGE_ICON_KEY, new ImageIcon(create.class.getResource("/resources/savepreference.png")) ); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_W ); putValue( Action.SHORT_DESCRIPTION, "Enregistrer prefrences" ); 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" ); } }; /** * Affiche le code XMl du fichier d'analyse */ private AbstractAction actCodeFichierAnalyse = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Affiche le code XML" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfomini.png")) ); putValue( Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfo.png")) ); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_J ); putValue( Action.SHORT_DESCRIPTION, "Affiche le code XML (CTRL+J)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_J, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { txtpnmessages.setContentType("text/plain"); if(commandes.fichierAnalyseValide) { txtpnmessages.setText(Run.ecritureNode(commandes.sujet, 0).toString()); }else { txtpnmessages.setText("*** Veuillez charger un fichier d'analyse ***"); } System.out.println( "Affiche le code XML du fichier d'analyse." ); } }; /** * Affiche le code XMl du fichier d'analyse */ private AbstractAction actModifierFichierAnalyse = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Modifier le fichier d'analyse" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseModifmini.png")) ); putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseModif.png"))); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_M ); putValue( Action.SHORT_DESCRIPTION, "Modifier le fichier d'analyse (CTRL+M)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { create.getInstance(); evaluate.getInstance().dispose(); } }; /** * Charge la liste des étudiants sous la forme d'un fichier XML. */ private AbstractAction actChargeListeEtudiantCSV = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Charge la liste des étudiants" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierCSVmini.png")) ); putValue( Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierCSV.png")) ); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_L ); putValue( Action.SHORT_DESCRIPTION, "Charge la liste des étudiants (CTRL+L)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Choisir un fichier CSV"); chooser.setCurrentDirectory(new java.io.File(commandes.path)); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter filter = new FileNameExtensionFilter("Format CSV", "csv"); 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.nameCSV = chooser.getSelectedFile().getAbsolutePath(); commandes.nodeCSV = meptl.chargementFichierCSV(); commandes.fourniCSV=true; txtpnmessages.setContentType("text/plain"); if(!commandes.nodeCSV.getNomElt().equals("fileCSV")) { commandes.fourniCSV=false; txtpnmessages.setText("

*** Ce n'est pas un fichier format CSV contenant la liste des étudiants. ***

"); commandes.nodeCSV = null; } if(commandes.nodeCSV.getNodes().size()<=0) { commandes.fourniCSV=false; txtpnmessages.setText("

*** Le fichier ne contient pas d'étudiant ***

"); commandes.nodeCSV = null; } txtpnmessages.setText(Run.ecritureNode(commandes.nodeCSV, 0).toString()); System.out.println( "Charge la liste des étudiants." ); } else { // commandes.nameCSV = ""; // commandes.fourniCSV=false; // System.out.println("No Selection "); // commandes.nodeCSV = new node(); // refreshLabel(); } if(commandes.fourniCSV) { lblChargementFichierCSV.setBackground(new Color(40,180,40)); lblChargementFichierCSV.setOpaque(true); lblFichierCSV.setText("Fichier CSV : " + commandes.nameCSV + ""); }else { lblChargementFichierCSV.setOpaque(false); lblFichierCSV.setText("Fichier CSV"); } } }; /** * Affiche le code XMl du fichier d'analyse */ private AbstractAction actAfficheListeEtudiant = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Affiche la liste des étudiants" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfomini.png")) ); putValue( Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfo.png")) ); putValue( Action.MNEMONIC_KEY, KeyEvent.VK_L ); putValue( Action.SHORT_DESCRIPTION, "Affiche la liste des étudiants (ALT+L)" ); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.ALT_DOWN_MASK) ); } @Override public void actionPerformed( ActionEvent e ) { if(commandes.fourniCSV) { txtpnmessages.setText(Run.ecritureNode(commandes.nodeCSV, 0).toString()); System.out.println( "Affiche la liste des étudiants déjà en mémoire." ); }else { txtpnmessages.setText("*** Veuillez sélectionner un fichier CSV contenant la liste des étudiants. ***"); } } }; }