Annonce

Inscriptions terminées.

#1 26-04-2005 11:23:41

papy
Mega Power Member
Date d'inscription: 03-11-2004
Messages: 302

heritage et redefinition

bonjour les hommes,

j'ai une interface graphique (GUI pour les pros...) et j'en ai besoin d'un autre exactement identique mais avec la methode actionPerformed à redéfinir.

Comment proceder au regard que ma classe est composée de classe interne ?

Code:

/*
 * Created on 1 avr. 2005
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package IHM;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.Border;

import Utilities.Entreprise;
import Utilities.ExcelExpedition;
import Utilities.Fichier;
import Utilities.Machine;
import Utilities.Reservation;

/**
 * @author RCHAPERON
 *
 * Classe interaface graphique gerant l'expedition d'une machine
 */
public class IhmExpedition extends JDialog 
{
    
    JTabbedPane onglet = new JTabbedPane();
    EntreprisePane entreprisePane;
    AccessoiresPane accessoiresPane;
    
    private boolean nouvelleExpe = false;
    private Machine machineSeule;
    private Reservation reservationExistante;
    public boolean result = false;
    
    

    /**Constructeur pour une entreprise pour essai*/
    public IhmExpedition(JFrame parent,String title, Entreprise ent)
    {
        super(parent,title,true);//On instancie un JDialog modal
        this.addWindowListener(new WindowAdapter() {
                public void windowIconified(WindowEvent e) {
                }

                public void windowClosing(WindowEvent e) 
                {
                    System.exit(0);//dispose() à prévoir
                }
            });
            
        machineSeule = new Machine();
        JPanel contentPane = (JPanel) this.getContentPane();
        
        entreprisePane = new EntreprisePane(ent);//On appel le constructeur avec une entreprise en paramètre
        accessoiresPane = new AccessoiresPane();
    
        JButton ok = accessoiresPane.ok;
        JButton annul = accessoiresPane.annul;
        ok.addActionListener(new ActionList());
        annul.addActionListener(new ActionList());
        
        onglet.addTab("Entreprise", entreprisePane);
        onglet.addTab("Accessoires",accessoiresPane);
        contentPane.add(onglet);
        setup();
    }
    
    /**Constructeur pour une Reservation existante*/
        public IhmExpedition(JFrame parent,String title,Machine mac, Reservation res)
        {
            super(parent,title,true);//On instancie un JDialog modal
            this.addWindowListener(new WindowAdapter() {
                    public void windowIconified(WindowEvent e) {
                    }

                    public void windowClosing(WindowEvent e) 
                    {
                        System.exit(0);//dispose() à prévoir
                    }
                });
                
            nouvelleExpe = false;
            reservationExistante = res;
            machineSeule = mac;
            
            JPanel contentPane = (JPanel) this.getContentPane();
            entreprisePane = new EntreprisePane(res);//On appel le constructeur avec une réservation en paramètre
            accessoiresPane = new AccessoiresPane();
            
            JButton ok = accessoiresPane.ok;
            JButton annul = accessoiresPane.annul;
            ok.addActionListener(new ActionList());
            annul.addActionListener(new ActionList());
            
                    
            onglet.addTab("Entreprise", entreprisePane);
            onglet.addTab("Accessoires",accessoiresPane);
            contentPane.add(onglet);
            setup();
        }
        
        
    /**Constructeur pour une nouvelle entreprise d'expedition d'une machine
     * ATTENTION AFFICHAGE IMPOSSIBLE SI MACHINE NON PRESENTE A L AGENCE*/
    public IhmExpedition(JFrame parent,String title, Machine mac)
    {
        super(parent,title,true);//On instancie un JDialog modal
        this.addWindowListener(new WindowAdapter() {
                public void windowIconified(WindowEvent e) {
                }
    
                public void windowClosing(WindowEvent e) 
                {
                    System.exit(0);//dispose() à prévoir
                }
            });
            
        nouvelleExpe = true;
        machineSeule = mac;
        JPanel contentPane = (JPanel) this.getContentPane();
        entreprisePane = new EntreprisePane(mac);//On appel le constructeur avec une machine en paramètre
        accessoiresPane = new AccessoiresPane();
        
        JButton ok = accessoiresPane.ok;
        JButton annul = accessoiresPane.annul;
        ok.addActionListener(new ActionList());
        annul.addActionListener(new ActionList());
                    
        onglet.addTab("Entreprise", entreprisePane);
        onglet.addTab("Accessoires",accessoiresPane);
        contentPane.add(onglet);
        setup();
    }
    
