package com.ibtp.kontor;


import com.ibtp.kontor.comics.view.ComicsMenu;
import com.ibtp.kontor.library.view.LibraryMenu;
import com.ibtp.kontor.tradingcards.view.TradingCardsMenu;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by TPEETZ on 11.02.2015.
 */
public class KontorGUI extends javax.swing.JFrame {

    KontorApp application;
    JMenuBar menuBar;
    JMenu menuFile;
    JMenuItem menuFileExit;

    JMenuItem menuFileStart = new JMenuItem();

    JMenu menuHelp;
    JMenuItem menuHelpAbout;

    public KontorGUI(KontorApp kontorApp) {
        application = kontorApp;
        initComponents();
    }

    private void initComponents() {
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 300, Short.MAX_VALUE)
        );
        pack();
        setTitle("Kontor Application");
        createMainMenu();
        //createToolBar();
    }

    private void createMainMenu() {
        menuBar = new JMenuBar();
        menuFile = new JMenu("File");
        menuFileExit = new JMenuItem("Exit");
        menuHelp = new JMenu("Help");
        menuHelpAbout = new JMenuItem("About");
        setJMenuBar(menuBar);
        menuBar.add(menuFile);
        menuFile.add(menuFileExit);
        menuBar.add(new ComicsMenu());
        menuBar.add(new LibraryMenu());
        menuBar.add(new TradingCardsMenu());
        menuBar.add(menuHelp);
        menuHelp.add(menuHelpAbout);
        menuFileExit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                application.exitApplication();
            }
        });
    }
}
