package com.vgo.movie.ecran;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.RowFilter;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableRowSorter;
import com.l2fprod.common.swing.JDirectoryChooser;
import com.vgo.movie.data.DatabaseDAO;
import com.vgo.movie.domain.Generique;
import com.vgo.movie.domain.Movie;
import com.vgo.movie.domain.Utilisateurs;
import com.vgo.movie.editor.IntegerEditor;
import com.vgo.movie.thread.AnalyseMediaThread;
import com.vgo.movie.thread.ListeFilmsThread;
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 Main extends javax.swing.JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JProgressBar jProgressBar;
private JTable tableListeFilms;
private JScrollPane listeMovie;
private JMenu jMenuDonnes;
private JMenuItem exitMenuItem;
private JLabel jLabelQualite;
private JLabel jLabelLangue;
private JLabel jLabelCompression;
private JLabel jLabelStatut;
private JLabel jLabelNom;
private JComboBox jComboBoxCompression;
private JComboBox jComboBoxLangue;
private JComboBox jComboBoxQualite;
private static JComboBox jComboBoxStatut;
private JPanel jDetailFilmPanel;
private JLabel jLabelNbResult;
private JTextField jRechercherNom;
private JMenuItem nouveauFilmMenuItem;
private JMenu jMenuFichier;
private JMenuBar jMenuBar1;
private DefaultTableModel jListeFilmModel;
private ListeFilmsThread listeFilmThread;
private TableRowSorter<DefaultTableModel> jListeFilmSorter;
private JComboBox jComboBoxTypeMedia;
private JLabel jLabelTypeMedia;
private JLabel jLabelInformation;
private JTextField jRechercherNumero;
private JMenuItem qualiteMenuItem;
private JMenuItem langueMenuItem;
private JMenuItem bulkInsertMenuItem;
private JLabel jNumMedia;
private JPanel jPanelBas;
private JPanel jPanelHaut;
private Main me;
private Utilisateurs currentUser;
private JMenu jMenuUtilisateur;
private JMenuItem detailCurrentUserMenuItem;
private JMenu jMenuParametres;
private JMenuItem parametreSysteme;
private AnalyseMediaThread analyseMedia;
public Utilisateurs getCurrentUser() {
return currentUser;
}
public void setCurrentUser(Utilisateurs currentUser) {
this.currentUser = currentUser;
}
public Main(Utilisateurs tmpUtil) {
super();
this.setCurrentUser(tmpUtil);
Properties systemSettings = System.getProperties();
systemSettings.put("langue.utilisateur", tmpUtil.getLangue());
System.setProperties(systemSettings);
try {
Libelle.refreshProperties();
} catch (Exception e) {
e.printStackTrace();
}
initGUI();
initLibelle();
me = this;
listeFilmThread = new ListeFilmsThread(me);
listeFilmThread.start();
listeFilmThread.setDuTaf(true);
}
private void initGUI() {
try {
{
listeMovie = new JScrollPane();
getContentPane().add(listeMovie, BorderLayout.CENTER);
listeMovie.setPreferredSize(new java.awt.Dimension(999, 609));
{
jListeFilmModel = new DefaultTableModel(
new String[][] {},
new String[] { Libelle.getLibelle("titreColonneIdentifiant"), Libelle.getLibelle("titreColonneNom"), Libelle.getLibelle("titreColonneType"),Libelle.getLibelle("titreColonneNumero"),
Libelle.getLibelle("titreColonneStatut"), Libelle.getLibelle("titreColonneLangue"), Libelle.getLibelle("titreColonneCompression"), Libelle.getLibelle("titreColonneQualite") }){
private static final long serialVersionUID = 1L;
public Class<?> getColumnClass(int column){
Class returnValue;
if((column >= 0) && (column < getColumnCount())){
returnValue = getValueAt(0, column).getClass();
} else{
returnValue = Object.class;
}
return returnValue;
}
};
tableListeFilms = new JTable();
jListeFilmSorter = new TableRowSorter<DefaultTableModel>(jListeFilmModel);
listeMovie.setViewportView(getTableListeFilms());
tableListeFilms.setModel(jListeFilmModel);
tableListeFilms.setAutoCreateRowSorter(true);
tableListeFilms.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent evt) {
tableListeFilmsKeyReleased(evt);
}
});
tableListeFilms.setRowSorter(jListeFilmSorter);
tableListeFilms.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
tableListeFilmsMouseClicked(evt);
}
});
tableListeFilms.getColumnModel().getColumn(getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneNumero")).getModelIndex()).setCellEditor(new IntegerEditor());
this.resizeColumn();
}
}
{
jPanelHaut = new JPanel();
getContentPane().add(jPanelHaut, BorderLayout.NORTH);
jPanelHaut.setPreferredSize(new java.awt.Dimension(1016, 62));
{
jLabelNom = new JLabel();
jPanelHaut.add(jLabelNom);
jLabelNom.setPreferredSize(new java.awt.Dimension(85, 14));
}
{
jRechercherNom = new JTextField();
jPanelHaut.add(jRechercherNom);
jRechercherNom.setPreferredSize(new java.awt.Dimension(837, 24));
jRechercherNom.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent evt) {
appliquerFiltre();
}
});
}
{
jNumMedia = new JLabel();
jPanelHaut.add(jNumMedia);
}
{
jRechercherNumero = new JTextField();
jPanelHaut.add(jRechercherNumero);
jRechercherNumero.setPreferredSize(new java.awt.Dimension(56, 24));
jRechercherNumero.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent evt) {
appliquerFiltre();
}
});
}
{
jLabelTypeMedia = new JLabel();
jPanelHaut.add(jLabelTypeMedia);
}
{
ComboBoxModel jComboBoxTypeMediaModel = new DefaultComboBoxModel(
new String[] {});
jComboBoxTypeMedia = new JComboBox();
jPanelHaut.add(jComboBoxTypeMedia);
jComboBoxTypeMedia.setModel(jComboBoxTypeMediaModel);
remplirListeMedia();
}
{
jLabelStatut = new JLabel();
jPanelHaut.add(jLabelStatut);
jLabelStatut.setPreferredSize(new java.awt.Dimension(54, 14));
}
{
ComboBoxModel jComboBoxStatutModel = new DefaultComboBoxModel(
new String[] {});
jComboBoxStatut = new JComboBox();
jPanelHaut.add(jComboBoxStatut);
jComboBoxStatut.setModel(jComboBoxStatutModel);
remplirListeStatut();
jComboBoxStatut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
{
jLabelCompression = new JLabel();
jPanelHaut.add(jLabelCompression);
jLabelCompression.setPreferredSize(new java.awt.Dimension(
88,
14));
}
{
ComboBoxModel jComboBoxCompressionModel = new DefaultComboBoxModel(
new String[] {});
jComboBoxCompression = new JComboBox();
jPanelHaut.add(jComboBoxCompression);
jComboBoxCompression.setModel(jComboBoxCompressionModel);
this.remplirListeCompression();
jComboBoxCompression.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
{
jLabelLangue = new JLabel();
jPanelHaut.add(jLabelLangue);
jLabelLangue.setPreferredSize(new java.awt.Dimension(56, 14));
}
{
ComboBoxModel jComboBoxLangueModel = new DefaultComboBoxModel(
new String[] {});
jComboBoxLangue = new JComboBox();
jPanelHaut.add(jComboBoxLangue);
jComboBoxLangue.setModel(jComboBoxLangueModel);
this.remplirListeLangue();
jComboBoxLangue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
{
jLabelQualite = new JLabel();
jPanelHaut.add(jLabelQualite);
jLabelQualite.setPreferredSize(new java.awt.Dimension(
60,
14));
}
{
ComboBoxModel jComboBoxQualiteModel = new DefaultComboBoxModel(
new String[] {});
jComboBoxQualite = new JComboBox();
jPanelHaut.add(jComboBoxQualite);
jComboBoxQualite.setModel(jComboBoxQualiteModel);
this.remplirListeQualite();
jComboBoxQualite.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
}
{
jPanelBas = new JPanel();
getContentPane().add(jPanelBas, BorderLayout.SOUTH);
{
jLabelNbResult = new JLabel();
jPanelBas.add(jLabelNbResult);
jLabelNbResult.setPreferredSize(new java.awt.Dimension(161, 14));
}
{
jProgressBar = new JProgressBar();
jPanelBas.add(jProgressBar);
jProgressBar.setPreferredSize(new java.awt.Dimension(498, 14));
}
{
jLabelInformation = new JLabel();
jPanelBas.add(jLabelInformation);
jLabelInformation.setPreferredSize(new java.awt.Dimension(329, 11));
jLabelInformation.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelInformation.setHorizontalAlignment(SwingConstants.RIGHT);
}
}
this.setSize(1024, 768);
{
jMenuBar1 = new JMenuBar();
setJMenuBar(jMenuBar1);
{
jMenuFichier = new JMenu();
jMenuBar1.add(jMenuFichier);
{
exitMenuItem = new JMenuItem();
jMenuFichier.add(exitMenuItem);
exitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
});
}
}
if(getCurrentUser().getIsAdmin().equals("O")){
{
jMenuDonnes = new JMenu();
jMenuBar1.add(jMenuDonnes);
{
nouveauFilmMenuItem = new JMenuItem();
jMenuDonnes.add(nouveauFilmMenuItem);
nouveauFilmMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F1"));
nouveauFilmMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
AjoutFilm inst = new AjoutFilm(me);
inst.setVisible(true);
}
});
}
{
bulkInsertMenuItem = new JMenuItem();
jMenuDonnes.add(bulkInsertMenuItem);
bulkInsertMenuItem.setAccelerator(KeyStroke.getKeyStroke("alt shift F1"));
bulkInsertMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JDirectoryChooser chooser = new JDirectoryChooser();
chooser.setShowingCreateDirectory(false);
chooser.setDialogTitle(Libelle.getLibelle("selectionEmplacement"));
int choice = chooser.showOpenDialog(me);
if(choice != JDirectoryChooser.CANCEL_OPTION) {
BulkInsertSelection inst = new BulkInsertSelection(me);
inst.setVisible(true);
analyseMedia = new AnalyseMediaThread(inst,chooser.getSelectedFile().getAbsolutePath());
analyseMedia.start();
}
}
});
}
{
typeMediaMenuItem = new JMenuItem();
jMenuDonnes.add(typeMediaMenuItem);
typeMediaMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F2"));
typeMediaMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
GestionGenerique inst = new GestionGenerique(me, "typeMedia");
inst.setVisible(true);
}
});
}
{
compressionMenuItem = new JMenuItem();
jMenuDonnes.add(compressionMenuItem);
compressionMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F3"));
compressionMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
GestionGenerique inst = new GestionGenerique(me, "compression");
inst.setVisible(true);
}
});
}
{
langueMenuItem = new JMenuItem();
jMenuDonnes.add(langueMenuItem);
langueMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F4"));
langueMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
GestionGenerique inst = new GestionGenerique(me, "langue");
inst.setVisible(true);
}
});
}
{
qualiteMenuItem = new JMenuItem();
jMenuDonnes.add(qualiteMenuItem);
qualiteMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F5"));
qualiteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
GestionGenerique inst = new GestionGenerique(me, "qualite");
inst.setVisible(true);
}
});
}
}
}
{
jMenuUtilisateur = new JMenu();
jMenuBar1.add(jMenuUtilisateur);
{
detailCurrentUserMenuItem = new JMenuItem();
jMenuUtilisateur.add(detailCurrentUserMenuItem);
detailCurrentUserMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F6"));
detailCurrentUserMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
DetailUtilisateur inst = new DetailUtilisateur(me);
inst.setVisible(true);
}
});
}
}
{
jMenuParametres = new JMenu();
jMenuBar1.add(jMenuParametres);
{
parametreSysteme = new JMenuItem();
jMenuParametres.add(parametreSysteme);
parametreSysteme.setAccelerator(KeyStroke.getKeyStroke("shift F7"));
parametreSysteme.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ParametreSysteme inst = new ParametreSysteme(me);
inst.setVisible(true);
inst.setTitle(Libelle.getLibelle("titreFeneteParametreSysteme"));
}
});
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void initLibelle() {
jLabelNom.setText(Libelle.getLibelle("nomFilm"));
jNumMedia.setText(Libelle.getLibelle("numeroMedia"));
jLabelTypeMedia.setText(Libelle.getLibelle("typeMedia"));
jLabelStatut.setText(Libelle.getLibelle("statut"));
jLabelCompression.setText(Libelle.getLibelle("compression"));
jLabelLangue.setText(Libelle.getLibelle("langue"));
jLabelQualite.setText(Libelle.getLibelle("qualite"));
jLabelNbResult.setText(Libelle.getLibelle("nombreFilm",new String("0")));
jLabelInformation.setText(Libelle.getLibelle("information"));
jMenuFichier.setText(Libelle.getLibelle("menuFichier"));
exitMenuItem.setText(Libelle.getLibelle("menuFichierQuitter"));
jMenuDonnes.setText(Libelle.getLibelle("menuDonnees"));
nouveauFilmMenuItem.setText(Libelle.getLibelle("menuDonneesNouveauFilm"));
typeMediaMenuItem.setText(Libelle.getLibelle("menuDonneesTypeDeMedia"));
compressionMenuItem.setText(Libelle.getLibelle("menuDonneesCompression"));
langueMenuItem.setText(Libelle.getLibelle("menuDonneesLangue"));
qualiteMenuItem.setText(Libelle.getLibelle("menuDonneesQualite"));
jMenuUtilisateur.setText(Libelle.getLibelle("menuUtilisateur"));
detailCurrentUserMenuItem.setText(Libelle.getLibelle("menuUtilisateurDetail"));
jMenuParametres.setText(Libelle.getLibelle("menuParametre"));
parametreSysteme.setText(Libelle.getLibelle("menuParametreSysteme"));
bulkInsertMenuItem.setText(Libelle.getLibelle("menuInsertionEnMasse"));
}
public JTable getTableListeFilms() {
return tableListeFilms;
}
public DefaultTableModel getListFilmModel() {
return jListeFilmModel;
}
public JProgressBar getJProgressBar() {
return jProgressBar;
}
public JTextField getJRechercherNom() {
return jRechercherNom;
}
public JTextField getJRechercherNumero() {
return jRechercherNumero;
}
public JLabel getJLabelNbResult() {
return jLabelNbResult;
}
public JComboBox getJComboBoxStatut() {
return jComboBoxStatut;
}
public JComboBox getJComboBoxQualite() {
return jComboBoxQualite;
}
public JComboBox getJComboBoxLangue() {
return jComboBoxLangue;
}
public JComboBox getJComboBoxCompression() {
return jComboBoxCompression;
}
public void resizeColumn(){
TableColumn column = null;
getListFilmModel().getColumnCount();
column = getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneIdentifiant"));
column.setPreferredWidth(0);
column.setMaxWidth(0);
column.setMinWidth(0);
}
public JPanel getJDetailFilmPanel() {
return jDetailFilmPanel;
}
public void remplirListeStatut(){
try {
jComboBoxStatut.removeAllItems();
jComboBoxStatut.addItem(new String(""));
List tmpList = DatabaseDAO.selectAllStatuts();
Iterator tmpIterator = tmpList.listIterator();
while(tmpIterator.hasNext()){
jComboBoxStatut.addItem(((Movie)tmpIterator.next()).getStatut());
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public void remplirListeQualite(){
List tmpList=null;
ActionListener[] tmpListeners = jComboBoxQualite.getActionListeners();
//On commence par enlever le listener pour ne pas le perturber
for (int i=0; i<tmpListeners.length;i++){
jComboBoxQualite.removeActionListener(tmpListeners[i]);
}
jComboBoxQualite.removeAllItems();
jComboBoxQualite.addItem(new String(""));
try {
tmpList = DatabaseDAO.selectAllQualites();
} catch (SQLException e) {
JOptionPane.showOptionDialog(
SwingUtilities.getWindowAncestor(this),
Libelle.getLibelle("erreurInitialisationListeQualite"),
Libelle.getLibelle("erreur"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
null,
null);
}
Iterator tmpIterator = tmpList.listIterator();
while(tmpIterator.hasNext()){
jComboBoxQualite.addItem(((Generique)tmpIterator.next()).getCode());
}
//Et zou on remet le listener pour les filtres
jComboBoxQualite.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
public void remplirListeLangue(){
List tmpList=null;
ActionListener[] tmpListeners = jComboBoxLangue.getActionListeners();
//On commence par enlever le listener pour ne pas le perturber
for (int i=0; i<tmpListeners.length;i++){
jComboBoxLangue.removeActionListener(tmpListeners[i]);
}
jComboBoxLangue.removeAllItems();
jComboBoxLangue.addItem(new String(""));
try {
tmpList = DatabaseDAO.selectAllLangues();
} catch (SQLException e) {
JOptionPane.showOptionDialog(
SwingUtilities.getWindowAncestor(this),
Libelle.getLibelle("erreurInitialisationListeLangue"),
Libelle.getLibelle("erreur"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
null,
null);
}
Iterator tmpIterator = tmpList.listIterator();
while(tmpIterator.hasNext()){
jComboBoxLangue.addItem(((Generique)tmpIterator.next()).getCode());
}
//Et zou on remet le listener pour les filtres
jComboBoxLangue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
public void remplirListeCompression(){
List tmpList=null;
ActionListener[] tmpListeners = jComboBoxCompression.getActionListeners();
//On commence par enlever le listener pour ne pas le perturber
for (int i=0; i<tmpListeners.length;i++){
jComboBoxCompression.removeActionListener(tmpListeners[i]);
}
jComboBoxCompression.removeAllItems();
jComboBoxCompression.addItem(new String(""));
try {
tmpList = DatabaseDAO.selectAllCompressions();
}
catch (SQLException e) {
JOptionPane.showOptionDialog(
SwingUtilities.getWindowAncestor(this),
Libelle.getLibelle("erreurInitialisationListeCompression"),
Libelle.getLibelle("erreur"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
null,
null);
}
Iterator tmpIterator = tmpList.listIterator();
while(tmpIterator.hasNext()){
jComboBoxCompression.addItem(((Generique)tmpIterator.next()).getCode());
}
//Et zou on remet le listener pour les filtres
jComboBoxCompression.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
public void remplirListeMedia(){
List tmpList=null;
ActionListener[] tmpListeners = jComboBoxTypeMedia.getActionListeners();
//On commence par enlever le listener pour ne pas le perturber
for (int i=0; i<tmpListeners.length;i++){
jComboBoxTypeMedia.removeActionListener(tmpListeners[i]);
}
jComboBoxTypeMedia.removeAllItems();
jComboBoxTypeMedia.addItem(new String(""));
try {
tmpList = DatabaseDAO.selectAllMedias();
} catch (SQLException e) {
JOptionPane.showOptionDialog(
SwingUtilities.getWindowAncestor(this),
Libelle.getLibelle("erreurInitialisationListeTypeMedia"),
Libelle.getLibelle("erreur"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
null,
null);
}
Iterator tmpIterator = tmpList.listIterator();
while(tmpIterator.hasNext()){
jComboBoxTypeMedia.addItem(((Generique)tmpIterator.next()).getCode());
}
//Et zou on remet le listener pour les filtres
jComboBoxTypeMedia.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
appliquerFiltre();
}
});
}
private void tableListeFilmsMouseClicked(MouseEvent evt) {
if(evt.getClickCount() > 1 && evt.getButton() == 1){
String tmpNom = (String)getTableListeFilms().getValueAt(getTableListeFilms().getSelectedRow(), getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneNom")).getModelIndex());
DetailFilm inst = new DetailFilm(me, tmpNom);
inst.setVisible(true);
}
}
private void appliquerFiltre() {
jListeFilmSorter.setRowFilter(movieFilter);
getJLabelNbResult().setText(Libelle.getLibelle("nombreFilm", new Integer(jListeFilmSorter.getViewRowCount()).toString()));
}
private void tableListeFilmsKeyReleased(KeyEvent evt) {
if(evt.getKeyCode() == 127 ){
int[] selection = getTableListeFilms().getSelectedRows();
String tmpNom = new String();
Integer tmpId = new Integer(0);
int compteurSuppression = 0;
Movie tmpMovie = null;
for(int i = 0; i<selection.length; i++){
tmpNom = (String)getTableListeFilms().getValueAt(selection[i] - compteurSuppression, getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneNom")).getModelIndex());
tmpId = (Integer)getTableListeFilms().getValueAt(selection[i] - compteurSuppression, getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneIdentifiant")).getModelIndex());
//attention on essaye de supprimer
Object[] options = {Libelle.getLibelle("oui"),Libelle.getLibelle("non")};
int answer = JOptionPane.showOptionDialog(
SwingUtilities.getWindowAncestor(this),
Libelle.getLibelle("confirmationSuppressionFilm", tmpNom),
Libelle.getLibelle("titreSuppressionFilm"),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[1]);
if (answer == 0) {
tmpMovie = new Movie();
tmpMovie.setId(tmpId.intValue());
try {
DatabaseDAO.deleteMovie(tmpMovie);
getListFilmModel().removeRow(getTableListeFilms().convertRowIndexToModel(selection[i] - compteurSuppression));
compteurSuppression++;
} catch (SQLException e) {
JOptionPane.showOptionDialog(
SwingUtilities.getWindowAncestor(this),
Libelle.getLibelle("erreurSuppresionFilm", tmpNom),
Libelle.getLibelle("erreur"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
null,
null);
}
}
else{
selection[i] = -1;
}
}
if(compteurSuppression > 0){
if(compteurSuppression <= 1 )
getJLabelInformation().setText(Libelle.getLibelle("suppresionFilmSingulier"));
else
getJLabelInformation().setText(Libelle.getLibelle("suppresionFilmPluriel",(new Integer(compteurSuppression)).toString()));
getJLabelNbResult().setText(Libelle.getLibelle("nombreFilm",new Integer(jListeFilmSorter.getViewRowCount()).toString()));
}
}
}
public JLabel getJLabelInformation() {
return jLabelInformation;
}
public JComboBox getJComboBoxTypeMedia() {
return jComboBoxTypeMedia;
}
RowFilter<Object,Object> movieFilter = new RowFilter<Object,Object>() {
public boolean include(Entry<? extends Object, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if(i==getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneNom")).getModelIndex()){
if(!getJRechercherNom().getText().trim().equals("") && entry.getStringValue(i).toLowerCase().indexOf(getJRechercherNom().getText().toLowerCase()) < 0){
return false;
}
}
if(i==getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneNumero")).getModelIndex()){
if(!getJRechercherNumero().getText().trim().equals("") && !entry.getStringValue(i).equals(getJRechercherNumero().getText())){
return false;
}
}
if(i==getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneStatut")).getModelIndex()){
if(getJComboBoxStatut().getSelectedItem() != null){
if(!((String)getJComboBoxStatut().getSelectedItem()).trim().equals("") && !entry.getStringValue(i).equals((String)getJComboBoxStatut().getSelectedItem())){
return false;
}
}
}
if(i==getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneType")).getModelIndex()){
if(!((String)getJComboBoxTypeMedia().getSelectedItem()).trim().equals("") && !entry.getStringValue(i).equals((String)getJComboBoxTypeMedia().getSelectedItem())){
return false;
}
}
if(i==getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneQualite")).getModelIndex()){
if(!((String)getJComboBoxQualite().getSelectedItem()).trim().equals("") && !entry.getStringValue(i).equals((String)getJComboBoxQualite().getSelectedItem())){
return false;
}
}
if(i==getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneCompression")).getModelIndex()){
if(!((String)getJComboBoxCompression().getSelectedItem()).trim().equals("") && !entry.getStringValue(i).equals((String)getJComboBoxCompression().getSelectedItem())){
return false;
}
}
if(i==getTableListeFilms().getColumn(Libelle.getLibelle("titreColonneLangue")).getModelIndex()){
if(!((String)getJComboBoxLangue().getSelectedItem()).trim().equals("") && !entry.getStringValue(i).equals((String)getJComboBoxLangue().getSelectedItem())){
return false;
}
}
}
return true;
}
};
private JMenuItem compressionMenuItem;
private JMenuItem typeMediaMenuItem;
}