/*
 * Menus.java, 9 sept. 2005
 * 
 * This file is part of FilmZ.
 *
 * Copyright © 2005 Johan Cwiklinski
 *
 * File :               Menus.java
 * Author's email :     johan@x-tnd.be
 * Author's Website :   http://www.x-tnd.be/
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 */

package be.xtnd.gui;

import java.awt.Event;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;

import be.xtnd.commons.Config;
import be.xtnd.commons.GuiCommons;
import be.xtnd.commons.HelpWindow;
import be.xtnd.commons.MessagesCommons;
import be.xtnd.commons.gui.AboutBox;
import be.xtnd.commons.gui.MainGui;
import be.xtnd.films.Collection;
import be.xtnd.films.gui.Acteurs;
import be.xtnd.films.gui.AdvancedSearch;
import be.xtnd.films.gui.Collections;
import be.xtnd.films.gui.Films;
import be.xtnd.films.gui.FilmzOptions;
import be.xtnd.films.gui.Genres;
import be.xtnd.films.gui.Impressions;
import be.xtnd.films.gui.Login;
import be.xtnd.films.gui.Messages;
import be.xtnd.films.gui.Origines;
import be.xtnd.films.gui.Realisateurs;
import be.xtnd.films.plugins.RechercheWeb;

import com.jgoodies.looks.BorderStyle;
import com.jgoodies.looks.HeaderStyle;
import com.jgoodies.looks.Options;
import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;

/**
 * 
 *
 * @author Johan Cwiklinski
 */
public class Menus {
	private GuiCommons commons = new GuiCommons(Messages.getBundle());
	private static JMenuBar rootMenuBar = new JMenuBar();
	private static JToolBar toolBar = new JToolBar();

	/** Icône de l'application au format Image */
	public static final Image APPLI_ICON = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/filmz.png")).getImage();
	/** Icône de l'application */
	public static final ImageIcon FILMZ_ICON = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/filmz.png"));
	/** Icône des options */
	public static final ImageIcon OPTIONS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/options.png"));
	/** Icône des collections */
	public static final ImageIcon COLLECTIONS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/collections.png"));
	/** Icône des utilisateurs */
	public static final ImageIcon USERS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/users.png"));
	/** Icône des acteurs */
	public static final ImageIcon ACTORS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/acteurs.png"));
	/** Icône des réalisateurs */
	public static final ImageIcon DIRECTORS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/directors.png"));
	/** Icône des origines */
	public static final ImageIcon ORIGINS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/origins.png"));
	/** Icône des genres */
	public static final ImageIcon TYPES_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/genres.png"));
	/** Icône quiter */
	public static final ImageIcon QUIT_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/quit.png"));
	/** Icône nouveau */
	public static final ImageIcon NEW_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/new.png"));
	/** Icône modifier */
	public static final ImageIcon MODIF_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/open.png"));
	/** Icône supprimer */
	public static final ImageIcon DELETE_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/delete.png"));
	/** Icône chercher */
	public static final ImageIcon SEARCH_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/search.png"));
	/** Icône liste */
	public static final ImageIcon LIST_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/list.png"));

	/** Icône imprimer */
	public static final ImageIcon PRINT_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/print.png"));
	/** Icône préférences */
	public static final ImageIcon PREFS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/prefs.png"));
	/** Icône aide */
	public static final ImageIcon HELP_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/help.png"));
	/** Icône fermer */
	public static final ImageIcon CLOSE_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/close.png"));
	/** Icône web */
	public static final ImageIcon WEB_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/website.png"));
	/** Icône statistiques */
	public static final ImageIcon STATS_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/statistiques.png"));
	/** Icône sécurité */
	public static final ImageIcon SECURE_IMAGE = new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/secure.png"));

	private static JRadioButtonMenuItem active = new JRadioButtonMenuItem();
	private static JRadioButtonMenuItem inactive = new JRadioButtonMenuItem();
	private static JToggleButton secure;
	private JComboBox collections;

	/**
	 * Crée le menu
	 * @return JMenu
	 */
	public JMenuBar menus (){
		fileMenu();
		return rootMenuBar;
	}
	
