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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
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.jdbc.*;
import com.evolute.utils.jdo.*; import com.evolute.utils.jdo.*;
import com.evolute.utils.sql.*; import com.evolute.utils.sql.*;
import com.evolute.utils.strings.UnicodeChecker;
import com.evolute.utils.ui.*; import com.evolute.utils.ui.*;
import com.evolute.utils.ui.window.*; import com.evolute.utils.ui.window.*;

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

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

Loading…
Cancel
Save