    public void setup()
    {
        int largeur = 500;
        int hauteur = 550;
        setSize(largeur, hauteur);
//        On adapte la taille de la fenetre principale à la résolution de
//        l'ecran Client
        Dimension tailleEcran = Toolkit.getDefaultToolkit().getScreenSize();
        int yPos = (tailleEcran.width ) / 4;
        int xPos = (tailleEcran.height ) / 15;
        setLocation(yPos, xPos);
        setResizable(true);
        setVisible(true);
    }
    
    
        
        
        
    
    
    /**Classe Interne AccessoirePane*/
    class AccessoiresPane extends JPanel 
    {
        JPanel contentPane;
        JPanel contentPane1;
        JCheckBox check1;
        JCheckBox check2;
        Vector accessoires = new Vector();
        public JButton ok,annul;
        
        
        
        public AccessoiresPane()
        {
            
            
            super();
            contentPane = this;
            contentPane.setLayout(new BorderLayout());
            
            GridLayout grid = new GridLayout(0,2);
            contentPane1 = new JPanel();
            contentPane1.setLayout(grid);
            
            constructPane();
            contentPane.add(contentPane1);
            constructThirdPan();
            
        }
        
        
        public void constructPane()
        {
            constructFirstPan();
            constructSecondPan();
            
        }
        
        
        
        public void constructFirstPan()
        {
            String[] ac = {"Pied support","Cellule","Equerre Cellule", "support de tête",
                    "Tackymetre et roue","Kit secteur", "Encre/additif"};
            JPanel acPan = new JPanel();
            GridLayout g = new GridLayout(7,1);
            acPan.setLayout(g);
            Border etched = BorderFactory.createEtchedBorder(); 
            Border titled = BorderFactory.createTitledBorder(etched," Materiel "); 
            acPan.setBorder(titled); 


            for(int i = 0; i<ac.length; i++)
            {
                check1 = new JCheckBox(ac[i]);
                acPan.add(check1);
                accessoires.add(check1);
            }

            contentPane1.add(acPan);
        }
        
        
        public void constructThirdPan()
        {
            JPanel buttonPan = new JPanel();
            ok = new JButton("  OK  ");
            annul = new JButton("Annuler");
            
            ok.setActionCommand("ok");
            annul.setActionCommand("annuler");
            
            buttonPan.setLayout(new FlowLayout());
            buttonPan.add(ok);
            buttonPan.add(annul);
            contentPane.add(buttonPan, BorderLayout.SOUTH);
        }
        
        
        public void constructSecondPan()
        {
            String[] acS7 = {"Porte-cartouche", "Support S7","K7 extension", "Interface Indus.", "Terminal"};
            JPanel s7Pan = new JPanel();
            GridLayout g = new GridLayout(5,1);
            s7Pan.setLayout(g);
            Border etched = BorderFactory.createEtchedBorder(); 
            Border titled = BorderFactory.createTitledBorder(etched," S7 "); 
            s7Pan.setBorder(titled); 


            for(int i = 0; i<acS7.length; i++)
            {
                check2 = new JCheckBox(acS7[i]);
                s7Pan.add(check2);
                accessoires.add(check2);
            }

            contentPane1.add(s7Pan);
        }
            
            
            
        
    
        
        
    
    }
    
    
    