	/**
	 * Crée la barre d'outils
	 * @return JToolBar
	 */
	public JToolBar toolbar(){
		menuBar();
		return toolBar;
	}
	/**
	 * fileMenu() : génère la barre de menus
	 */
	private void fileMenu(){
		rootMenuBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
		rootMenuBar.putClientProperty(PlasticXPLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);

		JMenu filmzMenu = new JMenu();

		JMenu collections = new JMenu();
		JMenuItem listCollections = new JMenuItem();
		JMenuItem newCollection = new JMenuItem();
		
	    JMenu filmz = new JMenu ();
		JMenuItem listFilmz = new JMenuItem();
		JMenuItem newFilmz = new JMenuItem();
		JMenuItem searchFilmz = new JMenuItem();
		
	    JMenu actors = new JMenu ();
		JMenuItem listActors = new JMenuItem();
		JMenuItem newActor = new JMenuItem();
		
		JMenu directors = new JMenu();
		JMenuItem listDirectors = new JMenuItem();
		JMenuItem newDirector = new JMenuItem();
		
		JMenu origins = new JMenu();
		JMenuItem listOrigins = new JMenuItem();
		JMenuItem newOrigin = new JMenuItem();
		
		JMenu types = new JMenu();
		JMenuItem listTypes = new JMenuItem();
		JMenuItem newType = new JMenuItem();
		
		JMenu parental = new JMenu();
		active = new JRadioButtonMenuItem();
		inactive = new JRadioButtonMenuItem();
				
		JMenuItem statsMenuItem = new JMenuItem();
		JMenuItem optionsMenuItem = new JMenuItem();
		JMenuItem prefsMenuItem = new JMenuItem();
		JMenuItem printMenuItem = new JMenuItem();
		JMenuItem quitMenuItem = new JMenuItem();

		JMenu helpMenu = new JMenu();
	    JMenuItem helpMenuItem = new JMenuItem();
		JMenuItem aboutMenuItem = new JMenuItem();

		//raccourcis clavier
	    KeyStroke keystrokeExit = KeyStroke.getKeyStroke(KeyEvent.VK_Q,Event.CTRL_MASK); //exit application
	    KeyStroke keystrokeNew = KeyStroke.getKeyStroke(KeyEvent.VK_N,Event.CTRL_MASK); //new episode
	    KeyStroke keystrokeSearch = KeyStroke.getKeyStroke(KeyEvent.VK_F,Event.CTRL_MASK); //chercher
	    KeyStroke keystrokeHelp = KeyStroke.getKeyStroke("F1"); //aide 
	    KeyStroke keystrokePrint = KeyStroke.getKeyStroke(KeyEvent.VK_P,Event.CTRL_MASK); //impression
	    KeyStroke keystrokeOptions = KeyStroke.getKeyStroke(KeyEvent.VK_T,Event.CTRL_MASK); //options
	    KeyStroke keystrokePrefs = KeyStroke.getKeyStroke(KeyEvent.VK_E,Event.CTRL_MASK); //préférences
	    KeyStroke keystrokeStats = KeyStroke.getKeyStroke(KeyEvent.VK_S,Event.CTRL_MASK); //statistiques

	    //menu | FilmZ
	    rootMenuBar.add(commons.menuEntry(filmzMenu, "menus.movies", null));
	    
	    collections.add(commons.submenuEntry(listCollections, LIST_IMAGE,"menus.collections.list",null));
	    listCollections.addActionListener(new CollectionsList());
	    collections.add(commons.submenuEntry(newCollection,NEW_IMAGE,"menus.collections.new",null));
	    newCollection.addActionListener(new CollectionAdd());
	    filmzMenu.add(commons.menuEntry(collections, "menus.collections", COLLECTIONS_IMAGE));
	    
	    filmz.add(commons.submenuEntry(listFilmz, LIST_IMAGE,"menus.movies.list", null));
	    listFilmz.addActionListener(new FilmzList());
	    filmz.add(commons.submenuEntry(newFilmz, NEW_IMAGE,"menus.movies.new", keystrokeNew));	    
	    newFilmz.addActionListener(new AddFilmz());
	    filmz.add(commons.submenuEntry(searchFilmz, SEARCH_IMAGE,"menus.movies.search", keystrokeSearch));	    
	    searchFilmz.addActionListener(new SearchFilmz());
	    filmzMenu.add(commons.menuEntry(filmz, "menus.movies", FILMZ_ICON));
	    
	    actors.add(commons.submenuEntry(listActors, LIST_IMAGE, "menus.actors.list", null));
	    listActors.addActionListener(new ActorsList());
	    actors.add(commons.submenuEntry(newActor, NEW_IMAGE, "menus.actors.new", null));
	    newActor.addActionListener(new AddActor());
	    filmzMenu.add(commons.submenuEntry(actors, ACTORS_IMAGE, "menus.actors"));
	    
	    directors.add(commons.submenuEntry(listDirectors, LIST_IMAGE, "menus.directors.list", null));
	    listDirectors.addActionListener(new DirectorsList());
	    directors.add(commons.submenuEntry(newDirector, NEW_IMAGE, "menus.directors.new", null));
	    newDirector.addActionListener(new AddDirector());
	    filmzMenu.add(commons.submenuEntry(directors, DIRECTORS_IMAGE, "menus.directors"));
	    
	    origins.add(commons.submenuEntry(listOrigins, LIST_IMAGE, "menus.origins.list", null));
	    listOrigins.addActionListener(new OriginsList());
	    origins.add(commons.submenuEntry(newOrigin, NEW_IMAGE, "menus.origins.new", null));
	    newOrigin.addActionListener(new AddOrigin());
	    filmzMenu.add(commons.submenuEntry(origins, ORIGINS_IMAGE, "menus.origins"));
	    
	    types.add(commons.submenuEntry(listTypes, LIST_IMAGE, "menus.types.list", null));
	    listTypes.addActionListener(new TypesList());
	    types.add(commons.submenuEntry(newType, NEW_IMAGE, "menus.types.new", null));
	    newType.addActionListener(new AddType());
	    filmzMenu.add(commons.submenuEntry(types, TYPES_IMAGE, "menus.types"));
	    
	    filmzMenu.addSeparator();

	    ButtonGroup group = new ButtonGroup();
	    parental.add(commons.submenuEntry(active, null, "menus.parental.active", null));
	    active.setSelected(false);
	    group.add(active);
	    active.addActionListener(new ActiveListener());
	    parental.add(commons.submenuEntry(inactive, null, "menus.parental.inactive", null));
	    inactive.setSelected(true);
	    group.add(inactive);
	    inactive.addActionListener(new InactiveListener());
	    filmzMenu.add(commons.submenuEntry(parental, SECURE_IMAGE, "menus.parental"));
	    
	    filmzMenu.addSeparator();

	    filmzMenu.add(commons.submenuEntry(optionsMenuItem, OPTIONS_IMAGE, "menus.options", keystrokeOptions));
	    optionsMenuItem.addActionListener(new OptionsListener());
	    filmzMenu.add(commons.submenuEntry(statsMenuItem, STATS_IMAGE, "menus.statistics", keystrokeStats));
	    statsMenuItem.addActionListener(new StatsAction());
	    filmzMenu.add(commons.submenuEntry(prefsMenuItem, PREFS_IMAGE, "menus.preferences", keystrokePrefs));
	    prefsMenuItem.addActionListener(new PrefsAction());
	    
	    filmzMenu.addSeparator();
	    
	    filmzMenu.add(commons.submenuEntry(printMenuItem, PRINT_IMAGE, "menus.print", keystrokePrint));
	    printMenuItem.addActionListener(new PrintAction());

	    filmzMenu.addSeparator();
	    
	    filmzMenu.add(commons.submenuEntry(quitMenuItem, QUIT_IMAGE, "menus.quit", keystrokeExit));
	    quitMenuItem.addActionListener(new QuitAction());

	    //menu | Aide	    
	    helpMenu.add(commons.submenuEntry(helpMenuItem, HELP_IMAGE, "menus.help.contents", keystrokeHelp));
	    helpMenuItem.addActionListener(new HelpAction());
	    
	    helpMenu.addSeparator();

	    helpMenu.add(commons.submenuEntry(aboutMenuItem, null, "menus.help.about", null));
	    aboutMenuItem.addActionListener(new AboutAction());

	    rootMenuBar.add(commons.menuEntry(helpMenu, "menus.help", HELP_IMAGE));
}

