|
|
|
|
@ -14,15 +14,23 @@ import info.clearthought.layout.TableLayoutConstraints;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import javax.swing.event.TreeSelectionEvent;
|
|
|
|
|
import javax.swing.event.TreeSelectionListener;
|
|
|
|
|
import siprp.medicina.processo.data.MarcacoesProcessoData;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author fpalma
|
|
|
|
|
*/
|
|
|
|
|
public class ProcessoPanel extends JPanel
|
|
|
|
|
implements ActionListener
|
|
|
|
|
implements ActionListener, TreeSelectionListener
|
|
|
|
|
{
|
|
|
|
|
private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
|
|
|
|
|
|
|
|
|
|
private JTextField estadoText;
|
|
|
|
|
private JTextField inicioText;
|
|
|
|
|
private JTextField fimText;
|
|
|
|
|
@ -31,12 +39,16 @@ public class ProcessoPanel extends JPanel
|
|
|
|
|
private JButton emitirFAButton;
|
|
|
|
|
private JButton fecharButton;
|
|
|
|
|
|
|
|
|
|
private final EstruturaProcessoPanel estruturaPanel;
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of ProcessoPanel */
|
|
|
|
|
public ProcessoPanel()
|
|
|
|
|
public ProcessoPanel( EstruturaProcessoPanel estruturaPanel )
|
|
|
|
|
{
|
|
|
|
|
this.estruturaPanel = estruturaPanel;
|
|
|
|
|
setupComponents();
|
|
|
|
|
estruturaPanel.addTreeSelectionListener( this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setupComponents()
|
|
|
|
|
{
|
|
|
|
|
@ -62,11 +74,11 @@ public class ProcessoPanel extends JPanel
|
|
|
|
|
fecharButton.addActionListener( this );
|
|
|
|
|
|
|
|
|
|
double cols[] =
|
|
|
|
|
new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL,
|
|
|
|
|
TableLayout.PREFERRED, };
|
|
|
|
|
double rows[] =
|
|
|
|
|
new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
|
|
|
|
|
TableLayout.PREFERRED, TableLayout.FILL };
|
|
|
|
|
new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL,
|
|
|
|
|
TableLayout.PREFERRED, };
|
|
|
|
|
double rows[] =
|
|
|
|
|
new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
|
|
|
|
|
TableLayout.PREFERRED, TableLayout.FILL };
|
|
|
|
|
|
|
|
|
|
TableLayout tableLayout = new TableLayout( cols, rows );
|
|
|
|
|
setLayout( tableLayout );
|
|
|
|
|
@ -82,7 +94,7 @@ public class ProcessoPanel extends JPanel
|
|
|
|
|
add( emitirFAButton, new TableLayoutConstraints( 3, 2 ) );
|
|
|
|
|
add( fecharButton, new TableLayoutConstraints( 3, 3 ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e)
|
|
|
|
|
{
|
|
|
|
|
Object source = e.getSource();
|
|
|
|
|
@ -119,4 +131,65 @@ public class ProcessoPanel extends JPanel
|
|
|
|
|
protected void fecharProcesso()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void valueChanged(TreeSelectionEvent e)
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
mudarProcesso();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clear()
|
|
|
|
|
{
|
|
|
|
|
estadoText.setText( "" );
|
|
|
|
|
inicioText.setText( "" );
|
|
|
|
|
fimText.setText( "" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void disableButtons()
|
|
|
|
|
{
|
|
|
|
|
novoECDButton.setEnabled( false );
|
|
|
|
|
novaConsultaButton.setEnabled( false );
|
|
|
|
|
emitirFAButton.setEnabled( false );
|
|
|
|
|
fecharButton.setEnabled( false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void enableButtons()
|
|
|
|
|
{
|
|
|
|
|
novoECDButton.setEnabled( true );
|
|
|
|
|
novaConsultaButton.setEnabled( true );
|
|
|
|
|
emitirFAButton.setEnabled( true );
|
|
|
|
|
fecharButton.setEnabled( true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void mudarProcesso()
|
|
|
|
|
{
|
|
|
|
|
MarcacoesProcessoData processo = estruturaPanel.getProcessoEscolhido();
|
|
|
|
|
if( processo == null )
|
|
|
|
|
{
|
|
|
|
|
disableButtons();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
enableButtons();
|
|
|
|
|
Date dataInicio = ( Date ) processo.get( MarcacoesProcessoData.DATA_INICIO );
|
|
|
|
|
if( dataInicio != null )
|
|
|
|
|
{
|
|
|
|
|
inicioText.setText( D_F.format( dataInicio ) );
|
|
|
|
|
}
|
|
|
|
|
Date dataFim = ( Date ) processo.get( MarcacoesProcessoData.DATA_FIM );
|
|
|
|
|
if( dataFim != null )
|
|
|
|
|
{
|
|
|
|
|
fimText.setText( D_F.format( dataFim ) );
|
|
|
|
|
}
|
|
|
|
|
String estado = ( String ) processo.get( MarcacoesProcessoData.ESTADO );
|
|
|
|
|
if( estado == null )
|
|
|
|
|
{
|
|
|
|
|
estadoText.setText( ProcessoDataProvider.PROCESSO_POR_ABRIR_DESCRIPTION );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
estadoText.setText( ProcessoDataProvider.ESTADO_PROCESSO_BY_CODE.get( estado ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|