    /**Classe interne EntreprisePane*/
    class EntreprisePane extends JPanel 
     {

        /** Gestionnaire de mise en pages */
        private GridBagLayout gridBagLayout = new GridBagLayout();
        private BorderLayout borderLayout = new BorderLayout();
        private GridBagConstraints c = new GridBagConstraints();
        
        
        /** Ensemble des JPanel */
        private JPanel contentPane, machPane, datePane, entrPane, calPane,buttonPane, tempPane;
        /** Ensemble des JLabel */
        // Labels machPane
        private JLabel resMach = new JLabel("<html><p><b>Machine</b></p></html>");
        private JLabel labelRefMach = new JLabel("Ref : ");
        private JLabel labNumMach = new JLabel("N° : ");
        private JLabel labelChrono = new JLabel("N° Chrono :");
        private JLabel labelStatut = new JLabel("Statut :");
        // Labels datePane
        private JLabel labelDate = new JLabel("Dates (jj/mm/aa)");
        private JLabel labelDbt = new JLabel("*Début : ");
        private JLabel labelFin = new JLabel("*Fin : ");
        // Labels calPane
        private JLabel labelCal = new JLabel("*Commercial : ");
        private JLabel labelTech = new JLabel("*Technicien : ");
        // Labels Entreprise
        private JLabel labelEntreprise = new JLabel("<html><p><b>Entreprise</b></p></html>");
        private JLabel labelNomEntre = new JLabel("*Nom : ");
        private JLabel labelNumTelEntre = new JLabel("*N° Tel : ");
        private JLabel labelAdrEntre = new JLabel("*Adresse : ");
        private JLabel labelCodPostalEntre = new JLabel("*Code Postal : ");
        private JLabel labelContactEntre = new JLabel("*Contact : ");
        private JLabel labelInfoEntre = new JLabel("Info : ");
        /** Ensemble des JTextField */
        // Champs machPane
        public JTextField champsRefMach = new JTextField(10);
        public JTextField champsNumMach = new JTextField(10);
        public JTextField champsChrono = new JTextField(8);
        public JTextField champsStatut = new JTextField(10);
        // Champs datePane
        public JTextField champsDbt = new JTextField(8);
        public JTextField champsFin = new JTextField(8);
        // Champs calPane
        public JTextField champsCal = new JTextField(10);
        public JTextField champsTech = new JTextField(10);
        // Champs entrPane
        public JTextField champsNomEntre = new JTextField(10);
        public JTextField champsNumTelEntre = new JTextField(10);
        public JTextArea champsAdrEntre = new JTextArea(3, 20);
        public JTextField champsCodPostalEntre = new JTextField(5);
        public JTextField champsContactEntre = new JTextField(10);
        public JTextArea champsInfoEntre = new JTextArea(4, 20);
        private Toolkit tool = null;
        
        public Machine machine;
        public Entreprise existeEnt;
        public Reservation existReservation;


        public EntreprisePane(Machine mach)//Constructeur pour champs vides
        {
            // Création et installation des composants (liste, boutons)
            creeComposants();
            machine = mach;
            setChampsMachine(machine);//on pré-remplis les champs machine
        }

    
        public EntreprisePane(Entreprise ent)//Constructeur pour champs pré-remplis entreprise Historique
        {
            // Création et installation des composants (liste, boutons)
            creeComposants();
            existeEnt = ent;
            setChamps(existeEnt);//On pré-rempli les champs
                    
        }
    
    
        public EntreprisePane(Reservation res)//Constructeur pour champs pré-remplis entreprise Historique
        {
            // Création et installation des composants (liste, boutons)
            creeComposants();
            existReservation = res;
            setChamps(existReservation);//On pré-rempli les champs
        }


