package siprp.higiene.gestao;

import java.awt.Dimension;

import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

import siprp.database.cayenne.objects.Empresas;
import siprp.higiene.gestao.legislacao.AdicionarLegislacaoPanel;
import siprp.higiene.gestao.normalizacao.AdicionarNormalizacaoPanel;
import siprp.higiene.gestao.postos.GerirAreasPanel;
import siprp.higiene.gestao.riscos.AdicionarRiscosPanel;

import static com.evolute.utils.strings.UnicodeLatin1Map.*;

public class GerirEmpresaPanel extends JPanel
{

	private static final long serialVersionUID = 1L;
	
	private final GerirAreasPanel panelAreas = new GerirAreasPanel();
	private final AdicionarRiscosPanel panelRiscos = new AdicionarRiscosPanel();
	private final AdicionarEmailsPanel panelEmails = new AdicionarEmailsPanel();
	private final AdicionarLegislacaoPanel panelLegislacao = new AdicionarLegislacaoPanel();
	private final AdicionarNormalizacaoPanel panelNormalizacao = new AdicionarNormalizacaoPanel();

	public GerirEmpresaPanel()
	{
		startupComponents();
		setupLayout();
		placeComponents();
		startupListeners();
	}
	
	private void startupComponents()
	{
		panelAreas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) );
		panelRiscos.setBorder( BorderFactory.createTitledBorder( "Riscos" ) );
		panelEmails.setBorder( BorderFactory.createTitledBorder( "Emails" ) );
		panelLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + otilde + "es" ) );
		panelNormalizacao.setBorder( BorderFactory.createTitledBorder( "Normaliza" + ccedil + otilde + "es" ) );
		panelEmails.setPreferredSize( new Dimension(0,150) );
	}
	
	private void setupLayout()
	{
		double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, };
		double [] rows = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED };
		TableLayout layout = new TableLayout( cols, rows );
		layout.setHGap( 5 );
		layout.setVGap( 5 );
		this.setLayout( layout );
	}
	
	private void placeComponents()
	{
		this.add( panelAreas, new TableLayoutConstraints( 0, 0, 0, 2 ) );
		this.add( panelRiscos, new TableLayoutConstraints( 1, 0, 1, 2 ) );
		this.add( panelLegislacao, new TableLayoutConstraints( 2, 0  ) );
		this.add( panelNormalizacao, new TableLayoutConstraints( 2, 1  ) );
		this.add( panelEmails, new TableLayoutConstraints( 2, 2 ) );
	}
	
	private void startupListeners()
	{
		
	}

	public void setEmpresa( Empresas empresa )
	{
		panelAreas.setEmpresa( empresa );
		panelEmails.setEmpresa( empresa );
		panelLegislacao.setEmpresa( empresa );
		panelRiscos.setEmpresa( empresa );
		panelNormalizacao.setEmpresa( empresa );
	}
	
}
