Package com.vgo.movie.ecran

Source Code of com.vgo.movie.ecran.DetailUtilisateur

package com.vgo.movie.ecran;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import com.vgo.movie.data.DatabaseDAO;
import com.vgo.movie.domain.Generique;
import com.vgo.movie.domain.Utilisateurs;
import com.vgo.movie.util.Libelle;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class DetailUtilisateur extends javax.swing.JDialog {

  private static final long serialVersionUID = 1L;
  private JLabel jLabelLogin;
  private JLabel jLabelAncienPass;
  private JLabel jLabelNouveauPass1;
  private JPasswordField jPasswordFieldNouveau1;
  private JLabel jLabelNouveauPass2;
  private JLabel jLabelLangue;
  private JComboBox jComboBoxLangueProgramme;
  private JTextField jTextFieldId;
  private JButton jButtonModifier;
  private JPasswordField jPasswordFieldNouveau2;
  private JPasswordField jPasswordFieldAncien;
  private JTextArea jTextAreaDescription;
  private JLabel jLabelLibelle;
  private JButton jButtonCetOrdinateur;
  private JTextField jTextFieldLoginNT;
  private JLabel jLabelConnexionAuto;
  private JTextField jTextFieldLogin;
  private Main localParent;

  public DetailUtilisateur(Main frame) {
    super(frame);
    localParent=frame;
    initGUI();
    initLibelle();
  }

  private void initGUI() {
    try {
      {
        getContentPane().setLayout(null);
        {
          jLabelLogin = new JLabel();
          getContentPane().add(jLabelLogin);
          jLabelLogin.setBounds(7, 14, 224, 28);
        }
        {
          jTextFieldLogin = new JTextField();
          getContentPane().add(jTextFieldLogin);
          jTextFieldLogin.setBounds(238, 14, 336, 28);
          jTextFieldLogin.setText(localParent.getCurrentUser().getLogin());
        }
        {
          jLabelLibelle = new JLabel();
          getContentPane().add(jLabelLibelle);
          jLabelLibelle.setBounds(7, 77, 224, 28);
        }
        {
          jTextAreaDescription = new JTextArea();
          getContentPane().add(jTextAreaDescription);
          jTextAreaDescription.setBounds(238, 49, 336, 77);
          jTextAreaDescription.setText(localParent.getCurrentUser().getLibelle());
        }
        {
          jLabelAncienPass = new JLabel();
          getContentPane().add(jLabelAncienPass);
          jLabelAncienPass.setBounds(7, 182, 224, 28);
        }
        {
          jPasswordFieldAncien = new JPasswordField();
          getContentPane().add(jPasswordFieldAncien);
          jPasswordFieldAncien.setBounds(238, 182, 336, 28);
          jPasswordFieldAncien.setText(localParent.getCurrentUser().getMotDePasse());         
        }
        {
          jLabelNouveauPass1 = new JLabel();
          getContentPane().add(jLabelNouveauPass1);
          jLabelNouveauPass1.setBounds(7, 217, 224, 28);
        }
        {
          jPasswordFieldNouveau1 = new JPasswordField();
          getContentPane().add(jPasswordFieldNouveau1);
          jPasswordFieldNouveau1.setBounds(238, 217, 336, 28);
        }
        {
          jLabelNouveauPass2 = new JLabel();
          getContentPane().add(jLabelNouveauPass2);
          jLabelNouveauPass2.setBounds(7, 259, 224, 28);
        }
        {
          jPasswordFieldNouveau2 = new JPasswordField();
          getContentPane().add(jPasswordFieldNouveau2);
          jPasswordFieldNouveau2.setBounds(238, 259, 336, 28);
        }
        {
          jButtonModifier = new JButton();
          getContentPane().add(jButtonModifier);
          jButtonModifier.setBounds(189, 350, 224, 28);
          jButtonModifier.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              jButtonModifierActionPerformed(evt);
            }
          });
        }
        {
          jTextFieldId = new JTextField();
          getContentPane().add(jTextFieldId);
          jTextFieldId.setBounds(7, 49, 63, 28);
          jTextFieldId.setVisible(false);
          jTextFieldId.setText(localParent.getCurrentUser().getIdUtilisateur().toString());
        }
        {
          jLabelLangue = new JLabel();
          getContentPane().add(jLabelLangue);
          jLabelLangue.setBounds(7, 140, 224, 28);
        }
        {
          ComboBoxModel jComboBoxLangueModel = new DefaultComboBoxModel(new String[]{});
          jComboBoxLangueProgramme = new JComboBox();
          getContentPane().add(jComboBoxLangueProgramme);
          jComboBoxLangueProgramme.setModel(jComboBoxLangueModel);
          jComboBoxLangueProgramme.setBounds(238, 140, 336, 28);
          remplirListeLangueProgramme();
         
        }
        {
          jLabelConnexionAuto = new JLabel();
          getContentPane().add(jLabelConnexionAuto);
          jLabelConnexionAuto.setBounds(7, 301, 224, 28);
        }
        {
          jTextFieldLoginNT = new JTextField();
          getContentPane().add(jTextFieldLoginNT);
          jTextFieldLoginNT.setBounds(238, 301, 168, 28);
          jTextFieldLoginNT.setText(localParent.getCurrentUser().getLoginNT());
        }
        {
          jButtonCetOrdinateur = new JButton();
          getContentPane().add(jButtonCetOrdinateur);
          jButtonCetOrdinateur.setBounds(413, 301, 161, 28);
          jButtonCetOrdinateur
            .addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              jButtonCetOrdinateurActionPerformed(evt);
            }
            });
        }
      }
      this.setSize(596, 426);     
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void initLibelle() {
    jButtonModifier.setText(Libelle.getLibelle("updateFiche"));
    jLabelNouveauPass2.setText(Libelle.getLibelle("retapeNouveauPass"));
    jLabelNouveauPass1.setText(Libelle.getLibelle("nouveauPassword"));
    jLabelAncienPass.setText(Libelle.getLibelle("ancienPassword"));
    jLabelLibelle.setText(Libelle.getLibelle("description"));
    jLabelLogin.setText(Libelle.getLibelle("login"));
    jLabelLangue.setText(Libelle.getLibelle("langue"));
    jButtonCetOrdinateur.setText(Libelle.getLibelle("surCetOrdi"));
    jLabelConnexionAuto.setText(Libelle.getLibelle("connexionAuto"));
   
  }

  private void jButtonModifierActionPerformed(ActionEvent evt) {
    boolean ficheAMettreAJour = false;

    Utilisateurs tmpUtilisateur = new Utilisateurs();
    tmpUtilisateur.setIdUtilisateur(new Integer(jTextFieldId.getText()));
    tmpUtilisateur.setLogin(jTextFieldLogin.getText());
    tmpUtilisateur.setLibelle(jTextAreaDescription.getText());
    tmpUtilisateur.setIsAdmin(localParent.getCurrentUser().getIsAdmin());
    tmpUtilisateur.setLoginNT(jTextFieldLoginNT.getText());
   
    Generique tmpGenerique=new Generique();
    tmpGenerique.setLibelle((String)jComboBoxLangueProgramme.getSelectedItem());
    try {
      tmpGenerique = (Generique)DatabaseDAO.selectDetailLangueProgramme(tmpGenerique);
    } catch (SQLException e) {
      JOptionPane.showOptionDialog(
          SwingUtilities.getWindowAncestor(this),
          Libelle.getLibelle("erreurDetailLangue"),
          Libelle.getLibelle("erreur"),
          JOptionPane.DEFAULT_OPTION,
          JOptionPane.ERROR_MESSAGE,
          null,
          null,
          null);
    }
    tmpUtilisateur.setLangue(tmpGenerique.getCode());

    String ancienPassword = new String(jPasswordFieldAncien.getPassword());
    String nouveauPassword1 = new String(jPasswordFieldNouveau1.getPassword());
    String nouveauPassword2 = new String(jPasswordFieldNouveau2.getPassword());

    if(!nouveauPassword1.equals("") || !nouveauPassword2.equals("")){
      if(nouveauPassword1.equals(nouveauPassword2)){
        tmpUtilisateur.setMotDePasse(nouveauPassword1);
        ficheAMettreAJour = true;
      }
      else{
        JOptionPane.showOptionDialog(
            SwingUtilities.getWindowAncestor(this),
            Libelle.getLibelle("motDePasseNonEgaux"),
            Libelle.getLibelle("erreur"),
            JOptionPane.DEFAULT_OPTION,
            JOptionPane.ERROR_MESSAGE,
            null,
            null,
            null);
        jPasswordFieldNouveau1.setText("");
        jPasswordFieldNouveau2.setText("")
      }
    }
    else{
      tmpUtilisateur.setMotDePasse(ancienPassword);
      ficheAMettreAJour = true;
    }

    if(ficheAMettreAJour){
      try {
        DatabaseDAO.updateFicheUtilisateur(tmpUtilisateur);
        JOptionPane.showOptionDialog(
            SwingUtilities.getWindowAncestor(this),
            Libelle.getLibelle("updateFicheOk"),
            Libelle.getLibelle("information"),
            JOptionPane.DEFAULT_OPTION,
            JOptionPane.INFORMATION_MESSAGE,
            null,
            null,
            null);
        localParent.setCurrentUser(tmpUtilisateur);
        this.dispose();
      } catch (SQLException e) {
        JOptionPane.showOptionDialog(
            SwingUtilities.getWindowAncestor(this),
            Libelle.getLibelle("erreurUpdateUser"),
            Libelle.getLibelle("erreur"),
            JOptionPane.DEFAULT_OPTION,
            JOptionPane.ERROR_MESSAGE,
            null,
            null,
            null);
      }
    }
  }
 
  private void remplirListeLangueProgramme() {
    List tmpList=null;
   
    jComboBoxLangueProgramme.removeAllItems();
   
    try {
      tmpList = DatabaseDAO.selectAllLanguesProgramme();     
    } catch (SQLException e) {
      JOptionPane.showOptionDialog(
          SwingUtilities.getWindowAncestor(this),
          Libelle.getLibelle("erreurInitialisationListeLangue"),
          Libelle.getLibelle("erreur"),
          JOptionPane.DEFAULT_OPTION,
          JOptionPane.ERROR_MESSAGE,
          null,
          null,
          null);
    }   

    Generique tmpGenerique = new Generique();
    int i=0;
    int goodIndex=0;
   
    Iterator tmpIterator = tmpList.listIterator();   
    while(tmpIterator.hasNext()){
      tmpGenerique = (Generique)tmpIterator.next();
      jComboBoxLangueProgramme.addItem(tmpGenerique.getLibelle());
      if(localParent.getCurrentUser().getLangue().equals(tmpGenerique.getCode())){
        goodIndex=i;
      }
      i++;
   
   
    jComboBoxLangueProgramme.setSelectedIndex(goodIndex);
 
 
  private void jButtonCetOrdinateurActionPerformed(ActionEvent evt) {
    jTextFieldLoginNT.setText(System.getenv("COMPUTERNAME") + "\\" +System.getenv().get("USERNAME"));
  }

}
TOP

Related Classes of com.vgo.movie.ecran.DetailUtilisateur

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.