        private void creeComposants() {
            /** Initialisation des JPanel */
            // init contentPane
            contentPane = this;
            contentPane.setLayout(gridBagLayout);
            // init machPane
            machPane = new JPanel();
            machPane.setLayout(gridBagLayout);
            // init datePane
            datePane = new JPanel();
            datePane.setLayout(gridBagLayout);
            // init calPane
            calPane = new JPanel();
            calPane.setLayout(gridBagLayout);
            // init entrPane
            entrPane = new JPanel();
            entrPane.setLayout(gridBagLayout);
            // init buttonPane
            buttonPane = new JPanel();
            buttonPane.setLayout(gridBagLayout);

        
            // Ajout des labels
            c.anchor = GridBagConstraints.WEST;//accrochage du coin gauche à gauche du Panel principal
            c.fill = GridBagConstraints.BOTH;//on rempli vertical et horizontal
            c.insets = new Insets(0, 4, 0, 0);//ecart entre objet (haut,gauche,bas,droite)

            /** construction machPane */
            // label machine
            c.gridx = 0;//position en colonne
            c.gridy = 2; // Colonne 0, Ligne 2//position en ligne
            c.gridwidth = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule)
            c.gridheight = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule)
            gridBagLayout.setConstraints(resMach, c);
            machPane.add(resMach);

            // label ref
            c.gridx = 3;
            c.gridy = 4; // Colonne 3, Ligne 4
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(labelRefMach, c);
            machPane.add(labelRefMach);
            // champs ref
            c.gridx = 5;
            c.gridy = 4; // Colonne 5, Ligne 4
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(champsRefMach, c);
            machPane.add(champsRefMach);
            // label num
            c.gridx = 8;
            c.gridy = 4; // Colonne 8, Ligne 4
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(labNumMach, c);
            machPane.add(labNumMach);
            // champs num
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 10;
            gridBagLayout.setConstraints(champsNumMach, c);
            machPane.add(champsNumMach);
        
    


            /** contruction datePane */
            // Ajout des labels
            c.anchor = GridBagConstraints.WEST;
            c.gridwidth = 1;
            // label date
            c.gridx = 0;
            c.gridy = 2; // Colonne 0, Ligne 2
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(labelDate, c);
            datePane.add(labelDate);
            // label Début
            c.gridx = 0;
            c.gridy = 4; // Colonne 3, Ligne 4
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(labelDbt, c);
            datePane.add(labelDbt);
            // champs Début
            c.gridx = 5;
            c.gridy = 4; // Colonne 5, Ligne 4
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(champsDbt, c);
            datePane.add(champsDbt);
            // label Fin
            c.gridx = 7; // Colonne 7, Ligne 4
            c.gridwidth = 1;
            c.gridheight = 1;
            c.insets = new Insets(0, 4, 0, 0); //top, left, bottom, right
            gridBagLayout.setConstraints(labelFin, c);
            datePane.add(labelFin);
            // champs Fin
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 9; // Colonne 9, Ligne 4
            gridBagLayout.setConstraints(champsFin, c);
            datePane.add(champsFin);
        


            /** contruction calPane */
            // Ajout des labels
            c.anchor = GridBagConstraints.WEST;
            c.gridwidth = 1;
            c.gridx = 0;
            c.gridy = 2; // Colonne 0, Ligne 2
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(labelChrono, c);
            calPane.add(labelChrono);
             // champs chrono
            c.gridx = 10;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.insets = new Insets(10, 4, 10, 0); //top, left, bottom, right
            gridBagLayout.setConstraints(champsChrono, c);
            calPane.add(champsChrono);
             // label statut
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 12;
            gridBagLayout.setConstraints(labelStatut, c);
            calPane.add(labelStatut);
             // champs statut
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 20;
            gridBagLayout.setConstraints(champsStatut, c);
            calPane.add(champsStatut);
                
