forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.3 KiB
95 lines
2.3 KiB
package siprp.higiene.gestao;
|
|
|
|
import info.clearthought.layout.TableLayout;
|
|
import info.clearthought.layout.TableLayoutConstraints;
|
|
|
|
import java.awt.event.ItemEvent;
|
|
import java.awt.event.ItemListener;
|
|
import java.util.List;
|
|
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTabbedPane;
|
|
|
|
import siprp.database.cayenne.objects.Empresas;
|
|
import siprp.database.cayenne.providers.MedicinaDAO;
|
|
|
|
public class EmpresaPanel extends JPanel
|
|
{
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private final JComboBox comboEmpresa = new JComboBox();
|
|
|
|
private final GerirEmpresaPanel panelEmpresa = new GerirEmpresaPanel();
|
|
|
|
private final GerirEstabelecimentosPanel panelEstabelecimentos = new GerirEstabelecimentosPanel();
|
|
|
|
private final JTabbedPane tabs = new JTabbedPane();
|
|
|
|
public EmpresaPanel()
|
|
{
|
|
startupListeners();
|
|
startupComponents();
|
|
setupLayout();
|
|
placeComponents();
|
|
|
|
}
|
|
|
|
private void startupComponents()
|
|
{
|
|
List<Empresas> empresas = new MedicinaDAO().getAllEmpresas();
|
|
if( empresas != null )
|
|
{
|
|
for( Empresas empresa : empresas )
|
|
{
|
|
comboEmpresa.addItem( empresa );
|
|
}
|
|
}
|
|
tabs.addTab( "Empresa", panelEmpresa );
|
|
tabs.addTab( "Estabelecimentos", panelEstabelecimentos );
|
|
}
|
|
|
|
private void setupLayout()
|
|
{
|
|
double[] cols = new double[]{
|
|
TableLayout.MINIMUM, TableLayout.FILL,
|
|
};
|
|
double[] rows = new double[]{
|
|
TableLayout.MINIMUM, TableLayout.FILL,
|
|
};
|
|
TableLayout layout = new TableLayout(cols,rows);
|
|
layout.setHGap( 10 );
|
|
layout.setVGap( 10 );
|
|
this.setLayout( layout );
|
|
}
|
|
|
|
private void placeComponents()
|
|
{
|
|
this.add( new JLabel( "Empresa" ), new TableLayoutConstraints(0,0) );
|
|
this.add( comboEmpresa, new TableLayoutConstraints(1,0) );
|
|
this.add( tabs, new TableLayoutConstraints(0,1,1,1) );
|
|
}
|
|
|
|
private void startupListeners()
|
|
{
|
|
comboEmpresa.addItemListener( new ItemListener(){
|
|
@Override
|
|
public void itemStateChanged( ItemEvent e )
|
|
{
|
|
Object item = e.getItem();
|
|
if( item != null && ItemEvent.SELECTED == e.getStateChange() )
|
|
{
|
|
if( item instanceof Empresas )
|
|
{
|
|
panelEmpresa.setEmpresa( (Empresas) item );
|
|
panelEstabelecimentos.setEmpresa( (Empresas) item );
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|