package project.app.gui;

import project.archive.*;
import project.app.gui.appframe.*;	
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;	

/**
 * Rappresenta un frame da cui e' possibile effettuare 
 * l'accesso all'area Gestore o Cliente
 * 
 * @author Roberto Ruccia
 */
public class GuiStartMenuFrame extends AppFrame {
	
	/**
	 * Costruttore
	 * @param archive Un archivio
	 */
	public GuiStartMenuFrame(Archive archive) { 
		super(archive, "Seleziona una zona d'accesso");
	}
	
	/**
	 * Implementazione del metodo della superclasse
	 */
	public void createComponents() {		
		
			// manager area button
		JButton manBtn = new JButton(new AbstractAction("Gestore", new ImageIcon(getClass().getResource("/icons/manager.gif"))) {
			public void actionPerformed(ActionEvent event) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {	
						frame.setVisible(false);
						new ManagerAreaFrame(frame, archive).createAndShowGUI();	// creo nuovo frame
					}
				});
			}
		});
		manBtn.setToolTipText("Zona riservata ai gestori");
		
			// customer area button
		JButton cusBtn = new JButton(new AbstractAction("Cliente", new ImageIcon(getClass().getResource("/icons/user.gif"))) {
			public void actionPerformed(ActionEvent event) {
				frame.setVisible(false);
				new CustomerAreaFrame(frame, archive).createAndShowGUI();
			}
		});
		cusBtn.setToolTipText("Zona riservata ai clienti");
		
		frame.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
			// imposto margini
		c.insets = new Insets(30,30,30,30);
		
			// prima colonna
		c.gridx = 0;	
		c.anchor = GridBagConstraints.CENTER;	
		addC(manBtn, c, 0);
		addC(cusBtn, c, 1);
	}
}
