|
|
|
|
@ -12,29 +12,39 @@ import java.util.*;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.data.*;
|
|
|
|
|
import com.evolute.utils.dataui.*;
|
|
|
|
|
import com.evolute.utils.metadb.*;
|
|
|
|
|
import com.evolute.utils.ui.button.*;
|
|
|
|
|
import com.evolute.utils.ui.panel.*;
|
|
|
|
|
|
|
|
|
|
import siprp.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author fpalma
|
|
|
|
|
*/
|
|
|
|
|
public class EmpresaPanel extends JPanel
|
|
|
|
|
implements FillerSaverWrapper
|
|
|
|
|
implements ControllableComponent
|
|
|
|
|
{
|
|
|
|
|
private JTextField designacaoSocialText;
|
|
|
|
|
private JTextField estabelecimentoText;
|
|
|
|
|
private JTextField localidadeText;
|
|
|
|
|
// private RadioButtonGroup servicoSaudeTipoGroup;
|
|
|
|
|
// private RadioButtonGroup servicoHigieneTipoGroup;
|
|
|
|
|
private RadioButtonFixedPanel servicoSaudeTipoPanel;
|
|
|
|
|
private RadioButtonFixedPanel servicoHigieneTipoPanel;
|
|
|
|
|
private JTextField designacaoText;
|
|
|
|
|
|
|
|
|
|
private FichaDataProvider provider;
|
|
|
|
|
private ComponentsHashtable components;
|
|
|
|
|
|
|
|
|
|
private MetaObject estabelecimento;
|
|
|
|
|
private MetaObject empresa;
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of EmpresaPanel */
|
|
|
|
|
public EmpresaPanel()
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
provider = (FichaDataProvider)FichaDataProvider.getProvider();
|
|
|
|
|
setupComponents();
|
|
|
|
|
setupComponentsHashtable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupComponents()
|
|
|
|
|
@ -51,15 +61,6 @@ public class EmpresaPanel extends JPanel
|
|
|
|
|
JLabel localidadeLabel = new JLabel( "Localidade" );
|
|
|
|
|
localidadeText = new JTextField();
|
|
|
|
|
JLabel servicoSaudeLabel = new JLabel( "Servi\u00e7o de Sa\u00fade: Tipo" );
|
|
|
|
|
// JRadioButton saudeInterno = new JRadioButton( "Interno" );
|
|
|
|
|
// JRadioButton saudeInterempresas = new JRadioButton( "Interempresas" );
|
|
|
|
|
// JRadioButton saudeExterno = new JRadioButton( "Externo" );
|
|
|
|
|
// JRadioButton saudeSNS = new JRadioButton( "Servi\u00e7o Nacional de Sa\u00fade" );
|
|
|
|
|
// servicoSaudeTipoGroup =
|
|
|
|
|
// new RadioButtonGroup( servicoSaudePanel,
|
|
|
|
|
// new Vector( Arrays.asList( new Object[]{
|
|
|
|
|
// "Interno", "Interempresas",
|
|
|
|
|
// "Externo", "Servi\u00e7o Nacional de Sa\u00fade" } ) ), false );
|
|
|
|
|
servicoSaudeTipoPanel =
|
|
|
|
|
new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer(1), "Interno" ),
|
|
|
|
|
new MappableObject( new Integer(2), "Interempresas" ),
|
|
|
|
|
@ -115,14 +116,6 @@ public class EmpresaPanel extends JPanel
|
|
|
|
|
gridbag.setConstraints( localidadeText, constraints );
|
|
|
|
|
add( localidadeText );
|
|
|
|
|
|
|
|
|
|
// constraints.weightx = 1;
|
|
|
|
|
// constraints.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
|
|
// JPanel servicoSaudeOuterPanel = new JPanel();
|
|
|
|
|
// servicoSaudeOuterPanel.setLayout( new BorderLayout( 0, 0 ) );
|
|
|
|
|
// servicoSaudeOuterPanel.add( servicoSaudeLabel, BorderLayout.WEST );
|
|
|
|
|
// servicoSaudeOuterPanel.add( servicoSaudeTipoPanel, BorderLayout.CENTER );
|
|
|
|
|
// gridbag.setConstraints( servicoSaudeOuterPanel, constraints );
|
|
|
|
|
// add( servicoSaudeOuterPanel );
|
|
|
|
|
constraints.weightx = 0;
|
|
|
|
|
constraints.gridwidth = 2;
|
|
|
|
|
gridbag.setConstraints( servicoSaudeLabel, constraints );
|
|
|
|
|
@ -133,15 +126,6 @@ public class EmpresaPanel extends JPanel
|
|
|
|
|
gridbag.setConstraints( servicoSaudeTipoPanel, constraints );
|
|
|
|
|
add( servicoSaudeTipoPanel );
|
|
|
|
|
|
|
|
|
|
// constraints.weightx = 1;
|
|
|
|
|
// constraints.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
|
|
// JPanel servicoHigieneOuterPanel = new JPanel();
|
|
|
|
|
// servicoHigieneOuterPanel.setLayout( new BorderLayout( 0, 0 ) );
|
|
|
|
|
// servicoHigieneOuterPanel.add( servicoHigieneLabel, BorderLayout.WEST );
|
|
|
|
|
// servicoHigieneOuterPanel.add( servicoHigieneTipoPanel, BorderLayout.CENTER );
|
|
|
|
|
// gridbag.setConstraints( servicoHigieneOuterPanel, constraints );
|
|
|
|
|
// add( servicoHigieneOuterPanel );
|
|
|
|
|
|
|
|
|
|
constraints.weightx = 0;
|
|
|
|
|
constraints.gridwidth = 3;
|
|
|
|
|
gridbag.setConstraints( servicoHigieneLabel, constraints );
|
|
|
|
|
@ -165,12 +149,88 @@ public class EmpresaPanel extends JPanel
|
|
|
|
|
add( designacaoText );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupComponentsHashtable()
|
|
|
|
|
{
|
|
|
|
|
components = new ComponentsHashtable();
|
|
|
|
|
components.putComponent( provider.T_EMPRESAS + "." + provider.DESIGNACAO_SOCIAL, designacaoSocialText );
|
|
|
|
|
components.put( provider.T_EMPRESAS + "." + provider.SERVICO_SAUDE_TIPO, servicoSaudeTipoPanel );
|
|
|
|
|
components.putDummy( provider.T_EMPRESAS + "." + provider.SERVICO_SAUDE_DESIGNACAO );
|
|
|
|
|
components.put( provider.T_EMPRESAS + "." + provider.SERVICO_HIGIENE_TIPO, servicoHigieneTipoPanel );
|
|
|
|
|
components.putComponent( provider.T_EMPRESAS + "." + provider.SERVICO_HIGIENE_DESIGNACAO, designacaoText );
|
|
|
|
|
|
|
|
|
|
components.putComponent( provider.T_ESTABELECIMENTOS + "." + provider.NOME, estabelecimentoText );
|
|
|
|
|
components.putComponent( provider.T_ESTABELECIMENTOS + "." + provider.LOCALIDADE, localidadeText );
|
|
|
|
|
|
|
|
|
|
components.putDummy( provider.T_EMPRESAS + "." + provider.INACTIVO );
|
|
|
|
|
components.putDummy( provider.T_ESTABELECIMENTOS + "." + provider.EMPRESA_ID );
|
|
|
|
|
components.putDummy( provider.T_ESTABELECIMENTOS + "." + provider.INACTIVO );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void fill(Object value)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object save()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if( estabelecimento == null )
|
|
|
|
|
{
|
|
|
|
|
estabelecimento = provider.createObject( provider.ESTABELECIMENTOS );
|
|
|
|
|
}
|
|
|
|
|
if( empresa == null )
|
|
|
|
|
{
|
|
|
|
|
empresa = provider.createObject( provider.EMPRESAS );
|
|
|
|
|
}
|
|
|
|
|
DBField fields[] = provider.EMPRESAS.getInsertFields();
|
|
|
|
|
String empresaFields[] = new String[ fields.length ];
|
|
|
|
|
for( int i = 0; i < empresaFields.length; ++i )
|
|
|
|
|
{
|
|
|
|
|
empresaFields[ i ] = fields[ i ].FULL_NAME;
|
|
|
|
|
}
|
|
|
|
|
Hashtable hash = new Hashtable();
|
|
|
|
|
ComponentController.save( empresaFields, hash, components );
|
|
|
|
|
Enumeration enum = hash.keys();
|
|
|
|
|
while( enum.hasMoreElements() )
|
|
|
|
|
{
|
|
|
|
|
String name = ( String )enum.nextElement();
|
|
|
|
|
empresa.setProperty( name, hash.get( name ) );
|
|
|
|
|
}
|
|
|
|
|
fields = provider.ESTABELECIMENTOS.getInsertFields();
|
|
|
|
|
String estabelecimentoFields[] = new String[ fields.length ];
|
|
|
|
|
for( int i = 0; i < estabelecimentoFields.length; ++i )
|
|
|
|
|
{
|
|
|
|
|
estabelecimentoFields[ i ] = fields[ i ].FULL_NAME;
|
|
|
|
|
}
|
|
|
|
|
hash = new Hashtable();
|
|
|
|
|
ComponentController.save( estabelecimentoFields, hash, components );
|
|
|
|
|
enum = hash.keys();
|
|
|
|
|
while( enum.hasMoreElements() )
|
|
|
|
|
{
|
|
|
|
|
String name = ( String )enum.nextElement();
|
|
|
|
|
estabelecimento.setProperty( name, hash.get( name ) );
|
|
|
|
|
}
|
|
|
|
|
estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa );
|
|
|
|
|
empresa.save();
|
|
|
|
|
estabelecimento.save();
|
|
|
|
|
return empresa.getPrimaryKeyValue();
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clear()
|
|
|
|
|
{
|
|
|
|
|
String names[] = (String[])components.keySet().toArray( new String[0] );
|
|
|
|
|
ComponentController.clear( names, components );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setEnabled( boolean enable )
|
|
|
|
|
{
|
|
|
|
|
String names[] = (String[])components.keySet().toArray( new String[0] );
|
|
|
|
|
ComponentController.setEnabled( names, enable, components );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|