	/**
	 * void menuBar()
	 * mise en place de la barre de menu générale</p>
	 */
	public void menuBar(){
		toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
		toolBar.putClientProperty(PlasticXPLookAndFeel.BORDER_STYLE_KEY, BorderStyle.EMPTY);
		toolBar.setRollover(true);

		JButton listFilmz = new JButton();
		JButton listActors = new JButton();
		JButton helpButton = new JButton();
		JButton quitButton = new JButton();
		JButton webSearch = new JButton();
		JButton stats = new JButton();
		secure = new JToggleButton();
		
		toolBar.add(commons.buildBarButton(listFilmz, "menus.movies.list", FILMZ_ICON));
		listFilmz.addActionListener(new FilmzList());
		toolBar.add(commons.buildBarButton(listActors, "menus.actors.list", ACTORS_IMAGE));
		listActors.addActionListener(new ActorsList());
		
		toolBar.addSeparator();
		
		toolBar.add(commons.buildBarButton(helpButton, "menus.help.contents", HELP_IMAGE));
		helpButton.addActionListener(new HelpAction());
		
		toolBar.addSeparator();
		
		toolBar.add(commons.buildBarButton(quitButton, "menus.quit", QUIT_IMAGE));
		quitButton.addActionListener(new QuitAction());
		
		toolBar.addSeparator();
		
		toolBar.add(commons.buildBarButton(webSearch, "menus.web", WEB_IMAGE));
		webSearch.addActionListener(new SearchOnWeb());
		
		toolBar.addSeparator();
		
		toolBar.add(commons.buildBarButton(stats, "menus.statistics", STATS_IMAGE));
		stats.addActionListener(new StatsAction());		
		
		toolBar.addSeparator();
		
		collections = new JComboBox();// = commons.buildNewCombo(Collection.liste());
		collections.addItemListener(new ItemListener(){
			public void itemStateChanged(ItemEvent evt) {
	            JComboBox cb = (JComboBox)evt.getSource();
	            
	            // Get the affected item
	            Object item = evt.getItem();
	    
	            if (evt.getStateChange() == ItemEvent.SELECTED && cb.getSelectedIndex()!=0) {
	            	System.err.println("Item "+item+" was just selected");
	            	FilmzMain.collection.changeTo(item.toString());
	            	
	        		JInternalFrame[] frames = FilmzMain.desktop.getAllFrames();
	        		int i = 0;
	        		while(i < frames.length){
	        			String name = frames[i].getName();
	        			frames[i].dispose();

	        			if(name.equals(Films.LIST_NAME)){
	        				Films films = new Films();
	        				films.getList();
	        			}
	        			/*if(frames[i].getName().equals(name)){
	        				System.out.println("name matches : "+name);
	        				load = false;
	        				frames[i].toFront();
	        				if(defaultLoc != null)
	        					frames[i].setLocation(defaultLoc);
	        				try {
	        					frames[i].setSelected(true);
	        				} catch (PropertyVetoException e) {}
	        			}*/
	        			i++;
	        		}

	            	
	            } else if (evt.getStateChange() == ItemEvent.DESELECTED) {
	            	System.err.println("Item "+item+" is no longer selected");
	            }
			}
		});
		toolBar.add(collections);

		secure.putClientProperty(Options.IS_NARROW_KEY, Boolean.TRUE);
	  	secure.setIcon(SECURE_IMAGE);
	  	secure.setToolTipText(Messages.getString("menus.parental.tooltip"));
	  	secure.setMnemonic(Messages.getString("menus.parental.mnemonic").charAt(0));
	  	secure.addActionListener(new SecureListener());
		toolBar.add(secure);
		
		toolBar.setFloatable(false);
	}
	