            // label commercial
            c.gridx = 0;
            c.gridy = 3; // Colonne 0, Ligne 2
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(labelCal, c);
            calPane.add(labelCal);
            // champs commercial
            c.gridx = 10;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.insets = new Insets(10, 4, 10, 0); //top, left, bottom, right
            gridBagLayout.setConstraints(champsCal, c);
            calPane.add(champsCal);
            // label Technicien
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 12;
            gridBagLayout.setConstraints(labelTech, c);
            calPane.add(labelTech);
            // champs Technicien
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 20;
            gridBagLayout.setConstraints(champsTech, c);
            calPane.add(champsTech);

            /** construction entrPane */
            // Ajout des labels
            c.anchor = GridBagConstraints.NORTHWEST;
            c.fill = GridBagConstraints.NONE;
            c.insets = new Insets(4, 4, 0, 0); //top, left, bottom, right
            // label Entreprise
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 0;
            c.gridy = 2; // Colonne 0, Ligne 2
            gridBagLayout.setConstraints(labelEntreprise, c);
            entrPane.add(labelEntreprise);
            // label nom entreprise
            c.gridx = 0;
            c.gridy = 4; // Colonne 0, Ligne 4
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(labelNomEntre, c);
            entrPane.add(labelNomEntre);
            // champs nom entreprise
            c.gridx = 2;
            c.gridwidth = 1;
            c.gridheight = 1;
            gridBagLayout.setConstraints(champsNomEntre, c);
            entrPane.add(champsNomEntre);

            // label num tel
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 4; // Colonne 5, Ligne 4
            gridBagLayout.setConstraints(labelNumTelEntre, c);
            entrPane.add(labelNumTelEntre);
            // champs tel entreprise
            c.weightx = 1.0;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 6; // Colonne 6, Ligne 4
            gridBagLayout.setConstraints(champsNumTelEntre, c);
            entrPane.add(champsNumTelEntre);

            // label adresse
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 0;
            c.gridy = 6; // Colonne 0, Ligne 6
            gridBagLayout.setConstraints(labelAdrEntre, c);
            entrPane.add(labelAdrEntre);
            // champs adresse entreprise
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridx = 2;
            c.gridheight = 1;
            /** On souhaite un retour à ligne automatique : */
            champsAdrEntre.setLineWrap(true);

            /** On souhaite que les mots ne soient pas coupés : */
            champsAdrEntre.setWrapStyleWord(true);
            JScrollPane scrollAdr = new JScrollPane(champsAdrEntre);
            gridBagLayout.setConstraints(scrollAdr, c);
            entrPane.add(scrollAdr);

            // label code postal
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 0;
            c.gridy = 8; // Colonne 0, Ligne 8
            gridBagLayout.setConstraints(labelCodPostalEntre, c);
            entrPane.add(labelCodPostalEntre);
            // champs code postal entreprise
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 2; // Colonne 2, Ligne 8
            gridBagLayout.setConstraints(champsCodPostalEntre, c);
            entrPane.add(champsCodPostalEntre);

            // label contact entreprise
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 4; // Colonne 6, Ligne 8
            gridBagLayout.setConstraints(labelContactEntre, c);
            entrPane.add(labelContactEntre);
            // champs contact entreprise
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 6; // Colonne 6, Ligne 8
            gridBagLayout.setConstraints(champsContactEntre, c);
            entrPane.add(champsContactEntre);

            // label info Entreprise
            c.gridwidth = 1;
            c.gridheight = 1;
            c.gridx = 0;
            c.gridy = 10; // Colonne 0, Ligne 10
            c.insets = new Insets(20, 4, 0, 0); //top, left, bottom, right
            gridBagLayout.setConstraints(labelInfoEntre, c);
            entrPane.add(labelInfoEntre);
            // champs contact entreprise
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridx = 2; // Colonne 2, Ligne 10
            c.gridheight = 1;
        
            /** On souhaite un retour à ligne automatique : */
            champsInfoEntre.setLineWrap(true);

