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

package siprp.clientes;

import java.awt.*;
import javax.swing.*;

import com.evolute.utils.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.ui.*;

import siprp.data.*;
/**
 *
 * @author  fpalma
 */
public class UserWindow extends CustomJDialog
{
	protected JDOProvider 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 = ( JDOProvider ) 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
		{
			EmpresaData empresa = ( EmpresaData )JDO.load( EmpresaData.class, empresaID );
			if( empresa == null )
			{
				return;
			}
//			empresaText.setText( (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
			setTitle( (String)empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
		}
		userPanel.setEmpresaID( empresaID );
	}
}
