/*
 * UserWindow.java
 *
 * Created on 15 de Marco de 2005, 11:35
 */

package siprp.clientes;

import java.awt.BorderLayout;

import javax.swing.JFrame;

import siprp.data.outer.EmpresasData;

import com.evolute.entity.ProviderInterface;
import com.evolute.utils.Singleton;
import com.evolute.utils.ui.CustomJDialog;
/**
 *
 * @author  fpalma
 */
public class UserWindow extends CustomJDialog
{
	protected ProviderInterface JDO;
//	protected JTextField empresaText;
	protected UserPanel userPanel;
	protected Integer empresaID;
	
	/** Creates a new instance of UserWindow */
	public UserWindow( JFrame owner, Integer empresaID )
		throws Exception
	{
		super( owner, true );
		this.empresaID = empresaID;
		JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
		setupComponents();
		centerSuper();
	}
	
	private void setupComponents()
		throws Exception
	{
		setSize( 500, 200 );
		userPanel = new UserPanel();
//		empresaText = new JTextField();
		getContentPane().setLayout( new BorderLayout() );
//		getContentPane().add( empresaText, BorderLayout.NORTH );
		getContentPane().add( userPanel, BorderLayout.CENTER );
		
		if( empresaID == null )
		{
//			empresaText.setText( "SIPRP" );
			setTitle( "SIPRP" );
		}
		else
		{
			EmpresasData empresa = ( EmpresasData )JDO.load( EmpresasData.class, empresaID );
			if( empresa == null )
			{
				return;
			}
//			empresaText.setText( (String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL ) );
			setTitle( (String)empresa.get( EmpresasData.DESIGNACAO_SOCIAL ) );
		}
		userPanel.setEmpresaID( empresaID );
	}
}
