forked from Coded/SIPRP
				
			git-svn-id: https://svn.coded.pt/svn/SIPRP@730 bb69d46d-e84e-40c8-a05a-06db0d633741
	
		
	
				
					
				
			
							parent
							
								
									74d9ecc15b
								
							
						
					
					
						commit
						82e8d1d031
					
				| @ -0,0 +1,54 @@ | |||||||
|  | /* | ||||||
|  |  * RemarcacoesActionFactory.java | ||||||
|  |  * | ||||||
|  |  * Created on January 31, 2007, 6:37 PM | ||||||
|  |  * | ||||||
|  |  * To change this template, choose Tools | Template Manager | ||||||
|  |  * and open the template in the editor. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package siprp.lembretes.externos; | ||||||
|  | 
 | ||||||
|  | import javax.swing.Action; | ||||||
|  | 
 | ||||||
|  | import siprp.lembretes.externos.actions.TratarExternoAction; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.data.IDObject; | ||||||
|  | import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author fpalma | ||||||
|  |  */ | ||||||
|  | public class ExternosActionFactory implements ActionFactory<IDObject> | ||||||
|  | { | ||||||
|  | 	public static final int TRABALHADOR = 0; | ||||||
|  | 	 | ||||||
|  | 	protected final int TIPO; | ||||||
|  | 	 | ||||||
|  | 	/** | ||||||
|  | 	 * Creates a new instance of RemarcacoesActionFactory | ||||||
|  | 	 */ | ||||||
|  | 	public ExternosActionFactory( int tipo ) | ||||||
|  | 	{ | ||||||
|  | 		TIPO = tipo; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public Action createAction(IDObject[] objects) | ||||||
|  | 	{ | ||||||
|  | 		return null; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public Action createAction(IDObject object) | ||||||
|  | 	{ | ||||||
|  | 		switch( TIPO ) | ||||||
|  | 		{ | ||||||
|  | 			case TRABALHADOR: | ||||||
|  | 				return new TratarExternoAction( object ); | ||||||
|  | 				 | ||||||
|  | 			default: | ||||||
|  | 				return null; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,141 @@ | |||||||
|  | /* | ||||||
|  |  * RemarcacoesDataProvider.java | ||||||
|  |  * | ||||||
|  |  * Created on February 14, 2007, 10:56 AM | ||||||
|  |  * | ||||||
|  |  * To change this template, choose Tools | Template Manager | ||||||
|  |  * and open the template in the editor. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package siprp.lembretes.externos; | ||||||
|  | 
 | ||||||
|  | import java.text.DateFormat; | ||||||
|  | import java.util.Date; | ||||||
|  | import java.util.Locale; | ||||||
|  | 
 | ||||||
|  | import siprp.lembretes.LembretesConstants; | ||||||
|  | import siprp.lembretes.LembretesDataProvider; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.Singleton; | ||||||
|  | import com.evolute.utils.arrays.Virtual2DArray; | ||||||
|  | import com.evolute.utils.data.IDObject; | ||||||
|  | import com.evolute.utils.data.MappableObject; | ||||||
|  | import com.evolute.utils.db.DBManager; | ||||||
|  | import com.evolute.utils.db.Executer; | ||||||
|  | import com.evolute.utils.sql.Expression; | ||||||
|  | import com.evolute.utils.sql.Field; | ||||||
|  | import com.evolute.utils.sql.Select; | ||||||
|  | import com.evolute.utils.sql.Select2; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author lflores | ||||||
|  |  */ | ||||||
|  | public class LembretesExternosDataProvider | ||||||
|  | { | ||||||
|  | 	private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); | ||||||
|  | 	 | ||||||
|  | 	private static final Object LOCK = new Object(); | ||||||
|  | 	private static LembretesExternosDataProvider instance = null; | ||||||
|  | 	 | ||||||
|  | 	private Executer EXECUTER; | ||||||
|  | 	private LembretesDataProvider lembretesProvider; | ||||||
|  | 	 | ||||||
|  | 	/** Creates a new instance of RemarcacoesDataProvider */ | ||||||
|  | 	public LembretesExternosDataProvider() | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); | ||||||
|  | 		EXECUTER = dbm.getSharedExecuter( this ); | ||||||
|  | 		lembretesProvider = LembretesDataProvider.getProvider(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public static LembretesExternosDataProvider getProvider() | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		synchronized( LOCK ) | ||||||
|  | 		{ | ||||||
|  | 			if( instance == null ) | ||||||
|  | 			{ | ||||||
|  | 				instance = new LembretesExternosDataProvider(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return instance; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private Expression whereExpressionLembretesRemarcacao( Integer empresaID, Integer estabelecimentoID ) throws Exception | ||||||
|  | 	{ | ||||||
|  | 		Expression result = new Field( "lembretes.tipo_id" ).isEqual(  | ||||||
|  | 				lembretesProvider.getTipoLembreteByCodigo( LembretesConstants.CODE_EXTERNO ).getID() ).and(  | ||||||
|  | 			new Field( "lembretes.data" ).isLessOrEqual( new Field( "current_date" ) ) ).and( | ||||||
|  | 					new Field( "lembretes.deleted_date" ).isEqual( null ) ); | ||||||
|  | 		if( empresaID != null ) | ||||||
|  | 		{ | ||||||
|  | 			result = result.and( new Field("empresas.id").isEqual( empresaID ) ); | ||||||
|  | 			if( estabelecimentoID != null ) | ||||||
|  | 			{ | ||||||
|  | 				result = result.and( new Field("estabelecimentos.id").isEqual( estabelecimentoID ) ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public IDObject[] getLembretesMarcacaoTrabalhador( Integer empresaID, Integer estabelecimentoID ) | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		Select select = | ||||||
|  | 				new Select2( new String[]{ "lembretes", "marcacoes_trabalhador", "trabalhadores",  | ||||||
|  | 											"estabelecimentos", "empresas", "trabalhadores_consultas_datas", "trabalhadores_ecds_datas"}, | ||||||
|  | 								new Integer [] { | ||||||
|  | 								                Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER, | ||||||
|  | 								                Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER, | ||||||
|  | 								                Select2.JOIN_LEFT_OUTER, Select2.JOIN_LEFT_OUTER | ||||||
|  | 								                }, | ||||||
|  | 								new Expression[]{  | ||||||
|  | 										new Field( "lembretes.marcacao_trabalhador_id" ).isEqual( new Field( "marcacoes_trabalhador.id" ) ),/*.or( | ||||||
|  | 												new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) )		 | ||||||
|  | 										).or( | ||||||
|  | 												new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) ) | ||||||
|  | 										), | ||||||
|  | 										*/ | ||||||
|  | 										new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ).or( new Field( "lembretes.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ), | ||||||
|  | 										new Field( "trabalhadores.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), | ||||||
|  | 										new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ), | ||||||
|  | 										new Field( "lembretes.trabalhadores_consultas_datas_id" ).isEqual( new Field( "trabalhadores_consultas_datas.id" ) ), | ||||||
|  | 										new Field( "lembretes.trabalhadores_ecds_datas_id" ).isEqual( new Field( "trabalhadores_ecds_datas.id" ) ) | ||||||
|  | 									}, | ||||||
|  | 								new String[]{ "lembretes.id", "lembretes.descricao",  | ||||||
|  | 												"marcacoes_trabalhador.tipo", "lembretes.data", | ||||||
|  | 												"trabalhadores.nome", "estabelecimentos.nome", "empresas.designacao_social", | ||||||
|  | 												"trabalhadores.nome_plain" }, | ||||||
|  | 								whereExpressionLembretesRemarcacao( empresaID, estabelecimentoID ), | ||||||
|  | 								new String[]{ "trabalhadores.nome_plain" }, | ||||||
|  | 								null, | ||||||
|  | 								null, | ||||||
|  | 								null | ||||||
|  | 							); | ||||||
|  | 		Virtual2DArray array = EXECUTER.executeQuery( select ); | ||||||
|  | 		IDObject lembretes[] = new IDObject[ array.columnLength() ]; | ||||||
|  | 		for( int n = 0; n < lembretes.length; n++ ) | ||||||
|  | 		{ | ||||||
|  | 			Integer id = ( Integer ) array.get( n, 0 ); | ||||||
|  | 			String descricao = ( String ) array.get( n, 1 ); | ||||||
|  | 			Date data = ( Date ) array.get( n, 3 ); | ||||||
|  | 			 | ||||||
|  | 			String trabalhador = ( String ) array.get( n, 4 ); | ||||||
|  | 			String split[] = trabalhador.split( " " ); | ||||||
|  | 			trabalhador = split[ 0 ] + " " + ( split.length > 2 ? split[ 1 ].charAt( 0 ) + ". " : " " ) + | ||||||
|  | 							( split.length > 1 ? split[ split.length - 1 ] : "" ); | ||||||
|  | 			String estabelecimento = ( String ) array.get( n, 5 ); | ||||||
|  | 			String empresa = ( String ) array.get( n, 6 ); | ||||||
|  | 			String str = "<html><body><font color=\"#00009f\">" + trabalhador + "</font>" | ||||||
|  | 							+ "<br>   " + "" + " de " + D_F.format( data ) | ||||||
|  | 							+ "<br>   <font color=\"#009f00\">" + descricao + "</font>" | ||||||
|  | 							+ "<br>   " + empresa.substring( 0, empresa.length() > 20 ? 20 : empresa.length() ) | ||||||
|  | 							+ " / " + estabelecimento.substring( 0, estabelecimento.length() > 10 ? 10 : estabelecimento.length() ) | ||||||
|  | 							+ "</body></html>"; | ||||||
|  | 			lembretes[ n ] = new MappableObject( id, str ); | ||||||
|  | 		} | ||||||
|  | 		return lembretes; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,69 @@ | |||||||
|  | /* | ||||||
|  |  * LembretesRemarcacaoPanel.java | ||||||
|  |  * | ||||||
|  |  * Created on 13 de Fevereiro de 2007, 23:24 | ||||||
|  |  * | ||||||
|  |  * To change this template, choose Tools | Template Manager | ||||||
|  |  * and open the template in the editor. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package siprp.lembretes.externos; | ||||||
|  | 
 | ||||||
|  | import java.awt.BorderLayout; | ||||||
|  | import java.awt.GridLayout; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JLabel; | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | import javax.swing.JScrollPane; | ||||||
|  | 
 | ||||||
|  | import siprp.lembretes.LembretesConstants; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.jdo.JDOProvider; | ||||||
|  | import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class LembretesExternosPanel extends JPanel | ||||||
|  | 	implements LembretesConstants | ||||||
|  | { | ||||||
|  | 	protected JScrollPane listTrabalhadoresScroll; | ||||||
|  | 	protected MultipleActionListPanel listTrabalhadoresPanel; | ||||||
|  | 	 | ||||||
|  | 	protected LembretesExternosDataProvider provider; | ||||||
|  | 	 | ||||||
|  | 	private final Integer empresaID; | ||||||
|  | 	private final Integer estabelecimentoID; | ||||||
|  | 	 | ||||||
|  | 	private JDOProvider JDO; | ||||||
|  | 	 | ||||||
|  | 	/** Creates a new instance of LembretesRemarcacaoPanel */ | ||||||
|  | 	public LembretesExternosPanel( Integer empresaID, Integer estabelecimentoID ) | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		this.empresaID = empresaID; | ||||||
|  | 		this.estabelecimentoID = estabelecimentoID; | ||||||
|  | 		provider = LembretesExternosDataProvider.getProvider(); | ||||||
|  | 		setupComponents(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupComponents() | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		listTrabalhadoresPanel =  | ||||||
|  | 				new MultipleActionListPanel(  | ||||||
|  | 					new ExternosActionFactory[]{ }, | ||||||
|  | 					new ExternosActionFactory[]{ new ExternosActionFactory( ExternosActionFactory.TRABALHADOR ) } ); | ||||||
|  | 		listTrabalhadoresScroll =  | ||||||
|  | 			new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, | ||||||
|  | 								JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); | ||||||
|  | 		setLayout( new GridLayout( 1, 2 ) ); | ||||||
|  | 		JPanel trabalhadoresPanel = new JPanel(); | ||||||
|  | 		add( trabalhadoresPanel ); | ||||||
|  | 		 | ||||||
|  | 		trabalhadoresPanel.setLayout( new BorderLayout() ); | ||||||
|  | 		trabalhadoresPanel.add( new JLabel( "Consultas / ECDs", JLabel.CENTER ), BorderLayout.NORTH ); | ||||||
|  | 		trabalhadoresPanel.add( listTrabalhadoresScroll, BorderLayout.CENTER ); | ||||||
|  | 	 | ||||||
|  | 		listTrabalhadoresPanel.showList( provider.getLembretesMarcacaoTrabalhador( empresaID, estabelecimentoID ) ); | ||||||
|  | //		listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) );
 | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,101 @@ | |||||||
|  | /* | ||||||
|  |  * TratarMarcacaoTrabalhadorAction.java | ||||||
|  |  * | ||||||
|  |  * Created on January 31, 2007, 6:21 PM | ||||||
|  |  * | ||||||
|  |  * To change this template, choose Tools | Template Manager | ||||||
|  |  * and open the template in the editor. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package siprp.lembretes.externos.actions; | ||||||
|  | 
 | ||||||
|  | import java.awt.event.ActionEvent; | ||||||
|  | 
 | ||||||
|  | import javax.swing.AbstractAction; | ||||||
|  | import javax.swing.JOptionPane; | ||||||
|  | 
 | ||||||
|  | import siprp.SIPRPTracker; | ||||||
|  | import siprp.SingletonConstants; | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | import siprp.database.cayenne.objects.Estabelecimentos; | ||||||
|  | import siprp.database.cayenne.objects.Trabalhadores; | ||||||
|  | import siprp.database.cayenne.providers.MedicinaDAO; | ||||||
|  | import siprp.lembretes.Lembrete; | ||||||
|  | import siprp.lembretes.LembretesDataProvider; | ||||||
|  | import siprp.medicina.processo.logic.MedicinaProcessoLogic; | ||||||
|  | import siprp.medicina.processo.ui.MedicinaProcessoWindow; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.Singleton; | ||||||
|  | import com.evolute.utils.data.IDObject; | ||||||
|  | import com.evolute.utils.ui.DialogException; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  *  | ||||||
|  |  * @author fpalma | ||||||
|  |  */ | ||||||
|  | public class TratarExternoAction extends AbstractAction | ||||||
|  | { | ||||||
|  | 	private LembretesDataProvider lembretesProvider; | ||||||
|  | 	private SIPRPTracker tracker; | ||||||
|  | 
 | ||||||
|  | 	private Integer lembreteID; | ||||||
|  | 
 | ||||||
|  | 	private MedicinaDAO medicinaDAO = new MedicinaDAO(); | ||||||
|  | 
 | ||||||
|  | 	/** | ||||||
|  | 	 * Creates a new instance of TratarMarcacaoTrabalhadorAction | ||||||
|  | 	 */ | ||||||
|  | 	public TratarExternoAction(IDObject lembrete) | ||||||
|  | 	{ | ||||||
|  | 		super( "Tratar" ); | ||||||
|  | 		try | ||||||
|  | 		{ | ||||||
|  | 			lembreteID = lembrete.getID(); | ||||||
|  | 			lembretesProvider = LembretesDataProvider.getProvider(); | ||||||
|  | 		} catch( Exception ex ) | ||||||
|  | 		{ | ||||||
|  | 			ex.printStackTrace(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void actionPerformed( ActionEvent e ) | ||||||
|  | 	{ | ||||||
|  | 		try | ||||||
|  | 		{ | ||||||
|  | 			tracker = (SIPRPTracker) Singleton.getInstance( SingletonConstants.SIPRP_TRACKER ); | ||||||
|  | 			Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID ); | ||||||
|  | 			boolean irParaProcessos = false; | ||||||
|  | 			if( lembrete == null ) | ||||||
|  | 			{ | ||||||
|  | 				JOptionPane.showMessageDialog( null, "Este lembrete j\u00e1 foi tratado.", "J\u00e1 tratado", JOptionPane.WARNING_MESSAGE ); | ||||||
|  | 				return; | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				irParaProcessos = JOptionPane.showConfirmDialog( null, "Deseja visualizar os processos deste trabalhador?", "Abrir Processos", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE ) == JOptionPane.OK_OPTION; | ||||||
|  | 			} | ||||||
|  | 			if( irParaProcessos ) | ||||||
|  | 			{ | ||||||
|  | 				Trabalhadores trabalhador = null; | ||||||
|  | 				Estabelecimentos estabelecimento = null; | ||||||
|  | 				Empresas empresa = null; | ||||||
|  | 				trabalhador = medicinaDAO.getTrabalhadorByID( lembrete.getTrabalhadorID() ); | ||||||
|  | 				estabelecimento = trabalhador.getToEstabelecimentos(); | ||||||
|  | 				empresa = estabelecimento.getToEmpresas(); | ||||||
|  | 				MedicinaProcessoWindow window = tracker.getMedicinaProcessoWindow(); | ||||||
|  | 
 | ||||||
|  | 				window.runActionLater( MedicinaProcessoLogic.SELECT_EMPRESA, empresa ); | ||||||
|  | 				window.runActionLater( MedicinaProcessoLogic.SELECT_ESTABELECIMENTO, estabelecimento ); | ||||||
|  | 				window.runActionLater( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador ); | ||||||
|  | 				window.runActionLater( MedicinaProcessoLogic.SELECT_TRABALHADOR, trabalhador ); | ||||||
|  | 				window.runPendingActions(); | ||||||
|  | 				window.setVisible( true ); | ||||||
|  | 			} | ||||||
|  | 			lembretesProvider.apagarLembreteByID( lembreteID ); | ||||||
|  | 		} catch( Exception ex ) | ||||||
|  | 		{ | ||||||
|  | 			DialogException.showExceptionMessage( ex, "Erro a tratar", true ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -1,183 +0,0 @@ | |||||||
| /* |  | ||||||
|  * EscolherMotivoDialog.java |  | ||||||
|  * |  | ||||||
|  * Created on 13 de Maio de 2007, 22:16 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.data.IDObject; |  | ||||||
| import com.evolute.utils.data.MappableObject; |  | ||||||
| import com.evolute.utils.ui.CustomJDialog; |  | ||||||
| import java.awt.Dimension; |  | ||||||
| import java.awt.FlowLayout; |  | ||||||
| import java.awt.GridLayout; |  | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
| import java.awt.event.ActionListener; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import javax.swing.AbstractButton; |  | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JToggleButton; |  | ||||||
| import javax.swing.SwingUtilities; |  | ||||||
| import siprp.medicina.MedicinaConstants; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author Frederico |  | ||||||
|  */ |  | ||||||
| public class EscolherMotivoDialog extends CustomJDialog |  | ||||||
| 	implements ActionListener, MedicinaConstants |  | ||||||
| { |  | ||||||
| 	protected IDObject MOTIVOS[] =  |  | ||||||
| 		new IDObject[]{ |  | ||||||
| 			new MappableObject( MOTIVO_ADMISSAO_INTEGER, MOTIVO_ADMISSAO_STR ),  |  | ||||||
| 			new MappableObject( MOTIVO_PERIODICO_INTEGER, MOTIVO_PERIODICO_STR ), |  | ||||||
| 			new MappableObject( MOTIVO_PERIODICO_INICIAL_INTEGER, MOTIVO_PERIODICO_INICIAL_STR ), |  | ||||||
| 			new MappableObject( MOTIVO_OCASIONAL_INTEGER, MOTIVO_OCASIONAL_STR ) |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	protected IDObject SUB_MOTIVOS[][] =  |  | ||||||
| 		new IDObject[][]{ |  | ||||||
| 			{}, |  | ||||||
| 			{}, |  | ||||||
| 			{}, |  | ||||||
| 			{ new MappableObject( SUB_MOTIVO_APOS_DOENCA_INTEGER, SUB_MOTIVO_APOS_DOENCA_STR ),  |  | ||||||
| 				new MappableObject( SUB_MOTIVO_APOS_ACIDENTE_INTEGER, SUB_MOTIVO_APOS_ACIDENTE_STR ), |  | ||||||
| 				new MappableObject( SUB_MOTIVO_PEDIDO_TRABALHADOR_INTEGER, SUB_MOTIVO_PEDIDO_TRABALHADOR_STR ),  |  | ||||||
| 				new MappableObject( SUB_MOTIVO_PEDIDO_SERVICO_INTEGER, SUB_MOTIVO_PEDIDO_SERVICO_STR ), |  | ||||||
| 				new MappableObject( SUB_MOTIVO_MUDANCA_FUNCAO_INTEGER, SUB_MOTIVO_MUDANCA_FUNCAO_STR ), |  | ||||||
| 				new MappableObject( SUB_MOTIVO_ALTERACAO_CONDICOES_INTEGER, SUB_MOTIVO_ALTERACAO_CONDICOES_STR ), |  | ||||||
| 				new MappableObject( SUB_MOTIVO_OUTRO_INTEGER, SUB_MOTIVO_OUTRO_STR ) |  | ||||||
| 			} |  | ||||||
| 	}; |  | ||||||
| 	 |  | ||||||
| 	protected AbstractButton motivoButtons[]; |  | ||||||
| 	protected HashMap<AbstractButton,JButton[]> subMotivoButtons; |  | ||||||
| 	protected HashMap<AbstractButton,Integer> motivoButtonIDs; |  | ||||||
| 	protected HashMap<JButton,Integer> subMotivoButtonIDs; |  | ||||||
| 	protected JPanel motivoPanel; |  | ||||||
| 	protected JPanel subMotivoPanel; |  | ||||||
| 	 |  | ||||||
| 	protected Integer motivoTemp; |  | ||||||
| 	protected Integer motivo; |  | ||||||
| 	protected Integer subMotivo; |  | ||||||
| 	 |  | ||||||
| 	/** Creates a new instance of EscolherMotivoDialog */ |  | ||||||
| 	public EscolherMotivoDialog( JFrame owner ) |  | ||||||
| 	{ |  | ||||||
| 		super( owner, true ); |  | ||||||
| 		setupComponents(); |  | ||||||
| 		 |  | ||||||
| 		if( owner != null ) |  | ||||||
| 		{ |  | ||||||
| 			centerSuper(); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			center(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		setTitle( "Escolher Motivo" ); |  | ||||||
| 		setLayout( new FlowLayout( FlowLayout.LEFT ) ); |  | ||||||
| 		motivoButtons = new JToggleButton[ MOTIVOS.length ]; |  | ||||||
| 		subMotivoButtons = new HashMap<AbstractButton,JButton[]>(); |  | ||||||
| 		motivoButtonIDs = new HashMap<AbstractButton,Integer>(); |  | ||||||
| 		subMotivoButtonIDs = new HashMap<JButton,Integer>(); |  | ||||||
| 		for( int m = 0; m < MOTIVOS.length; m++ ) |  | ||||||
| 		{ |  | ||||||
| 			JToggleButton motivoButton = new JToggleButton( MOTIVOS[ m ].toString() ); |  | ||||||
| 			motivoButton.addActionListener( this ); |  | ||||||
| 			motivoButtonIDs.put( motivoButton, MOTIVOS[ m ].getID() ); |  | ||||||
| 			motivoButton.setPreferredSize( new Dimension( 250, 20 ) ); |  | ||||||
| 			motivoButtons[ m ] = motivoButton; |  | ||||||
| 			if( SUB_MOTIVOS[ m ].length > 0 ) |  | ||||||
| 			{ |  | ||||||
| 				JButton subButtons[] = new JButton[ SUB_MOTIVOS[ m ].length ]; |  | ||||||
| 				for( int sm = 0; sm < SUB_MOTIVOS[ m ].length; sm++ ) |  | ||||||
| 				{ |  | ||||||
| 					JButton subButton = new JButton( SUB_MOTIVOS[ m ][ sm ].toString() ); |  | ||||||
| 					subMotivoButtonIDs.put( subButton, SUB_MOTIVOS[ m ][ sm ].getID() ); |  | ||||||
| 					subButtons[ sm ] = subButton; |  | ||||||
| 					subButton.setPreferredSize( new Dimension( 300, 20 ) ); |  | ||||||
| 					subButton.addActionListener( this ); |  | ||||||
| 				} |  | ||||||
| 				subMotivoButtons.put( motivoButton, subButtons ); |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 				subMotivoButtons.put( motivoButton, null ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		motivoPanel = new JPanel(); |  | ||||||
| 		subMotivoPanel = new JPanel(); |  | ||||||
| 		 |  | ||||||
| 		motivoPanel.setLayout( new GridLayout( motivoButtons.length + 1, 1 ) ); |  | ||||||
| 		for( int n = 0; n < motivoButtons.length; n++ ) |  | ||||||
| 		{ |  | ||||||
| 			motivoPanel.add( motivoButtons[ n ] ); |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 		add( motivoPanel ); |  | ||||||
| 		add( subMotivoPanel ); |  | ||||||
| 		 |  | ||||||
| 		pack(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void actionPerformed(ActionEvent e) |  | ||||||
| 	{ |  | ||||||
| 		AbstractButton source = ( AbstractButton ) e.getSource(); |  | ||||||
| 		if( motivoButtonIDs.containsKey( source ) ) |  | ||||||
| 		{ |  | ||||||
| 			motivoTemp = motivoButtonIDs.get( source ); |  | ||||||
| 		} |  | ||||||
| 		else if( subMotivoButtonIDs.containsKey( source ) ) |  | ||||||
| 		{ |  | ||||||
| 			motivo = motivoTemp; |  | ||||||
| 			subMotivo = subMotivoButtonIDs.get( source ); |  | ||||||
| 			close(); |  | ||||||
| 		} |  | ||||||
| 		if( subMotivoButtons.containsKey( source ) ) |  | ||||||
| 		{ |  | ||||||
| 			JButton subButtons[] = subMotivoButtons.get( source ); |  | ||||||
| 			if( subButtons == null || subButtons.length == 0 ) |  | ||||||
| 			{ |  | ||||||
| 				motivo = motivoTemp; |  | ||||||
| 				close(); |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 				subMotivoPanel.removeAll(); |  | ||||||
| 				subMotivoPanel.setLayout( new GridLayout( 0, 1 ) ); |  | ||||||
| 				for( int n = 0; n < subButtons.length; n++ ) |  | ||||||
| 				{ |  | ||||||
| 					subMotivoPanel.add( subButtons[ n ] ); |  | ||||||
| 				} |  | ||||||
| 				pack(); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void close() |  | ||||||
| 	{ |  | ||||||
| 		SwingUtilities.invokeLater( new Runnable(){ |  | ||||||
| 			public void run() |  | ||||||
| 			{ |  | ||||||
| 				setVisible( false ); |  | ||||||
| 				dispose(); |  | ||||||
| 			} |  | ||||||
| 		} ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Integer[] getMotivo() |  | ||||||
| 	{ |  | ||||||
| 		return new Integer[]{ motivo, subMotivo }; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,405 +0,0 @@ | |||||||
|  /* |  | ||||||
|  * ProcessoController.java |  | ||||||
|  * |  | ||||||
|  * Created on 25 de Abril de 2007, 15:10 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo; |  | ||||||
| //
 |  | ||||||
| //import com.evolute.utils.Singleton;
 |  | ||||||
| //import com.evolute.utils.data.MappableObject;
 |  | ||||||
| //import com.evolute.utils.jdo.JDOProvider;
 |  | ||||||
| //import com.evolute.utils.ui.DialogException;
 |  | ||||||
| //import javax.swing.event.ListSelectionEvent;
 |  | ||||||
| //import javax.swing.event.ListSelectionListener;
 |  | ||||||
| //import siprp.data.TrabalhadorData;
 |  | ||||||
| //import siprp.medicina.processo.detalhes.DetalhesProcessoPanel;
 |  | ||||||
| //import siprp.medicina.processo.estrutura.EstruturaProcessoPanel;
 |  | ||||||
| //
 |  | ||||||
| ///**
 |  | ||||||
| // *
 |  | ||||||
| // * @author Frederico
 |  | ||||||
| // */
 |  | ||||||
| //public class ProcessoController 
 |  | ||||||
| //	implements ProcessoListener, ListSelectionListener
 |  | ||||||
| //{
 |  | ||||||
| //	protected ProcessoUpperPanel processoUpperPanel;
 |  | ||||||
| //	protected EstruturaProcessoPanel estruturaProcessoPanel;
 |  | ||||||
| //	protected ProcessoPanel processoPanel;
 |  | ||||||
| //	protected DetalhesProcessoPanel detalhesProcessoPanel;
 |  | ||||||
| //	protected ProcessoDataProvider provider;
 |  | ||||||
| //	
 |  | ||||||
| //	protected JDOProvider JDO;
 |  | ||||||
| //	
 |  | ||||||
| //	protected Integer idProcesso;
 |  | ||||||
| //	protected Integer idMarcacao;
 |  | ||||||
| //	protected Integer idData;
 |  | ||||||
| //		
 |  | ||||||
| //	/** Creates a new instance of ProcessoController */
 |  | ||||||
| //	public ProcessoController( ProcessoUpperPanel processoUpperPanel, EstruturaProcessoPanel estruturaProcessoPanel, 
 |  | ||||||
| //								ProcessoPanel processoPanel, DetalhesProcessoPanel detalhesProcessoPanel )
 |  | ||||||
| //			throws Exception
 |  | ||||||
| //	{
 |  | ||||||
| //		this.processoUpperPanel = processoUpperPanel;
 |  | ||||||
| //		this.estruturaProcessoPanel = estruturaProcessoPanel;
 |  | ||||||
| //		this.processoPanel = processoPanel;
 |  | ||||||
| //		this.detalhesProcessoPanel = detalhesProcessoPanel;
 |  | ||||||
| //		processoUpperPanel.addListSelectionListener( this );
 |  | ||||||
| //		estruturaProcessoPanel.addProcessoListener( this );
 |  | ||||||
| //		processoPanel.addProcessoListener( this );
 |  | ||||||
| //		detalhesProcessoPanel.addProcessoListener( this );
 |  | ||||||
| //		
 |  | ||||||
| //		provider = ProcessoDataProvider.getProvider();
 |  | ||||||
| //		JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
 |  | ||||||
| //	}
 |  | ||||||
| //
 |  | ||||||
| //	public void processoStateChanged(ProcessoEvent e)
 |  | ||||||
| //	{
 |  | ||||||
| //		int accao = e.getAccao();
 |  | ||||||
| //		switch( accao )
 |  | ||||||
| //		{
 |  | ||||||
| //			case ProcessoEvent.ACCAO_RECARREGAR_TRABALHADOR:
 |  | ||||||
| //				recarregarTrabalhador( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_PROCESSO:
 |  | ||||||
| //				escolherProcesso( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_CONSULTA:
 |  | ||||||
| //				escolherConsulta( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_ECDS:
 |  | ||||||
| //				escolherECDs( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_FA:
 |  | ||||||
| //				escolherFichaAptidao( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_DATA:
 |  | ||||||
| //				escolherData( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_OBSERVACOES:
 |  | ||||||
| //				escolherObservacoes( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_MAIL:
 |  | ||||||
| //				escolherMail( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCOLHER_MOTIVO:
 |  | ||||||
| //				escolherMotivo( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_MARCAR_CONSULTA:
 |  | ||||||
| //				marcarConsulta( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_MARCAR_ECDS:
 |  | ||||||
| //				marcarECDs( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_EMITIR_FA:
 |  | ||||||
| //				emitirFichaAptidao( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_FECHAR:
 |  | ||||||
| //				fecharProcesso( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO:
 |  | ||||||
| //				mudarEstadoMarcacao( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO:
 |  | ||||||
| //				mudarDataMarcacao( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES:
 |  | ||||||
| //				escreverObservacoes( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //			case ProcessoEvent.ACCAO_ESCREVER_MAIL:
 |  | ||||||
| //				escreverMail( e );
 |  | ||||||
| //				break;
 |  | ||||||
| //				
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void recarregarTrabalhador( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		idProcesso = null;
 |  | ||||||
| //		estruturaProcessoPanel.reload();
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherProcesso( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			processoPanel.fill( idProcesso );
 |  | ||||||
| //			detalhesProcessoPanel.clear();
 |  | ||||||
| //			detalhesProcessoPanel.setProcessoID( idProcesso );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherConsulta( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			Integer idProcessoAntigo = idProcesso;
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			processoPanel.fill( idProcesso );
 |  | ||||||
| //			detalhesProcessoPanel.setProcessoID( idProcesso );
 |  | ||||||
| //			idMarcacao = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 |  | ||||||
| //			detalhesProcessoPanel.setConsulta( idMarcacao );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherECDs( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			Integer idProcessoAntigo = idProcesso;
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			processoPanel.fill( idProcesso );
 |  | ||||||
| //			detalhesProcessoPanel.setProcessoID( idProcesso );
 |  | ||||||
| //
 |  | ||||||
| //			idMarcacao = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 |  | ||||||
| //			detalhesProcessoPanel.setECDs( idMarcacao );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherFichaAptidao( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			Integer idFichaAptidao = e.getObjecto( ProcessoEvent.TIPO_FICHA_APTIDAO );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherData( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			Integer idProcessoAntigo = idProcesso;
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			processoPanel.fill( idProcesso );
 |  | ||||||
| //			detalhesProcessoPanel.setProcessoID( idProcesso );
 |  | ||||||
| //			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 |  | ||||||
| //			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 |  | ||||||
| //			Integer idData = e.getObjecto( ProcessoEvent.TIPO_DATA );
 |  | ||||||
| //			if( idConsulta != null )
 |  | ||||||
| //			{
 |  | ||||||
| //				idMarcacao = idConsulta;
 |  | ||||||
| //				detalhesProcessoPanel.setConsulta( idConsulta );
 |  | ||||||
| //			}
 |  | ||||||
| //			else if( idECDs != null )
 |  | ||||||
| //			{
 |  | ||||||
| //				idMarcacao = idECDs;
 |  | ||||||
| //				detalhesProcessoPanel.setECDs( idECDs );
 |  | ||||||
| //			}
 |  | ||||||
| //			else
 |  | ||||||
| //			{
 |  | ||||||
| //				idMarcacao = null;
 |  | ||||||
| //				detalhesProcessoPanel.clear();
 |  | ||||||
| //			}
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherObservacoes( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			escolherData( e );
 |  | ||||||
| //			Integer idObservacoes = e.getObjecto( ProcessoEvent.TIPO_OBSERVACOES );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherMail( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			escolherData( e );
 |  | ||||||
| //			Integer idMail = e.getObjecto( ProcessoEvent.TIPO_MAIL );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escolherMotivo( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
 |  | ||||||
| //			detalhesProcessoPanel.setProcessoID( idProcesso );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //			DialogException.showExceptionMessage( ex, "Erro a actualizar dados", true );
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void marcarConsulta( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			detalhesProcessoPanel.setConsulta( null );
 |  | ||||||
| //			
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void marcarECDs( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			detalhesProcessoPanel.setECDs( null );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void emitirFichaAptidao( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void fecharProcesso( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void mudarEstadoMarcacao( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 |  | ||||||
| //			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 |  | ||||||
| //			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 |  | ||||||
| //			estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void mudarDataMarcacao( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 |  | ||||||
| //			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 |  | ||||||
| //			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 |  | ||||||
| //			estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escreverObservacoes( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 |  | ||||||
| //			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 |  | ||||||
| //			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 |  | ||||||
| //			estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void escreverMail( ProcessoEvent e )
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 |  | ||||||
| //			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 |  | ||||||
| //			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 |  | ||||||
| //			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 |  | ||||||
| //			estruturaProcessoPanel.actualizarMarcacaoEscolhida( idProcesso, idMarcacao );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //
 |  | ||||||
| //	public void valueChanged(ListSelectionEvent e)
 |  | ||||||
| //	{
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			Integer ids[] = ( Integer [] ) processoUpperPanel.save();
 |  | ||||||
| //			Integer trabalhadorID = ids[ 2 ];
 |  | ||||||
| //			processoPanel.setTrabalhadorID( trabalhadorID );
 |  | ||||||
| //			if( trabalhadorID != null )
 |  | ||||||
| //			{
 |  | ||||||
| //				TrabalhadorData trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID );
 |  | ||||||
| //				estruturaProcessoPanel.setTrabalhador( new MappableObject( trabalhadorID, trabalhador.get( TrabalhadorData.NOME ) ) );
 |  | ||||||
| //			}
 |  | ||||||
| //			else
 |  | ||||||
| //			{
 |  | ||||||
| //				estruturaProcessoPanel.clear();
 |  | ||||||
| //			}
 |  | ||||||
| //			processoPanel.clear();
 |  | ||||||
| //			detalhesProcessoPanel.clear();
 |  | ||||||
| //			processoPanel.setTrabalhadorID( trabalhadorID );
 |  | ||||||
| //			detalhesProcessoPanel.setTrabalhadorID( trabalhadorID );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //			DialogException.showExceptionMessage( ex, "Erro a carregar trabalhador", true );
 |  | ||||||
| //		}
 |  | ||||||
| //	}
 |  | ||||||
| //}
 |  | ||||||
| @ -1,74 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ProcessoEvent.java |  | ||||||
|  * |  | ||||||
|  * Created on 25 de Abril de 2007, 10:53 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo; |  | ||||||
| 
 |  | ||||||
| import java.util.HashMap; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author Frederico |  | ||||||
|  */ |  | ||||||
| public class ProcessoEvent |  | ||||||
| { |  | ||||||
| 	public static final int ACCAO_RECARREGAR_TRABALHADOR = 0; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_PROCESSO = 1; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_CONSULTA = 2; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_ECDS = 3; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_FA = 4; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_DATA = 5; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_OBSERVACOES = 6; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_MAIL = 7; |  | ||||||
| 	public static final int ACCAO_ESCOLHER_MOTIVO = 8; |  | ||||||
| 	public static final int ACCAO_MARCAR_CONSULTA = 9; |  | ||||||
| 	public static final int ACCAO_MARCAR_ECDS = 10; |  | ||||||
| 	public static final int ACCAO_EMITIR_FA = 11; |  | ||||||
| 	public static final int ACCAO_FECHAR = 12; |  | ||||||
| 	public static final int ACCAO_MUDAR_ESTADO_MARCACAO = 13; |  | ||||||
| 	public static final int ACCAO_MUDAR_DATA_MARCACAO = 14; |  | ||||||
| 	public static final int ACCAO_ESCREVER_OBSERVACOES = 15; |  | ||||||
| 	public static final int ACCAO_ESCREVER_MAIL = 16; |  | ||||||
| 	 |  | ||||||
| 	public static final Integer TIPO_ANY = new Integer( 0 ); |  | ||||||
| 	public static final Integer TIPO_PROCESSO = new Integer( 1 ); |  | ||||||
| 	public static final Integer TIPO_CONSULTA = new Integer( 2 ); |  | ||||||
| 	public static final Integer TIPO_ECDS = new Integer( 3 ); |  | ||||||
| 	public static final Integer TIPO_DATA = new Integer( 4 ); |  | ||||||
| 	public static final Integer TIPO_OBSERVACOES = new Integer( 5 ); |  | ||||||
| 	public static final Integer TIPO_MAIL = new Integer( 6 ); |  | ||||||
| 	public static final Integer TIPO_FICHA_APTIDAO = new Integer( 7 ); |  | ||||||
| 	 |  | ||||||
| 	protected final Object source; |  | ||||||
| 	protected final int accao; |  | ||||||
| 	protected final HashMap<Integer,Integer> idsObjectos; |  | ||||||
| 	 |  | ||||||
| 	/** Creates a new instance of ProcessoEvent */ |  | ||||||
| 	public ProcessoEvent( Object source, int accao, HashMap<Integer,Integer> idsObjectos ) |  | ||||||
| 	{ |  | ||||||
| 		this.source = source; |  | ||||||
| 		this.accao = accao; |  | ||||||
| 		this.idsObjectos = idsObjectos; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Object getSource() |  | ||||||
| 	{ |  | ||||||
| 		return source; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public int getAccao() |  | ||||||
| 	{ |  | ||||||
| 		return accao; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Integer getObjecto( Integer tipo ) |  | ||||||
| 	{ |  | ||||||
| 		return idsObjectos.get( tipo ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| } |  | ||||||
| @ -1,19 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ProcessoListener.java |  | ||||||
|  * |  | ||||||
|  * Created on 25 de Abril de 2007, 10:55 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author Frederico |  | ||||||
|  */ |  | ||||||
| public interface ProcessoListener |  | ||||||
| { |  | ||||||
| 	public void processoStateChanged( ProcessoEvent e ); |  | ||||||
| } |  | ||||||
| @ -1,413 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ProcessoPanel.java |  | ||||||
|  * |  | ||||||
|  * Created on March 21, 2007, 9:11 AM |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.dataui.ControllableComponent; |  | ||||||
| import com.evolute.utils.images.ImageIconLoader; |  | ||||||
| import com.evolute.utils.ui.DialogException; |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| 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.HashMap; |  | ||||||
| import java.util.Locale; |  | ||||||
| import java.util.Vector; |  | ||||||
| import javax.swing.*; |  | ||||||
| import siprp.ficha.FichaWindow; |  | ||||||
| import siprp.ficha.SaveExameListener; |  | ||||||
| import siprp.medicina.MedicinaConstants; |  | ||||||
| import siprp.medicina.MedicinaDataProvider; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresProcessoData; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author fpalma |  | ||||||
|  */ |  | ||||||
| public class ProcessoPanel extends JPanel |  | ||||||
| 		implements ActionListener, ControllableComponent,  |  | ||||||
| 					MedicinaConstants, ProcessoConstants, SaveExameListener |  | ||||||
| { |  | ||||||
| 	private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); |  | ||||||
| 	 |  | ||||||
| 	private JTextField estadoText; |  | ||||||
| 	private JTextField inicioText; |  | ||||||
| 	private JTextField fimText; |  | ||||||
| 	private JButton motivoButton; |  | ||||||
| //	private JButton novoECDButton;
 |  | ||||||
| //	private JButton novaConsultaButton;
 |  | ||||||
| 	private JButton emitirFAButton; |  | ||||||
| 	private JButton fecharButton; |  | ||||||
| 		 |  | ||||||
| 	protected JFrame owner; |  | ||||||
| 	 |  | ||||||
| 	private final Vector<ProcessoListener> PROCESSO_LISTENERS = new Vector<ProcessoListener>(); |  | ||||||
| 	 |  | ||||||
| 	private ProcessoDataProvider provider; |  | ||||||
| 	 |  | ||||||
| 	private Integer trabalhadorID = null; |  | ||||||
| 	private TrabalhadoresProcessoData processo; |  | ||||||
| 	 |  | ||||||
| 	/** Creates a new instance of ProcessoPanel */ |  | ||||||
| 	public ProcessoPanel( JFrame owner ) |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		this.owner = owner; |  | ||||||
| 		provider = ProcessoDataProvider.getProvider(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 		enableButtons(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		JLabel motivoLabel = new JLabel( "Motivo" ); |  | ||||||
| 		motivoButton = new JButton( "Escolher" ); |  | ||||||
| 		motivoButton.addActionListener( this ); |  | ||||||
| 		JLabel estadoLabel = new JLabel( "Estado" ); |  | ||||||
| 		estadoText = new JTextField(); |  | ||||||
| 		estadoText.setPreferredSize( new Dimension( 150, 20 ) ); |  | ||||||
| 		estadoText.setEditable( false ); |  | ||||||
| 		JLabel inicioLabel = new JLabel( "In\u00edcio" ); |  | ||||||
| 		inicioText = new JTextField(); |  | ||||||
| 		inicioText.setPreferredSize( new Dimension( 150, 20 ) ); |  | ||||||
| 		inicioText.setEditable( false ); |  | ||||||
| 		JLabel fimLabel = new JLabel( "Fim" ); |  | ||||||
| 		fimText = new JTextField(); |  | ||||||
| 		fimText.setPreferredSize( new Dimension( 150, 20 ) ); |  | ||||||
| 		fimText.setEditable( false ); |  | ||||||
| //		novoECDButton = new JButton( "Marcar ECDs" );
 |  | ||||||
| //		novoECDButton.setIcon( getIcon( ECDS_ICON_PATH ) );
 |  | ||||||
| //		novoECDButton.addActionListener( this );
 |  | ||||||
| //		novaConsultaButton = new JButton( "Marcar Consulta" );
 |  | ||||||
| //		novaConsultaButton.setIcon( getIcon( CONSULTA_ICON_PATH ) );
 |  | ||||||
| //		novaConsultaButton.addActionListener( this );
 |  | ||||||
| 		emitirFAButton = new JButton( "Emitir Ficha de Aptid\u00e3o" ); |  | ||||||
| 		emitirFAButton.setIcon( getIcon( FICHA_APTIDAO_ICON_PATH ) ); |  | ||||||
| 		emitirFAButton.addActionListener( this ); |  | ||||||
| 		fecharButton = new JButton( "Fechar Processo" ); |  | ||||||
| 		fecharButton.setIcon( getIcon( FECHAR_ICON_PATH ) ); |  | ||||||
| 		fecharButton.addActionListener( this ); |  | ||||||
| 		JPanel buttonPanel = new JPanel(); |  | ||||||
| 		 |  | ||||||
| 		double cols[] = |  | ||||||
| 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL }; |  | ||||||
| 		double rows[] = |  | ||||||
| 				new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; |  | ||||||
| 		 |  | ||||||
| 		TableLayout tableLayout = new TableLayout( cols, rows ); |  | ||||||
| 		setLayout( tableLayout ); |  | ||||||
| 		 |  | ||||||
| 		add( motivoLabel, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		add( motivoButton, new TableLayoutConstraints( 1, 0 ) ); |  | ||||||
| 		add( estadoLabel, new TableLayoutConstraints( 2, 0 ) ); |  | ||||||
| 		add( estadoText, new TableLayoutConstraints( 3, 0 ) ); |  | ||||||
| 		add( inicioLabel, new TableLayoutConstraints( 0, 1 ) ); |  | ||||||
| 		add( inicioText, new TableLayoutConstraints( 1, 1 ) ); |  | ||||||
| 		add( fimLabel, new TableLayoutConstraints( 2, 1 ) ); |  | ||||||
| 		add( fimText, new TableLayoutConstraints( 3, 1 ) ); |  | ||||||
| 		add( emitirFAButton, new TableLayoutConstraints( 0, 2, 1, 2 ) ); |  | ||||||
| 		add( fecharButton, new TableLayoutConstraints( 2, 2, 3, 2 ) ); |  | ||||||
| 		//add( buttonPanel, new TableLayoutConstraints( 0, 2, 3, 2 ) );
 |  | ||||||
| 		 |  | ||||||
| //		buttonPanel.setLayout( new GridLayout( 1, 2 ) );
 |  | ||||||
| ////		buttonPanel.add( novoECDButton );
 |  | ||||||
| ////		buttonPanel.add( novaConsultaButton );
 |  | ||||||
| //		buttonPanel.add( emitirFAButton );
 |  | ||||||
| //		buttonPanel.add( fecharButton );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void actionPerformed(ActionEvent e) |  | ||||||
| 	{ |  | ||||||
| 		Object source = e.getSource(); |  | ||||||
| 		if( source.equals( motivoButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			escolherMotivo(); |  | ||||||
| 		} |  | ||||||
| //		else if( source.equals( novoECDButton ) )
 |  | ||||||
| //		{
 |  | ||||||
| //			novoECD();
 |  | ||||||
| //		}
 |  | ||||||
| //		else if( source.equals( novaConsultaButton ) )
 |  | ||||||
| //		{
 |  | ||||||
| //			novaConsulta();
 |  | ||||||
| //		}
 |  | ||||||
| 		else if( source.equals( emitirFAButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			emitirFA(); |  | ||||||
| 		} |  | ||||||
| 		else if( source.equals( fecharButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			fecharProcesso(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected boolean gravarProcesso() |  | ||||||
| 	{ |  | ||||||
| 		if( processo.get( TrabalhadoresProcessoData.ESTADO ) == null ) |  | ||||||
| 		{ |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.ESTADO, PROCESSO_ABERTO_CODE ); |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.DATA_INICIO, new Date() ); |  | ||||||
| 		} |  | ||||||
| 		try |  | ||||||
| 		{ |  | ||||||
| 			provider.saveProcesso( processo ); |  | ||||||
| 			 |  | ||||||
| 			return true; |  | ||||||
| 		} |  | ||||||
| 		catch( Exception ex ) |  | ||||||
| 		{ |  | ||||||
| 			DialogException.showExceptionMessage( ex, "Erro a gravar processo", true ); |  | ||||||
| 			return false; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void escolherMotivo() |  | ||||||
| 	{ |  | ||||||
| 		EscolherMotivoDialog dialog = new EscolherMotivoDialog( owner ); |  | ||||||
| 		dialog.setVisible( true ); |  | ||||||
| 		Integer motivo[] = dialog.getMotivo(); |  | ||||||
| 		if( motivo != null && motivo[ 0 ] != null ) |  | ||||||
| 		{ |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.MOTIVO, motivo[ 0 ] ); |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.SUB_MOTIVO, motivo[ 1 ] ); |  | ||||||
| 			if( gravarProcesso() ) |  | ||||||
| 			{ |  | ||||||
| 				reload(); |  | ||||||
| 				HashMap<Integer,Integer> ids = new HashMap<Integer,Integer>(); |  | ||||||
| 				ids.put( ProcessoEvent.TIPO_PROCESSO, ( Integer ) processo.get( TrabalhadoresProcessoData.ID ) ); |  | ||||||
| 				ProcessoEvent event = new ProcessoEvent( this, ProcessoEvent.ACCAO_ESCOLHER_MOTIVO, ids ); |  | ||||||
| 				for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) |  | ||||||
| 				{ |  | ||||||
| 					PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void novoECD() |  | ||||||
| 	{ |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void novaConsulta() |  | ||||||
| 	{ |  | ||||||
| 		notifyListeners( ProcessoEvent.ACCAO_MARCAR_CONSULTA ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void emitirFA() |  | ||||||
| 	{ |  | ||||||
| 		if( trabalhadorID != null ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				FichaWindow.getWindow().editTrabalhador( trabalhadorID, this ); |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showException( ex ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void fecharProcesso() |  | ||||||
| 	{ |  | ||||||
| 		String options[] = new String[]{ "N\u00e3o", "Sim" }; |  | ||||||
| 		int option = JOptionPane.showOptionDialog( owner,  |  | ||||||
| 						"Tem a certeza que quer fechar o processo sem Ficha de Aptid\u00e3o?", |  | ||||||
| 						"Fechar", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,  |  | ||||||
| 						getIcon( FECHAR_ICON_PATH ), options, options[ 0 ] ); |  | ||||||
| 		if( option == 1 ) |  | ||||||
| 		{ |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.ESTADO, PROCESSO_FECHADO_CODE ); |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.DATA_FIM, new Date() ); |  | ||||||
| 			if( gravarProcesso() ) |  | ||||||
| 			{ |  | ||||||
| 				enableButtons(); |  | ||||||
| 				notifyListeners( ProcessoEvent.ACCAO_FECHAR ); |  | ||||||
| 				reload(); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| 		processo = null; |  | ||||||
| 		estadoText.setText( "" ); |  | ||||||
| 		inicioText.setText( "" ); |  | ||||||
| 		fimText.setText( "" ); |  | ||||||
| 		motivoButton.setText( "Escolher" ); |  | ||||||
| 		enableButtons(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void enableButtons() |  | ||||||
| 	{ |  | ||||||
| 		String estado = null; |  | ||||||
| 		Integer motivo = null; |  | ||||||
| 		boolean consultasPorRealizar = false; |  | ||||||
| 		boolean ecdsPorRealizar = false; |  | ||||||
| 		if( processo != null ) |  | ||||||
| 		{ |  | ||||||
| 			Integer id = ( Integer ) processo.get( TrabalhadoresProcessoData.ID ); |  | ||||||
| 			estado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO ); |  | ||||||
| 			motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO ); |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				if( id != null ) |  | ||||||
| 				{ |  | ||||||
| 					consultasPorRealizar = provider.getProcessoTemConsultasPorRealizar( id ); |  | ||||||
| 					ecdsPorRealizar = provider.getProcessoTemECDsPorRealizar( id ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				ex.printStackTrace(); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| //		novoECDButton.setEnabled( processo != null && motivo != null );
 |  | ||||||
| //		novoECDButton.setEnabled( false );
 |  | ||||||
| //		novaConsultaButton.setEnabled( processo != null && motivo != null && !consultasPorRealizar );
 |  | ||||||
| 		emitirFAButton.setEnabled( processo != null && motivo != null ); |  | ||||||
| 		fecharButton.setEnabled( processo != null && motivo != null && PROCESSO_ABERTO_CODE.equals( estado ) ); |  | ||||||
| 		motivoButton.setEnabled( processo != null ); |  | ||||||
| 	} |  | ||||||
| 		 |  | ||||||
| 	public void addProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.add( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void removeProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.remove( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Icon getIcon( String path ) |  | ||||||
| 	{ |  | ||||||
| 		try |  | ||||||
| 		{ |  | ||||||
| 			return ImageIconLoader.loadImageIcon( getClass(), path ); |  | ||||||
| 		} |  | ||||||
| 		catch( Exception ex ) |  | ||||||
| 		{ |  | ||||||
| 			ex.printStackTrace(); |  | ||||||
| 			return null; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Object save() |  | ||||||
| 	{ |  | ||||||
| 		return null; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void enableComponents( boolean enable ) |  | ||||||
| 	{ |  | ||||||
| 		 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void fill( Object value ) |  | ||||||
| 	{ |  | ||||||
| 		clear(); |  | ||||||
| 		if( trabalhadorID == null ) |  | ||||||
| 		{ |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		if( value != null ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				processo = provider.getProcessoByID( ( Integer ) value ); |  | ||||||
| 				if( processo == null ) |  | ||||||
| 				{ |  | ||||||
| 					processo = new TrabalhadoresProcessoData(); |  | ||||||
| 					processo.set( TrabalhadoresProcessoData.TRABALHADOR_ID, trabalhadorID ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a carregar dados do processo", true ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		reload(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void reload() |  | ||||||
| 	{ |  | ||||||
| 		enableButtons(); |  | ||||||
| 		if( processo != null ) |  | ||||||
| 		{ |  | ||||||
| 			String estado = null; |  | ||||||
| 			Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO ); |  | ||||||
| 			if( dataInicio != null ) |  | ||||||
| 			{ |  | ||||||
| 				inicioText.setText( D_F.format( dataInicio ) ); |  | ||||||
| 			} |  | ||||||
| 			Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM ); |  | ||||||
| 			if( dataFim != null ) |  | ||||||
| 			{ |  | ||||||
| 				fimText.setText( D_F.format( dataFim ) ); |  | ||||||
| 			} |  | ||||||
| 			estado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO ); |  | ||||||
| 			if( estado == null ) |  | ||||||
| 			{ |  | ||||||
| 				estadoText.setText( ProcessoDataProvider.PROCESSO_POR_ABRIR_DESCRIPTION ); |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 				estadoText.setText( ProcessoDataProvider.ESTADO_PROCESSO_BY_CODE.get( estado ) ); |  | ||||||
| 			} |  | ||||||
| 			Integer motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO ); |  | ||||||
| 			Integer subMotivo = ( Integer ) processo.get( TrabalhadoresProcessoData.SUB_MOTIVO ); |  | ||||||
| 			String motivoStr = "Motivo"; |  | ||||||
| 			if( motivo != null ) |  | ||||||
| 			{ |  | ||||||
| 				motivoStr = MedicinaDataProvider.MOTIVOS_BY_ID.get( motivo ); |  | ||||||
| 				if( subMotivo != null ) |  | ||||||
| 				{ |  | ||||||
| 					motivoStr += " > " + MedicinaDataProvider.SUB_MOTIVOS_BY_ID.get( subMotivo ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			motivoButton.setText( motivoStr ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setTrabalhadorID( Integer trabalhadorID ) |  | ||||||
| 	{ |  | ||||||
| 		this.trabalhadorID = trabalhadorID; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void exameSaved( Integer trabalhadorID, Integer exameID ) |  | ||||||
| 	{ |  | ||||||
| 		if( trabalhadorID.equals( this.trabalhadorID ) ) |  | ||||||
| 		{ |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.ESTADO, PROCESSO_FECHADO_CODE ); |  | ||||||
| 			processo.set( TrabalhadoresProcessoData.DATA_FIM, new Date() ); |  | ||||||
| 			if( gravarProcesso() ) |  | ||||||
| 			{ |  | ||||||
| 				enableButtons(); |  | ||||||
| 				notifyListeners( ProcessoEvent.ACCAO_EMITIR_FA ); |  | ||||||
| 				reload(); |  | ||||||
| 			} |  | ||||||
| 			System.out.println( "NOTIFIED EXAME: " + exameID ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void notifyListeners( int accao ) |  | ||||||
| 	{ |  | ||||||
| 		HashMap<Integer,Integer> ids = new HashMap<Integer,Integer>(); |  | ||||||
| 		ids.put( ProcessoEvent.TIPO_PROCESSO, ( Integer ) processo.get( TrabalhadoresProcessoData.ID ) ); |  | ||||||
| 		ProcessoEvent event = new ProcessoEvent( this, accao, ids ); |  | ||||||
| 		for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,254 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ProcessoUpperPanel.java |  | ||||||
|  * |  | ||||||
|  * Created on February 1, 2006, 6:48 PM |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo; |  | ||||||
| 
 |  | ||||||
| import java.awt.*; |  | ||||||
| import javax.swing.*; |  | ||||||
| import javax.swing.event.*; |  | ||||||
| import java.util.*; |  | ||||||
| import com.evolute.utils.dataui.*; |  | ||||||
| import com.evolute.utils.tables.*; |  | ||||||
| import com.evolute.utils.ui.*; |  | ||||||
| import siprp.medicina.MedicinaDataProvider; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author fpalma |  | ||||||
|  */ |  | ||||||
| public class ProcessoUpperPanel extends JPanel |  | ||||||
| 		implements ListSelectionListener, ControllableComponent |  | ||||||
| { |  | ||||||
| 	protected BaseTable empresasTable; |  | ||||||
| 	protected VectorTableModel empresasModel; |  | ||||||
| 	protected BaseTable estabelecimentosTable; |  | ||||||
| 	protected VectorTableModel estabelecimentosModel; |  | ||||||
| 	protected BaseTable trabalhadoresTable; |  | ||||||
| 	protected VectorTableModel trabalhadoresModel; |  | ||||||
| 	 |  | ||||||
| 	protected MedicinaDataProvider provider; |  | ||||||
| 	 |  | ||||||
| 	protected final Vector listeners; |  | ||||||
| 	 |  | ||||||
| 	protected boolean editing = false; |  | ||||||
| 	 |  | ||||||
| 	/** |  | ||||||
| 	 * Creates a new instance of ProcessoUpperPanel |  | ||||||
| 	 */ |  | ||||||
| 	public ProcessoUpperPanel() |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); |  | ||||||
| 		listeners = new Vector(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		empresasModel = new VectorTableModel( new String[]{ "empresas" } ); |  | ||||||
| 		empresasTable = new BaseTable( empresasModel ); |  | ||||||
| 		empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); |  | ||||||
| 		empresasTable.setNonResizableNorReordable(); |  | ||||||
| 		JScrollPane empresasScroll =  |  | ||||||
| 				new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, |  | ||||||
| 									JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); |  | ||||||
| 		empresasTable.getSelectionModel().addListSelectionListener( this ); |  | ||||||
| 		estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } ); |  | ||||||
| 		estabelecimentosTable = new BaseTable( estabelecimentosModel ); |  | ||||||
| 		estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); |  | ||||||
| 		estabelecimentosTable.setNonResizableNorReordable(); |  | ||||||
| 		JScrollPane estabelecimentosScroll =  |  | ||||||
| 				new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, |  | ||||||
| 									JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); |  | ||||||
| 		estabelecimentosTable.getSelectionModel().addListSelectionListener( this ); |  | ||||||
| 		trabalhadoresModel = new VectorTableModel( new String[]{ "trabalhadores" } ); |  | ||||||
| 		trabalhadoresTable = new BaseTable( trabalhadoresModel ); |  | ||||||
| 		trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); |  | ||||||
| 		trabalhadoresTable.setNonResizableNorReordable(); |  | ||||||
| 		JScrollPane trabalhadoresScroll =  |  | ||||||
| 				new JScrollPane( trabalhadoresTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, |  | ||||||
| 									JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); |  | ||||||
| 		trabalhadoresTable.getSelectionModel().addListSelectionListener( this ); |  | ||||||
| 		 |  | ||||||
| 		GridBagLayout gridbag = new GridBagLayout(); |  | ||||||
| 		setLayout( gridbag ); |  | ||||||
| 		GridBagConstraints constraints = new GridBagConstraints(); |  | ||||||
| 		constraints.insets = new Insets( 1, 1, 1, 1 ); |  | ||||||
| 		constraints.fill = GridBagConstraints.BOTH; |  | ||||||
| 		constraints.gridwidth = 1; |  | ||||||
| 		constraints.gridheight = 1; |  | ||||||
| 		constraints.weightx = 0.3; |  | ||||||
| 		constraints.weighty = 1; |  | ||||||
| 		 |  | ||||||
| 		gridbag.setConstraints( empresasScroll, constraints ); |  | ||||||
| 		 |  | ||||||
| 		gridbag.setConstraints( estabelecimentosScroll, constraints ); |  | ||||||
| 		 |  | ||||||
| 		constraints.weightx = 0.4; |  | ||||||
| 		constraints.gridheight = GridBagConstraints.REMAINDER; |  | ||||||
| 		gridbag.setConstraints( trabalhadoresScroll, constraints ); |  | ||||||
| 		 |  | ||||||
| 		add( empresasScroll ); |  | ||||||
| 		add( estabelecimentosScroll ); |  | ||||||
| 		add( trabalhadoresScroll ); |  | ||||||
| 		 |  | ||||||
| 		ColumnizedMappable empresas[] = provider.getAllEmpresas(); |  | ||||||
| 		Vector values = empresasModel.getValues(); |  | ||||||
| 		values.addAll( Arrays.asList( empresas ) ); |  | ||||||
| 		empresasModel.setValues( values ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void valueChanged( ListSelectionEvent e ) |  | ||||||
| 	{ |  | ||||||
| 		Object source = e.getSource(); |  | ||||||
| 		if( e.getValueIsAdjusting() ) |  | ||||||
| 		{ |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		if( source.equals( empresasTable.getSelectionModel() ) ) |  | ||||||
| 		{ |  | ||||||
| 			carregarEstabelecimentos(); |  | ||||||
| 		} |  | ||||||
| 		else if( source.equals( estabelecimentosTable.getSelectionModel() ) ) |  | ||||||
| 		{ |  | ||||||
| 			carregarTrabalhadores(); |  | ||||||
| 		} |  | ||||||
| 		else if( source.equals( trabalhadoresTable.getSelectionModel() ) ) |  | ||||||
| 		{ |  | ||||||
| 			notifyListeners( e ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void carregarEstabelecimentos() |  | ||||||
| 	{ |  | ||||||
| 		estabelecimentosTable.clearSelection(); |  | ||||||
| 		int selected = empresasTable.getSelectedRow(); |  | ||||||
| 		estabelecimentosModel.clearAll(); |  | ||||||
| 		if( selected > -1 ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID(); |  | ||||||
| 				ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID); |  | ||||||
| 				Vector values = estabelecimentosModel.getValues(); |  | ||||||
| 				values.addAll( Arrays.asList( estabelecimentos ) ); |  | ||||||
| 				estabelecimentosModel.setValues( values ); |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true ); |  | ||||||
| 				estabelecimentosModel.clearAll(); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void carregarTrabalhadores() |  | ||||||
| 	{ |  | ||||||
| 		trabalhadoresTable.clearSelection(); |  | ||||||
| 		int selected = estabelecimentosTable.getSelectedRow(); |  | ||||||
| 		trabalhadoresModel.clearAll(); |  | ||||||
| 		if( selected > -1 ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID(); |  | ||||||
| 				ColumnizedMappable trabalhadores[] = provider.getAllTrabalhadoresForEstabelecimento( estabelecimentoID ); |  | ||||||
| 				Vector values = trabalhadoresModel.getValues(); |  | ||||||
| 				values.addAll( Arrays.asList( trabalhadores ) ); |  | ||||||
| 				trabalhadoresModel.setValues( values ); |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a carregar trabalhadores.", true ); |  | ||||||
| 				trabalhadoresModel.clearAll(); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void notifyListeners( ListSelectionEvent e ) |  | ||||||
| 	{ |  | ||||||
| 		for( int n = 0; n < listeners.size(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			ListSelectionEvent event =  |  | ||||||
| 					new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() ); |  | ||||||
| 			( ( ListSelectionListener ) listeners.elementAt( n ) ).valueChanged( event ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void addListSelectionListener( ListSelectionListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		listeners.add( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void removeSelectionListener( ListSelectionListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		listeners.remove( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| //		empresasTable.clearSelection();
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void fill( Object value ) |  | ||||||
| 	{ |  | ||||||
| 		if( value == null ) |  | ||||||
| 		{ |  | ||||||
| 			clear(); |  | ||||||
| 		} |  | ||||||
| 		Integer ids[] = ( Integer [] ) value; |  | ||||||
| 		for( int n = 0; n < empresasTable.getRowCount(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) ) |  | ||||||
| 			{ |  | ||||||
| 				empresasTable.setRowSelectionInterval( n, n ); |  | ||||||
| 				break; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 		for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) ) |  | ||||||
| 			{ |  | ||||||
| 				estabelecimentosTable.setRowSelectionInterval( n, n ); |  | ||||||
| 				break; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 		for( int n = 0; n < trabalhadoresTable.getRowCount(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			if( ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( n ) ).getID().equals( ids[ 2 ] ) ) |  | ||||||
| 			{ |  | ||||||
| 				trabalhadoresTable.setRowSelectionInterval( n, n ); |  | ||||||
| 				break; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Object save() |  | ||||||
| 	{ |  | ||||||
| 		int empresaSelected = empresasTable.getSelectedRow(); |  | ||||||
| 		int estabelecimentoSelected = estabelecimentosTable.getSelectedRow(); |  | ||||||
| 		int trabalhadorSelected = trabalhadoresTable.getSelectedRow(); |  | ||||||
| 		return new Integer[]{ |  | ||||||
| 				empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(), |  | ||||||
| 				estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID(), |  | ||||||
| 				trabalhadorSelected == -1 ? null : ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( trabalhadorSelected ) ).getID() |  | ||||||
| 			}; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setEnabled( boolean enable ) |  | ||||||
| 	{ |  | ||||||
| 		editing = !enable; |  | ||||||
| 		empresasTable.setEnabled( enable ); |  | ||||||
| 		estabelecimentosTable.setEnabled( enable ); |  | ||||||
| 		trabalhadoresTable.setEnabled( enable ); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,104 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ProcessoWindow.java |  | ||||||
|  * |  | ||||||
|  * Created on March 21, 2007, 9:06 AM |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo; |  | ||||||
| //
 |  | ||||||
| //import info.clearthought.layout.TableLayout;
 |  | ||||||
| //import info.clearthought.layout.TableLayoutConstraints;
 |  | ||||||
| //
 |  | ||||||
| //import java.awt.Dimension;
 |  | ||||||
| //
 |  | ||||||
| //import javax.swing.BorderFactory;
 |  | ||||||
| //import javax.swing.JFrame;
 |  | ||||||
| //import javax.swing.SwingUtilities;
 |  | ||||||
| //
 |  | ||||||
| //import siprp.medicina.processo.detalhes.DetalhesConsultaPanel;
 |  | ||||||
| //import siprp.medicina.processo.detalhes.DetalhesProcessoPanel;
 |  | ||||||
| //import siprp.medicina.processo.estrutura.EstruturaProcessoPanel;
 |  | ||||||
| //
 |  | ||||||
| //import com.evolute.utils.tracker.TrackableWindow;
 |  | ||||||
| //
 |  | ||||||
| ///**
 |  | ||||||
| // *
 |  | ||||||
| // * @author fpalma
 |  | ||||||
| // */
 |  | ||||||
| //public class ProcessoWindow extends JFrame
 |  | ||||||
| //		implements TrackableWindow
 |  | ||||||
| //{
 |  | ||||||
| //	private static final long serialVersionUID = 1L;
 |  | ||||||
| //
 |  | ||||||
| //	public static final String TITLE = "Processos de trabalhadores";
 |  | ||||||
| //	
 |  | ||||||
| //	private ProcessoUpperPanel upperPanel;
 |  | ||||||
| //	private EstruturaProcessoPanel estruturaPanel;
 |  | ||||||
| //	private ProcessoPanel processoPanel;
 |  | ||||||
| //	private DetalhesProcessoPanel detalhesPanel;
 |  | ||||||
| //	
 |  | ||||||
| //	/** Creates a new instance of ProcessoWindow */
 |  | ||||||
| //	public ProcessoWindow()
 |  | ||||||
| //		throws Exception
 |  | ||||||
| //	{
 |  | ||||||
| //		setupComponents();
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	private void setupComponents()
 |  | ||||||
| //		throws Exception
 |  | ||||||
| //	{
 |  | ||||||
| //		setSize( 1024, 700 );
 |  | ||||||
| //		setTitle( TITLE );
 |  | ||||||
| //		
 |  | ||||||
| //		upperPanel = new ProcessoUpperPanel();
 |  | ||||||
| //		upperPanel.setPreferredSize( new Dimension( 1024, 200 ) );
 |  | ||||||
| //		estruturaPanel = new EstruturaProcessoPanel();
 |  | ||||||
| //		processoPanel = new ProcessoPanel( this );
 |  | ||||||
| //		processoPanel.setBorder( BorderFactory.createEtchedBorder() );
 |  | ||||||
| //		detalhesPanel = new DetalhesProcessoPanel( this );
 |  | ||||||
| //		detalhesPanel.setBorder( BorderFactory.createEtchedBorder() );
 |  | ||||||
| //		double cols[] =
 |  | ||||||
| //				new double[]{ TableLayout.FILL, TableLayout.PREFERRED };
 |  | ||||||
| //		double rows[] = 
 |  | ||||||
| //				new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL };
 |  | ||||||
| //		
 |  | ||||||
| //		TableLayout tableLayout = new TableLayout( cols, rows );
 |  | ||||||
| //		setLayout( tableLayout );
 |  | ||||||
| //		
 |  | ||||||
| //		add( upperPanel, new TableLayoutConstraints( 0, 0, 1, 0 ) );
 |  | ||||||
| //		add( estruturaPanel, new TableLayoutConstraints( 0, 1, 0, 2 ) );
 |  | ||||||
| //		add( processoPanel, new TableLayoutConstraints( 1, 1 ) );
 |  | ||||||
| ////		add( detalhesPanel, new TableLayoutConstraints( 1, 2 ) );
 |  | ||||||
| //		add( new DetalhesConsultaPanel( this ), new TableLayoutConstraints( 1, 2 ) );
 |  | ||||||
| //		new ProcessoController( upperPanel, estruturaPanel, processoPanel, detalhesPanel );
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void refresh()
 |  | ||||||
| //	{
 |  | ||||||
| //	}
 |  | ||||||
| //
 |  | ||||||
| //	public void open()
 |  | ||||||
| //	{
 |  | ||||||
| //		setVisible( true );
 |  | ||||||
| //	}
 |  | ||||||
| //	
 |  | ||||||
| //	public void close()
 |  | ||||||
| //	{
 |  | ||||||
| //		SwingUtilities.invokeLater( new Runnable() {
 |  | ||||||
| //			public void run()
 |  | ||||||
| //			{
 |  | ||||||
| //				setVisible( false );
 |  | ||||||
| //				dispose();
 |  | ||||||
| //			}
 |  | ||||||
| //		} );
 |  | ||||||
| //	}
 |  | ||||||
| //
 |  | ||||||
| //	public boolean closeIfPossible()
 |  | ||||||
| //	{
 |  | ||||||
| //		close();
 |  | ||||||
| //		return true;
 |  | ||||||
| //	}
 |  | ||||||
| //}
 |  | ||||||
| @ -1,367 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ConsultaPanel.java |  | ||||||
|  * |  | ||||||
|  * Created on March 22, 2007, 10:58 AM |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
| import java.awt.event.ActionListener; |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.Vector; |  | ||||||
| 
 |  | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JLabel; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.event.ChangeEvent; |  | ||||||
| import javax.swing.event.ChangeListener; |  | ||||||
| 
 |  | ||||||
| import siprp.medicina.MedicinaConstants; |  | ||||||
| import siprp.medicina.processo.ProcessoConstants; |  | ||||||
| import siprp.medicina.processo.ProcessoDataProvider; |  | ||||||
| import siprp.medicina.processo.ProcessoEvent; |  | ||||||
| import siprp.medicina.processo.ProcessoListener; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresConsultasData; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresConsultasDatasData; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.Singleton; |  | ||||||
| import com.evolute.utils.data.IDObject; |  | ||||||
| import com.evolute.utils.jdo.JDOProvider; |  | ||||||
| import com.evolute.utils.ui.DialogException; |  | ||||||
| import com.evolute.utils.ui.calendar.JCalendarPanel; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author fpalma |  | ||||||
|  */ |  | ||||||
| public class DataConsultaPanel extends JPanel |  | ||||||
| 		implements ActionListener, MedicinaConstants, ChangeListener |  | ||||||
| { |  | ||||||
| 	protected JFrame owner; |  | ||||||
| 	protected JCalendarPanel dataConsultaPanel; |  | ||||||
| 	protected JButton estadoButton; |  | ||||||
| 	protected JButton emailButton; |  | ||||||
| 	protected JButton observacoesButton; |  | ||||||
| 	protected ObservacoesDialog observacoesDialog; |  | ||||||
| 	 |  | ||||||
| 	protected final Vector<ProcessoListener> PROCESSO_LISTENERS = new Vector<ProcessoListener>(); |  | ||||||
| 	protected JDOProvider JDO; |  | ||||||
| 	protected ProcessoDataProvider provider; |  | ||||||
| 	 |  | ||||||
| 	protected Integer trabalhadorID; |  | ||||||
| 	protected Integer processoID; |  | ||||||
| 	protected TrabalhadoresConsultasData consulta; |  | ||||||
| 	protected TrabalhadoresConsultasDatasData consultaData; |  | ||||||
| 	 |  | ||||||
| 	/** Creates a new instance of ConsultaPanel */ |  | ||||||
| 	public DataConsultaPanel( JFrame owner ) |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		this.owner = owner; |  | ||||||
| 		JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); |  | ||||||
| 		provider = ProcessoDataProvider.getProvider(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		JLabel dataLabel = new JLabel( "Data" ); |  | ||||||
| 		dataConsultaPanel = new JCalendarPanel( null ); |  | ||||||
| 		dataConsultaPanel.addChangeListener( this ); |  | ||||||
| 		estadoButton = new JButton( " " ); |  | ||||||
| 		estadoButton.addActionListener( this ); |  | ||||||
| 		emailButton = new JButton( "Email" ); |  | ||||||
| 		emailButton.addActionListener( this ); |  | ||||||
| 		observacoesButton = new JButton( "Coment\u00e1rio" ); |  | ||||||
| 		observacoesButton.addActionListener( this ); |  | ||||||
| 		 |  | ||||||
| 		double cols[] = |  | ||||||
| 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL }; |  | ||||||
| 		double rows[] =  |  | ||||||
| 				new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM,  |  | ||||||
| 								TableLayout.MINIMUM, TableLayout.MINIMUM }; |  | ||||||
| 		 |  | ||||||
| 		TableLayout tableLayout = new TableLayout( cols, rows ); |  | ||||||
| 		tableLayout.setVGap( 5 ); |  | ||||||
| 		setLayout( tableLayout ); |  | ||||||
| 		 |  | ||||||
| 		add( dataLabel, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		add( dataConsultaPanel, new TableLayoutConstraints( 1, 0 ) ); |  | ||||||
| 		add( estadoButton, new TableLayoutConstraints( 0, 1, 1, 1 ) ); |  | ||||||
| 		add( emailButton, new TableLayoutConstraints( 0, 2, 1, 2 ) ); |  | ||||||
| 		add( observacoesButton, new TableLayoutConstraints( 0, 3, 1, 3 ) ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void actionPerformed(ActionEvent e) |  | ||||||
| 	{ |  | ||||||
| 		Object source = e.getSource(); |  | ||||||
| 		if( source.equals( observacoesButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			editarObservacoes(); |  | ||||||
| 		} |  | ||||||
| 		else if( source.equals( emailButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			enviarEmail(); |  | ||||||
| 		} |  | ||||||
| 		else if( source.equals( estadoButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			mudarEstado(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void stateChanged(ChangeEvent e) |  | ||||||
| 	{ |  | ||||||
| 		Object source = e.getSource(); |  | ||||||
| 		 |  | ||||||
| 		if( source.equals( dataConsultaPanel ) ) |  | ||||||
| 		{ |  | ||||||
| 			Date data = dataConsultaPanel.getDate(); |  | ||||||
| 			if( data == null ) |  | ||||||
| 			{ |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				boolean nova = false; |  | ||||||
| 				if( consulta == null ) |  | ||||||
| 				{ |  | ||||||
| 					nova = true; |  | ||||||
| 					Integer consultaID = provider.getConsultaEmAbertoForProcesso( processoID ); |  | ||||||
| 					if( consultaID == null ) |  | ||||||
| 					{ |  | ||||||
| 						consulta = new TrabalhadoresConsultasData(); |  | ||||||
| 						consulta.set( TrabalhadoresConsultasData.TRABALHADOR_ID, trabalhadorID ); |  | ||||||
| 						consulta.set( TrabalhadoresConsultasData.PROCESSO_ID, processoID ); |  | ||||||
| 						consulta.set( TrabalhadoresConsultasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); |  | ||||||
| 					} |  | ||||||
| 					else |  | ||||||
| 					{ |  | ||||||
| 						consulta = provider.getConsultaByID( consultaID ); |  | ||||||
| 						consulta.set( TrabalhadoresConsultasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 				consulta.set( TrabalhadoresConsultasData.DATA, data ); |  | ||||||
| 				provider.saveConsulta( consulta ); |  | ||||||
| 				if( consultaData == null ) |  | ||||||
| 				{ |  | ||||||
| 					Integer consultaID = ( Integer )consulta.get( TrabalhadoresConsultasData.ID ); |  | ||||||
| 					Integer consultaDataID = provider.getLastConsultaDataIDForConsulta( consultaID ); |  | ||||||
| 					if( consultaDataID == null || nova ) |  | ||||||
| 					{ |  | ||||||
| 						consultaData = new TrabalhadoresConsultasDatasData(); |  | ||||||
| 						consultaData.set( TrabalhadoresConsultasDatasData.TRABALHADORES_CONSULTAS_ID, consultaID ); |  | ||||||
| 						consultaData.set( TrabalhadoresConsultasDatasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ); |  | ||||||
| 					} |  | ||||||
| 					else |  | ||||||
| 					{ |  | ||||||
| 						consultaData = provider.getConsultaDataByID( consultaDataID ); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 				consultaData.set( TrabalhadoresConsultasDatasData.DATA, data ); |  | ||||||
| 				provider.saveConsultaData( consultaData ); |  | ||||||
| 				 |  | ||||||
| 				notifyListeners( ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO ); |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a gravar dados da consulta", true ); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void editarObservacoes() |  | ||||||
| 	{ |  | ||||||
| 		if( observacoesDialog == null ) |  | ||||||
| 		{ |  | ||||||
| 			observacoesDialog = new ObservacoesDialog( owner ); |  | ||||||
| 		} |  | ||||||
| 		String texto = ""; |  | ||||||
| 		try |  | ||||||
| 		{ |  | ||||||
| 			Integer dataID = provider.getLastConsultaDataIDForConsulta( ( Integer ) consulta.get( TrabalhadoresConsultasData.ID ) ); |  | ||||||
| 			IDObject observacoes = provider.getObservacoesConsultaData( dataID ); |  | ||||||
| 			if( observacoes != null ) |  | ||||||
| 			{ |  | ||||||
| 				texto = observacoes.toString(); |  | ||||||
| 			} |  | ||||||
| 			texto = observacoesDialog.editarObservacao( texto ); |  | ||||||
| 			if( texto != null ) |  | ||||||
| 			{ |  | ||||||
| 				provider.saveObservacoesConsultaData( dataID, texto ); |  | ||||||
| 				notifyListeners( ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		catch( Exception ex ) |  | ||||||
| 		{ |  | ||||||
| 			DialogException.showExceptionMessage( ex, "Erro a carregar dados", true ); |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void enviarEmail() |  | ||||||
| 	{ |  | ||||||
| 		if( consulta == null ) |  | ||||||
| 		{ |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		try |  | ||||||
| 		{ |  | ||||||
| 			Integer consultaDataID; |  | ||||||
| 			if( consultaData == null ) |  | ||||||
| 			{ |  | ||||||
| 				Integer consultaID = ( Integer )consulta.get( TrabalhadoresConsultasDatasData.ID ); |  | ||||||
| 				consultaDataID = provider.getLastConsultaDataIDForConsulta( consultaID ); |  | ||||||
| 				consultaData = provider.getConsultaDataByID( consultaDataID ); |  | ||||||
| 			} |  | ||||||
| 			consultaDataID = ( Integer ) consultaData.get( TrabalhadoresConsultasDatasData.ID ); |  | ||||||
| 			provider.saveEmailConsultaData( consultaDataID, "teste@siprp.pt", "Email de teste.", "" ); |  | ||||||
| 			notifyListeners( ProcessoEvent.ACCAO_ESCREVER_MAIL ); |  | ||||||
| 		} |  | ||||||
| 		catch( Exception ex ) |  | ||||||
| 		{ |  | ||||||
| 			DialogException.showExceptionMessage( ex, "Erro a gravar dados da consulta", true ); |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void mudarEstado() |  | ||||||
| 	{ |  | ||||||
| 		if( consulta == null ) |  | ||||||
| 		{ |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); |  | ||||||
| 		EstadoChooser chooser =  |  | ||||||
| 			new EstadoChooser( owner, ProcessoConstants.TIPO_CONSULTA,  |  | ||||||
| 								estado != null ? estado.intValue() : MedicinaConstants.ESTADO_POR_REALIZAR ); |  | ||||||
| 		chooser.setVisible( true ); |  | ||||||
| 		int novoEstado = chooser.getEstado(); |  | ||||||
| 		if( estado == null || estado.intValue() != novoEstado ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				consulta.set( TrabalhadoresConsultasData.ESTADO, new Integer( novoEstado ) ); |  | ||||||
| 				provider.saveConsulta( consulta ); |  | ||||||
| 				if( consultaData == null ) |  | ||||||
| 				{ |  | ||||||
| 					Integer consultaID = ( Integer )consulta.get( TrabalhadoresConsultasDatasData.ID ); |  | ||||||
| 					Integer consultaDataID = provider.getLastConsultaDataIDForConsulta( consultaID ); |  | ||||||
| 					consultaData = provider.getConsultaDataByID( consultaDataID ); |  | ||||||
| 				} |  | ||||||
| 				consultaData.set( TrabalhadoresConsultasDatasData.ESTADO, new Integer( novoEstado ) ); |  | ||||||
| 				provider.saveConsultaData( consultaData ); |  | ||||||
| 				 |  | ||||||
| 				notifyListeners( ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO ); |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a gravar dados da consulta", true ); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void addProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.add( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void removeProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.remove( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| 		dataConsultaPanel.setDate( null ); |  | ||||||
| 		estadoButton.setText( " " ); |  | ||||||
| 		consulta = null; |  | ||||||
| 		consultaData = null; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void fill( Object value ) |  | ||||||
| 	{ |  | ||||||
| 		clear(); |  | ||||||
| 		if( value != null ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				consulta = ( TrabalhadoresConsultasData ) JDO.load( TrabalhadoresConsultasData.class, ( Integer ) value ); |  | ||||||
| 				Date data = ( Date ) consulta.get( TrabalhadoresConsultasData.DATA ); |  | ||||||
| 				Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); |  | ||||||
| 				dataConsultaPanel.setDate( data ); |  | ||||||
| 				if( estado != null ) |  | ||||||
| 				{ |  | ||||||
| 					estadoButton.setText( ESTADOS_CONSULTA_STR[ estado.intValue() ] ); |  | ||||||
| 				} |  | ||||||
| 				else |  | ||||||
| 				{ |  | ||||||
| 					estadoButton.setText( " " ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a carregar dados da consulta", true ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		enableButtons(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void enableButtons() |  | ||||||
| 	{ |  | ||||||
| 		if( consulta != null ) |  | ||||||
| 		{ |  | ||||||
| 			Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); |  | ||||||
| 			dataConsultaPanel.setEnabled( estado == null || estado.intValue() == ESTADO_POR_REALIZAR ); |  | ||||||
| 			estadoButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); |  | ||||||
| 			emailButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); |  | ||||||
| 			observacoesButton.setEnabled( consulta.get( TrabalhadoresConsultasData.DATA ) != null ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			dataConsultaPanel.setEnabled( true ); |  | ||||||
| 			estadoButton.setEnabled( false ); |  | ||||||
| 			emailButton.setEnabled( false ); |  | ||||||
| 			observacoesButton.setEnabled( false ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setTrabalhadorID( Integer trabalhadorID ) |  | ||||||
| 	{ |  | ||||||
| 		this.trabalhadorID = trabalhadorID; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setProcessoID( Integer processoID ) |  | ||||||
| 	{ |  | ||||||
| 		this.processoID = processoID; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void notifyListeners( int accao ) |  | ||||||
| 	{ |  | ||||||
| 		HashMap<Integer,Integer> ids = new HashMap<Integer,Integer>(); |  | ||||||
| 		ids.put( ProcessoEvent.TIPO_PROCESSO, processoID ); |  | ||||||
| 		if( consulta != null ) |  | ||||||
| 		{ |  | ||||||
| 			ids.put( ProcessoEvent.TIPO_CONSULTA, ( Integer ) consulta.get( TrabalhadoresConsultasData.ID ) ); |  | ||||||
| 		} |  | ||||||
| 		if( consultaData != null ) |  | ||||||
| 		{ |  | ||||||
| 			ids.put( ProcessoEvent.TIPO_DATA, ( Integer ) consulta.get( TrabalhadoresConsultasDatasData.ID ) ); |  | ||||||
| 		} |  | ||||||
| 		ProcessoEvent event = new ProcessoEvent( this, accao, ids ); |  | ||||||
| 		for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,145 +0,0 @@ | |||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
| import java.awt.event.ActionListener; |  | ||||||
| import java.util.Vector; |  | ||||||
| 
 |  | ||||||
| import javax.swing.Icon; |  | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JScrollPane; |  | ||||||
| import javax.swing.JTextField; |  | ||||||
| 
 |  | ||||||
| import siprp.medicina.MedicinaConstants; |  | ||||||
| import siprp.medicina.prestadores.PrestadoresDataProvider; |  | ||||||
| import siprp.medicina.prestadores.data.PrestadoresData; |  | ||||||
| import siprp.medicina.processo.ProcessoConstants; |  | ||||||
| import siprp.medicina.processo.ProcessoDataProvider; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresConsultasData; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.dataui.ControllableComponent; |  | ||||||
| import com.evolute.utils.images.ImageIconLoader; |  | ||||||
| import com.evolute.utils.tables.BaseTable; |  | ||||||
| import com.evolute.utils.tables.ColumnizedObjectArray; |  | ||||||
| import com.evolute.utils.tables.VectorTableModel; |  | ||||||
| import com.evolute.utils.ui.DialogException; |  | ||||||
| 
 |  | ||||||
| public class DetalhesConsultaPanel |  | ||||||
| 	extends JPanel |  | ||||||
| 	implements ControllableComponent, ProcessoConstants, |  | ||||||
| 				ActionListener |  | ||||||
| { |  | ||||||
| 	protected JFrame owner; |  | ||||||
| 	protected JButton marcarButton; |  | ||||||
| 	protected JButton cancelarButton; |  | ||||||
| 	protected JTextField estadoText; |  | ||||||
| 	protected BaseTable datasTable; |  | ||||||
| 	protected VectorTableModel datasModel; |  | ||||||
| 	 |  | ||||||
| 	protected ProcessoDataProvider processoProvider; |  | ||||||
| 	 |  | ||||||
| 	public DetalhesConsultaPanel( JFrame owner ) |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		this.owner = owner; |  | ||||||
| 		processoProvider = ProcessoDataProvider.getProvider(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		Icon marcarIcon = getIcon( DATA_ICON_PATH ); |  | ||||||
| 		marcarButton = new JButton( "Fazer Marca\u00e7\u00e3o" ); |  | ||||||
| 		marcarButton.setIcon( marcarIcon ); |  | ||||||
| 		marcarButton.addActionListener( this ); |  | ||||||
| 		Icon cancelarIcon = getIcon( DATA_ICON_PATH ); |  | ||||||
| 		cancelarButton = new JButton( "Cancelar Consulta" ); |  | ||||||
| 		cancelarButton.setIcon( cancelarIcon ); |  | ||||||
| 		cancelarButton.addActionListener( this ); |  | ||||||
| 		 |  | ||||||
| 		estadoText = new JTextField(); |  | ||||||
| 		estadoText.setEditable( false ); |  | ||||||
| 		datasModel = new VectorTableModel( new String[]{ "data", "prestador", "estado" } ); |  | ||||||
| 		datasTable = new BaseTable( datasModel ); |  | ||||||
| 		JScrollPane datasScroll = new JScrollPane( datasTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |  | ||||||
| 					JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); |  | ||||||
| 		 |  | ||||||
| 		double cols[] = new double[]{ TableLayout.FILL, TableLayoutConstraints.FILL }; |  | ||||||
| 		double rows[] = new double[]{ TableLayout.PREFERRED, TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL }; |  | ||||||
| 		TableLayout layout = new TableLayout( cols, rows ); |  | ||||||
| 		layout.setHGap( 5 ); |  | ||||||
| 		layout.setVGap( 5 ); |  | ||||||
| 		setLayout( layout ); |  | ||||||
| 		add( marcarButton, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		add( cancelarButton, new TableLayoutConstraints( 1, 0 ) ); |  | ||||||
| 		add( estadoText, new TableLayoutConstraints( 0, 1, 1, 1 ) ); |  | ||||||
| 		add( datasScroll, new TableLayoutConstraints( 0, 2, 1, 2 ) ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Object save() |  | ||||||
| 	{ |  | ||||||
| 		return null; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void fill( Object value ) |  | ||||||
| 	{ |  | ||||||
| 		clear(); |  | ||||||
| 		Integer id = ( Integer ) value; |  | ||||||
| 		if( id != null ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				TrabalhadoresConsultasData consulta = processoProvider.getConsultaByID( id ); |  | ||||||
| 				Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); |  | ||||||
| 				String estadoStr = MedicinaConstants.ESTADOS_CONSULTA_STR[ estado != null ? estado.intValue() : 0 ]; |  | ||||||
| 				estadoText.setText( estadoStr ); |  | ||||||
| 				Vector values = datasModel.getValues(); |  | ||||||
| 				Object datas[][] = processoProvider.getDatasConsulta( id ); |  | ||||||
| 				for( int n = 0; n < datas.length; n++ ) |  | ||||||
| 				{ |  | ||||||
| 					PrestadoresData prestador = PrestadoresDataProvider.getProvider().getPrestadorByID( ( Integer ) datas[ n ][ 2 ] ); |  | ||||||
| 					datas[ n ][ 2 ] = prestador.get( PrestadoresData.NOME ); |  | ||||||
| 					Integer estadoData = ( Integer ) datas[ n ][ 3 ]; |  | ||||||
| 					datas[ n ][ 3 ] = MedicinaConstants.ESTADOS_CONSULTA_STR[ estadoData != null ? estadoData.intValue() : 0 ]; |  | ||||||
| 					values.add( new ColumnizedObjectArray( datas[ n ], true ) ); |  | ||||||
| 				} |  | ||||||
| 				datasModel.setValues( values ); |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a carregar dados da consulta", true ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| 		estadoText.setText( "" ); |  | ||||||
| 		datasModel.clearAll(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setEnabled( boolean enable ) |  | ||||||
| 	{ |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void actionPerformed( ActionEvent e ) |  | ||||||
| 	{ |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Icon getIcon( String path ) |  | ||||||
| 	{ |  | ||||||
| 		try |  | ||||||
| 		{ |  | ||||||
| 			return ImageIconLoader.loadImageIcon( getClass(), path ); |  | ||||||
| 		} |  | ||||||
| 		catch( Exception ex ) |  | ||||||
| 		{ |  | ||||||
| 			ex.printStackTrace(); |  | ||||||
| 			return null; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,198 +0,0 @@ | |||||||
| /* |  | ||||||
|  * DetalhesProcessoPanel.java |  | ||||||
|  * |  | ||||||
|  * Created on 25 de Abril de 2007, 17:34 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.awt.CardLayout; |  | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
| import java.awt.event.ActionListener; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.Vector; |  | ||||||
| 
 |  | ||||||
| import javax.swing.Icon; |  | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JLabel; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| 
 |  | ||||||
| import siprp.medicina.processo.ProcessoConstants; |  | ||||||
| import siprp.medicina.processo.ProcessoEvent; |  | ||||||
| import siprp.medicina.processo.ProcessoListener; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.images.ImageIconLoader; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author Frederico |  | ||||||
|  */ |  | ||||||
| public class DetalhesProcessoPanel extends JPanel |  | ||||||
| 	implements ProcessoConstants, ActionListener |  | ||||||
| { |  | ||||||
| 	private final Vector<ProcessoListener> PROCESSO_LISTENERS = new Vector<ProcessoListener>(); |  | ||||||
| 	 |  | ||||||
| 	private static final String CARD_BLANK = ""; |  | ||||||
| 	private static final String CARD_CONSULTA = "CONSULTA"; |  | ||||||
| 	private static final String CARD_ECDS = "ECDS"; |  | ||||||
| 	 |  | ||||||
| 	protected JFrame owner; |  | ||||||
| 	 |  | ||||||
| 	private JButton novoGrupoECDsButton; |  | ||||||
| 	private JButton novaConsultaButton; |  | ||||||
| 	private JLabel consultaLabel; |  | ||||||
| 	private JLabel ecdsLabel; |  | ||||||
| 	private JLabel fichaAptidaoLabel; |  | ||||||
| //	protected JPanel blankPanel;
 |  | ||||||
| //	protected DataConsultaPanel consultaPanel;
 |  | ||||||
| //	protected ECDsPanel ecdsPanel;
 |  | ||||||
| 	 |  | ||||||
| 	protected CardLayout cardLayout; |  | ||||||
| 	 |  | ||||||
| 	protected Integer processoId;  |  | ||||||
| 	 |  | ||||||
| 	/** |  | ||||||
| 	 * Creates a new instance of DetalhesProcessoPanel |  | ||||||
| 	 */ |  | ||||||
| 	public DetalhesProcessoPanel( JFrame owner ) |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		this.owner = owner; |  | ||||||
| 		setupComponents(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		Icon ecdsIcon = getIcon( ECDS_ICON_PATH ); |  | ||||||
| 		novoGrupoECDsButton = new JButton( "Marcar ECDs" ); |  | ||||||
| 		novoGrupoECDsButton.setIcon( ecdsIcon ); |  | ||||||
| 		novoGrupoECDsButton.addActionListener( this ); |  | ||||||
| 		Icon consultaIcon = getIcon( CONSULTA_ICON_PATH ); |  | ||||||
| 		novaConsultaButton = new JButton( "Marcar Consulta" ); |  | ||||||
| 		novaConsultaButton.setIcon( consultaIcon ); |  | ||||||
| 		novaConsultaButton.addActionListener( this ); |  | ||||||
| 		ecdsLabel = new JLabel( ecdsIcon, JLabel.LEFT ); |  | ||||||
| 		consultaLabel = new JLabel( consultaIcon, JLabel.LEFT ); |  | ||||||
| 		Icon fichaAptidaoIcon = getIcon( FICHA_APTIDAO_ICON_PATH ); |  | ||||||
| 		fichaAptidaoLabel = new JLabel( fichaAptidaoIcon, JLabel.LEFT ); |  | ||||||
| 		 |  | ||||||
| 		double cols[] =	new double[]{ TableLayout.FILL, TableLayout.FILL }; |  | ||||||
| 		double rows[] =	 |  | ||||||
| 			new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,  |  | ||||||
| 							TableLayout.PREFERRED, TableLayout.FILL }; |  | ||||||
| 	 |  | ||||||
| 		TableLayout tableLayout = new TableLayout( cols, rows ); |  | ||||||
| 		setLayout( tableLayout ); |  | ||||||
| 	 |  | ||||||
| 		add( novoGrupoECDsButton, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		add( novaConsultaButton, new TableLayoutConstraints( 1, 0 ) ); |  | ||||||
| 		add( ecdsLabel, new TableLayoutConstraints( 0, 1, 1, 1 ) ); |  | ||||||
| 		add( consultaLabel, new TableLayoutConstraints( 0, 2, 1, 2 ) ); |  | ||||||
| 		add( fichaAptidaoLabel, new TableLayoutConstraints( 0, 3, 1, 3 ) ); |  | ||||||
| 		 |  | ||||||
| //		blankPanel = new JPanel();
 |  | ||||||
| //		consultaPanel = new DataConsultaPanel( owner );
 |  | ||||||
| //		ecdsPanel = new ECDsPanel( owner );
 |  | ||||||
| //		
 |  | ||||||
| //		cardLayout = new CardLayout();
 |  | ||||||
| //		setLayout( cardLayout );
 |  | ||||||
| //		add( blankPanel, CARD_BLANK );
 |  | ||||||
| //		add( consultaPanel, CARD_CONSULTA );
 |  | ||||||
| //		add( ecdsPanel, CARD_ECDS );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void addProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.add( listener ); |  | ||||||
| //		consultaPanel.addProcessoListener( listener );
 |  | ||||||
| //		ecdsPanel.addProcessoListener( listener );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void removeProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.remove( listener ); |  | ||||||
| //		consultaPanel.removeProcessoListener( listener );
 |  | ||||||
| //		ecdsPanel.removeProcessoListener( listener );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void actionPerformed( ActionEvent e ) |  | ||||||
| 	{ |  | ||||||
| 		Object source = e.getSource(); |  | ||||||
| 		if( source.equals( novoGrupoECDsButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			novaConsulta(); |  | ||||||
| 		} |  | ||||||
| 		else if( source.equals( novaConsultaButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			novoGrupoECDs(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| //		cardLayout.first( this );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setTrabalhadorID( Integer trabalhadorID ) |  | ||||||
| 	{ |  | ||||||
| //		consultaPanel.setTrabalhadorID( trabalhadorID );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setProcessoID( Integer processoID ) |  | ||||||
| 	{ |  | ||||||
| 		this.processoId = processoID; |  | ||||||
| //		consultaPanel.setProcessoID( processoID );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setConsulta( Integer consultaID ) |  | ||||||
| 	{ |  | ||||||
| //		cardLayout.show( this, CARD_CONSULTA );
 |  | ||||||
| //		consultaPanel.fill( consultaID );
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setECDs( Integer ecdsID ) |  | ||||||
| 	{ |  | ||||||
| 		cardLayout.show( this, CARD_ECDS ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public Icon getIcon( String path ) |  | ||||||
| 	{ |  | ||||||
| 		try |  | ||||||
| 		{ |  | ||||||
| 			return ImageIconLoader.loadImageIcon( getClass(), path ); |  | ||||||
| 		} |  | ||||||
| 		catch( Exception ex ) |  | ||||||
| 		{ |  | ||||||
| 			ex.printStackTrace(); |  | ||||||
| 			return null; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void notifyListeners( int accao ) |  | ||||||
| 	{ |  | ||||||
| 		HashMap<Integer,Integer> ids = new HashMap<Integer,Integer>(); |  | ||||||
| 		ids.put( ProcessoEvent.TIPO_PROCESSO, processoId ); |  | ||||||
| 		ProcessoEvent event = new ProcessoEvent( this, accao, ids ); |  | ||||||
| 		for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void novoGrupoECDs() |  | ||||||
| 	{ |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void novaConsulta() |  | ||||||
| 	{ |  | ||||||
| 		notifyListeners( ProcessoEvent.ACCAO_MARCAR_CONSULTA ); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,30 +0,0 @@ | |||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JScrollPane; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.tables.BaseTable; |  | ||||||
| import com.evolute.utils.tables.VectorTableModel; |  | ||||||
| 
 |  | ||||||
| public class ECDsInfoPanel extends JPanel |  | ||||||
| { |  | ||||||
| 	protected final JFrame owner; |  | ||||||
| 	 |  | ||||||
| 	protected BaseTable marcacoesTable; |  | ||||||
| 	protected VectorTableModel marcacoesModel; |  | ||||||
| 	 |  | ||||||
| 	public ECDsInfoPanel( JFrame owner ) |  | ||||||
| 	{ |  | ||||||
| 		this.owner = owner; |  | ||||||
| 		setupComponents(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		marcacoesModel = new VectorTableModel( new String[]{ "data", "marcados", "realizados", "recusados", "estado" } ); |  | ||||||
| 		marcacoesTable = new BaseTable( marcacoesModel ); |  | ||||||
| 		JScrollPane marcacoesScroll = new JScrollPane( marcacoesTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,  |  | ||||||
| 														JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,360 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ECDsPanel.java |  | ||||||
|  * |  | ||||||
|  * Created on 13 de Maio de 2007, 17:07 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
| import java.awt.event.ActionListener; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.Vector; |  | ||||||
| 
 |  | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.event.ChangeEvent; |  | ||||||
| import javax.swing.event.ChangeListener; |  | ||||||
| 
 |  | ||||||
| import siprp.medicina.MedicinaConstants; |  | ||||||
| import siprp.medicina.processo.ProcessoDataProvider; |  | ||||||
| import siprp.medicina.processo.ProcessoEvent; |  | ||||||
| import siprp.medicina.processo.ProcessoListener; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresEcdsData; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresEcdsDatasData; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.jdo.JDOProvider; |  | ||||||
| import com.evolute.utils.ui.calendar.JCalendarPanel; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author Frederico |  | ||||||
|  */ |  | ||||||
| public class ECDsPanel  extends JPanel |  | ||||||
| 		implements ActionListener, MedicinaConstants, ChangeListener |  | ||||||
| { |  | ||||||
| 	protected JFrame owner; |  | ||||||
| 	protected JCalendarPanel dataEcdsPanel; |  | ||||||
| 	protected JButton estadoButton; |  | ||||||
| 	protected JButton emailButton; |  | ||||||
| 	protected JButton observacoesButton; |  | ||||||
| 	protected ObservacoesDialog observacoesDialog; |  | ||||||
| 	 |  | ||||||
| 	protected final Vector<ProcessoListener> PROCESSO_LISTENERS = new Vector<ProcessoListener>(); |  | ||||||
| 	protected JDOProvider JDO; |  | ||||||
| 	protected ProcessoDataProvider provider; |  | ||||||
| 	 |  | ||||||
| 	protected Integer trabalhadorID; |  | ||||||
| 	protected Integer processoID; |  | ||||||
| 	protected TrabalhadoresEcdsData ecds; |  | ||||||
| 	protected TrabalhadoresEcdsDatasData ecdsData; |  | ||||||
| 	 |  | ||||||
| 	/** |  | ||||||
| 	 * Creates a new instance of ECDsPanel |  | ||||||
| 	 */ |  | ||||||
| 	public ECDsPanel( JFrame owner ) |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| //		this.owner = owner;
 |  | ||||||
| //		JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
 |  | ||||||
| //		provider = ProcessoDataProvider.getProvider();
 |  | ||||||
| //		setupComponents();
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| //		JLabel dataLabel = new JLabel( "Data" );
 |  | ||||||
| //		dataConsultaPanel = new JCalendarPanel( null );
 |  | ||||||
| //		dataConsultaPanel.addChangeListener( this );
 |  | ||||||
| //		estadoButton = new JButton( " " );
 |  | ||||||
| //		estadoButton.addActionListener( this );
 |  | ||||||
| //		emailButton = new JButton( "Email" );
 |  | ||||||
| //		emailButton.addActionListener( this );
 |  | ||||||
| //		observacoesButton = new JButton( "Coment\u00e1rio" );
 |  | ||||||
| //		observacoesButton.addActionListener( this );
 |  | ||||||
| //		
 |  | ||||||
| //		double cols[] =
 |  | ||||||
| //				new double[]{ TableLayout.MINIMUM, TableLayout.FILL };
 |  | ||||||
| //		double rows[] = 
 |  | ||||||
| //				new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, 
 |  | ||||||
| //								TableLayout.MINIMUM, TableLayout.MINIMUM };
 |  | ||||||
| //		
 |  | ||||||
| //		TableLayout tableLayout = new TableLayout( cols, rows );
 |  | ||||||
| //		tableLayout.setVGap( 5 );
 |  | ||||||
| //		setLayout( tableLayout );
 |  | ||||||
| //		
 |  | ||||||
| //		add( dataLabel, new TableLayoutConstraints( 0, 0 ) );
 |  | ||||||
| //		add( dataEcdsPanel, new TableLayoutConstraints( 1, 0 ) );
 |  | ||||||
| //		add( estadoButton, new TableLayoutConstraints( 0, 1, 1, 1 ) );
 |  | ||||||
| //		add( emailButton, new TableLayoutConstraints( 0, 2, 1, 2 ) );
 |  | ||||||
| //		add( observacoesButton, new TableLayoutConstraints( 0, 3, 1, 3 ) );
 |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void actionPerformed(ActionEvent e) |  | ||||||
| 	{ |  | ||||||
| //		Object source = e.getSource();
 |  | ||||||
| //		if( source.equals( observacoesButton ) )
 |  | ||||||
| //		{
 |  | ||||||
| //			editarObservacoes();
 |  | ||||||
| //		}
 |  | ||||||
| //		else if( source.equals( emailButton ) )
 |  | ||||||
| //		{
 |  | ||||||
| //			enviarEmail();
 |  | ||||||
| //		}
 |  | ||||||
| //		else if( source.equals( estadoButton ) )
 |  | ||||||
| //		{
 |  | ||||||
| //			mudarEstado();
 |  | ||||||
| //		}
 |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void stateChanged(ChangeEvent e) |  | ||||||
| 	{ |  | ||||||
| //		Object source = e.getSource();
 |  | ||||||
| //		
 |  | ||||||
| //		if( source.equals( dataConsultaPanel ) )
 |  | ||||||
| //		{
 |  | ||||||
| //			Date data = dataConsultaPanel.getDate();
 |  | ||||||
| //			if( data == null )
 |  | ||||||
| //			{
 |  | ||||||
| //				return;
 |  | ||||||
| //			}
 |  | ||||||
| //			try
 |  | ||||||
| //			{
 |  | ||||||
| //				boolean nova = false;
 |  | ||||||
| //				if( ecds == null )
 |  | ||||||
| //				{
 |  | ||||||
| //					nova = true;
 |  | ||||||
| //					Integer ecdsID = provider.getEcdsEmAbertoForProcesso( processoID );
 |  | ||||||
| //					if( ecdsID == null )
 |  | ||||||
| //					{
 |  | ||||||
| //						ecds = new TrabalhadoresEcdsData();
 |  | ||||||
| //						ecds.set( TrabalhadoresEcdsData.TRABALHADOR_ID, trabalhadorID );
 |  | ||||||
| //						ecds.set( TrabalhadoresEcdsData.PROCESSO_ID, processoID );
 |  | ||||||
| //						ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
 |  | ||||||
| //					}
 |  | ||||||
| //					else
 |  | ||||||
| //					{
 |  | ||||||
| //						ecds = provider.getEcdsByID( ecdsID );
 |  | ||||||
| //						ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
 |  | ||||||
| //					}
 |  | ||||||
| //				}
 |  | ||||||
| //				ecds.set( TrabalhadoresConsultasData.DATA, data );
 |  | ||||||
| //				provider.saveEcds( ecds );
 |  | ||||||
| //				if( ecdsData == null )
 |  | ||||||
| //				{
 |  | ||||||
| //					Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
 |  | ||||||
| //					Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
 |  | ||||||
| //					if( ecdsDataID == null || nova )
 |  | ||||||
| //					{
 |  | ||||||
| //						ecdsData = new TrabalhadoresEcdsDatasData();
 |  | ||||||
| //						ecdsData.set( TrabalhadoresEcdsDatasData.TRABALHADORES_ECDS_ID, ecdsID );
 |  | ||||||
| //						ecdsData.set( TrabalhadoresEcdssDatasData.ESTADO, new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) );
 |  | ||||||
| //					}
 |  | ||||||
| //					else
 |  | ||||||
| //					{
 |  | ||||||
| //						ecdsData = provider.getEcdsDataByID( ecdsDataID );
 |  | ||||||
| //					}
 |  | ||||||
| //				}
 |  | ||||||
| //				ecdsData.set( TrabalhadoresEcdsDatasData.DATA, data );
 |  | ||||||
| //				provider.saveEcdsData( ecdsData );
 |  | ||||||
| //				
 |  | ||||||
| //				notifyListeners( ProcessoEvent.ACCAO_MUDAR_DATA_MARCACAO );
 |  | ||||||
| //			}
 |  | ||||||
| //			catch( Exception ex )
 |  | ||||||
| //			{
 |  | ||||||
| //				DialogException.showExceptionMessage( ex, "Erro a gravar dados dos ECDs", true );
 |  | ||||||
| //				return;
 |  | ||||||
| //			}
 |  | ||||||
| //		}
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void editarObservacoes() |  | ||||||
| 	{ |  | ||||||
| //		if( observacoesDialog == null )
 |  | ||||||
| //		{
 |  | ||||||
| //			observacoesDialog = new ObservacoesDialog( owner );
 |  | ||||||
| //		}
 |  | ||||||
| //		String texto = "";
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			Integer dataID = provider.getLastEcdsDataIDForEcds( ( Integer ) ecds.get( TrabalhadoresEcdssData.ID ) );
 |  | ||||||
| //			IDObject observacoes = provider.getObservacoesEcdsData( dataID );
 |  | ||||||
| //			if( observacoes != null )
 |  | ||||||
| //			{
 |  | ||||||
| //				texto = observacoes.toString();
 |  | ||||||
| //			}
 |  | ||||||
| //			texto = observacoesDialog.editarObservacao( texto );
 |  | ||||||
| //			if( texto != null )
 |  | ||||||
| //			{
 |  | ||||||
| //				provider.saveObservacoesEcdsData( dataID, texto );
 |  | ||||||
| //				notifyListeners( ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES );
 |  | ||||||
| //			}
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //			DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
 |  | ||||||
| //			return;
 |  | ||||||
| //		}
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void enviarEmail() |  | ||||||
| 	{ |  | ||||||
| //		if( ecds == null )
 |  | ||||||
| //		{
 |  | ||||||
| //			return;
 |  | ||||||
| //		}
 |  | ||||||
| //		try
 |  | ||||||
| //		{
 |  | ||||||
| //			Integer ecdsDataID;
 |  | ||||||
| //			if( ecdsData == null )
 |  | ||||||
| //			{
 |  | ||||||
| //				Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
 |  | ||||||
| //				ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
 |  | ||||||
| //				ecdsData = provider.getEcdsDataByID( ecdsDataID );
 |  | ||||||
| //			}
 |  | ||||||
| //			ecdsDataID = ( Integer ) ecdsData.get( TrabalhadoresEcdsDatasData.ID );
 |  | ||||||
| //			provider.saveEmailEcdsData( ecdsDataID, "teste@siprp.pt", "Email de teste.", "" );
 |  | ||||||
| //			notifyListeners( ProcessoEvent.ACCAO_ESCREVER_MAIL );
 |  | ||||||
| //		}
 |  | ||||||
| //		catch( Exception ex )
 |  | ||||||
| //		{
 |  | ||||||
| //			DialogException.showExceptionMessage( ex, "Erro a gravar dados", true );
 |  | ||||||
| //			return;
 |  | ||||||
| //		}
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void mudarEstado() |  | ||||||
| 	{ |  | ||||||
| //		if( ecds == null )
 |  | ||||||
| //		{
 |  | ||||||
| //			return;
 |  | ||||||
| //		}
 |  | ||||||
| //		Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
 |  | ||||||
| //		EstadoChooser chooser = 
 |  | ||||||
| //			new EstadoChooser( owner, ProcessoConstants.TIPO_ECDS, 
 |  | ||||||
| //								estado != null ? estado.intValue() : MedicinaConstants.ESTADO_POR_REALIZAR );
 |  | ||||||
| //		chooser.setVisible( true );
 |  | ||||||
| //		int novoEstado = chooser.getEstado();
 |  | ||||||
| //		if( estado == null || estado.intValue() != novoEstado )
 |  | ||||||
| //		{
 |  | ||||||
| //			try
 |  | ||||||
| //			{
 |  | ||||||
| //				ecds.set( TrabalhadoresEcdsData.ESTADO, new Integer( novoEstado ) );
 |  | ||||||
| //				provider.saveEcds( ecds );
 |  | ||||||
| //				if( ecdsData == null )
 |  | ||||||
| //				{
 |  | ||||||
| //					Integer ecdsID = ( Integer )ecds.get( TrabalhadoresEcdsData.ID );
 |  | ||||||
| //					Integer ecdsDataID = provider.getLastEcdsDataIDForEcds( ecdsID );
 |  | ||||||
| //					ecdsData = provider.getEcdsDataByID( ecdsDataID );
 |  | ||||||
| //				}
 |  | ||||||
| //				ecdsData.set( TrabalhadoresEcdsDatasData.ESTADO, new Integer( novoEstado ) );
 |  | ||||||
| //				provider.saveEcdsData( ecdsData );
 |  | ||||||
| //				
 |  | ||||||
| //				notifyListeners( ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO );
 |  | ||||||
| //			}
 |  | ||||||
| //			catch( Exception ex )
 |  | ||||||
| //			{
 |  | ||||||
| //				DialogException.showExceptionMessage( ex, "Erro a gravar dados", true );
 |  | ||||||
| //				return;
 |  | ||||||
| //			}
 |  | ||||||
| //		}
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void addProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.add( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void removeProcessoListener( ProcessoListener listener ) |  | ||||||
| 	{ |  | ||||||
| 		PROCESSO_LISTENERS.remove( listener ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| //		dataConsultaPanel.setDate( null );
 |  | ||||||
| //		estadoButton.setText( " " );
 |  | ||||||
| //		ecds = null;
 |  | ||||||
| //		ecdsData = null;
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void fill( Object value ) |  | ||||||
| 	{ |  | ||||||
| //		clear();
 |  | ||||||
| //		if( value != null )
 |  | ||||||
| //		{
 |  | ||||||
| //			try
 |  | ||||||
| //			{
 |  | ||||||
| //				ecds = ( TrabalhadoresEcdsData ) JDO.load( TrabalhadoresEcdsData.class, ( Integer ) value );
 |  | ||||||
| //				Date data = ( Date ) ecds.get( TrabalhadoresEcdsData.DATA );
 |  | ||||||
| //				Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
 |  | ||||||
| //				dataConsultaPanel.setDate( data );
 |  | ||||||
| //				if( estado != null )
 |  | ||||||
| //				{
 |  | ||||||
| //					estadoButton.setText( ESTADOS_EXAME_STR[ estado.intValue() ] );
 |  | ||||||
| //				}
 |  | ||||||
| //				else
 |  | ||||||
| //				{
 |  | ||||||
| //					estadoButton.setText( " " );
 |  | ||||||
| //				}
 |  | ||||||
| //			}
 |  | ||||||
| //			catch( Exception ex )
 |  | ||||||
| //			{
 |  | ||||||
| //				DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
 |  | ||||||
| //			}
 |  | ||||||
| //		}
 |  | ||||||
| //		enableButtons();
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void enableButtons() |  | ||||||
| 	{ |  | ||||||
| //		if( ecds != null )
 |  | ||||||
| //		{
 |  | ||||||
| //			Integer estado = ( Integer ) ecds.get( TrabalhadoresEcdsData.ESTADO );
 |  | ||||||
| //			dataEcdsPanel.setEnabled( estado == null || estado.intValue() == ESTADO_POR_REALIZAR );
 |  | ||||||
| //			estadoButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
 |  | ||||||
| //			emailButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
 |  | ||||||
| //			observacoesButton.setEnabled( ecds.get( TrabalhadoresEcdsData.DATA ) != null );
 |  | ||||||
| //		}
 |  | ||||||
| //		else
 |  | ||||||
| //		{
 |  | ||||||
| //			dataConsultaPanel.setEnabled( true );
 |  | ||||||
| //			estadoButton.setEnabled( false );
 |  | ||||||
| //			emailButton.setEnabled( false );
 |  | ||||||
| //			observacoesButton.setEnabled( false );
 |  | ||||||
| //		}
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setTrabalhadorID( Integer trabalhadorID ) |  | ||||||
| 	{ |  | ||||||
| 		this.trabalhadorID = trabalhadorID; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void setProcessoID( Integer processoID ) |  | ||||||
| 	{ |  | ||||||
| 		this.processoID = processoID; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	protected void notifyListeners( int accao ) |  | ||||||
| 	{ |  | ||||||
| 		HashMap<Integer,Integer> ids = new HashMap<Integer,Integer>(); |  | ||||||
| 		ids.put( ProcessoEvent.TIPO_PROCESSO, processoID ); |  | ||||||
| 		if( ecds != null ) |  | ||||||
| 		{ |  | ||||||
| 			ids.put( ProcessoEvent.TIPO_CONSULTA, ( Integer ) ecds.get( TrabalhadoresEcdsData.ID ) ); |  | ||||||
| 		} |  | ||||||
| 		if( ecdsData != null ) |  | ||||||
| 		{ |  | ||||||
| 			ids.put( ProcessoEvent.TIPO_DATA, ( Integer ) ecds.get( TrabalhadoresEcdsData.ID ) ); |  | ||||||
| 		} |  | ||||||
| 		ProcessoEvent event = new ProcessoEvent( this, accao, ids ); |  | ||||||
| 		for( int n = 0; n < PROCESSO_LISTENERS.size(); n++ ) |  | ||||||
| 		{ |  | ||||||
| 			PROCESSO_LISTENERS.get( n ).processoStateChanged( event ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,96 +0,0 @@ | |||||||
| /* |  | ||||||
|  * EstadoChooser.java |  | ||||||
|  * |  | ||||||
|  * Created on 13 de Maio de 2007, 11:54 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.ui.CustomJDialog; |  | ||||||
| import java.awt.Color; |  | ||||||
| import java.awt.GridLayout; |  | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
| import java.awt.event.ActionListener; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.SwingUtilities; |  | ||||||
| import siprp.medicina.MedicinaConstants; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author Frederico |  | ||||||
|  */ |  | ||||||
| public class EstadoChooser extends CustomJDialog |  | ||||||
| 	implements MedicinaConstants, ActionListener |  | ||||||
| { |  | ||||||
| 	protected int tipo; |  | ||||||
| 	protected int estado; |  | ||||||
| 	protected HashMap<JButton,Integer> buttonMap = new HashMap<JButton,Integer>(); |  | ||||||
| 	 |  | ||||||
| 	/** Creates a new instance of EstadoChooser */ |  | ||||||
| 	public EstadoChooser( JFrame owner, int tipo, int estadoActual ) |  | ||||||
| 	{ |  | ||||||
| 		super( owner, true ); |  | ||||||
| 		this.tipo = tipo; |  | ||||||
| 		estado = estadoActual; |  | ||||||
| 		setupComponents(); |  | ||||||
| 		 |  | ||||||
| 		if( owner != null ) |  | ||||||
| 		{ |  | ||||||
| 			centerSuper(); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			center(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		setTitle( "Escolha o novo estado" ); |  | ||||||
| 		setLayout( new GridLayout(  ESTADOS_STR[ tipo ].length, 1 ) ); |  | ||||||
| 		for( int n = 0; n < ESTADOS_STR[ tipo ].length; n++ ) |  | ||||||
| 		{ |  | ||||||
| 			if( ESTADOS_STR[ tipo ][ n ] == null ) |  | ||||||
| 			{ |  | ||||||
| 				continue; |  | ||||||
| 			} |  | ||||||
| 			JButton button = new JButton( ESTADOS_STR[ tipo ][ n ] ); |  | ||||||
| 			if( n == estado ) |  | ||||||
| 			{ |  | ||||||
| 				button.setForeground( Color.green ); |  | ||||||
| 			} |  | ||||||
| 			buttonMap.put( button, new Integer( n ) ); |  | ||||||
| 			add( button ); |  | ||||||
| 			button.addActionListener( this ); |  | ||||||
| 		} |  | ||||||
| 		pack(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void actionPerformed( ActionEvent e ) |  | ||||||
| 	{ |  | ||||||
| 		JButton source = ( JButton ) e.getSource(); |  | ||||||
| 		estado = buttonMap.get( source ).intValue(); |  | ||||||
| 		close(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void close() |  | ||||||
| 	{ |  | ||||||
| 		SwingUtilities.invokeLater( new Runnable(){ |  | ||||||
| 			public void run() |  | ||||||
| 			{ |  | ||||||
| 				setVisible( false ); |  | ||||||
| 				dispose(); |  | ||||||
| 			} |  | ||||||
| 		} ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public int getEstado() |  | ||||||
| 	{ |  | ||||||
| 		return estado; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,116 +0,0 @@ | |||||||
| /* |  | ||||||
|  * ObservacoesDialog.java |  | ||||||
|  * |  | ||||||
|  * Created on 13 de Maio de 2007, 13:13 |  | ||||||
|  * |  | ||||||
|  * To change this template, choose Tools | Template Manager |  | ||||||
|  * and open the template in the editor. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.ui.CustomJDialog; |  | ||||||
| import java.awt.BorderLayout; |  | ||||||
| import java.awt.GridLayout; |  | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
| import java.awt.event.ActionListener; |  | ||||||
| import javax.swing.JButton; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JScrollPane; |  | ||||||
| import javax.swing.JTextArea; |  | ||||||
| import javax.swing.SwingUtilities; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * |  | ||||||
|  * @author Frederico |  | ||||||
|  */ |  | ||||||
| public class ObservacoesDialog extends CustomJDialog |  | ||||||
| 	implements ActionListener |  | ||||||
| { |  | ||||||
| 	protected JTextArea observacoesText; |  | ||||||
| 	protected JButton okButton; |  | ||||||
| 	protected JButton cancelButton; |  | ||||||
| 	 |  | ||||||
| 	protected boolean ok = false; |  | ||||||
| 	 |  | ||||||
| 	public static void main( String args[] ) |  | ||||||
| 	{ |  | ||||||
| 		ObservacoesDialog dialog = new ObservacoesDialog( null ); |  | ||||||
| 		dialog.editarObservacao( "ISto e a observba" ); |  | ||||||
| 		System.exit( 0 ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	/** Creates a new instance of ObservacoesDialog */ |  | ||||||
| 	public ObservacoesDialog( JFrame owner ) |  | ||||||
| 	{ |  | ||||||
| 		super( owner, true ); |  | ||||||
| 		setupComponents(); |  | ||||||
| 		 |  | ||||||
| 		if( owner != null ) |  | ||||||
| 		{ |  | ||||||
| 			centerSuper(); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			center(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		setTitle( "Coment\u00e1rio" ); |  | ||||||
| 		setSize( 400, 200 ); |  | ||||||
| 		observacoesText = new JTextArea(); |  | ||||||
| 		observacoesText.setLineWrap( true ); |  | ||||||
| 		observacoesText.setWrapStyleWord( true ); |  | ||||||
| 		JScrollPane scp = new JScrollPane( observacoesText,  |  | ||||||
| 			JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); |  | ||||||
| 		okButton = new JButton( "Ok" ); |  | ||||||
| 		okButton.addActionListener( this ); |  | ||||||
| 		cancelButton = new JButton( "Cancelar" ); |  | ||||||
| 		cancelButton.addActionListener( this ); |  | ||||||
| 		JPanel buttonPanel = new JPanel(); |  | ||||||
| 		 |  | ||||||
| 		setLayout( new BorderLayout() ); |  | ||||||
| 		add( scp, BorderLayout.CENTER ); |  | ||||||
| 		add( buttonPanel, BorderLayout.SOUTH ); |  | ||||||
| 		 |  | ||||||
| 		buttonPanel.setLayout( new GridLayout( 1, 2 ) ); |  | ||||||
| 		buttonPanel.add( okButton ); |  | ||||||
| 		buttonPanel.add( cancelButton ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void actionPerformed( ActionEvent e ) |  | ||||||
| 	{ |  | ||||||
| 		Object source = e.getSource(); |  | ||||||
| 		if( source.equals( okButton ) ) |  | ||||||
| 		{ |  | ||||||
| 			ok = true; |  | ||||||
| 			close(); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			ok = false; |  | ||||||
| 			close(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public String editarObservacao( String observacao ) |  | ||||||
| 	{ |  | ||||||
| 		observacoesText.setText( observacao ); |  | ||||||
| 		setVisible( true ); |  | ||||||
| 		return ok ? observacoesText.getText() : null; |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public void close() |  | ||||||
| 	{ |  | ||||||
| 		SwingUtilities.invokeLater( new Runnable(){ |  | ||||||
| 			public void run() |  | ||||||
| 			{ |  | ||||||
| 				setVisible( false ); |  | ||||||
| 				dispose(); |  | ||||||
| 			} |  | ||||||
| 		} ); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,229 +0,0 @@ | |||||||
| package siprp.medicina.processo.detalhes; |  | ||||||
| 
 |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.awt.GridLayout; |  | ||||||
| import java.text.DateFormat; |  | ||||||
| import java.util.Arrays; |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.Locale; |  | ||||||
| import java.util.Vector; |  | ||||||
| 
 |  | ||||||
| import javax.swing.BorderFactory; |  | ||||||
| import javax.swing.JFrame; |  | ||||||
| import javax.swing.JLabel; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JScrollPane; |  | ||||||
| import javax.swing.JTextField; |  | ||||||
| 
 |  | ||||||
| import siprp.medicina.MedicinaConstants; |  | ||||||
| import siprp.medicina.MedicinaDataProvider; |  | ||||||
| import siprp.medicina.processo.ProcessoDataProvider; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresConsultasData; |  | ||||||
| import siprp.medicina.processo.data.TrabalhadoresProcessoData; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.dataui.ControllableComponent; |  | ||||||
| import com.evolute.utils.tables.BaseTable; |  | ||||||
| import com.evolute.utils.tables.ColumnizedObjectArray; |  | ||||||
| import com.evolute.utils.tables.VectorTableModel; |  | ||||||
| import com.evolute.utils.ui.DialogException; |  | ||||||
| 
 |  | ||||||
| public class ProcessoInfoPanel  |  | ||||||
| 	extends JPanel |  | ||||||
| 	implements ControllableComponent  |  | ||||||
| { |  | ||||||
| 	protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); |  | ||||||
| 	 |  | ||||||
| 	protected JFrame owner; |  | ||||||
| 	protected JTextField descricaoText; |  | ||||||
| 	protected JTextField estadoECDsText; |  | ||||||
| 	protected BaseTable ecdsTable; |  | ||||||
| 	protected VectorTableModel ecdsModel; |  | ||||||
| 	protected JTextField estadoConsultasText; |  | ||||||
| 	protected BaseTable consultasTable; |  | ||||||
| 	protected VectorTableModel consultasModel; |  | ||||||
| 	protected JTextField estadoFichaAptidaoText; |  | ||||||
| 	protected BaseTable fichaAptidaoTable; |  | ||||||
| 	protected VectorTableModel fichaAptidaoModel; |  | ||||||
| 	 |  | ||||||
| 	protected  ProcessoDataProvider processoProvider;  |  | ||||||
| 	 |  | ||||||
| 	public ProcessoInfoPanel( JFrame owner ) |  | ||||||
| 		throws Exception |  | ||||||
| 	{ |  | ||||||
| 		this.owner = owner; |  | ||||||
| 		processoProvider = ProcessoDataProvider.getProvider(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		descricaoText = new JTextField(); |  | ||||||
| 		descricaoText.setEditable( false ); |  | ||||||
| 		JLabel estadoECDsLabel = new JLabel( "Estado" ); |  | ||||||
| 		estadoECDsText = new JTextField();  |  | ||||||
| 		estadoECDsText.setEditable( false ); |  | ||||||
| 		ecdsModel = new VectorTableModel( new String[]{ "Situa\u00e7\u00e3o", "#", "\u00DAltima Data" } ); |  | ||||||
| 		ecdsTable = new BaseTable( ecdsModel ); |  | ||||||
| 		JScrollPane ecdsScroll =  |  | ||||||
| 			new JScrollPane( ecdsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |  | ||||||
| 										JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); |  | ||||||
| 		JLabel estadoConsultasLabel = new JLabel( "Estado" ); |  | ||||||
| 		estadoConsultasText = new JTextField(); |  | ||||||
| 		estadoConsultasText.setEditable( false ); |  | ||||||
| 		consultasModel = new VectorTableModel( new String[]{ "Situa\u00e7\u00e3o", "#", "\u00DAltima Data" } ); |  | ||||||
| 		consultasTable = new BaseTable( consultasModel ); |  | ||||||
| 		JScrollPane consultasScroll =  |  | ||||||
| 			new JScrollPane( consultasTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |  | ||||||
| 										JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); |  | ||||||
| 		JLabel estadoFichaAptidaoLabel = new JLabel( "Estado" ); |  | ||||||
| 		estadoFichaAptidaoText = new JTextField(); |  | ||||||
| 		estadoFichaAptidaoText.setEditable( false ); |  | ||||||
| 		fichaAptidaoModel = new VectorTableModel( new String[]{ "Situa\u00e7\u00e3o", "Resultado", "\u00DAltima Data" } ); |  | ||||||
| 		fichaAptidaoTable = new BaseTable( fichaAptidaoModel ); |  | ||||||
| 		JScrollPane fichaAptidaoScroll =  |  | ||||||
| 			new JScrollPane( fichaAptidaoTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |  | ||||||
| 										JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); |  | ||||||
| 		 |  | ||||||
| 		JPanel ecdsPanel = new JPanel(); |  | ||||||
| 		ecdsPanel.setBorder(  |  | ||||||
| 				BorderFactory.createTitledBorder(  |  | ||||||
| 						BorderFactory.createEtchedBorder(), |  | ||||||
| 						"ECDs") ); |  | ||||||
| 		double ecdsRows[] = new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL }; |  | ||||||
| 		double ecdsCols[] = new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL }; |  | ||||||
| 		TableLayout ecdsLayout = new TableLayout( ecdsCols, ecdsRows ); |  | ||||||
| 		ecdsPanel.setLayout( ecdsLayout ); |  | ||||||
| 		ecdsPanel.add( estadoECDsLabel, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		ecdsPanel.add( estadoECDsText, new TableLayoutConstraints( 1, 0 ) ); |  | ||||||
| 		ecdsPanel.add( ecdsScroll, new TableLayoutConstraints( 0, 1, 1, 1 ) ); |  | ||||||
| 		 |  | ||||||
| 		JPanel consultasPanel = new JPanel(); |  | ||||||
| 		consultasPanel.setBorder(  |  | ||||||
| 				BorderFactory.createTitledBorder(  |  | ||||||
| 						BorderFactory.createEtchedBorder(), |  | ||||||
| 						"Consultas") ); |  | ||||||
| 		double consultasRows[] = new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL }; |  | ||||||
| 		double consultasCols[] = new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL }; |  | ||||||
| 		TableLayout consultasLayout = new TableLayout( consultasCols, consultasRows ); |  | ||||||
| 		consultasPanel.setLayout( consultasLayout ); |  | ||||||
| 		consultasPanel.add( estadoConsultasLabel, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		consultasPanel.add( estadoConsultasText, new TableLayoutConstraints( 1, 0 ) ); |  | ||||||
| 		consultasPanel.add( consultasScroll, new TableLayoutConstraints( 0, 1, 1, 1 ) ); |  | ||||||
| 		 |  | ||||||
| 		JPanel fichaAptidaoPanel = new JPanel(); |  | ||||||
| 		fichaAptidaoPanel.setBorder(  |  | ||||||
| 				BorderFactory.createTitledBorder(  |  | ||||||
| 						BorderFactory.createEtchedBorder(), |  | ||||||
| 						"Ficha de Aptid\u00e3o") ); |  | ||||||
| 		double fichaAptidaoRows[] = new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL }; |  | ||||||
| 		double fichaAptidaoCols[] = new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL }; |  | ||||||
| 		TableLayout fichaAptidaoLayout = new TableLayout( fichaAptidaoCols, fichaAptidaoRows ); |  | ||||||
| 		fichaAptidaoPanel.setLayout( fichaAptidaoLayout ); |  | ||||||
| 		fichaAptidaoPanel.add( estadoFichaAptidaoLabel, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		fichaAptidaoPanel.add( estadoFichaAptidaoText, new TableLayoutConstraints( 1, 0 ) ); |  | ||||||
| 		fichaAptidaoPanel.add( fichaAptidaoScroll, new TableLayoutConstraints( 0, 1, 1, 1 ) ); |  | ||||||
| 		 |  | ||||||
| 		double rows[] = new double[]{ TableLayoutConstraints.MINIMUM, TableLayoutConstraints.FILL,  |  | ||||||
| 										TableLayoutConstraints.FILL, TableLayoutConstraints.FILL };   |  | ||||||
| 		double cols[] = new double[]{ TableLayoutConstraints.FILL }; |  | ||||||
| 		TableLayout layout = new TableLayout( cols, rows ); |  | ||||||
| 		layout.setHGap( 5 ); |  | ||||||
| 		layout.setVGap( 5 ); |  | ||||||
| 		setLayout( layout ); |  | ||||||
| 		add( descricaoText, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 		add( ecdsPanel, new TableLayoutConstraints( 0, 1 ) ); |  | ||||||
| 		add( consultasPanel, new TableLayoutConstraints( 0, 2 ) ); |  | ||||||
| 		add( fichaAptidaoPanel, new TableLayoutConstraints( 0, 3 ) ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	@Override |  | ||||||
| 	public void setEnabled( boolean enabled ) |  | ||||||
| 	{ |  | ||||||
| 		// TODO Auto-generated method stub
 |  | ||||||
| 		super.setEnabled( enabled ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@Override |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| 		descricaoText.setText( "" ); |  | ||||||
| 		ecdsModel.clearAll(); |  | ||||||
| 		consultasModel.clearAll(); |  | ||||||
| 		fichaAptidaoModel.clearAll(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@Override |  | ||||||
| 	public Object save() |  | ||||||
| 	{ |  | ||||||
| 		// TODO Auto-generated method stub
 |  | ||||||
| 		return null; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@Override |  | ||||||
| 	public void fill( Object value ) |  | ||||||
| 	{ |  | ||||||
| 		clear(); |  | ||||||
| 		Integer id = ( Integer ) value; |  | ||||||
| 		if( id != null ) |  | ||||||
| 		{ |  | ||||||
| 			try |  | ||||||
| 			{ |  | ||||||
| 				TrabalhadoresProcessoData processo = processoProvider.getProcessoByID( id ); |  | ||||||
| 				if( processo == null ) |  | ||||||
| 				{ |  | ||||||
| 					throw new Exception( "Processo n\u00e3o existente: " + id ); |  | ||||||
| 				} |  | ||||||
| 				Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO ); |  | ||||||
| 				Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM ); |  | ||||||
| 				String codigoEstado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO ); |  | ||||||
| 				String estado = processoProvider.getDescricaoEstadoProcessoByCodigo( codigoEstado ); |  | ||||||
| 				String desc = D_F.format( dataInicio ); |  | ||||||
| 				Integer motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO ); |  | ||||||
| 				desc += ": " + MedicinaDataProvider.MOTIVOS_BY_ID.get( motivo ) + " : " + estado; |  | ||||||
| 				descricaoText.setText( desc ); |  | ||||||
| 				 |  | ||||||
| 				Integer consultaIds[] = processoProvider.getConsultaIDsForProcesso( id ); |  | ||||||
| 				Arrays.sort( consultaIds ); |  | ||||||
| 				HashMap<Integer,Integer> numeroConsultasPorEstado = new HashMap<Integer,Integer>(); |  | ||||||
| 				HashMap<Integer,Date> dataConsultaPorEstado = new HashMap<Integer,Date>(); |  | ||||||
| 				for( int n = 0; n < consultaIds.length; n++ ) |  | ||||||
| 				{ |  | ||||||
| 					TrabalhadoresConsultasData consulta = processoProvider.getConsultaByID( consultaIds[ n ] ); |  | ||||||
| 					Date dataConsulta = ( Date ) consulta.get( TrabalhadoresConsultasData.DATA ); |  | ||||||
| 					Integer estadoConsulta = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); |  | ||||||
| 					if( estadoConsulta != null ) |  | ||||||
| 					{ |  | ||||||
| 						Integer oldCount = numeroConsultasPorEstado.get( estadoConsulta ); |  | ||||||
| 						if( oldCount == null ) |  | ||||||
| 						{ |  | ||||||
| 							oldCount = new Integer( 0 ); |  | ||||||
| 						} |  | ||||||
| 						numeroConsultasPorEstado.put( estadoConsulta, new Integer( oldCount.intValue() + 1 ) ); |  | ||||||
| 					} |  | ||||||
| 					dataConsultaPorEstado.put( estadoConsulta, dataConsulta ); |  | ||||||
| 				} |  | ||||||
| 				Vector consultasValues = consultasModel.getValues(); |  | ||||||
| 				Integer estadosConsultaUsados[] = numeroConsultasPorEstado.keySet().toArray( new Integer[ numeroConsultasPorEstado.size() ] ); |  | ||||||
| 				Arrays.sort( estadosConsultaUsados ); |  | ||||||
| 				for( int n = 0; n < estadosConsultaUsados.length; n++ ) |  | ||||||
| 				{ |  | ||||||
| 					String estadoStr = MedicinaConstants.ESTADOS_CONSULTA_STR[ estadosConsultaUsados[ n ].intValue() ]; |  | ||||||
| 					Integer numero = numeroConsultasPorEstado.get( estadosConsultaUsados[ n ] ); |  | ||||||
| 					Date dataUltimaConsulta = dataConsultaPorEstado.get( estadosConsultaUsados ); |  | ||||||
| 					Object linha[] = new Object[]{ estadoStr, numero, dataUltimaConsulta }; |  | ||||||
| 					consultasValues.add( new ColumnizedObjectArray( linha, false ) ); |  | ||||||
| 				} |  | ||||||
| 				consultasModel.setValues( consultasValues ); |  | ||||||
| 			} |  | ||||||
| 			catch( Exception ex ) |  | ||||||
| 			{ |  | ||||||
| 				DialogException.showExceptionMessage( ex, "Erro a carregar dados do processo", true ); |  | ||||||
| 				return; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		 |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
					Loading…
					
					
				
		Reference in new issue