/*
 * DetalhesProcessoPanel.java
 *
 * Created on 25 de Abril de 2007, 17:34
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package siprp.medicina.processo.detalhes;

import java.awt.CardLayout;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JPanel;
import siprp.medicina.processo.*;

/**
 *
 * @author Frederico
 */
public class DetalhesProcessoPanel extends JPanel
{
	private final Vector<ProcessoListener> PROCESSO_LISTENERS = new Vector<ProcessoListener>();
	
	private static final String CARD_BLANK = "";
	private static final String CARD_CONSULTA = "CONSULTA";
	private static final String CARD_ECDS = "ECDS";
	
	protected JFrame owner;
	
	protected JPanel blankPanel;
	protected ConsultaPanel consultaPanel;
	protected ECDsPanel ecdsPanel;
	
	protected CardLayout cardLayout;
	
	/**
	 * Creates a new instance of DetalhesProcessoPanel
	 */
	public DetalhesProcessoPanel( JFrame owner )
		throws Exception
	{
		this.owner = owner;
		setupComponents();
	}
	
	private void setupComponents()
		throws Exception
	{
		blankPanel = new JPanel();
		consultaPanel = new ConsultaPanel( owner );
		ecdsPanel = new ECDsPanel( owner );
		
		cardLayout = new CardLayout();
		setLayout( cardLayout );
		add( blankPanel, CARD_BLANK );
		add( consultaPanel, CARD_CONSULTA );
		add( ecdsPanel, CARD_ECDS );
	}
	
	public void addProcessoListener( ProcessoListener listener )
	{
		PROCESSO_LISTENERS.add( listener );
		consultaPanel.addProcessoListener( listener );
		ecdsPanel.addProcessoListener( listener );
	}
	
	public void removeProcessoListener( ProcessoListener listener )
	{
		PROCESSO_LISTENERS.remove( listener );
		consultaPanel.removeProcessoListener( listener );
		ecdsPanel.removeProcessoListener( listener );
	}
	
	public void clear()
	{
		cardLayout.first( this );
	}
	
	public void setTrabalhadorID( Integer trabalhadorID )
	{
		consultaPanel.setTrabalhadorID( trabalhadorID );
	}
	
	public void setProcessoID( Integer processoID )
	{
		consultaPanel.setProcessoID( processoID );
	}
	
	public void setConsulta( Integer consultaID )
	{
		cardLayout.show( this, CARD_CONSULTA );
		consultaPanel.fill( consultaID );
	}
	
	public void setECDs( Integer ecdsID )
	{
		cardLayout.show( this, CARD_ECDS );
	}
}
