/*
 * FilmsMain.java, 26 Juin 2005
 * 
 * This file is part of FilmZ.
 *
 * Copyright © 2005 Johan Cwiklinski
 *
 * File :               FilmsMain.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 javax.swing.ImageIcon;

import be.xtnd.commons.ShowGnu;
import be.xtnd.commons.db.Database;
import be.xtnd.commons.gui.MainGui;
import be.xtnd.films.Collection;
import be.xtnd.films.Preferences;
import be.xtnd.films.gui.Films;
import be.xtnd.films.gui.Messages;
import be.xtnd.films.plugins.Plugins;


/**
 * Main class
 * 
 * @author Johan Cwiklinski
 */
public class FilmzMain extends MainGui {
	private static final long serialVersionUID = 3193445179837396375L;
	/** */
	public static Menus menus = new Menus();
	/** connexion base de données */
	public static Database db;
	/** État du mode parental */
	private static boolean parental_state = false;
	/** */
	public static FilmzMain main;
	/** */
	public static Collection collection;
	/** */
	public static Preferences prefs;
	/** */
	public static Plugins plugins;

	/**
	 * Main de l'application
	 * @param args
	 */
    public static void main(String[] args) {
    	System.out.println(
    			"***** "+
				Messages.getString("appli.name")+
				" - "+
				Messages.getString("appli.author")+
    			" - Gnu GPL - V"+Messages.getString("appli.version")+
				" "+Messages.getString("appli.date")+
				" *****");
    	
    	new ShowGnu(
    			Messages.getString("appli.name")+" "+Messages.getString("appli.version"), 
    			Messages.getString("appli.date"),
				Messages.getString("appli.author"));  	    	
    	main = new FilmzMain();
		Films films = new Films();
		films.getList();
    }

    /**
     * 
     *
     */
    public FilmzMain() {
    	super(
    			"FilmZ By Trasher",
				new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/filmz.png")),
				menus.menus(),
				menus.toolbar(),
				"filmz-config.xml",
				new ImageIcon(ClassLoader.getSystemResource("be/xtnd/icons/x-tnd.png")).getImage(),
				Messages.getBundle()
			);
    	plugins = new Plugins();
    	menus.populateCollections();
    	prefs = new Preferences();
    	collection = new Collection(prefs.getDefault_collection());
    }
    
    /**
     * @return État du mode parental
     */
    public static boolean isParentalActive(){
    	return parental_state;
    }

    /**
     * @param b 
     */
    public static void setParentalActive(boolean b){
    	parental_state = b;
    }
    
    protected void finalize(){
    	db.disconnect();
    }

    /**
     * Chargement de la base de données
     */
    @Override
    public void loadDb(){
    	db = new Database(true);
    }
}
