package be.msyben.vinylManager.gui;

import be.msyben.vinylManager.VinylManager;
import be.msyben.vinylManager.gui.icon.Icons;
import be.msyben.vinylManager.tools.swing.JLink;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
/**
 * Frame d'affichage des informations sur l'application (about...)
 * @author Mathieu Syben
 */
public class About extends JFrame {
    
    /**
     * uid
     */
    private static final long serialVersionUID = 22688l;
    
        
    /**
     * Le bouton ok
     */
    private JButton ok = new JButton("OK");
    
    /**
     * La version
     */
    
    
    /**
     * Creates a new instance of About
     */
    public About() {
        super("A propos de Vinyl Manager");
        setIconImage(Icons.getInstance().icon.getImage());
        MainWindow.getInstance().setEnabled(false);
        this.setSize(450,420); // On donne une taille à notre fenêtre
        this.setLocationRelativeTo(null); // On centre la fenêtre sur l'ecran
        this.setResizable(false); // On interdit la redimensionnement de la
        // fenêtre
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.getContentPane().setLayout(null);
        putElements();
        setVisible(true);
        
    }
    
    /**
     * Place les éléments dans la fenêtre
     */
    private void putElements(){
        
        JLink version = new JLink("Vinyl Manager version " + VinylManager.version, "http://msyben.be/vinylManager/");
        
        JLabel image = new JLabel();
        
        JLabel label = new JLabel("L'auteur décline toute responsabilité en cas de perte ou ");
        JLabel label1 = new JLabel("endommagement de données qui pourraient survenir suite à ");
        JLabel label2 = new JLabel("l'utilisation de ce programme.");
        JLabel label3 = new JLabel("Contact : ");
        JLink link = new JLink("msyben@gmail.com", "mailto:msyben@gmail.com?subject=Vinyl%20Manager");
        JLabel label4 = new JLabel("(c) 2012-2025 - Mathieu Syben");
        
        version.setBounds(120,5,195,15);
        this.getContentPane().add(version);
        
        label.setBounds(5,235,455,15);
        this.getContentPane().add(label);
        label1.setBounds(5,250,455,15);
        this.getContentPane().add(label1);
        label2.setBounds(5,265,455,15);
        this.getContentPane().add(label2);
        
        label3.setBounds(5,290,70,15);
        this.getContentPane().add(label3);
        link.setBounds(75,290,200,15);
        //link.setBorder(javax.swing.plaf.basic.BasicBorders.getTextFieldBorder());
        this.getContentPane().add(link);
        
        
        label4.setBounds(5,315,390,15);
        this.getContentPane().add(label4);
        
        ok.setBounds(170,345,100,25);
        this.getContentPane().add(ok);
        ok.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e) {
                MainWindow.getInstance().setEnabled(true);
                dispose();
            }
        });
        
        ok.addKeyListener(new KeyAdapter(){
            
            @Override
            public void keyPressed(KeyEvent e) {
                if (e.getModifiersEx() == 0 && e.getKeyCode() == KeyEvent.VK_ENTER){
                    MainWindow.getInstance().setEnabled(true);
                    dispose();
                }
            }
            
        });
        
        image.setIcon(Icons.getInstance().logo);
        image.setBounds(120,30,200,200);
        this.getContentPane().add(image);
        
        this.addWindowListener(new WindowAdapter(){
            
            @Override
            public void windowClosing(WindowEvent e) {
                MainWindow.getInstance().setEnabled(true);
                dispose();
            }
        });
    }
}
