forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1427 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
9f5822c1a3
commit
aba7c5fd97
Binary file not shown.
Binary file not shown.
@ -1,238 +0,0 @@
|
||||
/*
|
||||
* PrestadoresDataProvider.java
|
||||
*
|
||||
* Created on February 2, 2007, 9:53 AM
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.prestadores;
|
||||
|
||||
import siprp.data.outer.ContactosData;
|
||||
import siprp.data.outer.PrestadoresData;
|
||||
|
||||
import com.evolute.entity.ProviderInterface;
|
||||
import com.evolute.utils.Singleton;
|
||||
import com.evolute.utils.arrays.Object2DArray;
|
||||
import com.evolute.utils.arrays.Virtual2DArray;
|
||||
import com.evolute.utils.data.IDObject;
|
||||
import com.evolute.utils.data.MappableObject;
|
||||
import com.evolute.utils.db.DBManager;
|
||||
import com.evolute.utils.db.Executer;
|
||||
import com.evolute.utils.sql.Assignment;
|
||||
import com.evolute.utils.sql.Begin;
|
||||
import com.evolute.utils.sql.Commit;
|
||||
import com.evolute.utils.sql.Delete;
|
||||
import com.evolute.utils.sql.Field;
|
||||
import com.evolute.utils.sql.Insert;
|
||||
import com.evolute.utils.sql.Rollback;
|
||||
import com.evolute.utils.sql.Select;
|
||||
import com.evolute.utils.ui.search.SearchDialog;
|
||||
import com.evolute.utils.ui.search.SearchExecuter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fpalma
|
||||
*/
|
||||
public class PrestadoresDataProvider
|
||||
implements SearchExecuter
|
||||
{
|
||||
private static final Object LOCK = new Object();
|
||||
private static PrestadoresDataProvider instance = null;
|
||||
|
||||
private static final String SEARCH_TITLE = "Procurar prestadores";
|
||||
private static final String SEARCH_COLUMNS[] =
|
||||
new String[]{ "Designa\u00e7\u00e3o", "Servi\u00e7os" };
|
||||
|
||||
private Executer EXECUTER;
|
||||
|
||||
private ProviderInterface JDO;
|
||||
|
||||
/** Creates a new instance of PrestadoresDataProvider */
|
||||
public PrestadoresDataProvider()
|
||||
throws Exception
|
||||
{
|
||||
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
||||
EXECUTER = dbm.getSharedExecuter( this );
|
||||
JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
|
||||
}
|
||||
|
||||
public static PrestadoresDataProvider getProvider()
|
||||
throws Exception
|
||||
{
|
||||
synchronized( LOCK )
|
||||
{
|
||||
if( instance == null )
|
||||
{
|
||||
instance = new PrestadoresDataProvider();
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean hasDetails()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getSearchTitle()
|
||||
{
|
||||
return SEARCH_TITLE;
|
||||
}
|
||||
|
||||
public String[] getColumnNames()
|
||||
{
|
||||
return SEARCH_COLUMNS;
|
||||
}
|
||||
|
||||
public void showDetails(SearchDialog dialog, Object o) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public Virtual2DArray search(String pattern) throws Exception
|
||||
{
|
||||
pattern = pattern.trim().toLowerCase();
|
||||
pattern = pattern.replace( ' ', '%' );
|
||||
Select select =
|
||||
new Select( new String[]{ "prestadores" },
|
||||
new String[]{ "id", "nome", "faz_consultas", "faz_ecds", "nome_plain" },
|
||||
new Field( "nome_plain" ).isLike( "%" + pattern + "%" ),
|
||||
new String[]{ "nome_plain" },
|
||||
null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
Object data[][] = new Object[ array.columnLength() ][ 3 ];
|
||||
for( int n = 0; n < data.length; n++ )
|
||||
{
|
||||
data[ n ][ 0 ] = array.get( n, 0 );
|
||||
data[ n ][ 1 ] = array.get( n, 1 );
|
||||
String str = "";
|
||||
if( "y".equals( array.get( n, 2 ) ) )
|
||||
{
|
||||
str += "consultas";
|
||||
}
|
||||
if( "y".equals( array.get( n, 3 ) ) )
|
||||
{
|
||||
str += ( str.length() > 0 ? ", " : "" ) + "ecds";
|
||||
}
|
||||
data[ n ][ 2 ] = str;
|
||||
}
|
||||
return new Object2DArray( data );
|
||||
}
|
||||
|
||||
public void setGruposProtocoloForPrestador( Integer prestadorID, Integer gruposProtocoloID[] )
|
||||
throws Exception
|
||||
{
|
||||
EXECUTER.executeQuery( Begin.BEGIN );
|
||||
try
|
||||
{
|
||||
Delete delete = new Delete( "prestadores_grupos_protocolo",
|
||||
new Field( "prestador_id" ).isEqual( prestadorID ) );
|
||||
EXECUTER.executeQuery( delete );
|
||||
Insert insert =
|
||||
new Insert( "prestadores_grupos_protocolo",
|
||||
new Assignment[]{
|
||||
new Assignment( new Field( "prestador_id" ), prestadorID ),
|
||||
new Assignment( new Field( "grupo_protocolo_id" ), gruposProtocoloID ) } );
|
||||
EXECUTER.executeQuery( insert );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
EXECUTER.executeQuery( Rollback.ROLLBACK );
|
||||
}
|
||||
EXECUTER.executeQuery( Commit.COMMIT );
|
||||
}
|
||||
|
||||
public Integer []getGruposProtocoloIDByPrestadorID( Integer prestadorID )
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select( new String[]{ "prestadores_grupos_protocolo" },
|
||||
new String[]{ "grupo_protocolo_id" },
|
||||
new Field( "prestador_id" ).isEqual( prestadorID ) );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
Integer ids[] = new Integer[ array.columnLength() ];
|
||||
for( int n = 0; n < ids.length; n++ )
|
||||
{
|
||||
ids[ n ] = ( Integer ) array.get( n, 0 );
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public PrestadoresData getPrestadorByID( Integer id )
|
||||
throws Exception
|
||||
{
|
||||
return ( PrestadoresData ) JDO.load( PrestadoresData.class, id );
|
||||
}
|
||||
|
||||
public void savePrestador( PrestadoresData prestador )
|
||||
throws Exception
|
||||
{
|
||||
if( prestador.get( PrestadoresData.CONTACTO_ID ) instanceof ContactosData )
|
||||
{
|
||||
ContactosData contacto = ( ContactosData )prestador.get( PrestadoresData.CONTACTO_ID );
|
||||
contacto.save();
|
||||
prestador.set( PrestadoresData.CONTACTO_ID, contacto.get( ContactosData.ID ) );
|
||||
}
|
||||
prestador.save();
|
||||
}
|
||||
|
||||
public IDObject[] getPrestadoresActivos()
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select( new String[]{ "prestadores" },
|
||||
new String[]{ "id", "nome", "nome_plain" },
|
||||
new Field( "activo" ).isEqual( "y" ),
|
||||
new String[]{ "nome_plain" }, null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
IDObject prestadores[] = new IDObject[ array.columnLength() ];
|
||||
for( int n = 0; n < prestadores.length; n++ )
|
||||
{
|
||||
Integer id = ( Integer ) array.get( n, 0 );
|
||||
String nome = ( String ) array.get( n, 1 );
|
||||
prestadores[ n ] = new MappableObject( id, nome );
|
||||
}
|
||||
return prestadores;
|
||||
}
|
||||
|
||||
public IDObject[] getPrestadoresConsultasActivos()
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select( new String[]{ "prestadores" },
|
||||
new String[]{ "id", "nome", "nome_plain" },
|
||||
new Field( "activo" ).isEqual( "y" ).and(
|
||||
new Field( "faz_consultas" ).isEqual( "y" ) ),
|
||||
new String[]{ "nome_plain" }, null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
IDObject prestadores[] = new IDObject[ array.columnLength() ];
|
||||
for( int n = 0; n < prestadores.length; n++ )
|
||||
{
|
||||
Integer id = ( Integer ) array.get( n, 0 );
|
||||
String nome = ( String ) array.get( n, 1 );
|
||||
prestadores[ n ] = new MappableObject( id, nome );
|
||||
}
|
||||
return prestadores;
|
||||
}
|
||||
|
||||
public IDObject[] getPrestadoresECDsActivos()
|
||||
throws Exception
|
||||
{
|
||||
Select select =
|
||||
new Select( new String[]{ "prestadores" },
|
||||
new String[]{ "id", "nome", "nome_plain" },
|
||||
new Field( "activo" ).isEqual( "y" ).and(
|
||||
new Field( "faz_ecds" ).isEqual( "y" ) ),
|
||||
new String[]{ "nome_plain" }, null );
|
||||
Virtual2DArray array = EXECUTER.executeQuery( select );
|
||||
IDObject prestadores[] = new IDObject[ array.columnLength() ];
|
||||
for( int n = 0; n < prestadores.length; n++ )
|
||||
{
|
||||
Integer id = ( Integer ) array.get( n, 0 );
|
||||
String nome = ( String ) array.get( n, 1 );
|
||||
prestadores[ n ] = new MappableObject( id, nome );
|
||||
}
|
||||
return prestadores;
|
||||
}
|
||||
}
|
||||
@ -1,446 +0,0 @@
|
||||
/*
|
||||
* PrestadoresWindow.java
|
||||
*
|
||||
* Created on February 2, 2007, 9:44 AM
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package siprp.medicina.prestadores;
|
||||
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
|
||||
import info.clearthought.layout.TableLayout;
|
||||
import info.clearthought.layout.TableLayoutConstraints;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import leaf.ui.LeafDialog;
|
||||
import siprp.clientes.ClientesDataProvider;
|
||||
import siprp.clientes.ContactoPanel;
|
||||
import siprp.data.outer.PrestadoresData;
|
||||
import siprp.data.outer.PrtGruposProtocoloData;
|
||||
import siprp.data.provider.MedicinaDataProvider;
|
||||
import siprp.ui.SIPRPEditorWindow;
|
||||
|
||||
import com.evolute.utils.data.IDObject;
|
||||
import com.evolute.utils.dataui.ComponentController;
|
||||
import com.evolute.utils.dataui.ComponentsHashtable;
|
||||
import com.evolute.utils.dataui.wrappers.JTextComponentPlainFillerSaver;
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
import com.evolute.utils.ui.DialogException;
|
||||
import com.evolute.utils.ui.panel.CheckBoxPanel;
|
||||
import com.evolute.utils.ui.search.SearchDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fpalma
|
||||
*/
|
||||
public class PrestadoresWindow extends SIPRPEditorWindow
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String TITLE = "Prestadores";
|
||||
|
||||
protected JTextField nomeText;
|
||||
protected JCheckBox activoCheck;
|
||||
protected JCheckBox consultasCheck;
|
||||
protected JCheckBox ecdsCheck;
|
||||
protected CheckBoxPanel ecdsPanel;
|
||||
protected JTextArea moradaText;
|
||||
protected JTextField codigoPostalText;
|
||||
protected JTextField localidadeCodigoPostalText;
|
||||
protected JTextField localidadeText;
|
||||
protected ContactoPanel contactoPanel;
|
||||
protected JTextField contribuinteText;
|
||||
|
||||
private final JLabel labelObservacoes = new JLabel( "Observa" + ccedil + otilde + "es" );
|
||||
private final JTextArea textObservacoes = new JTextArea();
|
||||
|
||||
protected PrestadoresDataProvider provider;
|
||||
protected ClientesDataProvider clientesProvider;
|
||||
|
||||
protected ComponentsHashtable components;
|
||||
|
||||
protected PrestadoresData prestador;
|
||||
protected Integer gruposProtocolo[];
|
||||
|
||||
private final JTabbedPane tabbedPane = new JTabbedPane();
|
||||
private final JPanel prestadoresPanel = new JPanel();
|
||||
private final JPanel analisadoresPanel = new JPanel();
|
||||
|
||||
private final JLabel labelGrupos = new JLabel( "Tipos de ECDs" );
|
||||
private final JLabel labelAnalisador = new JLabel( "Analisadores" );
|
||||
private final JLabel labelMessage = new JLabel( " " );
|
||||
|
||||
private final Map<PrtGruposProtocoloData, JLabel> mapLabel = new HashMap<PrtGruposProtocoloData, JLabel>();
|
||||
private final Map<PrtGruposProtocoloData, JComboBox> mapComboBox = new HashMap<PrtGruposProtocoloData, JComboBox>();
|
||||
|
||||
private final List<PrestadoresData> listAnalisadores = new ArrayList<PrestadoresData>();
|
||||
private final List<PrtGruposProtocoloData> listGrupos = new ArrayList<PrtGruposProtocoloData>();
|
||||
|
||||
private final MedicinaDataProvider medicinaCayenneDAO;
|
||||
|
||||
/** Creates a new instance of PrestadoresWindow */
|
||||
public PrestadoresWindow() throws Exception
|
||||
{
|
||||
super( new int[][] {
|
||||
{
|
||||
NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX, SELECT_BYNAME_INDEX
|
||||
}
|
||||
} );
|
||||
provider = PrestadoresDataProvider.getProvider();
|
||||
clientesProvider = (ClientesDataProvider) ClientesDataProvider.getProvider();
|
||||
medicinaCayenneDAO = MedicinaDataProvider.getProvider();
|
||||
setupComponents();
|
||||
setupComponentsHashtable();
|
||||
}
|
||||
|
||||
private void setupComponents()
|
||||
{
|
||||
setTitle( TITLE );
|
||||
setSize( 800, 600 );
|
||||
tabbedPane.addTab( "Prestadores", prestadoresPanel );
|
||||
tabbedPane.addTab( "Analisadores", analisadoresPanel );
|
||||
|
||||
setupAnalisadoresTab();
|
||||
setupPrestadoresTab();
|
||||
// pack();
|
||||
}
|
||||
|
||||
private void setupPrestadoresTab()
|
||||
{
|
||||
try
|
||||
{
|
||||
JLabel nomeLabel = new JLabel( "Designa\u00e7\u00e3o" );
|
||||
nomeText = new JTextField();
|
||||
nomeText.setPreferredSize( new Dimension( 500, 20 ) );
|
||||
activoCheck = new JCheckBox( "Activo (actualmente fornece servi\u00e7os \u00e0 SIPRP)" );
|
||||
consultasCheck = new JCheckBox( "Faz consultas" );
|
||||
ecdsCheck = new JCheckBox( "Faz ecds" );
|
||||
List<IDObject> gruposProtocolo = new Vector<IDObject>();
|
||||
IDObject gruposProtocoloReais[] = clientesProvider.getAllGruposProtocoloReais();
|
||||
if( gruposProtocoloReais != null && gruposProtocoloReais.length > 0 )
|
||||
{
|
||||
gruposProtocolo.addAll( Arrays.asList( gruposProtocoloReais ) );
|
||||
}
|
||||
IDObject gruposProtocoloFalsos[] = clientesProvider.getAllGruposProtocoloFalsos();
|
||||
if( gruposProtocoloFalsos != null && gruposProtocoloFalsos.length > 0 )
|
||||
{
|
||||
gruposProtocolo.addAll( Arrays.asList( gruposProtocoloFalsos ) );
|
||||
}
|
||||
ecdsPanel = new CheckBoxPanel( gruposProtocolo.toArray( new IDObject[gruposProtocolo.size()] ) );
|
||||
JLabel contactoLabel = new JLabel( "Contacto" );
|
||||
contactoPanel = new ContactoPanel();
|
||||
contactoPanel.setPreferredSize( new Dimension( 350, 120 ) );
|
||||
contactoPanel.setBorder( BorderFactory.createEtchedBorder() );
|
||||
JLabel moradaLabel = new JLabel( "Morada" );
|
||||
moradaText = new JTextArea();
|
||||
moradaText.setLineWrap( true );
|
||||
moradaText.setWrapStyleWord( true );
|
||||
JScrollPane moradaScroll = new JScrollPane( moradaText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
moradaScroll.setPreferredSize( new Dimension( 500, 50 ) );
|
||||
JLabel codigoPostalLabel = new JLabel( "C\u00f3digo Postal" );
|
||||
codigoPostalText = new JTextField();
|
||||
codigoPostalText.setPreferredSize( new Dimension( 100, 50 ) );
|
||||
localidadeCodigoPostalText = new JTextField();
|
||||
localidadeCodigoPostalText.setPreferredSize( new Dimension( 150, 50 ) );
|
||||
JLabel localidadeLabel = new JLabel( "Localidade" );
|
||||
localidadeText = new JTextField();
|
||||
JLabel contribuinteLabel = new JLabel( "Contribuinte" );
|
||||
contribuinteText = new JTextField();
|
||||
contribuinteText.setPreferredSize( new Dimension( 100, 50 ) );
|
||||
|
||||
double cols[] = new double[] {
|
||||
TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL
|
||||
};
|
||||
double rows[] = new double[] {
|
||||
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL
|
||||
};
|
||||
TableLayout tableLayout = new TableLayout( cols, rows );
|
||||
prestadoresPanel.setLayout( tableLayout );
|
||||
|
||||
tableLayout = new TableLayout( new double[] {
|
||||
TableLayout.FILL
|
||||
}, new double[] {
|
||||
TableLayout.FILL
|
||||
} );
|
||||
getContentPane().setLayout( tableLayout );
|
||||
getContentPane().add( tabbedPane, new TableLayoutConstraints( 0, 0 ) );
|
||||
|
||||
prestadoresPanel.add( nomeLabel, new TableLayoutConstraints( 0, 0 ) );
|
||||
prestadoresPanel.add( nomeText, new TableLayoutConstraints( 1, 0, 3, 0 ) );
|
||||
prestadoresPanel.add( activoCheck, new TableLayoutConstraints( 0, 1, 2, 1 ) );
|
||||
prestadoresPanel.add( consultasCheck, new TableLayoutConstraints( 0, 2 ) );
|
||||
prestadoresPanel.add( ecdsCheck, new TableLayoutConstraints( 0, 3 ) );
|
||||
prestadoresPanel.add( ecdsPanel, new TableLayoutConstraints( 1, 3, 2, 3 ) );
|
||||
prestadoresPanel.add( contactoLabel, new TableLayoutConstraints( 0, 4 ) );
|
||||
prestadoresPanel.add( contactoPanel, new TableLayoutConstraints( 1, 4, 2, 4 ) );
|
||||
prestadoresPanel.add( moradaLabel, new TableLayoutConstraints( 0, 5 ) );
|
||||
prestadoresPanel.add( moradaScroll, new TableLayoutConstraints( 1, 5, 3, 5 ) );
|
||||
prestadoresPanel.add( codigoPostalLabel, new TableLayoutConstraints( 0, 6 ) );
|
||||
prestadoresPanel.add( codigoPostalText, new TableLayoutConstraints( 1, 6 ) );
|
||||
prestadoresPanel.add( localidadeCodigoPostalText, new TableLayoutConstraints( 2, 6, 3, 6 ) );
|
||||
prestadoresPanel.add( localidadeLabel, new TableLayoutConstraints( 0, 7 ) );
|
||||
prestadoresPanel.add( localidadeText, new TableLayoutConstraints( 1, 7, 3, 7 ) );
|
||||
prestadoresPanel.add( contribuinteLabel, new TableLayoutConstraints( 0, 8 ) );
|
||||
prestadoresPanel.add( contribuinteText, new TableLayoutConstraints( 1, 8 ) );
|
||||
prestadoresPanel.add( labelObservacoes, new TableLayoutConstraints( 0, 9 ) );
|
||||
prestadoresPanel.add( textObservacoes, new TableLayoutConstraints( 0, 10, 3, 10 ) );
|
||||
} catch( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupComponentsHashtable()
|
||||
{
|
||||
components = new ComponentsHashtable();
|
||||
components.putComponent( PrestadoresData.NOME, nomeText );
|
||||
components.putComponent( PrestadoresData.NOME_PLAIN, new JTextComponentPlainFillerSaver( nomeText ) );
|
||||
components.putComponent( PrestadoresData.MORADA, moradaText );
|
||||
components.putComponent( PrestadoresData.CODIGO_POSTAL, codigoPostalText );
|
||||
components.putComponent( PrestadoresData.LOCALIDADE_CP, localidadeCodigoPostalText );
|
||||
components.putComponent( PrestadoresData.LOCALIDADE, localidadeText );
|
||||
components.putComponent( PrestadoresData.CONTRIBUINTE, contribuinteText );
|
||||
components.putComponent( PrestadoresData.OBSERVACOES, textObservacoes );
|
||||
components.putComponent( PrestadoresData.ACTIVO, activoCheck );
|
||||
components.putComponent( PrestadoresData.FAZ_CONSULTAS, consultasCheck );
|
||||
components.putComponent( PrestadoresData.FAZ_ECDS, ecdsCheck );
|
||||
|
||||
components.putComponent( PrestadoresData.TO_CONTACTO_ID, contactoPanel );
|
||||
|
||||
// components.putComponent( PrestadoresData.CONTACTO_ID,
|
||||
// new JDOControllable( (ProviderInterface) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER ), ContactosData.class, new String[] {
|
||||
// ContactosData.ID
|
||||
// }, contactoPanel ) );
|
||||
|
||||
}
|
||||
|
||||
public boolean searchByName()
|
||||
{
|
||||
SearchDialog search = new SearchDialog( provider );
|
||||
Integer id = (Integer) search.getSelected();
|
||||
if( id == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
clear( 0 );
|
||||
try
|
||||
{
|
||||
prestador = provider.getPrestadorByID( id );
|
||||
gruposProtocolo = provider.getGruposProtocoloIDByPrestadorID( id );
|
||||
reload( 0 );
|
||||
} catch( Exception ex )
|
||||
{
|
||||
DialogException.showExceptionMessage( ex, "Ocorreu um erro a carregar o prestador.", true );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void enableComponents( int index, boolean enable )
|
||||
{
|
||||
String names[] = (String[]) components.keySet().toArray( new String[0] );
|
||||
ComponentController.setEnabled( names, enable, components );
|
||||
ecdsPanel.setEnabled( enable );
|
||||
}
|
||||
|
||||
public void reload( int index )
|
||||
{
|
||||
try
|
||||
{
|
||||
String names[] = (String[]) components.keySet().toArray( new String[0] );
|
||||
ComponentController.fill( names, prestador.getHashData(), components );
|
||||
ecdsPanel.setSelected( gruposProtocolo );
|
||||
} catch( Exception ex )
|
||||
{
|
||||
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void clear( int index )
|
||||
{
|
||||
String names[] = (String[]) components.keySet().toArray( new String[0] );
|
||||
ComponentController.clear( names, components );
|
||||
ecdsPanel.clear();
|
||||
prestador = null;
|
||||
gruposProtocolo = null;
|
||||
}
|
||||
|
||||
public boolean newItem( int index )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean save( int index )
|
||||
{
|
||||
if( prestador == null )
|
||||
{
|
||||
prestador = new PrestadoresData();
|
||||
}
|
||||
String names[] = (String[]) components.keySet().toArray( new String[0] );
|
||||
Map<String,Object> data = prestador.getHashData();
|
||||
ComponentController.save( names, data, components );
|
||||
prestador.setHashData( data );
|
||||
|
||||
gruposProtocolo = ecdsPanel.getSelected();
|
||||
try
|
||||
{
|
||||
provider.savePrestador( prestador );
|
||||
provider.setGruposProtocoloForPrestador( (Integer) prestador.get( PrestadoresData.ID ), gruposProtocolo );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
ErrorLogger.logExceptionAndShow( ex );
|
||||
// DialogException.showExceptionMessage( ex, "Erro a guardar dados", true );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setupAnalisadoresTab()
|
||||
{
|
||||
loadAnalisadoresTabData();
|
||||
setupAnalisadoresTabLayout();
|
||||
setupAnalisadoresTabComponents();
|
||||
placeAnalisadoresTabComponents();
|
||||
setupAnalisadoresTabListeners();
|
||||
}
|
||||
|
||||
private void loadAnalisadoresTabData()
|
||||
{
|
||||
clearAnalisadoresTabData();
|
||||
listGrupos.addAll( medicinaCayenneDAO.getAllPrtGruposProtocolo() );
|
||||
listAnalisadores.addAll( medicinaCayenneDAO.getAllPrestadores() );
|
||||
}
|
||||
|
||||
private void clearAnalisadoresTabData()
|
||||
{
|
||||
mapComboBox.clear();
|
||||
mapLabel.clear();
|
||||
listGrupos.clear();
|
||||
listAnalisadores.clear();
|
||||
shout( null );
|
||||
}
|
||||
|
||||
private void setupAnalisadoresTabLayout()
|
||||
{
|
||||
double[] cols = new double[] {
|
||||
TableLayout.MINIMUM, TableLayout.FILL
|
||||
};
|
||||
double[] rows = new double[1 + listGrupos.size() + 2];
|
||||
for( int i = 0; i < rows.length; ++i )
|
||||
{
|
||||
rows[i] = TableLayout.MINIMUM;
|
||||
}
|
||||
TableLayout layout = new TableLayout( cols, rows );
|
||||
layout.setHGap( 5 );
|
||||
layout.setVGap( 5 );
|
||||
analisadoresPanel.setLayout( layout );
|
||||
}
|
||||
|
||||
private void setupAnalisadoresTabComponents()
|
||||
{
|
||||
Object[] analisadores = listAnalisadores.toArray();
|
||||
for( PrtGruposProtocoloData grupo : listGrupos )
|
||||
{
|
||||
JLabel label = new JLabel( grupo.getDescricao() );
|
||||
mapLabel.put( grupo, label );
|
||||
JComboBox combo = new JComboBox( analisadores );
|
||||
PrestadoresData analisador = grupo.toAnalisador_id();
|
||||
combo.setSelectedItem( analisador == null ? PrestadoresData.prestadorNulo : analisador );
|
||||
mapComboBox.put( grupo, combo );
|
||||
}
|
||||
labelMessage.setForeground( Color.RED.darker().darker() );
|
||||
}
|
||||
|
||||
private void placeAnalisadoresTabComponents()
|
||||
{
|
||||
analisadoresPanel.add( labelGrupos, new TableLayoutConstraints( 0, 0 ) );
|
||||
analisadoresPanel.add( labelAnalisador, new TableLayoutConstraints( 1, 0 ) );
|
||||
for( int i = 0; i < listGrupos.size(); ++i )
|
||||
{
|
||||
PrtGruposProtocoloData grupo = listGrupos.get( i );
|
||||
JLabel label = mapLabel.get( grupo );
|
||||
analisadoresPanel.add( label, new TableLayoutConstraints( 0, i + 1 ) );
|
||||
JComboBox combo = mapComboBox.get( grupo );
|
||||
analisadoresPanel.add( combo, new TableLayoutConstraints( 1, i + 1 ) );
|
||||
}
|
||||
int line = listGrupos.size() + 1;
|
||||
analisadoresPanel.add( new JSeparator(), new TableLayoutConstraints( 0, line, 1, line ) );
|
||||
++line;
|
||||
analisadoresPanel.add( labelMessage, new TableLayoutConstraints( 0, line, 1, line ) );
|
||||
}
|
||||
|
||||
private void setupAnalisadoresTabListeners()
|
||||
{
|
||||
for( PrtGruposProtocoloData grupo : listGrupos )
|
||||
{
|
||||
JComboBox combo = mapComboBox.get( grupo );
|
||||
setupListenersFor( combo );
|
||||
}
|
||||
}
|
||||
|
||||
private void setupListenersFor( JComboBox combo )
|
||||
{
|
||||
combo.addItemListener( new ItemListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void itemStateChanged( ItemEvent itemEvent )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( ItemEvent.SELECTED == itemEvent.getStateChange() )
|
||||
{
|
||||
JComboBox combo = (JComboBox) itemEvent.getSource();
|
||||
for( PrtGruposProtocoloData grupo : mapComboBox.keySet() )
|
||||
{
|
||||
if( mapComboBox.get( grupo ).equals( combo ) )
|
||||
{
|
||||
PrestadoresData analisador = (PrestadoresData) combo.getSelectedItem();
|
||||
grupo.setToAnalisador_id( PrestadoresData.prestadorNulo.equals( analisador ) ? null : analisador );
|
||||
grupo.save();
|
||||
shout( "Tipo de ECD: " + grupo.getDescricao() + " -> Analisador: " + analisador.getNome() + " [guardado]" );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch( Exception e )
|
||||
{
|
||||
LeafDialog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
private void shout( String message )
|
||||
{
|
||||
labelMessage.setText( message == null ? " " : message );
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue