// Implémentation de MouseListener @Override public void mouseClicked(MouseEvent event) { if (event.getSource() == this.jtable) { // Vérifier s'il s'agit d'un double click if (event.getClickCount() == 2) { // Vérifier s'il y a une ligne de séléctionnée if (this.jtable.getSelectedRow() != -1) { // Récupérer le nom du participant séléctionné String nomParticipant = this.getNomParticipant(); // Créer et afficher la fenêtre de modification de participant CollectorParticipantEditer collector = new CollectorParticipantEditer(nomParticipant); JDialog jd_participant = new JDParticipantEditer( this.w_parent, collector, ContestOrg.get().getCtrlParticipants().getInfosParticipant(nomParticipant)); collector.setWindow(jd_participant); jd_participant.setVisible(true); } } } }
/** @see ActionListener#actionPerformed(ActionEvent) */ @Override public void actionPerformed(ActionEvent event) { // Conserver la sélection du jtree actuelle TreePath path = this.jtree.getSelectionPath(); if (event.getSource() == this.jb_categories) { // Créer et afficher la fenêtre de gestion des catégories new JDCategories(this.w_parent).setVisible(true); } else if (event.getSource() == this.jb_poules) { // Créer et afficher la fenêtre de gestion des poules new JDPoules(this.w_parent).setVisible(true); } else if (event.getSource() == this.jb_nouveau) { // Récupérer la catégorie et la poule séléctionnées Pair<String, String> selection = this.getSelection(); // Créer et afficher la fenêtre de création de participant CollectorParticipantCreer collector = new CollectorParticipantCreer(); JDialog jd_participant = new JDParticipantCreer( this.w_parent, collector, selection.getFirst(), selection.getSecond()); collector.setWindow(jd_participant); jd_participant.setVisible(true); } else if (event.getSource() == this.jb_importer) { // Récupérer la catégorie et la poule séléctionnées Pair<String, String> selection = this.getSelection(); // Créer et afficher la fenêtre d'importation new JDImporterParticipants(this.w_parent, selection.getFirst(), selection.getSecond()) .setVisible(true); } else if (event.getSource() == this.jb_exporter) { // Récupérer la catégorie et la poule séléctionnées Pair<String, String> selection = this.getSelection(); // Créer et afficher la fenêtre de gestion d'exportation new JDExporter( this.w_parent, InfosTheme.CATEGORIE_PARTICIPANTS, selection.getFirst(), selection.getSecond(), null) .setVisible(true); } else if (event.getSource() == this.jb_editer) { // Vérifier s'il y a une ligne de séléctionnée if (this.jtable.getSelectedRow() != -1) { // Récupérer le nom du participant séléctionné String nomParticipant = this.getNomParticipant(); // Créer et afficher la fenêtre de modification de participant CollectorParticipantEditer collector = new CollectorParticipantEditer(nomParticipant); JDialog jd_participant = new JDParticipantEditer( this.w_parent, collector, ContestOrg.get().getCtrlParticipants().getInfosParticipant(nomParticipant)); collector.setWindow(jd_participant); jd_participant.setVisible(true); } else { // Message d'erreur ViewHelper.derror( this.w_parent, "Veuillez sélectionner " + (ContestOrg.get().getCtrlParticipants().getTypeParticipants() == InfosModelConcours.PARTICIPANTS_EQUIPES ? "l'équipe" : "le joueur") + " que vous désirez éditer."); } } else if (event.getSource() == this.jb_supprimer) { // Vérifier s'il y a une ligne de séléctionnée if (this.jtable.getSelectedRow() != -1) { if (this.jtable.getSelectedRowCount() == 1) { // Récupérer le nom du participant séléctionné String nomParticipant = this.getNomParticipant(); // Demander la suppression du participant if (ViewHelper.confirmation( this.w_parent, "Désirez-vous vraiment supprimer " + (ContestOrg.get().getCtrlParticipants().getTypeParticipants() == InfosModelConcours.PARTICIPANTS_EQUIPES ? "l'équipe" : "le joueur") + " \"" + nomParticipant + "\" ?")) { ContestOrg.get().getCtrlParticipants().removeParticipant(nomParticipant); } } else { // Récupérer les noms des participants séléctionnés ArrayList<String> nomParticipants = new ArrayList<String>(); for (int index : this.jtable.getSelectedRows()) { nomParticipants.add( (String) this.jtable .getModel() .getValueAt( this.jtable.getRowSorter().convertRowIndexToModel(index), this.jtable.getModel().getColumnCount() - 6)); } // Demander la suppression des participants if (ViewHelper.confirmation( this.w_parent, "Désirez-vous vraiment supprimer " + (ContestOrg.get().getCtrlParticipants().getTypeParticipants() == InfosModelConcours.PARTICIPANTS_EQUIPES ? "les équipe séléctionnées" : "les joueurs séléctionnés") + " ?")) { ContestOrg.get().getCtrlParticipants().removeParticipants(nomParticipants); } } } else { // Message d'erreur ViewHelper.derror( this.w_parent, "Veuillez sélectionner " + (ContestOrg.get().getCtrlParticipants().getTypeParticipants() == InfosModelConcours.PARTICIPANTS_EQUIPES ? "l'équipe" : "le joueur") + " que vous désirez supprimer."); } } // Remettre la sélection du jtree initiale this.jtree.setSelectionPath(path); }