            /** On souhaite que les mots ne soient pas coupés : */
            champsInfoEntre.setWrapStyleWord(true);
    
            JScrollPane scrollInfo = new JScrollPane(champsInfoEntre);
            gridBagLayout.setConstraints(scrollInfo, c);
            entrPane.add(scrollInfo);

            /** Construction buttonPane */
            FlowLayout flow = new FlowLayout();
            buttonPane.setLayout(flow);
            

            /** contruction contentPane */
            contentPane.add(machPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                    GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                    new Insets(0, 0, 9, 0), 1, 2));
            contentPane.add(datePane, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                    new Insets(0, 0, 9, 0), 1, 2));
            contentPane.add(calPane, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,
                    GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                    new Insets(2, 0, 9, 0), 1, 2));
            contentPane.add(entrPane, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0,
                    GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
                    new Insets(2, 0, 0, 0), 1, 2));
            JLabel use = new JLabel("* Champs obligatoires");
            contentPane.add(use, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0,
                    GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE,
                    new Insets(10, 0, 0, 0), 1, 2));
            contentPane.add(buttonPane, new GridBagConstraints(0, 14, 1, 1, 0.0,
                    0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
                    new Insets(10, 0, 0, 0), 1, 2));

            contentPane.validate();
        }

    
    
        
            public void setChamps(Entreprise en)
            {
                champsRefMach.setText(en.referenceMachine);
                champsNumMach.setText(en.numeroSerieMachine);
                champsDbt.setText(en.dateDebut); 
                champsFin.setText(en.dateFin);
                champsChrono.setText(en.numeroChrono);
                champsStatut.setText(en.natureStatut);
                champsCal.setText(en.commercial);
                champsTech.setText(en.technicien);
                champsNomEntre.setText(en.nom);
                champsNumTelEntre.setText(en.numeroDeTel);
                champsAdrEntre.setText(en.adresse.replaceAll("/","\n"));
                champsCodPostalEntre.setText(en.codePostal);
                champsContactEntre.setText(en.personneAcontacter);
                champsInfoEntre.setText(en.info);
            }
    
            public void setChampsMachine(Machine ma)
            {
        
                champsRefMach.setText(ma.getRef());
                champsNumMach.setText(ma.getNumeroSerie());
            
            
            }
        
        
        
        public void setChamps(Reservation res)
        {
            Entreprise en = res.getEntrepriseConcernee();
            champsRefMach.setText(en.referenceMachine);
            champsNumMach.setText(en.numeroSerieMachine);
            champsDbt.setText(res.getDateDebutReservation()); 
            champsFin.setText(res.getDateFinReservation());
            champsChrono.setText(en.numeroChrono);
            champsStatut.setText(en.natureStatut);
            champsCal.setText(en.commercial);
            champsTech.setText(en.technicien);
            champsNomEntre.setText(en.nom);
            champsNumTelEntre.setText(en.numeroDeTel);
            champsAdrEntre.setText(en.adresse.replaceAll("/","\n"));
            champsCodPostalEntre.setText(en.codePostal);
            champsContactEntre.setText(en.personneAcontacter);
            champsInfoEntre.setText(en.info);
        }
    
    

    }//checksum=674


