package siprp.higiene.gestao.legislacao;

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

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;

import siprp.database.cayenne.objects.Empresas;

import leaf.ui.LeafButton;

public class AdicionarLegislacaoPanel extends JPanel
{

	private static final long serialVersionUID = 1L;
	
	private final LeafButton buttonAdicionar = new LeafButton("Adicionar");
	
	private final LeafButton buttonRemover = new LeafButton("Remover");
	
	private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
	
	private final DefaultTreeModel model = new DefaultTreeModel( root );
	
	public final JTree tree = new JTree( model );
	
	private final JScrollPane scroll = new JScrollPane( tree );

	public AdicionarLegislacaoPanel()
	{
		startupComponents();
		setupLayout();
		placeComponents();
		startupListeners();
	}
	
	private void startupComponents()
	{
		buttonAdicionar.setEnabled( false );
		buttonRemover.setEnabled( false );
		tree.setRootVisible( false );
		tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
	}
	
	private void setupLayout()
	{
		TableLayout layout = new TableLayout(
				new double[]{ TableLayout.FILL },
				new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
				);
		layout.setHGap( 5 );
		layout.setVGap( 5 );
		setLayout( layout );
	}
	
	private void placeComponents()
	{
		JPanel panel = new JPanel();
		TableLayout layout = new TableLayout(
				new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM },
				new double[]{ TableLayout.MINIMUM }
				);
		layout.setHGap( 5 );
		layout.setVGap( 5 );
		panel.setLayout( layout );
		panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) );
		panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) );
			
		add( panel, new TableLayoutConstraints( 0, 0 ) );
		add( scroll, new TableLayoutConstraints( 0, 1 ) );
	}
	
	private void startupListeners()
	{
		
	}

	public void setEmpresa( Empresas empresa )
	{
		// TODO Auto-generated method stub
		
	}
	
}
