git-svn-id: https://svn.coded.pt/svn/SIPRP@556 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
Tiago Simão 18 years ago
parent 28371f8829
commit 95678a2e50

@ -11,6 +11,7 @@ import com.evolute.utils.error.*;
import com.evolute.utils.jdbc.*;
import com.evolute.utils.jdo.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.strings.UnicodeChecker;
import com.evolute.utils.ui.*;
import com.evolute.utils.ui.window.*;

@ -65,209 +65,209 @@ public class ECDsPanel extends JPanel
public ECDsPanel( JFrame owner )
throws Exception
{
this.owner = owner;
JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
provider = ProcessoDataProvider.getProvider();
setupComponents();
// this.owner = owner;
// JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
// provider = ProcessoDataProvider.getProvider();
// setupComponents();
}
private void setupComponents()
{
JLabel dataLabel = new JLabel( "Data" );
dataConsultaPanel = new JCalendarPanel( null );
dataConsultaPanel.addChangeListener( this );
estadoButton = new JButton( " " );
estadoButton.addActionListener( this );
emailButton = new JButton( "Email" );
emailButton.addActionListener( this );
observacoesButton = new JButton( "Coment\u00e1rio" );
observacoesButton.addActionListener( this );
double cols[] =
new double[]{ TableLayout.MINIMUM, TableLayout.FILL };
double rows[] =
new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM,
TableLayout.MINIMUM, TableLayout.MINIMUM };
TableLayout tableLayout = new TableLayout( cols, rows );
tableLayout.setVGap( 5 );
setLayout( tableLayout );
add( dataLabel, new TableLayoutConstraints( 0, 0 ) );
add( dataEcdsPanel, new TableLayoutConstraints( 1, 0 ) );
add( estadoButton, new TableLayoutConstraints( 0, 1, 1, 1 ) );
add( emailButton, new TableLayoutConstraints( 0, 2, 1, 2 ) );
add( observacoesButton, new TableLayoutConstraints( 0, 3, 1, 3 ) );
// JLabel dataLabel = new JLabel( "Data" );
// dataConsultaPanel = new JCalendarPanel( null );
// dataConsultaPanel.addChangeListener( this );
// estadoButton = new JButton( " " );
// estadoButton.addActionListener( this );
// emailButton = new JButton( "Email" );
// emailButton.addActionListener( this );
// observacoesButton = new JButton( "Coment\u00e1rio" );
// observacoesButton.addActionListener( this );
//
// double cols[] =
// new double[]{ TableLayout.MINIMUM, TableLayout.FILL };
// double rows[] =
// new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM,
// TableLayout.MINIMUM, TableLayout.MINIMUM };
//
// TableLayout tableLayout = new TableLayout( cols, rows );
// tableLayout.setVGap( 5 );
// setLayout( tableLayout );
//
// add( dataLabel, new TableLayoutConstraints( 0, 0 ) );
// add( dataEcdsPanel, new TableLayoutConstraints( 1, 0 ) );
// add( estadoButton, new TableLayoutConstraints( 0, 1, 1, 1 ) );
// add( emailButton, new TableLayoutConstraints( 0, 2, 1, 2 ) );
// add( observacoesButton, new TableLayoutConstraints( 0, 3, 1, 3 ) );
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if( source.equals( observacoesButton ) )
{
editarObservacoes();
}
else if( source.equals( emailButton ) )
{
enviarEmail();
}
else if( source.equals( estadoButton ) )
{
mudarEstado();
}
// Object source = e.getSource();
// if( source.equals( observacoesButton ) )
// {
// editarObservacoes();
// }
// else if( source.equals( emailButton ) )
// {
// enviarEmail();
// }
// else if( source.equals( estadoButton ) )
// {
// mudarEstado();
// }
}
public void stateChanged(ChangeEvent e)
{
Object source = e.getSource();
if( source.equals( dataConsultaPanel ) )
{
Date data = dataConsultaPanel.getDate();
if( data == null )
{
return;
}
try
{
boolean nova = false;
if( ecds == null )
{
nova = true;
Integer ecdsID = provider.getEcdsEmAbertoForProcesso( processoID );
if( ecdsID == null )
{
ecds = new TrabalhadoresEcdsData();
ecds.set( TrabalhadoresEcdsData.TRABALHADOR_ID, trabalhadorID );
ecds.set( TrabalhadoresEcdsData.PROCESSO_ID, processoID );
ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
}
else
{
ecds = provider.getEcdsByID( ecdsID );
ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
}
}
ecds.set( TrabalhadoresConsultasData.DATA, data );
provider.saveEcds( ecds );
if( ecdsData == null )
{
Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
if( ecdsDataID == null || nova )
{
ecdsData = new TrabalhadoresEcdsDatasData();
ecdsData.set( TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID, ecdsID );
ecdsData.set( TrabalhadoresEcdssDatasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
}
else
{
ecdsData = provider.getEcdsDataByID( ecdsDataID );
}
}
ecdsData.set( TrabalhadoresEcdsDatasData.DATA, data );
provider.saveEcdsData( ecdsData );
notifyListeners( ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar dados dos ECDs", true );
return;
}
}
// Object source = e.getSource();
//
// if( source.equals( dataConsultaPanel ) )
// {
// Date data = dataConsultaPanel.getDate();
// if( data == null )
// {
// return;
// }
// try
// {
// boolean nova = false;
// if( ecds == null )
// {
// nova = true;
// Integer ecdsID = provider.getEcdsEmAbertoForProcesso( processoID );
// if( ecdsID == null )
// {
// ecds = new TrabalhadoresEcdsData();
// ecds.set( TrabalhadoresEcdsData.TRABALHADOR_ID, trabalhadorID );
// ecds.set( TrabalhadoresEcdsData.PROCESSO_ID, processoID );
// ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
// }
// else
// {
// ecds = provider.getEcdsByID( ecdsID );
// ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
// }
// }
// ecds.set( TrabalhadoresConsultasData.DATA, data );
// provider.saveEcds( ecds );
// if( ecdsData == null )
// {
// Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
// Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
// if( ecdsDataID == null || nova )
// {
// ecdsData = new TrabalhadoresEcdsDatasData();
// ecdsData.set( TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID, ecdsID );
// ecdsData.set( TrabalhadoresEcdssDatasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
// }
// else
// {
// ecdsData = provider.getEcdsDataByID( ecdsDataID );
// }
// }
// ecdsData.set( TrabalhadoresEcdsDatasData.DATA, data );
// provider.saveEcdsData( ecdsData );
//
// notifyListeners( ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO );
// }
// catch( Exception ex )
// {
// DialogException.showExceptionMessage( ex, "Erro a gravar dados dos ECDs", true );
// return;
// }
// }
}
protected void editarObservacoes()
{
if( observacoesDialog == null )
{
observacoesDialog = new ObservacoesDialog( owner );
}
String texto = "";
try
{
Integer dataID = provider.getLastEcdsDataIDForEcds( ( Integer ) ecds.get( TrabalhadoresEcdssData.ID ) );
IDObject observacoes = provider.getObservacoesEcdsData( dataID );
if( observacoes != null )
{
texto = observacoes.toString();
}
texto = observacoesDialog.editarObservacao( texto );
if( texto != null )
{
provider.saveObservacoesEcdsData( dataID, texto );
notifyListeners( ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
return;
}
// if( observacoesDialog == null )
// {
// observacoesDialog = new ObservacoesDialog( owner );
// }
// String texto = "";
// try
// {
// Integer dataID = provider.getLastEcdsDataIDForEcds( ( Integer ) ecds.get( TrabalhadoresEcdssData.ID ) );
// IDObject observacoes = provider.getObservacoesEcdsData( dataID );
// if( observacoes != null )
// {
// texto = observacoes.toString();
// }
// texto = observacoesDialog.editarObservacao( texto );
// if( texto != null )
// {
// provider.saveObservacoesEcdsData( dataID, texto );
// notifyListeners( ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES );
// }
// }
// catch( Exception ex )
// {
// DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
// return;
// }
}
protected void enviarEmail()
{
if( ecds == null )
{
return;
}
try
{
Integer ecdsDataID;
if( ecdsData == null )
{
Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
ecdsData = provider.getEcdsDataByID( ecdsDataID );
}
ecdsDataID = ( Integer ) ecdsData.get( TrabalhadoresEcdsDatasData.ID );
provider.saveEmailEcdsData( ecdsDataID, "teste@siprp.pt", "Email de teste.", "" );
notifyListeners( ProcessoEvent.ACCAO_ESCREVER_MAIL );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar dados", true );
return;
}
// if( ecds == null )
// {
// return;
// }
// try
// {
// Integer ecdsDataID;
// if( ecdsData == null )
// {
// Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
// ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
// ecdsData = provider.getEcdsDataByID( ecdsDataID );
// }
// ecdsDataID = ( Integer ) ecdsData.get( TrabalhadoresEcdsDatasData.ID );
// provider.saveEmailEcdsData( ecdsDataID, "teste@siprp.pt", "Email de teste.", "" );
// notifyListeners( ProcessoEvent.ACCAO_ESCREVER_MAIL );
// }
// catch( Exception ex )
// {
// DialogException.showExceptionMessage( ex, "Erro a gravar dados", true );
// return;
// }
}
protected void mudarEstado()
{
if( ecds == null )
{
return;
}
Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
EstadoChooser chooser =
new EstadoChooser( owner, ProcessoConstants.TIPO_ECDS,
estado != null ? estado.intValue() : MedicinaConstants.ESTADO_POR_REALIZAR );
chooser.setVisible( true );
int novoEstado = chooser.getEstado();
if( estado == null || estado.intValue() != novoEstado )
{
try
{
ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( novoEstado ) );
provider.saveEcds( ecds );
if( ecdsData == null )
{
Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
ecdsData = provider.getEcdsDataByID( ecdsDataID );
}
ecdsData.set( TrabalhadoresEcdsDatasData.ESTADO, new Integer( novoEstado ) );
provider.saveEcdsData( ecdsData );
notifyListeners( ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a gravar dados", true );
return;
}
}
// if( ecds == null )
// {
// return;
// }
// Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
// EstadoChooser chooser =
// new EstadoChooser( owner, ProcessoConstants.TIPO_ECDS,
// estado != null ? estado.intValue() : MedicinaConstants.ESTADO_POR_REALIZAR );
// chooser.setVisible( true );
// int novoEstado = chooser.getEstado();
// if( estado == null || estado.intValue() != novoEstado )
// {
// try
// {
// ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( novoEstado ) );
// provider.saveEcds( ecds );
// if( ecdsData == null )
// {
// Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
// Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
// ecdsData = provider.getEcdsDataByID( ecdsDataID );
// }
// ecdsData.set( TrabalhadoresEcdsDatasData.ESTADO, new Integer( novoEstado ) );
// provider.saveEcdsData( ecdsData );
//
// notifyListeners( ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO );
// }
// catch( Exception ex )
// {
// DialogException.showExceptionMessage( ex, "Erro a gravar dados", true );
// return;
// }
// }
}
public void addProcessoListener( ProcessoListener listener )
@ -282,57 +282,57 @@ public class ECDsPanel extends JPanel
public void clear()
{
dataConsultaPanel.setDate( null );
estadoButton.setText( " " );
ecds = null;
ecdsData = null;
// dataConsultaPanel.setDate( null );
// estadoButton.setText( " " );
// ecds = null;
// ecdsData = null;
}
public void fill( Object value )
{
clear();
if( value != null )
{
try
{
ecds = ( TrabalhadoresEcdsData ) JDO.load( TrabalhadoresEcdsData.class, ( Integer ) value );
Date data = ( Date ) ecds.get( TrabalhadoresEcdsData.DATA );
Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
dataConsultaPanel.setDate( data );
if( estado != null )
{
estadoButton.setText( ESTADOS_EXAME_STR[ estado.intValue() ] );
}
else
{
estadoButton.setText( " " );
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
}
}
enableButtons();
// clear();
// if( value != null )
// {
// try
// {
// ecds = ( TrabalhadoresEcdsData ) JDO.load( TrabalhadoresEcdsData.class, ( Integer ) value );
// Date data = ( Date ) ecds.get( TrabalhadoresEcdsData.DATA );
// Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
// dataConsultaPanel.setDate( data );
// if( estado != null )
// {
// estadoButton.setText( ESTADOS_EXAME_STR[ estado.intValue() ] );
// }
// else
// {
// estadoButton.setText( " " );
// }
// }
// catch( Exception ex )
// {
// DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
// }
// }
// enableButtons();
}
protected void enableButtons()
{
if( ecds != null )
{
Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
dataEcdsPanel.setEnabled( estado == null || estado.intValue() == ESTADO_POR_REALIZAR );
estadoButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
emailButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
observacoesButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
}
else
{
dataConsultaPanel.setEnabled( true );
estadoButton.setEnabled( false );
emailButton.setEnabled( false );
observacoesButton.setEnabled( false );
}
// if( ecds != null )
// {
// Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
// dataEcdsPanel.setEnabled( estado == null || estado.intValue() == ESTADO_POR_REALIZAR );
// estadoButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
// emailButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
// observacoesButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
// }
// else
// {
// dataConsultaPanel.setEnabled( true );
// estadoButton.setEnabled( false );
// emailButton.setEnabled( false );
// observacoesButton.setEnabled( false );
// }
}
public void setTrabalhadorID( Integer trabalhadorID )

@ -1,4 +1,4 @@
<project name="SIPR" basedir="." default="list">
<project name="SIPRP" basedir="." default="list">
<!-- COMMON PROPERTIES -->
<property name="common.lib.dir" value="${basedir}/lib.common" />

Loading…
Cancel
Save