/**=================================CLASSE ANONYME GERANT LES EVENEMENTS====================================*/
    class ActionList implements ActionListener
    {
                
        

        public void actionPerformed(ActionEvent ev) 
        {
            if("ok".equalsIgnoreCase(ev.getActionCommand()))//Si on clique sur "OK"
            {
                Fichier.miseAjourDonnees();//on recharge si neccessaire
                
                Vector accessoires = accessoiresPane.accessoires;//on récupère le vecteur de l'objet accessoiresPane
                
            
                
                if(nouvelleExpe==true)//Si c'est une expedition sans lien avec une réservation existante
                {
                    Machine ma = machineSeule;
                    
                    Entreprise nouvelleEnt = ma.createEntrepriseEnCours();//on crée l'entreprise en cours
                    
                    nouvelleEnt.setDateDebut(entreprisePane.champsDbt.getText());
                    nouvelleEnt.setDateFin(entreprisePane.champsFin.getText());
                    nouvelleEnt.setNumeroChrono(entreprisePane.champsChrono.getText());
                    nouvelleEnt.setNatureStatut(entreprisePane.champsStatut.getText());
                    nouvelleEnt.setCommercial(entreprisePane.champsCal.getText());
                    nouvelleEnt.setTechnicien(entreprisePane.champsTech.getText());
                    nouvelleEnt.setNom(entreprisePane.champsNomEntre.getText());
                    nouvelleEnt.setNumeroDeTel(entreprisePane.champsNumTelEntre.getText());
                    nouvelleEnt.setAdresse(entreprisePane.champsAdrEntre.getText().replaceAll("\n"," "));
                    nouvelleEnt.setCodePostal(entreprisePane.champsCodPostalEntre.getText());
                    nouvelleEnt.setPersonne(entreprisePane.champsContactEntre.getText());
                    nouvelleEnt.setInfo(entreprisePane.champsInfoEntre.getText().replaceAll("\n"," "));
                    
                    //On ajoute les accessoires dans l'entreprise en cours
                    for(int i=0;i<accessoires.size();i++)
                    {
                        JCheckBox temp = (JCheckBox)accessoires.elementAt(i);
                        if(temp.isSelected())
                        {
                            nouvelleEnt.ajoutAccessoire(temp.getLabel().toString());
                            //System.out.println(temp.getLabel().toString());
                        }
                    }
                    
                    //on change le statut de la machine
                    ma.setStatut(nouvelleEnt.getNatureStatut());
                    ma.setCommercial(nouvelleEnt.getCommercial());
                    ma.setTechnicien(nouvelleEnt.getTechnicien());
                    
                    
                    Fichier.miseAjourFichier();
                    Fichier.miseAjourDonnees();
                    
                    ExcelExpedition excel = new ExcelExpedition(nouvelleEnt);
                    Thread excelThread = new Thread(excel);//Instanciation d'un thread
                    excelThread.start();
                }
                else//si on expedie une machine pour une réservation donnée
                {
                    Machine ma = machineSeule;
                    Entreprise nouvelleEnt = ma.createEntrepriseEnCours();//on crée l'entreprise en cours
                    
                    nouvelleEnt.setDateDebut(entreprisePane.champsDbt.getText());
                    nouvelleEnt.setDateFin(entreprisePane.champsFin.getText());
                    nouvelleEnt.setNumeroChrono(entreprisePane.champsChrono.getText());
                    nouvelleEnt.setNatureStatut(entreprisePane.champsStatut.getText());
                    nouvelleEnt.setCommercial(entreprisePane.champsCal.getText());
                    nouvelleEnt.setTechnicien(entreprisePane.champsTech.getText());
                    nouvelleEnt.setNom(entreprisePane.champsNomEntre.getText());
                    nouvelleEnt.setNumeroDeTel(entreprisePane.champsNumTelEntre.getText());
                    nouvelleEnt.setAdresse(entreprisePane.champsAdrEntre.getText().replaceAll("\n"," / "));
                    nouvelleEnt.setCodePostal(entreprisePane.champsCodPostalEntre.getText());
                    nouvelleEnt.setPersonne(entreprisePane.champsContactEntre.getText());
                    nouvelleEnt.setInfo(entreprisePane.champsInfoEntre.getText().replaceAll("\n"," "));

                    //On ajoute les accessoires dans l'entreprise en cours
                    for(int i=0;i<accessoires.size();i++)
                    {
                        JCheckBox temp = (JCheckBox)accessoires.elementAt(i);
                        if(temp.isSelected())
                        {
                            nouvelleEnt.ajoutAccessoire(temp.getLabel().toString());
                            //System.out.println(temp.getLabel().toString());
                        }
                    }

                    //on change le statut de la machine
                    ma.setStatut(nouvelleEnt.getNatureStatut());
                    ma.setCommercial(nouvelleEnt.getCommercial());
                    ma.setTechnicien(nouvelleEnt.getTechnicien());
                    ma.deleteReservation(reservationExistante);//On efface la réservation

                    Fichier.miseAjourFichier();
                    Fichier.miseAjourDonnees();
                    
                    ExcelExpedition excel = new ExcelExpedition(nouvelleEnt);
                    Thread excelThread = new Thread(excel);//Instanciation d'un thread
                    excelThread.start();
                }
                result = true;
                dispose();
            
            }
            
            
            if("annuler".equalsIgnoreCase(ev.getActionCommand()))//Si on clique sur "ANNULER"
            {
                dispose();
            }

        }
        
        
    }//Fin de classe interne
    
    
    
    

    public static void main(String[] args) 
    {
        Entreprise e = new Entreprise("s9","1234");
        e.setNom("essai Nom");
        IhmExpedition i = new IhmExpedition(null,"Expedition",e);
        
        
    }

    
}//cs = 866

Le seul et unique "MEGA Power Member" à être papa!
Java, ce qui differentie les hommes, des jeunes garçons...

Hors ligne

 

#2 26-04-2005 11:36:35

Borusse
Mega Power Member
Date d'inscription: 09-11-2004
Messages: 175

Re: heritage et redefinition

heu t'en herite et tu redéfinit ta fonction.


Papy tu n'es plus the only one "Power Member"

I'm the only one  "Powerfull Membré"

Hors ligne

 

#3 26-04-2005 11:40:34

papy
Mega Power Member
Date d'inscription: 03-11-2004
Messages: 302

Re: heritage et redefinition

Borusse a écrit:

heu t'en herite et tu redéfinit ta fonction.

regardes plus attentivement le code...la methode actionPerformed est dans une classe interne.


Le seul et unique "MEGA Power Member" à être papa!
Java, ce qui differentie les hommes, des jeunes garçons...

Hors ligne

 

#4 27-04-2005 10:27:49

yoda
Mega Power Member
Date d'inscription: 10-11-2004
Messages: 127

Re: heritage et redefinition

Deja tu peux pas definir le niveau de tes classes internes(public ou protected)?
Ensuite herite de la premiere et dans la seconde tu recréé une classe qui herite de la sous classe (a condition qu'elle soit au minimum protected sinon public) et tu redefini la methode qui te conviens.

Mais pourquoi utiliser comme ca des classes a l'interieur de d'autres?
J'espère avoir bien compris la question et sinon ... ben tant pis ;-)

Hors ligne

 

#5 27-04-2005 17:24:15

papy
Mega Power Member
Date d'inscription: 03-11-2004
Messages: 302

Re: heritage et redefinition

oui tu as bien comprit ma question.
J'implémente en utilisant des classes internes pour rendre d'avantage lisible mon code et faciliter la maintenance.

De plus, j'ai du implémenter comme ceci pour contourner le problème suivant:
http://www.lidrea.com/lescampeurs/viewtopic.php?id=1521

J'ai résolu le problème en implémentant comme ceci:

Code:

class MyFenetre extends JDialog { 
    controlButton.addActionListener(new ActionListener() { 
         public void actionPerformed(ActionEvent e) { 
              onControlClick(e); 
        } 
    }); 

    protected void onControlClick(ActionEvent e) { 
      ... 
    } 
} 

class MyFenetreFille extends MyFenetre { 

     //rdefinition de la methode 
     protected void onControlClick(ActionEvent e) { 
           ... 
    } 
}

Le seul et unique "MEGA Power Member" à être papa!
Java, ce qui differentie les hommes, des jeunes garçons...

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Classement Internet