diff --git a/trunk/siprp/ficha/ExamePDF.java b/trunk/siprp/ficha/ExamePDF.java index f16b5344..f878290e 100644 --- a/trunk/siprp/ficha/ExamePDF.java +++ b/trunk/siprp/ficha/ExamePDF.java @@ -297,10 +297,10 @@ public class ExamePDF { ph.add( doCheckedPhrase( "POR ALTERA\u00c7\u00c3O DAS CONDI\u00c7\u00d5ES DE TRABALHO\n", values.get( "tipo_trabalho" ) != null, true ) ); - ph.add( doCheckedPhrase( "OUTRO\n", values.get( "tipo_outro" ) != null ) ); + ph.add( doCheckedPhrase( "OUTRO\n", values.get( "tipo_outro" ) != null, true ) ); texto = new StringBuffer(); - texto.append( "ESPECIFIQUE: " + texto.append( " ESPECIFIQUE: " + ( ( values.get( "tipo_outro" ) == null ) ? "" : values.get( "tipo_outro" ) ) + "" ); ph.add( new Chunk( texto.toString(), FONT_NORMAL ) ); diff --git a/trunk/siprp/ficha/ExamePanel.java b/trunk/siprp/ficha/ExamePanel.java index 74c21011..ca479573 100644 --- a/trunk/siprp/ficha/ExamePanel.java +++ b/trunk/siprp/ficha/ExamePanel.java @@ -28,14 +28,14 @@ import siprp.data.*; * @author fpalma */ public class ExamePanel extends JPanel - implements ChangeListener, ControllableComponent + implements ChangeListener, ControllableComponent, ListSelectionListener { private JCalendarPanel dataExamePanel; private BetterButtonGroup tipoGroup; private JRadioButton admissaoRadio; private JRadioButton periodicoRadio; private JRadioButton ocasionalRadio; - private JRadioButton outroRadio; +// private JRadioButton outroRadio; private RadioButtonFixedPanel ocasionalPanel; private JTextField especificarText; private JCalendarPanel proximoExamePanel; @@ -80,17 +80,19 @@ public class ExamePanel extends JPanel ocasionalRadio = new JRadioButton( "Ocasional" ); tipoGroup.add( ocasionalRadio ); ocasionalRadio.addChangeListener( this ); - outroRadio = new JRadioButton( "Outro" ); - tipoGroup.add( outroRadio ); - outroRadio.addChangeListener( this ); +// outroRadio = new JRadioButton( "Outro" ); +// tipoGroup.add( outroRadio ); +// outroRadio.addChangeListener( this ); ocasionalPanel = new RadioButtonFixedPanel( new IDObject[]{ new MappableObject( new Integer( 1 ), "Ap\u00f3s doen\u00e7a" ), new MappableObject( new Integer( 2 ), "Ap\u00f3s acidente" ), new MappableObject( new Integer( 3 ), "A pedido do trabalhador" ), new MappableObject( new Integer( 4 ), "A pedido do servi\u00e7o" ), new MappableObject( new Integer( 5 ), "Por mudan\u00e7a de fun\u00e7\u00e3o" ), - new MappableObject( new Integer( 6 ), "Por altera\u00e7\u00e3o das condi\u00e7\u00f5es de trabalho" ) }, + new MappableObject( new Integer( 6 ), "Por altera\u00e7\u00e3o das condi\u00e7\u00f5es de trabalho" ), + new MappableObject( new Integer( 10 ), "Outro" ) }, false ); + ocasionalPanel.addListSelectionListener( this ); ocasionalPanel.setEnabled( false ); especificarText = new JTextField(); especificarText.setEnabled( false ); @@ -173,10 +175,10 @@ public class ExamePanel extends JPanel gridbag.setConstraints( ocasionalPanel, constraints ); tipoPanel.add( ocasionalPanel ); - constraints.weightx = 0; - constraints.gridwidth = 1; - gridbag.setConstraints( outroRadio, constraints ); - tipoPanel.add( outroRadio ); +// constraints.weightx = 0; +// constraints.gridwidth = 1; +// gridbag.setConstraints( outroRadio, constraints ); +// tipoPanel.add( outroRadio ); constraints.weightx = 1; constraints.gridwidth = GridBagConstraints.REMAINDER; @@ -264,12 +266,13 @@ public class ExamePanel extends JPanel { ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ; } - else if( e.getSource().equals( outroRadio ) ) - { - especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ) ; - } +// else if( e.getSource().equals( outroRadio ) ) +// { +// especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ); +// } } + public void fill( Object value ) { clear(); @@ -388,18 +391,23 @@ public class ExamePanel extends JPanel { tipo = 3; } - else if( outroRadio.isSelected() ) - { - tipo = 4; - } +// else if( outroRadio.isSelected() ) +// { +// tipo = 4; +// } exame.setProperty( FichaDataProvider.TIPO, new Integer( tipo ) ); if( tipo != 3 ) { exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OCASIONAL ).FULL_NAME, null ); + exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" ); } - if( tipo != 4 ) + else { - exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" ); + Integer ocasionalID = ( Integer )ocasionalPanel.save(); + if( ocasionalID == null || ocasionalID.intValue() != 10 ) + { + exame.setProperty( FichaDataProvider.EXAMES.getFieldByName( FichaDataProvider.OUTRO_TIPO ).FULL_NAME, "" ); + } } } catch( Exception ex ) @@ -430,8 +438,27 @@ public class ExamePanel extends JPanel admissaoRadio.setEnabled( enable ); periodicoRadio.setEnabled( enable ); ocasionalRadio.setEnabled( enable ); - outroRadio.setEnabled( enable ); +// outroRadio.setEnabled( enable ); ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ; - especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ); +// especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ); + setEspecificarState(); + } + + public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) + { + setEspecificarState(); + } + + public void setEspecificarState() + { + Integer id = ( Integer )ocasionalPanel.save(); + if( id != null && id.intValue() == 10 ) + { + especificarText.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ); + } + else + { + especificarText.setEnabled( false ); + } } }