package app; import java.awt.BorderLayout; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.io.File; 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.JPanel; import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.border.EmptyBorder; import javax.swing.filechooser.FileNameExtensionFilter; import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.SAXException; import MEPTL.commandes; import MEPTL.ecritureSujet; import MEPTL.meptl; import MEPTL.verificationFichierAnalyse; import cXML.Run; import cXML.node; import javax.swing.SwingConstants; import javax.swing.JScrollPane; import javax.swing.JProgressBar; import net.miginfocom.swing.MigLayout; import java.awt.event.InputEvent; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JOptionPane; import java.awt.Color; import java.awt.Desktop; import java.awt.EventQueue; import javax.swing.JEditorPane; 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 JCheckBox chckbxfichiersEtudaints; private JCheckBox chckbxZipfeedback; private JCheckBox chckbxnoFeedback; private JCheckBox chckbxNoNote; private JCheckBox chckCSVNotes; private JCheckBox chckbxNoLogo; private JCheckBox chckbxVerif; private JCheckBox chckbxNewLogo; private JEditorPane txtpnmessages; public JProgressBar progressBarre; /** * Create the frame. */ public evaluate() { ImageIcon img = new ImageIcon(getClass().getResource("/evalwriter.png") ); this.setIconImage(img.getImage()); this.setTitle(commandes.Titre); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 980, 700); 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("", "[309px][]", "[38.00][71px][71px][][71px][][74.00][][]")); JLabel lblTITRE = new JLabel("PARAMETRES"); lblTITRE.setForeground(Color.RED); lblTITRE.setFont(new Font("Tahoma", Font.BOLD, 16)); lblTITRE.setHorizontalAlignment(SwingConstants.CENTER); panelWest.add(lblTITRE, "cell 0 0,alignx left,aligny center"); lblFileAnalyse = new JLabel("Fichier de l'analyse : "); lblFileAnalyse.setHorizontalAlignment(SwingConstants.LEFT); lblFileAnalyse.setFont(new Font("Tahoma", Font.BOLD, 14)); panelWest.add(lblFileAnalyse, "flowy,cell 0 1,alignx left,growy"); chckbxfichiersEtudaints = new JCheckBox("Les fichiers ne sont pas dans des dossiers nominatifs"); chckbxfichiersEtudaints.setFont(new Font("Tahoma", Font.PLAIN, 12)); chckbxfichiersEtudaints.setToolTipText("Cochez si les fichiers des étudiants ne sont pas dans des dossier nominatifs"); panelWest.add(chckbxfichiersEtudaints, "flowy,cell 0 2,grow"); lblFichierCSV = new JLabel("Fichier CSV liste des étudiants :"); lblFichierCSV.setFont(new Font("Tahoma", Font.BOLD, 14)); panelWest.add(lblFichierCSV, "flowy,cell 0 4,grow"); lblFichierSVG = new JLabel("Fichier SVG :"); lblFichierSVG.setFont(new Font("Tahoma", Font.BOLD, 14)); panelWest.add(lblFichierSVG, "flowy,cell 0 6,growx"); chckCSVNotes = new JCheckBox("Créer un fichier CSV des notes"); chckCSVNotes.setToolTipText("Cochez si vous voulez importer les notes dans un fichier CSV."); panelWest.add(chckCSVNotes, "cell 0 4,grow"); 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 0 1,grow"); chckbxnoFeedback = new JCheckBox("Pas de feedback"); 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 0 2,grow"); chckbxZipfeedback = new JCheckBox("Zip les feedbacks"); 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 0 2,grow"); chckbxNoNote = new JCheckBox("Pas de note dans les feedbacks"); 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 0 2,grow"); chckbxVerif = new JCheckBox("Vérification des historiques avant analyse"); 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, "cell 0 2,grow"); chckbxNewLogo = new JCheckBox("Nouveau logo"); 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 0 6"); chckbxNoLogo = new JCheckBox("Pas de logo"); chckbxNoLogo.setToolTipText("Cochez si vous voulez pas de logo dans les feedbacks."); chckbxNoLogo.setFont(new Font("Tahoma", Font.PLAIN, 12)); panelWest.add(chckbxNoLogo, "cell 0 6"); JPanel panelCentre = new JPanel(); contentPane.add(panelCentre, BorderLayout.CENTER); panelCentre.setLayout(new BorderLayout(0, 0)); JScrollPane scrollPane = new JScrollPane(); panelCentre.add(scrollPane); progressBarre = new JProgressBar(); progressBarre.setEnabled(true); panelCentre.add(progressBarre, BorderLayout.NORTH); txtpnmessages = new JEditorPane(); txtpnmessages.setFont(new Font("Tahoma", Font.PLAIN, 14)); txtpnmessages.setText("*** Charger un fichier d'analyse. ***"); scrollPane.setViewportView(txtpnmessages); this.setExtendedState(MAXIMIZED_BOTH); refreshLabel(); setVisible(true); // Pro(); } private void Pro() { // progressBarre = new JProgressBar(); progressBarre.setMaximum(100000000); progressBarre.setStringPainted(true); for(int i = 0 ; i < 1000; i++) { progressBarre.setValue(i); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } 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 ); mnMenu_Fichier.addSeparator(); mnMenu_Fichier.add( actNewFichierAnalyse ); 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("Informations"); menuBar.add(mnMenu_Informations); mnMenu_Informations.add(actDocumentation); mnMenu_Informations.addSeparator(); mnMenu_Informations.add( actAbout ); } private void createToolBar() { toolBar = new JToolBar(); JButton btnSelectFileAnalyse = toolBar.add( actOpen ); 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.setHideActionText(true); btnAfficheCodeFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfo.png"))); toolBar.add(btnAfficheCodeFichierAnalyse); JButton btnModifierFichierAnalyse = toolBar.add(actModifierFichierAnalyse); btnModifierFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseModif.png"))); btnModifierFichierAnalyse.setHideActionText(true); toolBar.add(btnModifierFichierAnalyse); toolBar.addSeparator(); JButton btnNewFichierAnalyse = toolBar.add(actNewFichierAnalyse); btnNewFichierAnalyse.setHideActionText(true); btnNewFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierODF.png"))); toolBar.add(btnNewFichierAnalyse); toolBar.addSeparator(); JButton btnEvaluerLesFichiers = toolBar.add(actEvaluate); btnEvaluerLesFichiers.setHideActionText(true); JButton btnFichierCSV = toolBar.add(actChargeListeEtudiantCSV ); btnFichierCSV.setHideActionText(true); btnFichierCSV.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSV.png"))); toolBar.add(btnFichierCSV); JButton btnInfoListeEtudiant = toolBar.add(actAfficheListeEtudiant); btnInfoListeEtudiant.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfo.png"))); btnInfoListeEtudiant.setHideActionText(true); toolBar.add(btnInfoListeEtudiant); JButton btnVerificationCSVavecFichierAnalyse = toolBar.add( actVerifCSV ); 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.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 btnNewButton = toolBar.add( actDocumentation ); btnNewButton.setIcon(new ImageIcon(evaluate.class.getResource("/resources/documentation.png"))); btnNewButton.setHideActionText(true); toolBar.add(btnNewButton); JButton btnAbout = toolBar.add(actAbout); btnAbout.setIcon(new ImageIcon(evaluate.class.getResource("/resources/apropos.png"))); btnAbout.setHideActionText(true); toolBar.add(btnAbout); toolBar.addSeparator(); 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) { if(!MEPTL.verificationFichierAnalyse.messageErreur.toString().isEmpty()) txtpnmessages.setText(MEPTL.verificationFichierAnalyse.messageErreur.toString()); chckbxfichiersEtudaints.setEnabled(false); chckbxZipfeedback.setEnabled(false); chckbxnoFeedback.setEnabled(false); chckbxNoNote.setEnabled(false); chckCSVNotes.setEnabled(false); chckbxNewLogo.setEnabled(false); chckbxNoLogo.setEnabled(false); chckbxVerif.setEnabled(false); }else { chckbxfichiersEtudaints.setEnabled(true); chckbxZipfeedback.setEnabled(true); chckbxnoFeedback.setEnabled(true); chckbxNoNote.setEnabled(true); chckCSVNotes.setEnabled(true); chckbxNewLogo.setEnabled(true); chckbxNoLogo.setEnabled(true); chckbxVerif.setEnabled(true); StringBuilder text = new StringBuilder(); text.append("\n***********************************************"); text.append("\n INFORMATIONS"); text.append("\n***********************************************"); text.append("\nLe titre de l'exercice est : " + commandes.analyse_titre); text.append("\n"); text.append("\nLe sujet (metaSujet) est : " + commandes.analyse_metaSujet); text.append("\n"); text.append("\nL'auteur de l'exercice est : " + commandes.analyse_auteur); text.append("\n"); if(commandes.analyse_baremeABC==true) { text.append("\nLa notation est sous la forme d'un barème alphabétique ABCDE."); text.append("\n\tLa progression est de " + String.valueOf(commandes.analyse_progression)); }else { text.append("\nLa notation est sous la forme d'une note numérique."); text.append("\n\tLe barème est sur " + String.valueOf(commandes.analyse_notefrom)); text.append("\n\tLa progression est de " + String.valueOf(commandes.analyse_progression)); } text.append("\n______"); text.append("\nLe nom du fichier : " + commandes.analysis_filename); text.append("\nLe hash de l'évaluation est : " + commandes.hash); text.append("\n______"); text.append("\nHistoriques des modifications present : " + commandes.analyse_historiquePresent); text.append("\n______"); text.append("\nVerification de la presence metaSujet : " + commandes.analyse_presenceMetaSujet); text.append("\n______"); text.append("\nContrôle la date de céation : " + commandes.analyse_controleDateCreation); text.append("\n______"); text.append("\nContrôle l'auteur initial du fichier : " + commandes.analyse_controle_Initial_Creator); text.append("\n\n***********************************************"); text.append("\n\n***********************************************"); text.append("\nDossier de l'analyse contenant les fichiers des étudiants :"); text.append("\n"+commandes.path+"\n"); text.append("\nFichier d'analyse :"); text.append("\n"+commandes.PathFilenameAnalysis+"\n"); progressBarre.setVisible(false); txtpnmessages.setText(text.toString()); } 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 et analayser les 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 ) { if(commandes.fichierAnalyseValide) { // JOptionPane.showMessageDialog(null, "Je boss", "Je travaille", JOptionPane.PLAIN_MESSAGE, null); // new msgBox("Je travaille dure.",true,false,"Attendez"); evaluerLesFichiersEtudiants E = new evaluerLesFichiersEtudiants(chckbxfichiersEtudaints.isSelected(), chckbxZipfeedback.isSelected(),chckbxnoFeedback.isSelected(), chckbxNoNote.isSelected(), chckCSVNotes.isSelected(), chckbxNewLogo.isSelected(), chckbxNoLogo.isSelected(), chckbxVerif.isSelected(), progressBarre, txtpnmessages); E.run(); // try { // t1.join(); // t2.join(); // // } catch (InterruptedException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } }else { txtpnmessages.setText("*** Veuillez charger un fichier d'analyse ***"); new msgBox("Le fichier d'analyse n'est pas valide.",true,false,"Avertissement"); } } }; /** * Ouvre et affiche un fichier 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 ) { new filechooserXML(); refreshLabel(); System.out.println( "Open" ); } }; /** * Charge 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.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 */ 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.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"; 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"); } } }; /** * 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"); nodSujet = ecritureSujet.nodePourEcritureSujet(nodSujet,b,0); Run.ecritureNodeEnXML(nodSujet, "sujet",commandes.path,"Sujet"); txtpnmessages.setText(Run.ecritureNode(nodSujet, 0).toString() + "\n\n" +"\n*************************" +"\nLe fichier sujet.xml a été généré dans le dossier :" +"\n" + commandes.path +"\n*************************"); commandes.sujet = nodSujet; new verificationFichierAnalyse(); } catch (ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1) { e1.printStackTrace(); } } else { commandes.nameSujet = ""; commandes.PathFilenameAnalysis = ""; System.out.println("No Selection "); commandes.fichierAnalyseValide=false; refreshLabel(); } commandes.ecritCode = true; } }; /** * 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) { refreshLabel(); }else { txtpnmessages.setText("*** Veuillez charger un fichier d'analyse ***"); } System.out.println( "Refresh Labels and texts" ); } }; /** * 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 ) { 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()); dispose(); } } }; 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 ) { } }; 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 ) { } }; /** * Affiche la fenêtre d'information sur analyseWriter */ private AbstractAction actAbout = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Informations" ); putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/aproposmini.png")) ); 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" ); } }; /** * 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 ) { 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 ) { // if(commandes.fichierAnalyseValide) { // // }else { // txtpnmessages.setText("*** Veuillez sélectionner un fichier d'analyse pour le modifier ***"); // } new create(); dispose(); System.out.println( "Affiche la fenêtre pour la modification." ); } }; /** * Affiche la documentation */ private AbstractAction actDocumentation = new AbstractAction() { private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Documentation (CTRL+D)" ); putValue( Action.SMALL_ICON, new ImageIcon(evaluate.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." ); } }; /** * Charge la liste des étudiants sous la frome 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(); txtpnmessages.setText(Run.ecritureNode(commandes.nodeCSV, 0).toString()); commandes.fourniCSV=true; if(!commandes.nodeCSV.getNomElt().equals("fileCSV")) { commandes.fourniCSV=false; } if(commandes.nodeCSV.getNodes().size()<=0) { commandes.fourniCSV=false; txtpnmessages.setText("*** Le fichier ne contient pas d'étudiant ***"); } } else { commandes.nameCSV = ""; commandes.fourniCSV=false; System.out.println("No Selection "); commandes.nodeCSV = new node(); refreshLabel(); } System.out.println( "Charge la liste des étudiants." ); } }; /** * 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()); }else { txtpnmessages.setText("*** Veuillez sélectionner un fichier CSV contenant la liste des étudiants. ***"); } System.out.println( "Affiche la liste des étudaints déjà en mémoire." ); } }; // /** // * Permet l'évaluation des fichiers des étudaints. // * @throws ParserConfigurationException // * @throws SAXException // * @throws IOException // * @throws CloneNotSupportedException // */ // private void evaluerLesFichiersEtudiants() throws ParserConfigurationException, SAXException, IOException, CloneNotSupportedException { // // commandes.analyse=true; // progressBarre.setVisible(true); // // if(chckbxfichiersEtudaints.isSelected()) commandes.fichierStudentMoodle=true; // if(chckbxZipfeedback.isSelected()) commandes.zipfeedback=true; // if(chckbxnoFeedback.isSelected()) commandes.sansFeeback=true; // if(chckbxNoNote.isSelected()) commandes.noNote=true; // if(chckCSVNotes.isSelected()) commandes.ecritNoteCSV=true; // if(chckbxNewLogo.isSelected()) commandes.newLogo=true; // if(chckbxNoLogo.isSelected()) commandes.noLogo = true; // if(chckbxVerif.isSelected()) commandes.verifHisto2 = true; // // meptl.analyseVerifieHistoriqueLesFichiersEtudiantsEtExportNoteCSV(); // // txtpnmessages.setText(commandes.message.toString()); // // // } }