Package View

Source Code of View.GestionPromoView$MyListRender

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package View;

import Modele.Eleve;
import Modele.GestionPromotion;
import Modele.Promotion;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BeanProperty;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.Bindings;
import org.jdesktop.beansbinding.Property;
import org.jdesktop.swingbinding.JListBinding;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;

/**
*
* @author tiph
*/
public class GestionPromoView extends javax.swing.JFrame {

        /**
         * Gere l'affichage des elements de la liste
         */
        private class MyListRender extends JLabel implements ListCellRenderer {

                @Override
                public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                       
                       
                        setText(((Promotion) value).getLibelle());
                        if (isSelected) {
                                setBackground(list.getSelectionBackground());
                                setForeground(list.getSelectionForeground());
                        } else {
                                setBackground(Color.WHITE);
                                setForeground(Color.BLACK);
                        }
                        if (((Promotion) value).getLibelle() == null || ((Promotion) value).getLibelle().isEmpty()) {
                                setBackground(Color.RED);
                                setText("Entrez un libelle au dessus");
                        }
                        setOpaque(true);

                        setPreferredSize(new Dimension(list.getWidth(), 20));

                        return this;
                }
        }

        /**
         * Creates new form GestionPromoView
         */
        public GestionPromoView() {

                initComponents();
                initBindings();

        }
        JTableBinding belves;
        JListBinding bpromos;

        private void initBindings() {

                BindingGroup bg = new BindingGroup();
                bpromos = SwingBindings.createJListBinding(AutoBinding.UpdateStrategy.READ,
                        GestionPromotion.getInstance().getPromotions(), l_promos);
                bg.addBinding(bpromos);

                AutoBinding btextpromo = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, l_promos,
                        (Property) BeanProperty.create("selectedElement.libelle"), tb_libelle_promo, (Property) BeanProperty.create("text"));
                bg.addBinding(btextpromo);
                btextpromo.setSourceUnreadableValue("");

                belves = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ_WRITE, l_promos, (Property) BeanProperty.create("selectedElement.eleves"), t_eleves);
                belves.addColumnBinding(BeanProperty.create("nom")).setColumnName("Nom").setEditable(false).setColumnClass(String.class);
                belves.addColumnBinding(BeanProperty.create("prenom")).setColumnName("Prénom").setEditable(false).setColumnClass(String.class);
                belves.addColumnBinding(BeanProperty.create("email")).setColumnName("Email").setEditable(false).setColumnClass(String.class);
                belves.addColumnBinding(BeanProperty.create("num")).setColumnName("Numéro").setEditable(false).setColumnClass(String.class);
                bg.addBinding(belves);

                AutoBinding nom_e = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, t_eleves,
                        (Property) BeanProperty.create("selectedElement.nom"), tb_nom_eleve, (Property) BeanProperty.create("text"));
                nom_e.setSourceUnreadableValue("");
                AutoBinding prenom_e = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, t_eleves,
                        (Property) BeanProperty.create("selectedElement.prenom"), tb_prenom_eleve, (Property) BeanProperty.create("text"));
                prenom_e.setSourceUnreadableValue("");
                AutoBinding email_e = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, t_eleves,
                        (Property) BeanProperty.create("selectedElement.email"), tb_email_eleve, (Property) BeanProperty.create("text"));
                email_e.setSourceUnreadableValue("");
                AutoBinding num_e = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, t_eleves,
                        (Property) BeanProperty.create("selectedElement.num"), tb_num_eleve, (Property) BeanProperty.create("text"));
                num_e.setSourceUnreadableValue("");

                bg.addBinding(nom_e);
                bg.addBinding(prenom_e);
                bg.addBinding(email_e);
                bg.addBinding(num_e);

                bg.bind();
        }

        /**
         * This method is called from within the constructor to initialize the
         * form. WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
                bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

                jLabel6 = new javax.swing.JLabel();
                jScrollPane1 = new javax.swing.JScrollPane();
                l_promos = new javax.swing.JList();
                tb_libelle_promo = new javax.swing.JTextField();
                jScrollPane2 = new javax.swing.JScrollPane();
                t_eleves = new javax.swing.JTable();
                bt_import_eleves = new javax.swing.JButton();
                jlabal1 = new javax.swing.JLabel();
                bt_create_promo = new javax.swing.JButton();
                bt_delete_promo = new javax.swing.JButton();
                bt_ajouter_eleve = new javax.swing.JButton();
                bt_delete_eleve = new javax.swing.JButton();
                jLabel1 = new javax.swing.JLabel();
                jLabel2 = new javax.swing.JLabel();
                jLabel3 = new javax.swing.JLabel();
                jLabel4 = new javax.swing.JLabel();
                jLabel5 = new javax.swing.JLabel();
                tb_email_eleve = new javax.swing.JTextField();
                tb_num_eleve = new javax.swing.JTextField();
                tb_nom_eleve = new javax.swing.JTextField();
                tb_prenom_eleve = new javax.swing.JTextField();
                bt_enregistrer_eleve = new javax.swing.JButton();
                bt_enregistrer_promo = new javax.swing.JButton();

                jLabel6.setText("kjoj");
                jLabel6.setBorder(null);
                jLabel6.setMaximumSize(new java.awt.Dimension(1000, 1000));
                jLabel6.setMinimumSize(new java.awt.Dimension(0, 0));
                jLabel6.setPreferredSize(new java.awt.Dimension(100, 100));

                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

                l_promos.setCellRenderer(new MyListRender());
                jScrollPane1.setViewportView(l_promos);

                jScrollPane2.setViewportView(t_eleves);

                bt_import_eleves.setText("Importer");

                org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, l_promos, org.jdesktop.beansbinding.ELProperty.create("${selectedElement!=null && selectedElement.id != null}"), bt_import_eleves, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
                bindingGroup.addBinding(binding);

                bt_import_eleves.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                bt_import_elevesActionPerformed(evt);
                        }
                });

                jlabal1.setText("Promotions");

                bt_create_promo.setText("Créer");
                bt_create_promo.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                bt_create_promoActionPerformed(evt);
                        }
                });

                bt_delete_promo.setText("Supprimer");

                binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, l_promos, org.jdesktop.beansbinding.ELProperty.create("${selectedElement!=null}"), bt_delete_promo, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
                bindingGroup.addBinding(binding);

                bt_delete_promo.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                bt_delete_promoActionPerformed(evt);
                        }
                });

                bt_ajouter_eleve.setText("Ajouter");

                binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, l_promos, org.jdesktop.beansbinding.ELProperty.create("${selectedElement!=null && selectedElement.id!=null}"), bt_ajouter_eleve, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
                bindingGroup.addBinding(binding);

                bt_ajouter_eleve.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                bt_ajouter_eleveActionPerformed(evt);
                        }
                });

                bt_delete_eleve.setText("Supprimer");

                binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, t_eleves, org.jdesktop.beansbinding.ELProperty.create("${selectedElement!=null}"), bt_delete_eleve, org.jdesktop.beansbinding.BeanProperty.create("enabled"), "");
                bindingGroup.addBinding(binding);

                bt_delete_eleve.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                bt_delete_eleveActionPerformed(evt);
                        }
                });

                jLabel1.setText("Eleves");

                jLabel2.setText("Numéro :");

                jLabel3.setText("E-mail :");

                jLabel4.setText("Prénom :");

                jLabel5.setText("Nom :");

                tb_email_eleve.setText("jTextField2");

                tb_num_eleve.setText("jTextField3");

                tb_prenom_eleve.setText("jTextField1");

                bt_enregistrer_eleve.setText("Enregistrer");

                binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, t_eleves, org.jdesktop.beansbinding.ELProperty.create("${selectedElement!=null}"), bt_enregistrer_eleve, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
                bindingGroup.addBinding(binding);

                bt_enregistrer_eleve.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                bt_enregistrer_eleveActionPerformed(evt);
                        }
                });

                bt_enregistrer_promo.setText("Enregistrer");

                binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, l_promos, org.jdesktop.beansbinding.ELProperty.create("${selectedElement!=null}"), bt_enregistrer_promo, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
                bindingGroup.addBinding(binding);

                bt_enregistrer_promo.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                bt_enregistrer_promoActionPerformed(evt);
                        }
                });

                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                getContentPane().setLayout(layout);
                layout.setHorizontalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(layout.createSequentialGroup()
                                                .addComponent(tb_libelle_promo, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(bt_enregistrer_promo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addGroup(layout.createSequentialGroup()
                                                .addComponent(bt_create_promo, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(bt_delete_promo, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                                .addGap(106, 106, 106)
                                                .addComponent(jlabal1))
                                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(layout.createSequentialGroup()
                                                .addGap(13, 13, 13)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
                                                        .addGroup(layout.createSequentialGroup()
                                                                .addComponent(bt_import_eleves, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addGap(18, 18, 18)
                                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addComponent(jLabel1)
                                                                        .addGroup(layout.createSequentialGroup()
                                                                                .addComponent(bt_ajouter_eleve, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                .addGap(18, 18, 18)
                                                                                .addComponent(bt_delete_eleve, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                                .addGap(0, 0, Short.MAX_VALUE))))
                                        .addGroup(layout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(layout.createSequentialGroup()
                                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addComponent(jLabel2)
                                                                        .addComponent(jLabel3)
                                                                        .addComponent(jLabel4)
                                                                        .addComponent(jLabel5))
                                                                .addGap(73, 73, 73)
                                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addComponent(tb_num_eleve)
                                                                        .addComponent(tb_prenom_eleve)
                                                                        .addComponent(tb_email_eleve)
                                                                        .addComponent(tb_nom_eleve)))
                                                        .addGroup(layout.createSequentialGroup()
                                                                .addComponent(bt_enregistrer_eleve, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addGap(0, 0, Short.MAX_VALUE)))))
                                .addGap(11, 11, 11))
                );
                layout.setVerticalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jlabal1)
                                        .addComponent(jLabel1))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(bt_create_promo)
                                        .addComponent(bt_delete_promo)
                                        .addComponent(bt_import_eleves)
                                        .addComponent(bt_ajouter_eleve)
                                        .addComponent(bt_delete_eleve))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(tb_nom_eleve, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(jLabel5))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(tb_prenom_eleve, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(jLabel4))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(tb_email_eleve, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(jLabel3))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(tb_num_eleve, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(jLabel2))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(bt_enregistrer_eleve))
                                        .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(tb_libelle_promo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(bt_enregistrer_promo))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jScrollPane1)))
                                .addContainerGap())
                );

                bindingGroup.bind();

                pack();
        }// </editor-fold>//GEN-END:initComponents

        private void bt_enregistrer_eleveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_enregistrer_eleveActionPerformed

                int selectedrow = t_eleves.getSelectedRow();
                if (t_eleves.getSelectedRow() != -1) {
                        Eleve e = ((Promotion) l_promos.getSelectedValue()).getEleves().get(t_eleves.getSelectedRow());
                        e.setNom(tb_nom_eleve.getText());
                        e.setPrenom(tb_prenom_eleve.getText());
                        e.setEmail(tb_email_eleve.getText());
                        e.setNum(tb_num_eleve.getText());
                        e.save();
                        // refresh la liste d eleve
                        belves.unbind();
                        belves.bind();
                        // mais le focus sur l eleve
                        if (selectedrow < t_eleves.getRowCount()) {
                                t_eleves.setRowSelectionInterval(selectedrow, selectedrow);
                        }

                }
        }//GEN-LAST:event_bt_enregistrer_eleveActionPerformed

        private void bt_delete_eleveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_delete_eleveActionPerformed

                int selectedrow = t_eleves.getSelectedRow();
                if (t_eleves.getSelectedRow() != -1) {

                        ArrayList<Eleve> asup = new ArrayList<Eleve>();
                        for (int i : t_eleves.getSelectedRows()) {
                                Eleve e = ((Promotion) l_promos.getSelectedValue()).getEleves().get(i);
                                //place les etudiants a supprimer dans une liste
                                asup.add(e);
                        }
                        for (Eleve eleve : asup) {
                                eleve.getPromotion().deleteStudent(eleve);
                        }
                        // refresh le binding
                        belves.unbind();
                        belves.bind();

                        // focus une nouvelle ligne d eleve si possible
                        if (t_eleves.getRowCount() > selectedrow) {
                                t_eleves.setRowSelectionInterval(selectedrow, selectedrow);
                        } else if (t_eleves.getRowCount() > 1) {
                                t_eleves.setRowSelectionInterval(t_eleves.getRowCount() - 1, t_eleves.getRowCount() - 1);
                        }

                }
        }//GEN-LAST:event_bt_delete_eleveActionPerformed

        private void bt_ajouter_eleveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_ajouter_eleveActionPerformed

                // ajoute un eleve vide modifiable aprés avoir cliquer sur ajouter grace a l'edition
                Eleve e = new Eleve("", "", "", "", (Promotion) l_promos.getSelectedValue());
                // ajoute uniquement a la liste pas encore sauvegarder dans le xml
                ((Promotion) l_promos.getSelectedValue()).getEleves().addLast(e);

                belves.unbind();
                belves.bind();
                //selectionne la ligne ajouter
                t_eleves.setRowSelectionInterval(t_eleves.getRowCount() - 1, t_eleves.getRowCount() - 1);
                tb_nom_eleve.requestFocus();


        }//GEN-LAST:event_bt_ajouter_eleveActionPerformed

        private void bt_import_elevesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_import_elevesActionPerformed

                JFileChooser fc = new JFileChooser();
                if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
                        ((Promotion) l_promos.getSelectedValue()).importStudent(fc.getSelectedFile().getAbsolutePath());
                }
                belves.unbind();
                belves.bind();

        }//GEN-LAST:event_bt_import_elevesActionPerformed

        private void bt_enregistrer_promoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_enregistrer_promoActionPerformed

                int sel = l_promos.getSelectedIndex();
                if (sel != -1) {
                        ((Promotion) l_promos.getSelectedValue()).setLibelle(tb_libelle_promo.getText());
                        ((Promotion) l_promos.getSelectedValue()).save();
                        bpromos.unbind();
                        bpromos.bind();
                        l_promos.setSelectedIndex(sel);

                }

        }//GEN-LAST:event_bt_enregistrer_promoActionPerformed

        private void bt_create_promoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_create_promoActionPerformed

                Promotion p = new Promotion("");
                // ajoute a la liste sans sauvegarder dans le xml (sauvegarde se fait avec le bouton enregistrer)
                GestionPromotion.getInstance().getPromotions().addLast(p);
                bpromos.unbind();
                bpromos.bind();
                l_promos.setSelectedIndex(GestionPromotion.getInstance().getPromotions().size() - 1);
                tb_libelle_promo.requestFocus();
        }//GEN-LAST:event_bt_create_promoActionPerformed

        private void bt_delete_promoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_delete_promoActionPerformed

                int sel = l_promos.getSelectedIndex();
                if (sel != -1) {
                        GestionPromotion.getInstance().deletePromo((Promotion) l_promos.getSelectedValue());
                        bpromos.unbind();
                        bpromos.bind();
                        belves.unbind();
                        belves.bind();


                }
        }//GEN-LAST:event_bt_delete_promoActionPerformed
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton bt_ajouter_eleve;
        private javax.swing.JButton bt_create_promo;
        private javax.swing.JButton bt_delete_eleve;
        private javax.swing.JButton bt_delete_promo;
        private javax.swing.JButton bt_enregistrer_eleve;
        private javax.swing.JButton bt_enregistrer_promo;
        private javax.swing.JButton bt_import_eleves;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        private javax.swing.JLabel jlabal1;
        private javax.swing.JList l_promos;
        private javax.swing.JTable t_eleves;
        private javax.swing.JTextField tb_email_eleve;
        private javax.swing.JTextField tb_libelle_promo;
        private javax.swing.JTextField tb_nom_eleve;
        private javax.swing.JTextField tb_num_eleve;
        private javax.swing.JTextField tb_prenom_eleve;
        private org.jdesktop.beansbinding.BindingGroup bindingGroup;
        // End of variables declaration//GEN-END:variables
}
TOP

Related Classes of View.GestionPromoView$MyListRender

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.