	/**
	 * Met à jour la liste des collections
	 *
	 */
	public void populateCollections(){
		collections.removeAllItems();
		commons.buildCombo(collections, Collection.liste(true));
	}
	
	/**
	 * 
	 *
	 */
	public static void setInactive(){
		active.setSelected(false);
		inactive.setSelected(true);
		secure.setEnabled(false);
	}
	
	/** Actions */
	class QuitAction implements ActionListener {
		/**
		 * Action quitter
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			int response = JOptionPane.showConfirmDialog(
					MainGui.desktop, 
					MessagesCommons.getString("window.messages.quit"),
					MessagesCommons.getString("window.messages.quit.title"),
					JOptionPane.YES_NO_OPTION,
					JOptionPane.INFORMATION_MESSAGE);
    		if (response == JOptionPane.YES_OPTION) {
    		  	System.out.println("Bye, bye !");
    			System.exit(0);
    		}
		}
	}
	class HelpAction implements ActionListener {
		/**
		 * Action aide
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(HelpWindow.name,null)){
				new HelpWindow(Messages.getBundle());
			}
		}
	}
	class OptionsListener implements ActionListener {
		/**
		 * Action préférences
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(FilmzOptions.NAME,null)){
				new FilmzOptions();
			}
		}
	}
	class PrefsAction implements ActionListener {
		/**
		 * Action préférences
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Config.name,null)){
				try {
					MainGui.conf.new ConfigWindow(FilmzMain.main);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		}
	}
	class StatsAction implements ActionListener {
		/**
		 * Action aide
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Statistics.NAME,null)){
				new Statistics();
			}
		}
	}
	class PrintAction implements ActionListener {
		/**
		 * Action Imprimer
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			new Impressions();
		}
	}

	class CollectionsList implements ActionListener {
		/**
		 * Action liste films
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Collections.LIST_NAME,null)){
				Collections c = new Collections();
				c.getList();
			}
		}
	}
	class CollectionAdd implements ActionListener {
		/**
		 * Action liste films
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			/*Collection c = new Collection();
			c.enregistrer(true);*/
			if(MainGui.verifUnicite(Collections.NEW_NAME,null)){
				new Collections().nouveau();
			}
		}
	}

	class FilmzList implements ActionListener {
		/**
		 * Action liste films
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Films.LIST_NAME,null)){
				Films films = new Films();
				films.getList();
			}
		}
	}
	class AddFilmz implements ActionListener {
		/**
		 * Action ajouter film
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Films.NEW_NAME,null)){
				Films.Liste films = null;
				JInternalFrame[] frames = MainGui.desktop.getAllFrames();
				int i = 0;
				while(i < frames.length){
					if(frames[i].getName().equals(Films.LIST_NAME)){
						System.out.println("name matches : "+Films.LIST_NAME);
						films = (Films.Liste)frames[i];
					}
					i++;
				}
				if(films == null)
					films = new Films().new Liste();
				films.ajoute();
			}
		}
	}
	class SearchFilmz implements ActionListener {
		/**
		 * Action chercher film
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(AdvancedSearch.LIST_NAME,null)){
				new AdvancedSearch();
			}
		}
	}

	class ActorsList implements ActionListener {
		/**
		 * Action liste acteurs
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Acteurs.LIST_NAME,null)){
				Acteurs acteurs = new Acteurs();
				acteurs.getList();
			}
		}
	}
	class AddActor implements ActionListener {
		/**
		 * Action ajouter acteur
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Acteurs.NEW_NAME,null)){
				Acteurs acteurs = new Acteurs();
				acteurs.nouveau();
			}
		}
	}

	class DirectorsList implements ActionListener {
		/**
		 * Action liste réalisateurs
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Realisateurs.LIST_NAME,null)){
				Realisateurs realisateurs = new Realisateurs();
				realisateurs.getList();
			}
		}
	}
	class AddDirector implements ActionListener {
		/**
		 * Action ajouter réalisateur
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Realisateurs.NEW_NAME,null)){
				Realisateurs realisateurs = new Realisateurs();
				realisateurs.nouveau();
			}
		}
	}

	class OriginsList implements ActionListener {
		/**
		 * Action liste origines
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Realisateurs.LIST_NAME,null)){
				Origines origines = new Origines();
				origines.getList();
			}
		}
	}
	class AddOrigin implements ActionListener {
		/**
		 * Action ajouter origine
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Origines.NEW_NAME,null)){
				Origines origines = new Origines();
				origines.nouveau();
			}
		}
	}
	
	class TypesList implements ActionListener {
		/**
		 * Action liste genres
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Genres.LIST_NAME,null)){
				Genres genres = new Genres();
				genres.getList();
			}
		}
	}
	class AddType implements ActionListener {
		/**
		 * Action ajouter genre
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Genres.NEW_NAME,null)){
				Genres genres = new Genres();
				genres.nouveau();
			}
		}
	}

	class AboutAction implements ActionListener {
		/**
		 * Action à propos
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(AboutBox.name,AboutBox.location)){
				new AboutBox(Messages.getBundle());
			}
		}
	}

	class SearchOnWeb implements ActionListener {
		/**
		 * Action liste réalisateurs
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(RechercheWeb.NEW_WEB_SEARCH,null)){
				new RechercheWeb();
			}
		}
	}
	
	class ActiveListener implements ActionListener {
		/**
		 * Action aide
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			if(MainGui.verifUnicite(Login.NAME,null)){
				if(!FilmzMain.isParentalActive()) new Login();
			}
		}
	}

	class InactiveListener implements ActionListener {
		/**
		 * Action aide
		 * @param e
		 */
		public void actionPerformed(ActionEvent e) {
			FilmzMain.setParentalActive(false);
			FilmzMain.menus.populateCollections();
			FilmzMain.statusBar.setIcon(null);
		}
	}
	
	class SecureListener implements ActionListener{
		/**
		 * @param e
		 */
		public void actionPerformed(ActionEvent e){
			if(secure.isSelected()){
				if(MainGui.verifUnicite(Login.NAME,null)){
					if(!FilmzMain.isParentalActive()) new Login();
				}
				active.setSelected(true);
				inactive.setSelected(false);
			}else{
				FilmzMain.setParentalActive(false);
				FilmzMain.menus.populateCollections();
				FilmzMain.statusBar.setIcon(null);
				active.setSelected(false);
				inactive.setSelected(true);
			}
		}
	}
}
