|  |  | @ -14,19 +14,23 @@ import java.util.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.evolute.utils.data.*; |  |  |  | import com.evolute.utils.data.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.evolute.utils.dataui.*; |  |  |  | import com.evolute.utils.dataui.*; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.evolute.utils.metadb.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.evolute.utils.ui.*; |  |  |  | import com.evolute.utils.ui.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.evolute.utils.ui.button.*; |  |  |  | import com.evolute.utils.ui.button.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.evolute.utils.ui.panel.*; |  |  |  | import com.evolute.utils.ui.panel.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import siprp.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | /** |  |  |  | /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  * |  |  |  |  * | 
			
		
	
		
		
			
				
					
					|  |  |  |  * @author  fpalma |  |  |  |  * @author  fpalma | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | public class ExamePanel extends JPanel |  |  |  | public class ExamePanel extends JPanel | 
			
		
	
		
		
			
				
					
					|  |  |  | 	implements ChangeListener, FillerSaverWrapper |  |  |  | 	implements ChangeListener, ControllableComponent | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private JCalendarPanel dataExamePanel; |  |  |  | 	private JCalendarPanel dataExamePanel; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private BetterButtonGroup tipoGroup; |  |  |  | 	private BetterButtonGroup tipoGroup; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	private JRadioButton admissaoRadio; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	private JRadioButton periodicoRadio; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private JRadioButton ocasionalRadio; |  |  |  | 	private JRadioButton ocasionalRadio; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private JRadioButton outroRadio; |  |  |  | 	private JRadioButton outroRadio; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private RadioButtonFixedPanel ocasionalPanel; |  |  |  | 	private RadioButtonFixedPanel ocasionalPanel; | 
			
		
	
	
		
		
			
				
					|  |  | @ -36,10 +40,16 @@ public class ExamePanel extends JPanel | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private JTextField outrasFuncoesTexts[]; |  |  |  | 	private JTextField outrasFuncoesTexts[]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private JTextArea recomendacoesText; |  |  |  | 	private JTextArea recomendacoesText; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	private FichaDataProvider provider; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	private ComponentsHashtable components; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	/** Creates a new instance of ExamePanel */ |  |  |  | 	/** Creates a new instance of ExamePanel */ | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public ExamePanel() |  |  |  | 	public ExamePanel() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		provider = (FichaDataProvider)FichaDataProvider.getProvider(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		setupComponents(); |  |  |  | 		setupComponents(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		setupComponentsHashtable(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	private void setupComponents() |  |  |  | 	private void setupComponents() | 
			
		
	
	
		
		
			
				
					|  |  | @ -57,9 +67,9 @@ public class ExamePanel extends JPanel | 
			
		
	
		
		
			
				
					
					|  |  |  | 		tipoPanel.setBorder( BorderFactory.createTitledBorder(  |  |  |  | 		tipoPanel.setBorder( BorderFactory.createTitledBorder(  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				BorderFactory.createEtchedBorder(), "Tipo" ) ); |  |  |  | 				BorderFactory.createEtchedBorder(), "Tipo" ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		tipoGroup = new BetterButtonGroup( false ); |  |  |  | 		tipoGroup = new BetterButtonGroup( false ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		JRadioButton admissaoRadio = new JRadioButton( "Admiss\u00e3o" ); |  |  |  | 		admissaoRadio = new JRadioButton( "Admiss\u00e3o" ); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		tipoGroup.add( admissaoRadio ); |  |  |  | 		tipoGroup.add( admissaoRadio ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		JRadioButton periodicoRadio = new JRadioButton( "Peri\u00f3dico" ); |  |  |  | 		periodicoRadio = new JRadioButton( "Peri\u00f3dico" ); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		tipoGroup.add( periodicoRadio ); |  |  |  | 		tipoGroup.add( periodicoRadio ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		ocasionalRadio = new JRadioButton( "Ocasional" ); |  |  |  | 		ocasionalRadio = new JRadioButton( "Ocasional" ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		tipoGroup.add( ocasionalRadio ); |  |  |  | 		tipoGroup.add( ocasionalRadio ); | 
			
		
	
	
		
		
			
				
					|  |  | @ -223,24 +233,130 @@ public class ExamePanel extends JPanel | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	private void setupComponentsHashtable() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components = new ComponentsHashtable(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.DATA, dataExamePanel ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putDummy( provider.T_EXAMES + "." + provider.TIPO ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.OCASIONAL, ocasionalPanel ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.OUTRO_TIPO, especificarText ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.PROXIMO_EXAME, proximoExamePanel ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.RESULTADO, resultadoPanel ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_1, outrasFuncoesTexts[ 0 ] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_2, outrasFuncoesTexts[ 1 ] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_3, outrasFuncoesTexts[ 2 ] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.OUTRA_FUNCAO_4, outrasFuncoesTexts[ 3 ] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( provider.T_EXAMES + "." + provider.OUTRAS_RECOMENDACOES, recomendacoesText ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putDummy( provider.T_EXAMES + "." + provider.TRABALHADOR_ID ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putDummy( provider.T_EXAMES + "." + provider.MEDICO_ID ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public void stateChanged( ChangeEvent e )  |  |  |  | 	public void stateChanged( ChangeEvent e )  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if( e.getSource().equals( ocasionalRadio ) ) |  |  |  | 		if( e.getSource().equals( ocasionalRadio ) ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 			ocasionalPanel.setEnabled( ocasionalRadio.isSelected() ) ; |  |  |  | 			ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		else if( e.getSource().equals( outroRadio ) ) |  |  |  | 		else if( e.getSource().equals( outroRadio ) ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 			especificarText.setEnabled( outroRadio.isSelected() ) ; |  |  |  | 			especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ) ; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public void fill(Object value) |  |  |  | 	public void fill( Object value ) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public Object save() |  |  |  | 	public Object save() | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return null; |  |  |  | 		StringBuffer msg = new StringBuffer(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		boolean hasMsg = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		boolean hasData = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		MetaObject exame; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		try | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			exame = provider.createObject( provider.EXAMES ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			DBField fields[] = provider.EXAMES.getInsertFields(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String exameFields[] = new String[ fields.length ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			for( int i = 0; i < exameFields.length; ++i ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				exameFields[ i ] = fields[ i ].FULL_NAME; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Hashtable hash = new Hashtable(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			ComponentController.save( exameFields, hash, components ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Enumeration enum = hash.keys(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			while( enum.hasMoreElements() ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				String name = ( String )enum.nextElement(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				exame.setProperty( name, hash.get( name ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			int tipo = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if( admissaoRadio.isSelected() ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				tipo = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else if( periodicoRadio.isSelected() ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				tipo = 2; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else if( ocasionalRadio.isSelected() ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				tipo = 3; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else if( outroRadio.isSelected() ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				tipo = 4; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			exame.setProperty( provider.TIPO, new Integer( tipo ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if( tipo != 3 ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				exame.setProperty( provider.EXAMES.getFieldByName( provider.OCASIONAL ).FULL_NAME, null ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if( tipo != 4 ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				exame.setProperty( provider.EXAMES.getFieldByName( provider.OUTRO_TIPO ).FULL_NAME, "" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //			if( ((String)trabalhador.getProperty( provider.NOME )).trim().length() == 0 )
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //			{
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //				msg.append( "O trabalhador tem de ter nome\n" );
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //				hasMsg = true;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //			}
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //			if( trabalhador.getProperty( provider.SEXO ) == null )
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //			{
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //				msg.append( "O trabalhador tem de ter um sexo definido\n" );
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //				hasMsg = true;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //			}
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		catch( Exception ex ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			ex.printStackTrace(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if( hasMsg ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			throw new ValuesException( msg.toString() ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		return exame; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	public void clear() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		String names[] = (String[])components.keySet().toArray( new String[0] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		ComponentController.clear( names, components ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		tipoGroup.setIntSelected( 0 ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		dataExamePanel.setDate( new Date() ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	public void setEnabled( boolean enable ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		String names[] = (String[])components.keySet().toArray( new String[0] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		ComponentController.setEnabled( names, enable, components ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		admissaoRadio.setEnabled( enable ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		periodicoRadio.setEnabled( enable ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		ocasionalRadio.setEnabled( enable ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		outroRadio.setEnabled( enable ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		ocasionalPanel.setEnabled( ocasionalRadio.isSelected() && ocasionalRadio.isEnabled() ) ; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		especificarText.setEnabled( outroRadio.isSelected() && outroRadio.isEnabled() ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |