@ -12,6 +12,7 @@ import java.awt.Component;
import java.awt.Dimension ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
import java.util.Date ;
import java.util.EventObject ;
import javax.swing.BorderFactory ;
@ -41,6 +42,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png" ;
private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png" ;
private static final String ICON_NAME_SUBMIT = "siprp/higiene/relatorio/submit.png" ;
private final JCalendarPanel dataRelatorio = new JCalendarPanel ( null ) ;
@ -61,6 +63,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private final LeafIconButton buttonSave = LeafIconButton . createButton ( ICON_NAME_SAVE ) ;
private final LeafIconButton buttonRevert = LeafIconButton . createButton ( ICON_NAME_REVERT ) ;
private final LeafIconButton buttonSubmit = LeafIconButton . createButton ( "Submeter plano de actua" + ccedil + atilde + "o" , ICON_NAME_SUBMIT ) ;
private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel ( ) ;
@ -130,8 +133,22 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
panelAcompanhantes . add ( fieldNome3 , new TableLayoutConstraints ( 1 , 2 ) ) ;
panelAcompanhantes . add ( new JLabel ( "Fun" + ccedil + atilde + "o" ) , new TableLayoutConstraints ( 2 , 2 ) ) ;
panelAcompanhantes . add ( fieldFuncao3 , new TableLayoutConstraints ( 3 , 2 ) ) ;
add ( buttonSave , new TableLayoutConstraints ( 0 , 0 ) ) ;
add ( buttonRevert , new TableLayoutConstraints ( 1 , 0 ) ) ;
TableLayout layout = new TableLayout ( new double [ ] {
TableLayout . MINIMUM , TableLayout . MINIMUM , TableLayout . FILL , TableLayout . MINIMUM
} , new double [ ] {
TableLayout . MINIMUM
} ) ;
layout . setVGap ( 5 ) ;
layout . setHGap ( 5 ) ;
JPanel panel = new JPanel ( ) ;
panel . setLayout ( layout ) ;
panel . add ( buttonSave , new TableLayoutConstraints ( 0 , 0 ) ) ;
panel . add ( buttonRevert , new TableLayoutConstraints ( 1 , 0 ) ) ;
panel . add ( buttonSubmit , new TableLayoutConstraints ( 3 , 0 ) ) ;
add ( panel , new TableLayoutConstraints ( 0 , 0 , 7 , 0 ) ) ;
add ( new JLabel ( "Data do relat" + oacute + "rio" ) , new TableLayoutConstraints ( 0 , 1 , 2 , 1 ) ) ;
add ( dataRelatorio , new TableLayoutConstraints ( 3 , 1 ) ) ;
add ( new JLabel ( "Avalia" + ccedil + atilde + "o" ) , new TableLayoutConstraints ( 4 , 1 ) ) ;
@ -146,7 +163,6 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private void setupListeners ( )
{
fieldTecnico . addCaretListener ( this ) ;
fieldFuncao1 . addCaretListener ( this ) ;
fieldFuncao2 . addCaretListener ( this ) ;
fieldFuncao3 . addCaretListener ( this ) ;
@ -172,6 +188,24 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
revert ( ) ;
}
} ) ;
buttonSubmit . addActionListener ( new ActionListener ( )
{
@Override
public void actionPerformed ( ActionEvent e )
{
submit ( ) ;
}
} ) ;
}
private void submit ( )
{
if ( relatorio ! = null )
{
relatorio . setIsSubmetido ( new Date ( ) ) ;
relatorio . save ( ) ;
refresh ( ) ;
}
}
private void save ( )
@ -180,15 +214,15 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
{
relatorio . setData ( dataRelatorio . getDate ( ) ) ;
relatorio . setAvaliacaoInicial ( radioInicial . isSelected ( ) ) ;
MarcacoesEstabelecimento marcacao = relatorio . getToHsMarcacoesEstabelecimento ( ) ;
if ( marcacao ! = null )
{
MarcacoesTecnicosHst tecnico = marcacao . getToMarcacoesTecnicosHst ( ) ;
if ( tecnico ! = null )
{
tecnico . setNome ( fieldTecnico . getText ( ) ) ;
}
}
// MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento();
// if( marcacao != null )
// {
// MarcacoesTecnicosHst tecnico = marcacao.getToMarcacoesTecnicosHst();
// if( tecnico != null )
// {
// tecnico.setNome( fieldTecnico.getText() );
// }
// }
}
relatorio . setAcompanhante1 ( fieldNome1 . getText ( ) ) ;
relatorio . setAcompanhante2 ( fieldNome2 . getText ( ) ) ;
@ -197,6 +231,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
relatorio . setFuncaoAcompanhante1 ( fieldFuncao1 . getText ( ) ) ;
relatorio . setFuncaoAcompanhante2 ( fieldFuncao2 . getText ( ) ) ;
relatorio . setFuncaoAcompanhante3 ( fieldFuncao3 . getText ( ) ) ;
relatorio . save ( ) ;
refresh ( ) ;
buttonRevert . setEnabled ( false ) ;
buttonSave . setEnabled ( false ) ;
@ -249,13 +284,14 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
dataRelatorio . setEnabled ( enabled ) ;
radioInicial . setEnabled ( enabled ) ; ;
radioPeriodica . setEnabled ( enabled ) ;
fieldTecnico . setEnabled ( enabled ) ;
fieldTecnico . setEnabled ( false ) ;
fieldNome1 . setEnabled ( enabled ) ;
fieldNome2 . setEnabled ( enabled ) ;
fieldNome3 . setEnabled ( enabled ) ;
fieldFuncao1 . setEnabled ( enabled ) ;
fieldFuncao2 . setEnabled ( enabled ) ;
fieldFuncao3 . setEnabled ( enabled ) ;
buttonSubmit . setEnabled ( enabled ) ;
}
public void setRelatorio ( HsRelatorio relatorio )