forked from Coded/SIPRP
				
			git-svn-id: https://svn.coded.pt/svn/SIPRP@1307 bb69d46d-e84e-40c8-a05a-06db0d633741
	
		
	
				
					
				
			
							parent
							
								
									fd2b7430d2
								
							
						
					
					
						commit
						c5db679ee3
					
				
											
												Binary file not shown.
											
										
									
								| @ -1,212 +0,0 @@ | |||||||
| package siprp.medicina.processo.ui; |  | ||||||
| 
 |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CLOSE; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_LEMBRETE; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_PARCIAL_EXAME_MARCACAO; |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.awt.Dimension; |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| import javax.swing.JSeparator; |  | ||||||
| 
 |  | ||||||
| import leaf.ui.LeafCalendarDialog; |  | ||||||
| import leaf.ui.LeafOptionDialog; |  | ||||||
| import leaf.ui.LeafTextDialog; |  | ||||||
| import leaf.ui.LeafWindow; |  | ||||||
| import leaf.ui.LeafLogic.LeafUIActionBinding; |  | ||||||
| import siprp.MedicinaConstants; |  | ||||||
| import siprp.database.cayenne.objects.Lembretes; |  | ||||||
| import siprp.database.cayenne.objects.PrtGruposProtocolo; |  | ||||||
| import siprp.database.cayenne.objects.Trabalhadores; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcd; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; |  | ||||||
| import siprp.medicina.processo.logic.MedicinaProcessoLogic; |  | ||||||
| 
 |  | ||||||
| import com.evolute.adt.OrderedMap; |  | ||||||
| 
 |  | ||||||
| public class MedicinaProcessoWindow extends LeafWindow |  | ||||||
| { |  | ||||||
| 	private static final long serialVersionUID = 1L; |  | ||||||
| 
 |  | ||||||
| 	private static final Dimension WINDOW_DIMENSION = new Dimension( 1024, 700 ); |  | ||||||
| 
 |  | ||||||
| 	public static final String TITLE = "Processos de Trabalhadores"; |  | ||||||
| 
 |  | ||||||
| 	private static final Dimension DIMENSION_TRABALHADORES_CHOOSER = new Dimension( 0, 200 ); |  | ||||||
| 	private static final Dimension DIMENSION_PROCESSO_TOOLBAR = new Dimension( 150, 0 ); |  | ||||||
| 
 |  | ||||||
| 	public final JSeparator separator = new JSeparator(); |  | ||||||
| 	@LeafPanel |  | ||||||
| 	public final ProcessoDadosPanel panelProcessoDados; |  | ||||||
| 	@LeafPanel |  | ||||||
| 	public final ProcessoAccoesPanel panelProcessoToolbar; |  | ||||||
| 	@LeafPanel |  | ||||||
| 	public final ProcessoTreePanel panelProcessoTree; |  | ||||||
| 	@LeafPanel |  | ||||||
| 	public final TrabalhadoresChooserPanel panelTrabalhadoresChooser; |  | ||||||
| 
 |  | ||||||
| 	public MedicinaProcessoWindow() throws Exception |  | ||||||
| 	{ |  | ||||||
| 		super( new MedicinaProcessoLogic() ); |  | ||||||
| 		panelProcessoDados = new ProcessoDadosPanel( this ); |  | ||||||
| 		panelProcessoToolbar = new ProcessoAccoesPanel( this ); |  | ||||||
| 		panelProcessoTree = new ProcessoTreePanel( this ); |  | ||||||
| 		panelTrabalhadoresChooser = new TrabalhadoresChooserPanel( this ); |  | ||||||
| 
 |  | ||||||
| 		startup(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public MedicinaProcessoWindow(Trabalhadores trabalhador) throws Exception |  | ||||||
| 	{ |  | ||||||
| 		super( new MedicinaProcessoLogic() ); |  | ||||||
| 		panelProcessoDados = new ProcessoDadosPanel( this ); |  | ||||||
| 		panelProcessoToolbar = new ProcessoAccoesPanel( this ); |  | ||||||
| 		panelProcessoTree = new ProcessoTreePanel( this ); |  | ||||||
| 		panelTrabalhadoresChooser = new TrabalhadoresChooserPanel( this ); |  | ||||||
| 		startup(); |  | ||||||
| 		runAction( MedicinaProcessoLogic.LOAD_TRABALHADOR, trabalhador ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void startup() |  | ||||||
| 	{ |  | ||||||
| 		setSize( WINDOW_DIMENSION ); |  | ||||||
| 		setTitle( TITLE ); |  | ||||||
| 		setupLayout(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 		placeComponents(); |  | ||||||
| 		completeSetup(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupLayout() |  | ||||||
| 	{ |  | ||||||
| 		double[] cols = new double[] { |  | ||||||
| 				TableLayout.PREFERRED, TableLayout.FILL, TableLayout.FILL |  | ||||||
| 		}; |  | ||||||
| 		double[] rows = new double[] { |  | ||||||
| 				TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL |  | ||||||
| 		}; |  | ||||||
| 		TableLayout layout = new TableLayout( cols, rows ); |  | ||||||
| 		layout.setVGap( 5 ); |  | ||||||
| 		layout.setHGap( 5 ); |  | ||||||
| 		this.setLayout( layout ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		panelTrabalhadoresChooser.setPreferredSize( DIMENSION_TRABALHADORES_CHOOSER ); |  | ||||||
| 		panelProcessoToolbar.setPreferredSize( DIMENSION_PROCESSO_TOOLBAR ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void placeComponents() |  | ||||||
| 	{ |  | ||||||
| 		this.add( panelTrabalhadoresChooser, new TableLayoutConstraints( 0, 0, 2, 0 ) ); |  | ||||||
| 		this.add( separator, new TableLayoutConstraints( 0, 1, 2, 1 ) ); |  | ||||||
| 		this.add( panelProcessoToolbar, new TableLayoutConstraints( 0, 2 ) ); |  | ||||||
| 		this.add( panelProcessoTree, new TableLayoutConstraints( 1, 2 ) ); |  | ||||||
| 		this.add( panelProcessoDados, new TableLayoutConstraints( 2, 2 ) ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CLOSE) |  | ||||||
| 	public void closeWindow() |  | ||||||
| 	{ |  | ||||||
| 		close(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = REALIZAR_PARCIAL_EXAME_MARCACAO) |  | ||||||
| 	public void realizarExameParcial( TrabalhadoresEcdsDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		boolean atLeastOneRealizado = false; |  | ||||||
| 		boolean atLeastOneFalta = false; |  | ||||||
| 		if( marcacao != null ) |  | ||||||
| 		{ |  | ||||||
| 			List<TrabalhadoresEcd> ecds = marcacao.getTrabalhadoresEcdArray(); |  | ||||||
| 			if( ecds != null ) |  | ||||||
| 			{ |  | ||||||
| 				OrderedMap<PrtGruposProtocolo> allGrupos = marcacao.getStatesForeGruposExames(); |  | ||||||
| 				OrderedMap<PrtGruposProtocolo> grupos = new OrderedMap<PrtGruposProtocolo>(); |  | ||||||
| 				for( int row = 0; row < allGrupos.rows(); ++row ) |  | ||||||
| 				{ |  | ||||||
| 					List<Object> grupo = allGrupos.getRow( row ); |  | ||||||
| 					if( grupo != null && grupo.size() > 1 ) |  | ||||||
| 					{ |  | ||||||
| 						String estado = grupo.get( 1 ).toString(); |  | ||||||
| 						if( MedicinaConstants.ESTADOS_EXAME_STR[MedicinaConstants.ESTADO_POR_REALIZAR].equals( estado ) ) |  | ||||||
| 						{ |  | ||||||
| 							PrtGruposProtocolo key = allGrupos.getKeyForValue( grupo ); |  | ||||||
| 							grupos.addRow( key, grupo ); |  | ||||||
| 						} |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 
 |  | ||||||
| 				LeafOptionDialog<PrtGruposProtocolo> option = new LeafOptionDialog<PrtGruposProtocolo>( this, grupos, null, null, "Marcar falta para:", "Faltou >>" ); |  | ||||||
| 				List<PrtGruposProtocolo> selected = option.getSelected(); |  | ||||||
| 				if( selected != null ) |  | ||||||
| 				{ |  | ||||||
| 					for( TrabalhadoresEcd ecd : ecds ) |  | ||||||
| 					{ |  | ||||||
| 						if( selected.contains( ecd.getToPrtTiposElementosProtocolo().getToPrtGruposProtocolo() ) ) |  | ||||||
| 						{ |  | ||||||
| 							ecd.setEstado( MedicinaConstants.ESTADO_FALTOU ); |  | ||||||
| 							atLeastOneFalta = true; |  | ||||||
| 						} |  | ||||||
| 						else |  | ||||||
| 						{ |  | ||||||
| 							ecd.setEstado( MedicinaConstants.ESTADO_REALIZADO ); |  | ||||||
| 							atLeastOneRealizado = true; |  | ||||||
| 						} |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		if( atLeastOneFalta ) |  | ||||||
| 		{ |  | ||||||
| 			if( atLeastOneRealizado ) |  | ||||||
| 			{ |  | ||||||
| 				marcacao.setEstado( MedicinaConstants.ESTADO_PARCIALMENTE_REALIZADO ); |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 				marcacao.setEstado( MedicinaConstants.ESTADO_FALTOU ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			if( atLeastOneRealizado ) |  | ||||||
| 			{ |  | ||||||
| 				marcacao.setEstado( MedicinaConstants.ESTADO_REALIZADO ); |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_LEMBRETE) |  | ||||||
| 	public void createLembrete( Lembretes lembrete ) |  | ||||||
| 	{ |  | ||||||
| 		if( lembrete != null ) |  | ||||||
| 		{ |  | ||||||
| 			Date date = new LeafCalendarDialog( this ).getDate(); |  | ||||||
| 			if( date != null && date.getTime() != 0 ) |  | ||||||
| 			{ |  | ||||||
| 				String text = new LeafTextDialog( this, null, "", true ).getText(); |  | ||||||
| 				if( text != null && !text.trim().equals( "" ) ) |  | ||||||
| 				{ |  | ||||||
| 					lembrete.setData( date ); |  | ||||||
| 					lembrete.setDescricao( text ); |  | ||||||
| 				} |  | ||||||
| 				else |  | ||||||
| 				{ |  | ||||||
| 					abortAction( true ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 				abortAction( true ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,551 +0,0 @@ | |||||||
| package siprp.medicina.processo.ui; |  | ||||||
| 
 |  | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; |  | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; |  | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.otilde; |  | ||||||
| import static info.clearthought.layout.TableLayoutConstants.FILL; |  | ||||||
| import static info.clearthought.layout.TableLayoutConstants.MINIMUM; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.ANULAR_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_EXAME; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_FICHA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_LEMBRETE; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_SIPRP_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_SIPRP_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_TRABALHADOR_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.DESMARCAR_TRABALHADOR_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.FALTOU_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.FALTOU_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.FECHAR_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REALIZAR_PARCIAL_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_OBSERVACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_OBSERVACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_FICHA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR; |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.awt.CardLayout; |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| import javax.swing.BorderFactory; |  | ||||||
| import javax.swing.JComponent; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| 
 |  | ||||||
| import leaf.ui.LeafButton; |  | ||||||
| import leaf.ui.LeafWindow; |  | ||||||
| import leaf.ui.LeafLogic.LeafUIActionBinding; |  | ||||||
| import leaf.ui.LeafWindow.ActionActivation; |  | ||||||
| import siprp.MedicinaConstants; |  | ||||||
| import siprp.ProcessoConstants; |  | ||||||
| import siprp.database.cayenne.objects.Trabalhadores; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcds; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresFichasAptidao; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresProcesso; |  | ||||||
| 
 |  | ||||||
| public class ProcessoAccoesPanel extends JPanel |  | ||||||
| { |  | ||||||
| 	private static final long serialVersionUID = 1L; |  | ||||||
| 
 |  | ||||||
| 	private final LeafWindow parentWindow; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_START_NAME = "START_PANEL"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_TRABALHADOR_NAME = "TRABALHADOR_PANEL"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_PROCESSO_NAME = "PROCESSO_PANEL"; |  | ||||||
| 	 |  | ||||||
| 	private static final String PANEL_FICHA_NAME = "PANEL_FICHA_NAME"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_CONSULTA_NAME = "PANEL_CONSULTA_NAME"; |  | ||||||
| 	 |  | ||||||
| 	private static final String PANEL_CONSULTA_MARCACAO_NAME = "PANEL_CONSULTA_MARCACAO_NAME"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_EXAME_NAME = "EXAME_PANEL"; |  | ||||||
| 	 |  | ||||||
| 	private static final String PANEL_EXAME_MARCACAO_NAME = "PANEL_EXAME_MARCACAO_NAME"; |  | ||||||
| 
 |  | ||||||
| 	private final JPanel cardPanel = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final CardLayout cardLayout = new CardLayout(); |  | ||||||
| 
 |  | ||||||
| 	// panels
 |  | ||||||
| 	private final JPanel panelExame = new JPanel(); |  | ||||||
| 	private final JPanel panelExameMarcacao = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelConsulta = new JPanel(); |  | ||||||
| 	private final JPanel panelConsultaMarcacao = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelProcesso = new JPanel(); |  | ||||||
| 	 |  | ||||||
| 	private final JPanel panelFicha = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelTrabalhador = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelStart = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	// trabalhador
 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_PROCESSO, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoTrabalhadorProcesso = new LeafButton( "Novo Processo" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_LEMBRETE, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoLembrete = new LeafButton( "Novo Lembrete" ); |  | ||||||
| 
 |  | ||||||
| 	// processo
 |  | ||||||
| 	@ActionActivation(onSelect = FECHAR_PROCESSO, onChange = "") |  | ||||||
| 	public final LeafButton buttonFecharProcesso = new LeafButton( "Fechar Processo" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_FICHA, onChange = "") |  | ||||||
| 	public final LeafButton buttonCriarFicha = new LeafButton( "Ficha de Aptid"+atilde+"o" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = { |  | ||||||
| 			CREATE_CONSULTA, CREATE_CONSULTA_MARCACAO |  | ||||||
| 	}, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoProcessoConsulta = new LeafButton( "Nova Consulta" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = { |  | ||||||
| 			CREATE_EXAME, CREATE_EXAME_MARCACAO |  | ||||||
| 	}, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoProcessoExame = new LeafButton( "Novo Exame" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = APAGAR_PROCESSO, onChange = "") |  | ||||||
| 	public final LeafButton buttonApagarProcesso = new LeafButton( "Remover Processo" ); |  | ||||||
| 
 |  | ||||||
| 	// consulta
 |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = APAGAR_CONSULTA, onChange = "") |  | ||||||
| 	public final LeafButton buttonApagarConsulta = new LeafButton( "Apagar Consulta" );	 |  | ||||||
| 	 |  | ||||||
| 	// marcacao consulta
 |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoConsultaMarcacao = new LeafButton( "Nova Marca" + ccedil + atilde + "o" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = APAGAR_CONSULTA_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonApagarConsultaMarcacao = new LeafButton( "Apagar Marca" + ccedil + atilde + "o" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_EMAIL, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoConsultaMarcacaoEmail = new LeafButton( "e-Mail" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoConsultaMarcacaoEmailVacinas = new LeafButton( "e-Mail: Boletim" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_CONSULTA_MARCACAO_OBSERVACOES, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoConsultaMarcacaoObservacoes = new LeafButton( "Adicionar Observa" + ccedil + atilde + "o" ); |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = DESMARCAR_SIPRP_CONSULTA_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonConsultaMarcacaoDesmarcarSiprp = new LeafButton( "Desmarcar (SIPRP)" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = DESMARCAR_TRABALHADOR_CONSULTA_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonConsultaMarcacaoDesmarcarTrabalhador = new LeafButton( "Desmarcar (Trab)" ); |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = REALIZAR_CONSULTA_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonConsultaMarcacaoRealizar = new LeafButton( "Realizar" ); |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = FALTOU_CONSULTA_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonConsultaMarcacaoFaltou = new LeafButton( "Faltou" ); |  | ||||||
| 
 |  | ||||||
| 	// email marcacao consulta
 |  | ||||||
| 
 |  | ||||||
| 	// observacoes marcacao consulta
 |  | ||||||
| 
 |  | ||||||
| 	// exame
 |  | ||||||
| 	@ActionActivation(onSelect = APAGAR_EXAME, onChange = "") |  | ||||||
| 	public final LeafButton buttonApagarExame = new LeafButton( "Apagar Exame" ); |  | ||||||
| 
 |  | ||||||
| 	// marcacao exame
 |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoExameMarcacao = new LeafButton( "Nova Marca" + ccedil + atilde + "o" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = APAGAR_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonApagarExameMarcacao = new LeafButton( "Apagar Marca" + ccedil + atilde + "o" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = CREATE_EXAME_MARCACAO_EMAIL, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoExameMarcacaoEmail = new LeafButton( "e-Mail" ); |  | ||||||
| 	@ActionActivation(onSelect = CREATE_EXAME_MARCACAO_OBSERVACOES, onChange = "") |  | ||||||
| 	public final LeafButton buttonNovoExameMarcacaoObservacoes = new LeafButton( "Adicionar Observa" + ccedil + atilde + "o" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = DESMARCAR_SIPRP_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonExameMarcacaoDesmarcarSiprp = new LeafButton( "Desmarcar (SIPRP)" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = DESMARCAR_TRABALHADOR_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonExameMarcacaoDesmarcarTrabalhador = new LeafButton( "Desmarcar (Trab)" ); |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = REALIZAR_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonExameMarcacaoRealizar = new LeafButton( "Realizar" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = REALIZAR_PARCIAL_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonExameMarcacaoRealizarParcial = new LeafButton( "Realizar Parcial." ); |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = FALTOU_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonExameMarcacaoFaltou = new LeafButton( "Faltou" ); |  | ||||||
| 	 |  | ||||||
| 	@ActionActivation(onSelect = ANULAR_EXAME_MARCACAO, onChange = "") |  | ||||||
| 	public final LeafButton buttonExameMarcacaoAnular = new LeafButton( "Anular" ); |  | ||||||
| 
 |  | ||||||
| 	// email marcacao exame
 |  | ||||||
| 
 |  | ||||||
| 	// observacoes marcacao exame
 |  | ||||||
| 
 |  | ||||||
| 	// control
 |  | ||||||
| 
 |  | ||||||
| 	public ProcessoAccoesPanel(LeafWindow parentWindow) |  | ||||||
| 	{ |  | ||||||
| 		this.parentWindow = parentWindow; |  | ||||||
| 		setupLayout(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 		placeComponents(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupLayout() |  | ||||||
| 	{ |  | ||||||
| 		TableLayout layout = new TableLayout( new double[] { |  | ||||||
| 			TableLayout.FILL |  | ||||||
| 		}, new double[] { |  | ||||||
| 			TableLayout.FILL |  | ||||||
| 		} ); |  | ||||||
| 		this.setLayout( layout ); |  | ||||||
| 		cardPanel.setLayout( cardLayout ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		this.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Ac" + ccedil + otilde + "es" ) ); |  | ||||||
| 		setupStartPanel(); |  | ||||||
| 		setupTrabalhadorPanel(); |  | ||||||
| 		setupProcessoPanel(); |  | ||||||
| 		setupFichaPanel(); |  | ||||||
| 		setupConsultaPanel(); |  | ||||||
| 		setupConsultaMarcacaoPanel(); |  | ||||||
| 		setupExamePanel(); |  | ||||||
| 		setupExameMarcacaoPanel(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void placeComponents() |  | ||||||
| 	{ |  | ||||||
| 		cardPanel.add( panelStart, PANEL_START_NAME ); |  | ||||||
| 		cardPanel.add( panelTrabalhador, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		cardPanel.add( panelProcesso, PANEL_PROCESSO_NAME ); |  | ||||||
| 		cardPanel.add( panelFicha, PANEL_FICHA_NAME); |  | ||||||
| 		cardPanel.add( panelConsulta, PANEL_CONSULTA_NAME ); |  | ||||||
| 		cardPanel.add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME ); |  | ||||||
| 		cardPanel.add( panelExame, PANEL_EXAME_NAME ); |  | ||||||
| 		cardPanel.add( panelExameMarcacao, PANEL_EXAME_MARCACAO_NAME ); |  | ||||||
| 		this.add( cardPanel, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = { |  | ||||||
| 			LOAD_TRABALHADOR, SELECT_TRABALHADOR |  | ||||||
| 	}) |  | ||||||
| 	public void setForTrabalhador( Trabalhadores trabalhador ) |  | ||||||
| 	{ |  | ||||||
| 		if( trabalhador != null ) |  | ||||||
| 		{ |  | ||||||
| 			boolean processoAberto = false; |  | ||||||
| 			for( TrabalhadoresProcesso processo : (List<TrabalhadoresProcesso>) trabalhador.getTrabalhadoresProcessoArray() ) |  | ||||||
| 			{ |  | ||||||
| 				if( ProcessoConstants.PROCESSO_ABERTO_CODE.equals( processo.getEstado() ) ) |  | ||||||
| 				{ |  | ||||||
| 					processoAberto = true; |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			buttonNovoTrabalhadorProcesso.setEnabled( !processoAberto ); |  | ||||||
| 			buttonNovoLembrete.setEnabled( true ); |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_START_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_PROCESSO) |  | ||||||
| 	public void setForProcesso( TrabalhadoresProcesso processo ) |  | ||||||
| 	{ |  | ||||||
| 		if( processo != null ) |  | ||||||
| 		{ |  | ||||||
| 			buttonFecharProcesso.setEnabled( !ProcessoConstants.PROCESSO_FECHADO_CODE.equals( processo.getEstado() ) ); |  | ||||||
| 			buttonApagarProcesso.setEnabled( processo.isEmpty() ); |  | ||||||
| 			boolean consultaAberta = false; |  | ||||||
| 			for( TrabalhadoresConsultas consulta : (List<TrabalhadoresConsultas>) processo.getTrabalhadoresConsultasArray() ) |  | ||||||
| 			{ |  | ||||||
| 				if( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( consulta.getEstado() ) ) |  | ||||||
| 				{ |  | ||||||
| 					consultaAberta = true; |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			buttonNovoProcessoConsulta.setEnabled( !consultaAberta ); |  | ||||||
| 
 |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_PROCESSO_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_FICHA) |  | ||||||
| 	public void setForFicha( TrabalhadoresFichasAptidao ficha) |  | ||||||
| 	{ |  | ||||||
| 		if( ficha != null ) |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_FICHA_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA) |  | ||||||
| 	public void setForConsulta( TrabalhadoresConsultas consulta ) |  | ||||||
| 	{ |  | ||||||
| 		if( consulta != null ) |  | ||||||
| 		{ |  | ||||||
| 			boolean marcacaoAberta = false; |  | ||||||
| 			for( TrabalhadoresConsultasDatas marcacao : (List<TrabalhadoresConsultasDatas>) consulta.getTrabalhadoresConsultasDatasArray() ) |  | ||||||
| 			{ |  | ||||||
| 				if( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() ) ) |  | ||||||
| 				{ |  | ||||||
| 					marcacaoAberta = true; |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			buttonNovoConsultaMarcacao.setEnabled( !marcacaoAberta && !new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( consulta.getEstado() ) ); |  | ||||||
| 			buttonApagarConsulta.setEnabled( marcacaoAberta ); |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_CONSULTA_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO) |  | ||||||
| 	public void setForConsultaMarcacao( TrabalhadoresConsultasDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		if( marcacao != null ) |  | ||||||
| 		{ |  | ||||||
| 			boolean porRealizar = new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() ); |  | ||||||
| 			boolean realizada = new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( marcacao.getEstado() ); |  | ||||||
| 			List list = marcacao.getTrabalhadoresConsultasDatasObservacoesArray(); |  | ||||||
| 			boolean noObservacoes = (list == null || list.size() == 0) ? true : false; |  | ||||||
| 			buttonConsultaMarcacaoDesmarcarSiprp.setEnabled( porRealizar ); |  | ||||||
| 			buttonConsultaMarcacaoDesmarcarTrabalhador.setEnabled( porRealizar ); |  | ||||||
| 			buttonConsultaMarcacaoFaltou.setEnabled( porRealizar ); |  | ||||||
| 			buttonConsultaMarcacaoRealizar.setEnabled( porRealizar ); |  | ||||||
| 			buttonNovoConsultaMarcacaoObservacoes.setEnabled( noObservacoes ); |  | ||||||
| 			buttonNovoConsultaMarcacaoEmailVacinas.setEnabled( realizada ); |  | ||||||
| 			buttonApagarConsultaMarcacao.setEnabled( porRealizar ); |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_CONSULTA_MARCACAO_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_EMAIL) |  | ||||||
| 	public void setForConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_START_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_OBSERVACAO) |  | ||||||
| 	public void setForConsultaMarcacaoObservacao( TrabalhadoresConsultasDatasObservacoes obs ) |  | ||||||
| 	{ |  | ||||||
| 		if( obs != null ) |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_START_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME) |  | ||||||
| 	public void setForExame( TrabalhadoresEcds exame ) |  | ||||||
| 	{ |  | ||||||
| 		if( exame != null ) |  | ||||||
| 		{ |  | ||||||
| 			boolean porMarcar = new Integer( MedicinaConstants.ESTADO_POR_MARCAR ).equals( exame.getEstado() ); |  | ||||||
| 			boolean porRealizado = new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( exame.getEstado() ); |  | ||||||
| 			buttonNovoExameMarcacao.setEnabled( porMarcar ); |  | ||||||
| 			buttonApagarExame.setEnabled( porRealizado ); |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_EXAME_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO) |  | ||||||
| 	public void setForExameMarcacao( TrabalhadoresEcdsDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		if( marcacao != null ) |  | ||||||
| 		{ |  | ||||||
| 			boolean porRealizar = new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ).equals( marcacao.getEstado() ); |  | ||||||
| 			List list = marcacao.getTrabalhadoresEcdsDatasObservacoesArray(); |  | ||||||
| 			boolean noObservacoes = (list == null || list.size() == 0) ? true : false; |  | ||||||
| 			buttonExameMarcacaoDesmarcarSiprp.setEnabled( porRealizar ); |  | ||||||
| 			buttonExameMarcacaoDesmarcarTrabalhador.setEnabled( porRealizar ); |  | ||||||
| 			buttonExameMarcacaoFaltou.setEnabled( porRealizar ); |  | ||||||
| 			buttonExameMarcacaoRealizar.setEnabled( porRealizar ); |  | ||||||
| 			buttonExameMarcacaoRealizarParcial.setEnabled( porRealizar ); |  | ||||||
| 			buttonExameMarcacaoAnular.setEnabled( porRealizar ); |  | ||||||
| 			buttonApagarExameMarcacao.setEnabled( porRealizar ); |  | ||||||
| 			buttonNovoExameMarcacaoObservacoes.setEnabled( noObservacoes ); |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_EXAME_MARCACAO_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_EMAIL) |  | ||||||
| 	public void setForExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_START_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_OBSERVACAO) |  | ||||||
| 	public void setForExameMarcacaoObservacao( TrabalhadoresEcdsDatasObservacoes obs ) |  | ||||||
| 	{ |  | ||||||
| 		if( obs != null ) |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_START_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( cardPanel, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupStartPanel() |  | ||||||
| 	{ |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupTrabalhadorPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleActionsPanel( panelTrabalhador, buttonNovoTrabalhadorProcesso, buttonNovoLembrete, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupProcessoPanel() |  | ||||||
| 	{ |  | ||||||
| 		JPanel panelTopProcesso = new JPanel(); |  | ||||||
| 		JPanel panelBottomProcesso = new JPanel(); |  | ||||||
| 		setupSimpleActionsPanel( panelTopProcesso, buttonNovoProcessoConsulta, buttonNovoProcessoExame ); |  | ||||||
| 		setupSimpleActionsPanel( panelBottomProcesso, buttonCriarFicha, buttonFecharProcesso, buttonApagarProcesso ); |  | ||||||
| 		setupTopBottomSimpleActionsPanel( panelProcesso, panelTopProcesso, panelBottomProcesso ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupFichaPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleActionsPanel( panelFicha, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupConsultaPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleActionsPanel( panelConsulta, buttonNovoConsultaMarcacao, buttonApagarConsulta, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupConsultaMarcacaoPanel() |  | ||||||
| 	{ |  | ||||||
| 		JPanel consultaMarcacaoUpperPanel = new JPanel(); |  | ||||||
| 		JPanel consultaMarcacaoLowerPanel = new JPanel(); |  | ||||||
| 		setupSimpleActionsPanel( consultaMarcacaoUpperPanel, buttonNovoConsultaMarcacaoEmail, buttonNovoConsultaMarcacaoEmailVacinas, buttonNovoConsultaMarcacaoObservacoes ); |  | ||||||
| 		setupSimpleActionsPanel( consultaMarcacaoLowerPanel, buttonConsultaMarcacaoRealizar, buttonConsultaMarcacaoDesmarcarSiprp, buttonConsultaMarcacaoDesmarcarTrabalhador, buttonConsultaMarcacaoFaltou, buttonApagarConsultaMarcacao); |  | ||||||
| 		setupTopBottomSimpleActionsPanel(panelConsultaMarcacao, consultaMarcacaoUpperPanel, consultaMarcacaoLowerPanel); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupExameMarcacaoPanel() |  | ||||||
| 	{ |  | ||||||
| 		JPanel exameMarcacaoUpperPanel = new JPanel(); |  | ||||||
| 		JPanel exameMarcacaoLowerPanel = new JPanel(); |  | ||||||
| 		setupSimpleActionsPanel( exameMarcacaoUpperPanel, buttonNovoExameMarcacaoEmail, buttonNovoExameMarcacaoObservacoes, new JPanel() ); |  | ||||||
| 		setupSimpleActionsPanel( exameMarcacaoLowerPanel, buttonExameMarcacaoRealizar, buttonExameMarcacaoRealizarParcial, buttonExameMarcacaoFaltou, buttonExameMarcacaoAnular, buttonExameMarcacaoDesmarcarTrabalhador, buttonExameMarcacaoDesmarcarSiprp, buttonApagarExameMarcacao ); |  | ||||||
| 		setupTopBottomSimpleActionsPanel(panelExameMarcacao, exameMarcacaoUpperPanel, exameMarcacaoLowerPanel); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupExamePanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleActionsPanel( panelExame, buttonNovoExameMarcacao, buttonApagarExame, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	private void setupTopBottomSimpleActionsPanel(JPanel panel, JPanel top, JPanel bottom) |  | ||||||
| 	{ |  | ||||||
| 		TableLayout layout = new TableLayout(new double[]{TableLayout.FILL}, new double[]{TableLayout.MINIMUM, TableLayout.FILL,TableLayout.MINIMUM}); |  | ||||||
| 		panel.setLayout( layout ); |  | ||||||
| 		panel.add( top, new TableLayoutConstraints(0,0) ); |  | ||||||
| 		panel.add( new JPanel(), new TableLayoutConstraints(0,1) ); |  | ||||||
| 		panel.add( bottom, new TableLayoutConstraints(0,2) ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupSimpleActionsPanel( JPanel panel, JComponent... field ) |  | ||||||
| 	{ |  | ||||||
| 		double[] cols = new double[] { |  | ||||||
| 			FILL |  | ||||||
| 		}; |  | ||||||
| 		double[] rows = new double[field.length]; |  | ||||||
| 		for( int i = 0; i < field.length; rows[i++] = MINIMUM ) |  | ||||||
| 			; |  | ||||||
| 		rows[rows.length - 1] = FILL; |  | ||||||
| 		TableLayout layout = new TableLayout( cols, rows ); |  | ||||||
| 		panel.setLayout( layout ); |  | ||||||
| 
 |  | ||||||
| 		for( int i = 0; i < field.length; ++i ) |  | ||||||
| 		{ |  | ||||||
| 			panel.add( field[i], new TableLayoutConstraints( 0, i ) ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,902 +0,0 @@ | |||||||
| package siprp.medicina.processo.ui; |  | ||||||
| 
 |  | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; |  | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; |  | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.iacute; |  | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.otilde; |  | ||||||
| import static info.clearthought.layout.TableLayoutConstants.FILL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_CONSULTA_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_EXAME_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_OBSERVACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_OBSERVACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_FICHA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TRABALHADOR; |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.awt.CardLayout; |  | ||||||
| import java.io.File; |  | ||||||
| import java.util.Calendar; |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.List; |  | ||||||
| import java.util.Map; |  | ||||||
| import java.util.Vector; |  | ||||||
| 
 |  | ||||||
| import javax.swing.BorderFactory; |  | ||||||
| import javax.swing.JComponent; |  | ||||||
| import javax.swing.JLabel; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| 
 |  | ||||||
| import leaf.ui.LeafCalendarDialog; |  | ||||||
| import leaf.ui.LeafInputField; |  | ||||||
| import leaf.ui.LeafOptionDialog; |  | ||||||
| import leaf.ui.LeafTextDialog; |  | ||||||
| import leaf.ui.LeafWindow; |  | ||||||
| import leaf.ui.LeafLogic.LeafUIActionBinding; |  | ||||||
| import leaf.ui.LeafWindow.ActionActivation; |  | ||||||
| import siprp.CompanyDataLoader; |  | ||||||
| import siprp.MedicinaConstants; |  | ||||||
| import siprp.ProcessoConstants; |  | ||||||
| import siprp.SingletonConstants; |  | ||||||
| import siprp.database.cayenne.objects.Contactos; |  | ||||||
| import siprp.database.cayenne.objects.Estabelecimentos; |  | ||||||
| import siprp.database.cayenne.objects.Prestadores; |  | ||||||
| import siprp.database.cayenne.objects.PrtGruposProtocolo; |  | ||||||
| import siprp.database.cayenne.objects.Trabalhadores; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcd; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcds; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresFichasAptidao; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresProcesso; |  | ||||||
| import siprp.medicina.MedicinaDataProvider; |  | ||||||
| import siprp.medicina.processo.mail.MailDialog; |  | ||||||
| 
 |  | ||||||
| import com.evolute.adt.OrderedMap; |  | ||||||
| import com.evolute.utils.Singleton; |  | ||||||
| 
 |  | ||||||
| public class ProcessoDadosPanel extends JPanel |  | ||||||
| { |  | ||||||
| 	private static final long serialVersionUID = 1L; |  | ||||||
| 	private final LeafWindow parentWindow; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_START_NAME = "START_PANEL"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_TRABALHADOR_NAME = "TRABALHADOR_PANEL"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_PROCESSO_NAME = "PROCESSO_PANEL"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_FICHA_NAME = "PANEL_FICHA_NAME"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_CONSULTA_NAME = "PANEL_CONSULTA_NAME"; |  | ||||||
| 	private static final String PANEL_CONSULTA_MARCACAO_NAME = "PANEL_CONSULTA_MARCACAO_NAME"; |  | ||||||
| 	private static final String PANEL_CONSULTA_MARCACAO_EMAIL_NAME = "PANEL_CONSULTA_MARCACAO_EMAIL_NAME"; |  | ||||||
| 	private static final String PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME = "PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME"; |  | ||||||
| 
 |  | ||||||
| 	private static final String PANEL_EXAME_NAME = "EXAME_PANEL"; |  | ||||||
| 	private static final String PANEL_EXAME_MARCACAO_NAME = "PANEL_EXAME_MARCACAO_NAME"; |  | ||||||
| 	private static final String PANEL_EXAME_MARCACAO_EMAIL_NAME = "PANEL_EXAME_MARCACAO_EMAIL_NAME"; |  | ||||||
| 	private static final String PANEL_EXAME_MARCACAO_OBSERVACAO_NAME = "PANEL_EXAME_MARCACAO_OBSERVACAO_NAME"; |  | ||||||
| 
 |  | ||||||
| 	private final CardLayout cardLayout = new CardLayout(); |  | ||||||
| 
 |  | ||||||
| 	// panels
 |  | ||||||
| 	private final JPanel panelExame = new JPanel(); |  | ||||||
| 	private final JPanel panelExameMarcacao = new JPanel(); |  | ||||||
| 	private final JPanel panelExameMarcacaoEmail = new JPanel(); |  | ||||||
| 	private final JPanel panelExameMarcacaoObservacao = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelConsulta = new JPanel(); |  | ||||||
| 	private final JPanel panelConsultaMarcacao = new JPanel(); |  | ||||||
| 	private final JPanel panelConsultaMarcacaoEmail = new JPanel(); |  | ||||||
| 	private final JPanel panelConsultaMarcacaoObservacao = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelProcesso = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelTrabalhador = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelFicha = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	private final JPanel panelStart = new JPanel(); |  | ||||||
| 
 |  | ||||||
| 	// trabalhador
 |  | ||||||
| 	private final JLabel labelTrabalhadorNome = new JLabel( "Nome" ); |  | ||||||
| 	private final JLabel labelTrabalhadorSexo = new JLabel( "Sexo" ); |  | ||||||
| 	private final JLabel labelTrabalhadoresDataNascimento = new JLabel( "Data de Nascimento" ); |  | ||||||
| 	private final JLabel labelTrabalhadorNacionalidade = new JLabel( "Nacionalidade" ); |  | ||||||
| 	private final JLabel labelTrabalhadorBI = new JLabel( "B.I." ); |  | ||||||
| 	private final JLabel labelTrabalhadorObservacoes = new JLabel( "Observa" + ccedil + otilde + "es" ); |  | ||||||
| 	private final JLabel labelTrabalhadoresDataAdmissao = new JLabel( "Data de Admiss" + atilde + "o" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<String> inputTrabalhadorNome = new LeafInputField<String>(); |  | ||||||
| 	public final LeafInputField<HashMap<String, String>> inputTrabalhadorSexo = new LeafInputField<HashMap<String, String>>(); |  | ||||||
| 	public final LeafInputField<Date> inputTrabalhadoresDataNascimento = new LeafInputField<Date>(); |  | ||||||
| 	public final LeafInputField<String> inputTrabalhadorNacionalidade = new LeafInputField<String>(); |  | ||||||
| 	public final LeafInputField<String> inputTrabalhadorBI = new LeafInputField<String>(); |  | ||||||
| 	public final LeafInputField<String> inputTrabalhadorObservacoes = new LeafInputField<String>(); |  | ||||||
| 	public final LeafInputField<Date> inputTrabalhadoresDataAdmissao = new LeafInputField<Date>(); |  | ||||||
| 
 |  | ||||||
| 	// processo
 |  | ||||||
| 
 |  | ||||||
| 	private final JLabel labelProcessoEstado = new JLabel( "Estado" ); |  | ||||||
| 	private final JLabel labelProcessoDataInicio = new JLabel( "In" + iacute + "cio" ); |  | ||||||
| 	private final JLabel labelProcessoDataFim = new JLabel( "Fim" ); |  | ||||||
| 	private final JLabel labelProcessoMotivo = new JLabel( "Motivo" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<HashMap<String, String>> inputProcessoEstado = new LeafInputField<HashMap<String, String>>(); |  | ||||||
| 	public final LeafInputField<Date> inputProcessoDataInicio = new LeafInputField<Date>(); |  | ||||||
| 	public final LeafInputField<Date> inputProcessoDataFim = new LeafInputField<Date>(); |  | ||||||
| 	@ActionActivation(onSelect = "", onChange = SAVE_PROCESSO) |  | ||||||
| 	public final LeafInputField<HashMap<Integer, String>> inputProcessoMotivo = new LeafInputField<HashMap<Integer, String>>(); |  | ||||||
| 
 |  | ||||||
| 	// consulta
 |  | ||||||
| 	private final JLabel labelConsultaEstado = new JLabel( "Estado" ); |  | ||||||
| 	private final JLabel labelConsultaData = new JLabel( "Data" ); |  | ||||||
| 	private final JLabel labelConsultaPrestador = new JLabel( "Prestador" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<HashMap<Integer, String>> inputConsultaEstado = new LeafInputField<HashMap<Integer, String>>(); |  | ||||||
| 	public final LeafInputField<Date> inputConsultaData = new LeafInputField<Date>(); |  | ||||||
| 	public final LeafInputField<String> inputConsultaPrestador = new LeafInputField<String>(); |  | ||||||
| 
 |  | ||||||
| 	// marcacao consulta
 |  | ||||||
| 	private final JLabel labelConsultaMarcacaoEstado = new JLabel( "Estado" ); |  | ||||||
| 	private final JLabel labelConsultaMarcacaoData = new JLabel( "Data" ); |  | ||||||
| 	private final JLabel labelConsultaMarcacaoPrestador = new JLabel( "Prestador" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<HashMap<Integer, String>> inputConsultaMarcacaoEstado = new LeafInputField<HashMap<Integer, String>>(); |  | ||||||
| 	public final LeafInputField<Date> inputConsultaMarcacaoData = new LeafInputField<Date>(); |  | ||||||
| 	@ActionActivation(onSelect = "", onChange = SAVE_CONSULTA_MARCACAO) |  | ||||||
| 	public final LeafInputField<OrderedMap<Prestadores>> inputConsultaMarcacaoPrestador = new LeafInputField<OrderedMap<Prestadores>>(); |  | ||||||
| 
 |  | ||||||
| 	// email marcacao consulta
 |  | ||||||
| 	private final JLabel labelConsultaMarcacaoEmailData = new JLabel( "Data" ); |  | ||||||
| 	private final JLabel labelConsultaMarcacaoEmailSubject = new JLabel( "Assunto" ); |  | ||||||
| 	private final JLabel labelConsultaMarcacaoEmailBody = new JLabel( "Mensagem" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<Date> inputConsultaMarcacaoEmailData = new LeafInputField<Date>(); |  | ||||||
| 	public final LeafInputField<String> inputConsultaMarcacaoEmailSubject = new LeafInputField<String>(); |  | ||||||
| 	public final LeafInputField<String> inputConsultaMarcacaoEmailBody = new LeafInputField<String>(); |  | ||||||
| 
 |  | ||||||
| 	// observacao marcacao consulta
 |  | ||||||
| 	@ActionActivation(onSelect = "", onChange = SAVE_CONSULTA_MARCACAO_OBSERVACOES) |  | ||||||
| 	public final LeafInputField<String> inputConsultaMarcacaoObsMensagem = new LeafInputField<String>(); |  | ||||||
| 
 |  | ||||||
| 	// exame
 |  | ||||||
| 	private final JLabel labelExameEstado = new JLabel( "Estado" ); |  | ||||||
| 	private final JLabel labelExameData = new JLabel( "Data" ); |  | ||||||
| 	private final JLabel labelExameGruposEcds = new JLabel( "ECDs" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<HashMap<Integer, String>> inputExameEstado = new LeafInputField<HashMap<Integer, String>>(); |  | ||||||
| 	public final LeafInputField<OrderedMap<PrtGruposProtocolo>> inputExameGruposEcds = new LeafInputField<OrderedMap<PrtGruposProtocolo>>(); |  | ||||||
| 	public final LeafInputField<Date> inputExameData = new LeafInputField<Date>(); |  | ||||||
| 
 |  | ||||||
| 	// marcacao exame
 |  | ||||||
| 	private final JLabel labelExameMarcacaoEstado = new JLabel( "Estado" ); |  | ||||||
| 	private final JLabel labelExameMarcacaoData = new JLabel( "Data" ); |  | ||||||
| 	private final JLabel labelExameMarcacaoGruposEcds = new JLabel( "ECDs" ); |  | ||||||
| 	private final JLabel labelExameMarcacaoPrestador = new JLabel( "Prestador" ); |  | ||||||
| 	private final JLabel labelExameMarcacaoAnalisador = new JLabel( "Analisadores" ); |  | ||||||
| 	private final JLabel labelExameMarcacaoDataRecepcao = new JLabel( "Data de recep" + ccedil + atilde + "o" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<HashMap<Integer, String>> inputExameMarcacaoEstado = new LeafInputField<HashMap<Integer, String>>(); |  | ||||||
| 	public final LeafInputField<Date> inputExameMarcacaoData = new LeafInputField<Date>(); |  | ||||||
| 	@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO) |  | ||||||
| 	public final LeafInputField<Date> inputExameMarcacaoDataRecepcao = new LeafInputField<Date>(); |  | ||||||
| 	public final LeafInputField<OrderedMap<PrtGruposProtocolo>> inputExameMarcacaoGruposEcds = new LeafInputField<OrderedMap<PrtGruposProtocolo>>(); |  | ||||||
| 	@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO) |  | ||||||
| 	public final LeafInputField<OrderedMap<Prestadores>> inputExameMarcacaoPrestador = new LeafInputField<OrderedMap<Prestadores>>(); |  | ||||||
| 	@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO) |  | ||||||
| 	public final LeafInputField<OrderedMap<PrtGruposProtocolo>> inputExameMarcacaoAnalisador = new LeafInputField<OrderedMap<PrtGruposProtocolo>>(); |  | ||||||
| 
 |  | ||||||
| 	// email marcacao exame
 |  | ||||||
| 	private final JLabel labelExameMarcacaoEmailData = new JLabel( "Data" ); |  | ||||||
| 	private final JLabel labelExameMarcacaoEmailSubject = new JLabel( "Assunto" ); |  | ||||||
| 	private final JLabel labelExameMarcacaoEmailBody = new JLabel( "Mensagem" ); |  | ||||||
| 
 |  | ||||||
| 	public final LeafInputField<Date> inputExameMarcacaoEmailData = new LeafInputField<Date>(); |  | ||||||
| 	public final LeafInputField<String> inputExameMarcacaoEmailSubject = new LeafInputField<String>(); |  | ||||||
| 	public final LeafInputField<String> inputExameMarcacaoEmailBody = new LeafInputField<String>(); |  | ||||||
| 
 |  | ||||||
| 	// observacao marcacao exame
 |  | ||||||
| 	@ActionActivation(onSelect = "", onChange = SAVE_EXAME_MARCACAO_OBSERVACOES) |  | ||||||
| 	public final LeafInputField<String> inputExameMarcacaoObsMensagem = new LeafInputField<String>(); |  | ||||||
| 
 |  | ||||||
| 	public ProcessoDadosPanel(LeafWindow parentWindow) |  | ||||||
| 	{ |  | ||||||
| 		this.parentWindow = parentWindow; |  | ||||||
| 		setupLayout(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 		placeComponents(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupLayout() |  | ||||||
| 	{ |  | ||||||
| 		this.setLayout( cardLayout ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		setupStartPanel(); |  | ||||||
| 		setupTrabalhadorPanel(); |  | ||||||
| 		setupProcessoPanel(); |  | ||||||
| 		setupFichaPanel(); |  | ||||||
| 		setupConsultaPanel(); |  | ||||||
| 		setupConsultaMarcacaoPanel(); |  | ||||||
| 		setupConsultaMarcacaoEmailPanel(); |  | ||||||
| 		setupConsultaMarcacaoObservacoesPanel(); |  | ||||||
| 		setupExamePanel(); |  | ||||||
| 		setupExameMarcacaoPanel(); |  | ||||||
| 		setupExameMarcacaoEmailPanel(); |  | ||||||
| 		setupExameMarcacaoObservacoesPanel(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void placeComponents() |  | ||||||
| 	{ |  | ||||||
| 		add( panelStart, PANEL_START_NAME ); |  | ||||||
| 		add( panelTrabalhador, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		add( panelFicha, PANEL_FICHA_NAME ); |  | ||||||
| 		add( panelProcesso, PANEL_PROCESSO_NAME ); |  | ||||||
| 		add( panelConsulta, PANEL_CONSULTA_NAME ); |  | ||||||
| 		add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME ); |  | ||||||
| 		add( panelConsultaMarcacaoEmail, PANEL_CONSULTA_MARCACAO_EMAIL_NAME ); |  | ||||||
| 		add( panelConsultaMarcacaoObservacao, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME ); |  | ||||||
| 		add( panelExame, PANEL_EXAME_NAME ); |  | ||||||
| 		add( panelExameMarcacao, PANEL_EXAME_MARCACAO_NAME ); |  | ||||||
| 		add( panelExameMarcacaoEmail, PANEL_EXAME_MARCACAO_EMAIL_NAME ); |  | ||||||
| 		add( panelExameMarcacaoObservacao, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private int getIdade( Date nascimento ) |  | ||||||
| 	{ |  | ||||||
| 		int result = 0; |  | ||||||
| 		if( nascimento != null ) |  | ||||||
| 		{ |  | ||||||
| 			Calendar now = Calendar.getInstance(); |  | ||||||
| 			Calendar birth = Calendar.getInstance(); |  | ||||||
| 			birth.setTime( nascimento ); |  | ||||||
| 			int birthYear = birth.get( Calendar.YEAR ); |  | ||||||
| 			int currentYear = now.get( Calendar.YEAR ); |  | ||||||
| 			if( birthYear < currentYear ) |  | ||||||
| 			{ |  | ||||||
| 				result = currentYear - birthYear; |  | ||||||
| 				birth.add( Calendar.YEAR, result ); |  | ||||||
| 				if( birth.after( now ) ) |  | ||||||
| 				{ |  | ||||||
| 					--result; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		return result; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = { |  | ||||||
| 			LOAD_TRABALHADOR, SELECT_TRABALHADOR |  | ||||||
| 	}) |  | ||||||
| 	public void setForTrabalhador( Trabalhadores trabalhador ) |  | ||||||
| 	{ |  | ||||||
| 		if( trabalhador != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputTrabalhadoresDataNascimento.setObject( trabalhador.getDataNascimento() ); |  | ||||||
| 			inputTrabalhadorSexo.setObject( trabalhador.getSexos(), trabalhador.getSexo() ); |  | ||||||
| 			inputTrabalhadorNome.setObject( trabalhador.getNome() ); |  | ||||||
| 			inputTrabalhadorNacionalidade.setObject( trabalhador.getNacionalidade() ); |  | ||||||
| 			inputTrabalhadorBI.setObject( trabalhador.getBi() ); |  | ||||||
| 			inputTrabalhadorObservacoes.setObject( trabalhador.getObservacoesGestao() ); |  | ||||||
| 			inputTrabalhadoresDataAdmissao.setObject( trabalhador.getDataAdmissao() ); |  | ||||||
| 			labelTrabalhadoresDataNascimento.setText( "Data de Nascimento (" + getIdade( trabalhador.getDataNascimento() ) + " anos)" ); |  | ||||||
| 
 |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_START_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_PROCESSO) |  | ||||||
| 	public void setForProcesso( TrabalhadoresProcesso processo ) |  | ||||||
| 	{ |  | ||||||
| 		if( processo != null ) |  | ||||||
| 		{ |  | ||||||
| 			boolean isFechado = ProcessoConstants.PROCESSO_FECHADO_CODE.equals( processo.getEstado() ); |  | ||||||
| 			inputProcessoDataFim.setObject( processo.getDataFim() ); |  | ||||||
| 			inputProcessoDataInicio.setObject( processo.getDataInicio() ); |  | ||||||
| 			inputProcessoEstado.setObject( processo.getEstados(), processo.getEstado() ); |  | ||||||
| 			inputProcessoMotivo.setEditable( !isFechado ); |  | ||||||
| 			inputProcessoMotivo.setObject( processo.getMotivos(), processo.getMotivo() ); |  | ||||||
| 			cardLayout.show( this, PANEL_PROCESSO_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_FICHA) |  | ||||||
| 	public void setForFicha( TrabalhadoresFichasAptidao ficha ) |  | ||||||
| 	{ |  | ||||||
| 		if( ficha != null ) |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_FICHA_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA) |  | ||||||
| 	public void setForConsulta( TrabalhadoresConsultas consulta ) |  | ||||||
| 	{ |  | ||||||
| 		if( consulta != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputConsultaEstado.setObject( MedicinaDataProvider.getConsultaEstados(), consulta.getEstado() ); |  | ||||||
| 			inputConsultaData.setObject( consulta.getData() == null ? new Date( 0 ) : consulta.getData() ); |  | ||||||
| 
 |  | ||||||
| 			inputConsultaPrestador.setObject( (consulta.getToPrestadores() == null || consulta.getToPrestadores().getNome() == null) ? " " : consulta.getToPrestadores().getNome() ); |  | ||||||
| 
 |  | ||||||
| 			cardLayout.show( this, PANEL_CONSULTA_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO) |  | ||||||
| 	public void setForConsultaMarcacao( TrabalhadoresConsultasDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		if( marcacao != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputConsultaMarcacaoData.setObject( marcacao.getData() ); |  | ||||||
| 			inputConsultaMarcacaoEstado.setObject( MedicinaDataProvider.getConsultaEstados(), marcacao.getEstado() ); |  | ||||||
| 
 |  | ||||||
| 			inputConsultaMarcacaoPrestador.setEditable( true ); |  | ||||||
| 
 |  | ||||||
| 			Prestadores prestador = marcacao.getToPrestadores(); |  | ||||||
| 			List<Prestadores> allPrestadores = Prestadores.getAllPrestadores(); |  | ||||||
| 			inputConsultaMarcacaoPrestador.setObject( new OrderedMap<Prestadores>( allPrestadores ), prestador == null ? Prestadores.prestadorNulo : prestador ); |  | ||||||
| 			cardLayout.show( this, PANEL_CONSULTA_MARCACAO_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_EMAIL) |  | ||||||
| 	public void setForConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputConsultaMarcacaoEmailBody.setObject( email.getBody() ); |  | ||||||
| 			inputConsultaMarcacaoEmailSubject.setObject( email.getSubject() ); |  | ||||||
| 			inputConsultaMarcacaoEmailData.setObject( email.getData() ); |  | ||||||
| 			cardLayout.show( this, PANEL_CONSULTA_MARCACAO_EMAIL_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_OBSERVACAO) |  | ||||||
| 	public void setForConsultaMarcacaoObs( TrabalhadoresConsultasDatasObservacoes obs ) |  | ||||||
| 	{ |  | ||||||
| 		if( obs != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputConsultaMarcacaoObsMensagem.setEditable( true ); |  | ||||||
| 			inputConsultaMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() ); |  | ||||||
| 			cardLayout.show( this, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME) |  | ||||||
| 	public void setForExame( TrabalhadoresEcds exame ) |  | ||||||
| 	{ |  | ||||||
| 		if( exame != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputExameData.setObject( exame.getData() ); |  | ||||||
| 			inputExameEstado.setObject( exame.getEstados(), exame.getEstado() ); |  | ||||||
| 			OrderedMap<PrtGruposProtocolo> grupos = exame.getGruposExamesForPerfil(); |  | ||||||
| 			inputExameGruposEcds.setCollapseOptions( false ); |  | ||||||
| 			inputExameGruposEcds.setObject( grupos, grupos.getFirst() ); |  | ||||||
| 			cardLayout.show( this, PANEL_EXAME_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO) |  | ||||||
| 	public void setForExameMarcacao( TrabalhadoresEcdsDatas exameMarcacao ) |  | ||||||
| 	{ |  | ||||||
| 		if( exameMarcacao != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputExameMarcacaoData.setObject( exameMarcacao.getData() ); |  | ||||||
| 			Date dataRecepcao = exameMarcacao.getDataRecepcao(); |  | ||||||
| 			inputExameMarcacaoDataRecepcao.setObject( dataRecepcao == null ? new Date(0) : dataRecepcao ); |  | ||||||
| 			inputExameMarcacaoDataRecepcao.setEditable( true ); |  | ||||||
| 			inputExameMarcacaoEstado.setObject( exameMarcacao.getEstados(), exameMarcacao.getEstado() ); |  | ||||||
| 			OrderedMap<PrtGruposProtocolo> grupos = exameMarcacao.getStatesForeGruposExames(); |  | ||||||
| 			inputExameMarcacaoGruposEcds.setCollapseOptions( false ); |  | ||||||
| 			inputExameMarcacaoGruposEcds.setObject( grupos, grupos.getFirst() ); |  | ||||||
| 
 |  | ||||||
| 			Prestadores prestador = exameMarcacao.getToPrestadores(); |  | ||||||
| 			List<Prestadores> allPrestadores = Prestadores.getAllPrestadores(); |  | ||||||
| 
 |  | ||||||
| 			if( prestador == null ) |  | ||||||
| 			{ |  | ||||||
| 				prestador = Prestadores.prestadorNulo; |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			inputExameMarcacaoPrestador.setEditable( true ); |  | ||||||
| 			inputExameMarcacaoPrestador.setObject( new OrderedMap<Prestadores>( allPrestadores ), prestador ); |  | ||||||
| 
 |  | ||||||
| 			boolean editable = Prestadores.prestadorNulo.equals( prestador ); |  | ||||||
| 			inputExameMarcacaoAnalisador.setCollapseOptions( false ); |  | ||||||
| 
 |  | ||||||
| 			List<TrabalhadoresEcd> allECDS = exameMarcacao.getTrabalhadoresEcdArray(); |  | ||||||
| 			OrderedMap<PrtGruposProtocolo> analisadoresForGrupos = new OrderedMap<PrtGruposProtocolo>(); |  | ||||||
| 
 |  | ||||||
| 			if( allECDS != null ) |  | ||||||
| 			{ |  | ||||||
| 				for( TrabalhadoresEcd current : allECDS ) |  | ||||||
| 				{ |  | ||||||
| 					Prestadores currentAnalisador = current.getToAnalisador(); |  | ||||||
| 
 |  | ||||||
| 					if( !prestador.equals( Prestadores.prestadorNulo ) ) |  | ||||||
| 					{ |  | ||||||
| 						currentAnalisador = prestador; |  | ||||||
| 					} |  | ||||||
| 					else if( currentAnalisador == null ) |  | ||||||
| 					{ |  | ||||||
| 						currentAnalisador = Prestadores.prestadorNulo; |  | ||||||
| 					} |  | ||||||
| 
 |  | ||||||
| 					PrtGruposProtocolo grupo = current.getToPrtTiposElementosProtocolo().getToPrtGruposProtocolo(); |  | ||||||
| 					if( !analisadoresForGrupos.containsKey( grupo ) ) |  | ||||||
| 					{ |  | ||||||
| 						analisadoresForGrupos.putLast( grupo, grupo.getDescricao() ); |  | ||||||
| 						LeafInputField<OrderedMap<Prestadores>> leaf = new LeafInputField<OrderedMap<Prestadores>>(); |  | ||||||
| 						leaf.setObject( new OrderedMap<Prestadores>( allPrestadores ), currentAnalisador ); |  | ||||||
| 						leaf.setEditable( editable ); |  | ||||||
| 						analisadoresForGrupos.putLast( grupo, leaf ); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			inputExameMarcacaoAnalisador.setObject( analisadoresForGrupos ); |  | ||||||
| 
 |  | ||||||
| 			inputExameMarcacaoAnalisador.setEditable( Prestadores.prestadorNulo.equals( prestador ) ); |  | ||||||
| 
 |  | ||||||
| 			cardLayout.show( this, PANEL_EXAME_MARCACAO_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_EMAIL) |  | ||||||
| 	public void setForExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputExameMarcacaoEmailBody.setObject( email.getBody() ); |  | ||||||
| 			inputExameMarcacaoEmailSubject.setObject( email.getSubject() ); |  | ||||||
| 			inputExameMarcacaoEmailData.setObject( email.getData() ); |  | ||||||
| 			cardLayout.show( this, PANEL_EXAME_MARCACAO_EMAIL_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_OBSERVACAO) |  | ||||||
| 	public void setForExameMarcacaoObs( TrabalhadoresEcdsDatasObservacoes obs ) |  | ||||||
| 	{ |  | ||||||
| 		if( obs != null ) |  | ||||||
| 		{ |  | ||||||
| 			inputExameMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() ); |  | ||||||
| 			inputExameMarcacaoObsMensagem.setEditable( true ); |  | ||||||
| 			cardLayout.show( this, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			cardLayout.show( this, PANEL_TRABALHADOR_NAME ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_PROCESSO) |  | ||||||
| 	public void setForNewProcesso( TrabalhadoresProcesso processo ) |  | ||||||
| 	{ |  | ||||||
| 		HashMap<Integer, String> tipos = processo.getMotivos(); |  | ||||||
| 		LeafOptionDialog<Integer> option = new LeafOptionDialog<Integer>( parentWindow, tipos, "Escolha o tipo de processo:" ); |  | ||||||
| 		Integer chosen = option.getOption(); |  | ||||||
| 		if( chosen != null ) |  | ||||||
| 		{ |  | ||||||
| 			processo.setMotivo( chosen ); |  | ||||||
| 		} |  | ||||||
| 		inputProcessoMotivo.setObject( tipos, chosen ); |  | ||||||
| 		inputProcessoDataInicio.setObject( processo.getDataInicio() ); |  | ||||||
| 		inputProcessoDataFim.setObject( processo.getDataFim() ); |  | ||||||
| 		inputProcessoEstado.setObject( processo.getEstados(), processo.getEstado() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO) |  | ||||||
| 	public void setForNewConsultaMarcacao( TrabalhadoresConsultasDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		LeafCalendarDialog calendar = new LeafCalendarDialog( parentWindow, false, true ); |  | ||||||
| 		Date date = calendar.getDate(); |  | ||||||
| 		if( date == null ) |  | ||||||
| 		{ |  | ||||||
| 			parentWindow.abortAction( true ); |  | ||||||
| 		} |  | ||||||
| 		marcacao.setData( date ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL) |  | ||||||
| 	public void setForNewConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			TrabalhadoresConsultasDatas consultaMarcacao = email.getToTrabalhadoresConsultasDatas(); |  | ||||||
| 			if( consultaMarcacao != null ) |  | ||||||
| 			{ |  | ||||||
| 				TrabalhadoresConsultas consulta = consultaMarcacao.getToTrabalhadoresConsultas(); |  | ||||||
| 				if( consulta != null ) |  | ||||||
| 				{ |  | ||||||
| 					String[] subjectAndBody = MedicinaConstants.ESTADO_REALIZADO == consulta.getEstado() ? sendMail( consulta.getToTrabalhadores(), consultaMarcacao.getDataString(), "", "" ) : sendMail( consulta.getToTrabalhadores(), consultaMarcacao.getDataString(), SingletonConstants.LETTER_CONSULTA, SingletonConstants.SUBJECT_CONSULTA ); |  | ||||||
| 					if( subjectAndBody != null ) |  | ||||||
| 					{ |  | ||||||
| 						email.setSubject( subjectAndBody[0] ); |  | ||||||
| 						email.setBody( subjectAndBody[1] ); |  | ||||||
| 					} |  | ||||||
| 					else |  | ||||||
| 					{ |  | ||||||
| 						parentWindow.abortAction( true ); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL_VACINAS) |  | ||||||
| 	public void setForNewConsultaMarcacaoEmailVacinas( TrabalhadoresConsultasDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			TrabalhadoresConsultasDatas consultaMarcacao = email.getToTrabalhadoresConsultasDatas(); |  | ||||||
| 			if( consultaMarcacao != null ) |  | ||||||
| 			{ |  | ||||||
| 				TrabalhadoresConsultas consulta = consultaMarcacao.getToTrabalhadoresConsultas(); |  | ||||||
| 				if( consulta != null ) |  | ||||||
| 				{ |  | ||||||
| 					String[] subjectAndBody = sendMail( consulta.getToTrabalhadores(), consultaMarcacao.getDataString(), SingletonConstants.LETTER_CONSULTA_VACINAS, SingletonConstants.SUBJECT_CONSULTA_VACINAS ); |  | ||||||
| 					if( subjectAndBody != null ) |  | ||||||
| 					{ |  | ||||||
| 						email.setSubject( subjectAndBody[0] ); |  | ||||||
| 						email.setBody( subjectAndBody[1] ); |  | ||||||
| 					} |  | ||||||
| 					else |  | ||||||
| 					{ |  | ||||||
| 						parentWindow.abortAction( true ); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private String[] sendMail( Trabalhadores trabalhador, String data, String letterName, String subjectName ) |  | ||||||
| 	{ |  | ||||||
| 		String[] result = null; |  | ||||||
| 		if( trabalhador != null ) |  | ||||||
| 		{ |  | ||||||
| 			Estabelecimentos estabelecimento = trabalhador.getToEstabelecimentos(); |  | ||||||
| 			if( estabelecimento != null ) |  | ||||||
| 			{ |  | ||||||
| 				String to = ""; |  | ||||||
| 				String bcc = ""; |  | ||||||
| 				String subject = ""; |  | ||||||
| 				String body = ""; |  | ||||||
| 
 |  | ||||||
| 				subject = (String) Singleton.getInstance( subjectName ); |  | ||||||
| 				if( subject == null ) |  | ||||||
| 				{ |  | ||||||
| 					subject = ""; |  | ||||||
| 				} |  | ||||||
| 				subject = subject.replaceAll( CompanyDataLoader.NOME, trabalhador.getNome() ); |  | ||||||
| 
 |  | ||||||
| 				body = (String) Singleton.getInstance( letterName ); |  | ||||||
| 				if( body == null ) |  | ||||||
| 				{ |  | ||||||
| 					body = ""; |  | ||||||
| 				} |  | ||||||
| 				body = body.replaceAll( CompanyDataLoader.DATA, data ); |  | ||||||
| 				body = body.replaceAll( CompanyDataLoader.NOME, trabalhador.getNome() ); |  | ||||||
| 				// body = body.replaceAll( CompanyDataLoader.MORADA, morada );
 |  | ||||||
| 				body = body.replaceAll( "%0A", "<br>" ); |  | ||||||
| 
 |  | ||||||
| 				Contactos estabelecimentoContacto = estabelecimento.getToContactos(); |  | ||||||
| 				if( estabelecimentoContacto != null ) |  | ||||||
| 				{ |  | ||||||
| 					String estabelecimentoEmail = estabelecimentoContacto.getEmail(); |  | ||||||
| 					if( estabelecimentoEmail != null ) |  | ||||||
| 					{ |  | ||||||
| 						to = estabelecimentoEmail; |  | ||||||
| 						try |  | ||||||
| 						{ |  | ||||||
| 							MailDialog mailDialog = new MailDialog( parentWindow, to, bcc, subject, body, new Vector<File>() ); |  | ||||||
| 							result = new String[2]; |  | ||||||
| 							result[0] = mailDialog.getSubject(); |  | ||||||
| 							result[1] = mailDialog.getMessage(); |  | ||||||
| 						} catch( Exception e ) |  | ||||||
| 						{ |  | ||||||
| 							e.printStackTrace( System.out ); |  | ||||||
| 							e.printStackTrace(); |  | ||||||
| 							result = null; |  | ||||||
| 						} |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		return result; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES) |  | ||||||
| 	public void setForNewConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes ) |  | ||||||
| 	{ |  | ||||||
| 		LeafTextDialog textDialog = new LeafTextDialog( parentWindow, this, "", true ); |  | ||||||
| 		String text = textDialog.getText(); |  | ||||||
| 		observacoes.setObservacao( text ); |  | ||||||
| 		inputConsultaMarcacaoObsMensagem.setEditable( true ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO) |  | ||||||
| 	public void setForNewExameMarcacao( TrabalhadoresEcdsDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		LeafCalendarDialog calendar = new LeafCalendarDialog( parentWindow, false, true ); |  | ||||||
| 		Date date = calendar.getDate(); |  | ||||||
| 		if( date == null ) |  | ||||||
| 		{ |  | ||||||
| 			parentWindow.abortAction( true ); |  | ||||||
| 		} |  | ||||||
| 		marcacao.setData( date ); |  | ||||||
| 
 |  | ||||||
| 		OrderedMap<PrtGruposProtocolo> allGrupos = marcacao.getToTrabalhadoresEcds().getGruposExamesForPerfil(); |  | ||||||
| 		OrderedMap<PrtGruposProtocolo> grupos = new OrderedMap<PrtGruposProtocolo>(); |  | ||||||
| 		Map<PrtGruposProtocolo, Boolean> gruposSelected = new HashMap<PrtGruposProtocolo, Boolean>(); |  | ||||||
| 		for( int row = 0; row < allGrupos.rows(); ++row ) |  | ||||||
| 		{ |  | ||||||
| 			List<Object> grupo = allGrupos.getRow( row ); |  | ||||||
| 			if( grupo != null && grupo.size() > 1 ) |  | ||||||
| 			{ |  | ||||||
| 				String estado = grupo.get( 1 ).toString(); |  | ||||||
| 				if( MedicinaConstants.ESTADOS_EXAME_STR[MedicinaConstants.ESTADO_POR_MARCAR].equals( estado ) ) |  | ||||||
| 				{ |  | ||||||
| 					PrtGruposProtocolo key = allGrupos.getKeyForValue( grupo ); |  | ||||||
| 					gruposSelected.put( key, true ); |  | ||||||
| 					grupos.addRow( key, grupo ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		LeafOptionDialog<PrtGruposProtocolo> gruposChosen = new LeafOptionDialog<PrtGruposProtocolo>( parentWindow, grupos, gruposSelected, null, "Escolha os ECDs para esta marca" + ccedil + atilde + "o", "Marcar >>" ); |  | ||||||
| 		for( PrtGruposProtocolo grupo : gruposChosen.getSelected() ) |  | ||||||
| 		{ |  | ||||||
| 			marcacao.marcarGrupoExames( grupo ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_EMAIL) |  | ||||||
| 	public void setForNewExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			TrabalhadoresEcdsDatas exameMarcacao = email.getToTrabalhadoresEcdsDatas(); |  | ||||||
| 			if( exameMarcacao != null ) |  | ||||||
| 			{ |  | ||||||
| 				TrabalhadoresEcds exame = exameMarcacao.getToTrabalhadoresEcds(); |  | ||||||
| 				if( exame != null ) |  | ||||||
| 				{ |  | ||||||
| 					String[] subjectAndBody = MedicinaConstants.ESTADO_REALIZADO == exame.getEstado() ? |  | ||||||
| 							sendMail( exame.getToTrabalhadores(), exame.getDataString(), "", "" ) |  | ||||||
| 							: |  | ||||||
| 								sendMail( exame.getToTrabalhadores(), exameMarcacao.getDataString(), SingletonConstants.LETTER_EXAMES, SingletonConstants.SUBJECT_EXAMES ); |  | ||||||
| 					if( subjectAndBody != null ) |  | ||||||
| 					{ |  | ||||||
| 						email.setSubject( subjectAndBody[0] ); |  | ||||||
| 						email.setBody( subjectAndBody[1] ); |  | ||||||
| 					} |  | ||||||
| 					else |  | ||||||
| 					{ |  | ||||||
| 						parentWindow.abortAction( true ); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_OBSERVACOES) |  | ||||||
| 	public void setForNewExameMarcacaoObservacoes( TrabalhadoresEcdsDatasObservacoes observacoes ) |  | ||||||
| 	{ |  | ||||||
| 		LeafTextDialog textDialog = new LeafTextDialog( parentWindow, this, "", true ); |  | ||||||
| 		String text = textDialog.getText(); |  | ||||||
| 		observacoes.setObservacao( text ); |  | ||||||
| 		inputExameMarcacaoObsMensagem.setEditable( true ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SAVE_PROCESSO) |  | ||||||
| 	public void updateToSaveProcesso( TrabalhadoresProcesso processo ) |  | ||||||
| 	{ |  | ||||||
| 		processo.setMotivo( (Integer) inputProcessoMotivo.getSelectedObject() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO) |  | ||||||
| 	public void updateToSaveConsultaMarcacao( TrabalhadoresConsultasDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		Prestadores prestador = (Prestadores) inputConsultaMarcacaoPrestador.getSelectedObject(); |  | ||||||
| 		prestador = Prestadores.prestadorNulo.equals( prestador ) ? null : prestador; |  | ||||||
| 		marcacao.setToPrestadores( prestador ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_OBSERVACOES) |  | ||||||
| 	public void updateToSaveConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes ) |  | ||||||
| 	{ |  | ||||||
| 		observacoes.setObservacao( inputConsultaMarcacaoObsMensagem.getObject() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SAVE_EXAME_MARCACAO) |  | ||||||
| 	public void updateToSaveExameMarcacao( TrabalhadoresEcdsDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		Date dataRecepcao = inputExameMarcacaoDataRecepcao.getObject(); |  | ||||||
| 		if( dataRecepcao == null || dataRecepcao.getTime() == 0l ) |  | ||||||
| 		{ |  | ||||||
| 			marcacao.setDataRecepcao( null ); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			marcacao.setDataRecepcao( dataRecepcao ); |  | ||||||
| 		} |  | ||||||
| 		Prestadores prestador = (Prestadores) inputExameMarcacaoPrestador.getSelectedObject(); |  | ||||||
| 		prestador = Prestadores.prestadorNulo.equals( prestador ) ? null : prestador; |  | ||||||
| 		marcacao.setToPrestadores( prestador ); |  | ||||||
| 
 |  | ||||||
| 		List<TrabalhadoresEcd> allEcd = marcacao.getTrabalhadoresEcdArray(); |  | ||||||
| 		if( allEcd != null ) |  | ||||||
| 		{ |  | ||||||
| 			OrderedMap<PrtGruposProtocolo> map = inputExameMarcacaoAnalisador.getObject(); |  | ||||||
| 			for( TrabalhadoresEcd ecd : allEcd ) |  | ||||||
| 			{ |  | ||||||
| 				PrtGruposProtocolo grupo = ecd.getToPrtTiposElementosProtocolo().getToPrtGruposProtocolo(); |  | ||||||
| 				Object value = map.getValue( grupo, 1 ); |  | ||||||
| 				if( value != null ) |  | ||||||
| 				{ |  | ||||||
| 					LeafInputField<OrderedMap<Prestadores>> leaf = (LeafInputField<OrderedMap<Prestadores>>) value; |  | ||||||
| 					Prestadores ecdAnalisador = Prestadores.prestadorNulo.equals( (Prestadores) leaf.getSelectedObject() ) ? null : ((Prestadores) leaf.getSelectedObject()); |  | ||||||
| 					ecd.setToAnalisador( ecdAnalisador ); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SAVE_EXAME_MARCACAO_OBSERVACOES) |  | ||||||
| 	public void updateToSaveExameMarcacaoObservacoes( TrabalhadoresEcdsDatasObservacoes observacoes ) |  | ||||||
| 	{ |  | ||||||
| 		observacoes.setObservacao( inputExameMarcacaoObsMensagem.getObject() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupStartPanel() |  | ||||||
| 	{ |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupSimpleDataPanel( JPanel panel, String name, JComponent... field ) |  | ||||||
| 	{ |  | ||||||
| 		double[] cols = new double[] { |  | ||||||
| 			FILL |  | ||||||
| 		}; |  | ||||||
| 		double[] rows = new double[field.length]; |  | ||||||
| 		for( int i = 0; i < field.length; rows[i++] = TableLayout.PREFERRED ) |  | ||||||
| 			; |  | ||||||
| 		rows[rows.length - 1] = FILL; |  | ||||||
| 		TableLayout layout = new TableLayout( cols, rows ); |  | ||||||
| 		layout.setHGap( 5 ); |  | ||||||
| 		layout.setVGap( 5 ); |  | ||||||
| 		panel.setLayout( layout ); |  | ||||||
| 		if( name != null ) |  | ||||||
| 		{ |  | ||||||
| 			panel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), name ) ); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		for( int i = 0; i < field.length; ++i ) |  | ||||||
| 		{ |  | ||||||
| 			panel.add( field[i], new TableLayoutConstraints( 0, i ) ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupTrabalhadorPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelTrabalhador, "Trabalhador", labelTrabalhadorNome, inputTrabalhadorNome, labelTrabalhadorSexo, inputTrabalhadorSexo, labelTrabalhadorBI, inputTrabalhadorBI, labelTrabalhadorNacionalidade, inputTrabalhadorNacionalidade, labelTrabalhadoresDataNascimento, inputTrabalhadoresDataNascimento, labelTrabalhadoresDataAdmissao, inputTrabalhadoresDataAdmissao, labelTrabalhadorObservacoes, inputTrabalhadorObservacoes ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupProcessoPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelProcesso, "Processo", labelProcessoEstado, inputProcessoEstado, labelProcessoDataInicio, inputProcessoDataInicio, labelProcessoDataFim, inputProcessoDataFim, labelProcessoMotivo, inputProcessoMotivo, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupConsultaPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelConsulta, "Consulta", labelConsultaEstado, inputConsultaEstado, labelConsultaData, inputConsultaData, labelConsultaPrestador, inputConsultaPrestador, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupFichaPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelFicha, "Ficha de Aptid" + atilde + "o", new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupConsultaMarcacaoPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelConsultaMarcacao, "Marca" + ccedil + atilde + "o de Consulta", labelConsultaMarcacaoEstado, inputConsultaMarcacaoEstado, labelConsultaMarcacaoData, inputConsultaMarcacaoData, labelConsultaMarcacaoPrestador, inputConsultaMarcacaoPrestador, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupConsultaMarcacaoEmailPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelConsultaMarcacaoEmail, "Email", labelConsultaMarcacaoEmailData, inputConsultaMarcacaoEmailData, labelConsultaMarcacaoEmailSubject, inputConsultaMarcacaoEmailSubject, labelConsultaMarcacaoEmailBody, inputConsultaMarcacaoEmailBody ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupConsultaMarcacaoObservacoesPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelConsultaMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputConsultaMarcacaoObsMensagem ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupExamePanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelExame, "Exame", labelExameEstado, inputExameEstado, labelExameData, inputExameData, labelExameGruposEcds, inputExameGruposEcds, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupExameMarcacaoPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelExameMarcacao, "Marca" + ccedil + atilde + "o de Exame", labelExameMarcacaoEstado, inputExameMarcacaoEstado, labelExameMarcacaoData, inputExameMarcacaoData, labelExameMarcacaoGruposEcds, inputExameMarcacaoGruposEcds, labelExameMarcacaoPrestador, inputExameMarcacaoPrestador, labelExameMarcacaoAnalisador, inputExameMarcacaoAnalisador, labelExameMarcacaoDataRecepcao, inputExameMarcacaoDataRecepcao, new JPanel() ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupExameMarcacaoEmailPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelExameMarcacaoEmail, "Email", labelExameMarcacaoEmailData, inputExameMarcacaoEmailData, labelExameMarcacaoEmailSubject, inputExameMarcacaoEmailSubject, labelExameMarcacaoEmailBody, inputExameMarcacaoEmailBody ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupExameMarcacaoObservacoesPanel() |  | ||||||
| 	{ |  | ||||||
| 		setupSimpleDataPanel( panelExameMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputExameMarcacaoObsMensagem ); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,497 +0,0 @@ | |||||||
| package siprp.medicina.processo.ui; |  | ||||||
| 
 |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.APAGAR_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_EMAIL; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME_MARCACAO_OBSERVACOES; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_FICHA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_PROCESSO; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.REFRESH; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_TREE_NODE; |  | ||||||
| import info.clearthought.layout.TableLayout; |  | ||||||
| import info.clearthought.layout.TableLayoutConstraints; |  | ||||||
| 
 |  | ||||||
| import java.util.ArrayList; |  | ||||||
| import java.util.HashMap; |  | ||||||
| import java.util.List; |  | ||||||
| import java.util.Map; |  | ||||||
| 
 |  | ||||||
| import javax.swing.BorderFactory; |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JScrollPane; |  | ||||||
| import javax.swing.JTree; |  | ||||||
| import javax.swing.tree.DefaultMutableTreeNode; |  | ||||||
| import javax.swing.tree.DefaultTreeModel; |  | ||||||
| import javax.swing.tree.TreePath; |  | ||||||
| 
 |  | ||||||
| import leaf.ui.LeafWindow; |  | ||||||
| import leaf.ui.LeafLogic.LeafUIActionBinding; |  | ||||||
| import leaf.ui.LeafWindow.ActionActivation; |  | ||||||
| 
 |  | ||||||
| import org.apache.cayenne.CayenneDataObject; |  | ||||||
| 
 |  | ||||||
| import siprp.database.cayenne.objects.Trabalhadores; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcds; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresFichasAptidao; |  | ||||||
| import siprp.database.cayenne.objects.TrabalhadoresProcesso; |  | ||||||
| import siprp.medicina.processo.ProcessoDataProvider; |  | ||||||
| import siprp.medicina.processo.estrutura.ConsultaMutableTreeNode; |  | ||||||
| import siprp.medicina.processo.estrutura.DataMutableTreeNode; |  | ||||||
| import siprp.medicina.processo.estrutura.ECDsMutableTreeNode; |  | ||||||
| import siprp.medicina.processo.estrutura.EstruturaProcessoRenderer; |  | ||||||
| import siprp.medicina.processo.estrutura.FichaAptidaoMutableTreeNode; |  | ||||||
| import siprp.medicina.processo.estrutura.MailMutableTreeNode; |  | ||||||
| import siprp.medicina.processo.estrutura.ObservacoesMutableTreeNode; |  | ||||||
| import siprp.medicina.processo.estrutura.ProcessoMutableTreeNode; |  | ||||||
| import siprp.medicina.processo.estrutura.TrabalhadorMutableTreeNode; |  | ||||||
| 
 |  | ||||||
| public class ProcessoTreePanel extends JPanel |  | ||||||
| { |  | ||||||
| 	private static final long serialVersionUID = 1L; |  | ||||||
| 
 |  | ||||||
| 	private final LeafWindow parentWindow; |  | ||||||
| 
 |  | ||||||
| 	private final JScrollPane mainScroll = new JScrollPane();; |  | ||||||
| 
 |  | ||||||
| 	protected TrabalhadorMutableTreeNode rootNode; |  | ||||||
| 
 |  | ||||||
| 	private final Map<CayenneDataObject, DefaultMutableTreeNode> nodeByObject = new HashMap<CayenneDataObject, DefaultMutableTreeNode>(); |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = SELECT_TREE_NODE, onChange = "") |  | ||||||
| 	public JTree mainTree; |  | ||||||
| 
 |  | ||||||
| 	protected ProcessoDataProvider provider; |  | ||||||
| 
 |  | ||||||
| 	public ProcessoTreePanel(LeafWindow parentWindow) |  | ||||||
| 	{ |  | ||||||
| 		super(); |  | ||||||
| 		this.parentWindow = parentWindow; |  | ||||||
| 		try |  | ||||||
| 		{ |  | ||||||
| 			provider = ProcessoDataProvider.getProvider(); |  | ||||||
| 
 |  | ||||||
| 		} catch( Exception e ) |  | ||||||
| 		{ |  | ||||||
| 			provider = null; |  | ||||||
| 			e.printStackTrace(); |  | ||||||
| 		} |  | ||||||
| 		setupLayout(); |  | ||||||
| 		setupComponents(); |  | ||||||
| 		placeComponents(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupLayout() |  | ||||||
| 	{ |  | ||||||
| 		double[] cols = new double[] { |  | ||||||
| 			TableLayout.FILL |  | ||||||
| 		}; |  | ||||||
| 		double[] rows = new double[] { |  | ||||||
| 			TableLayout.FILL |  | ||||||
| 		}; |  | ||||||
| 		TableLayout layout = new TableLayout( cols, rows ); |  | ||||||
| 		this.setLayout( layout ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		this.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Processos" ) ); |  | ||||||
| 		mainScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ); |  | ||||||
| 		mainScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); |  | ||||||
| 		rootNode = new TrabalhadorMutableTreeNode( "" ); |  | ||||||
| 		mainTree = new JTree( rootNode ); |  | ||||||
| 		mainTree.setExpandsSelectedPaths( true ); |  | ||||||
| 		mainTree.setCellRenderer( new EstruturaProcessoRenderer() ); |  | ||||||
| 		mainScroll.setViewportView( mainTree ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void placeComponents() |  | ||||||
| 	{ |  | ||||||
| 		this.add( mainScroll, new TableLayoutConstraints( 0, 0 ) ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = LOAD_TRABALHADOR) |  | ||||||
| 	public void setTrabalhador( Trabalhadores trabalhador ) |  | ||||||
| 	{ |  | ||||||
| 		clear(); |  | ||||||
| 		if( trabalhador == null ) |  | ||||||
| 		{ |  | ||||||
| 			return; |  | ||||||
| 		} |  | ||||||
| 		rootNode.setUserObject( trabalhador ); |  | ||||||
| 		List<DefaultMutableTreeNode> nodes = loadProcessos( trabalhador ); |  | ||||||
| 		for( DefaultMutableTreeNode node : nodes ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( node, rootNode ); |  | ||||||
| 		} |  | ||||||
| 		((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode ); |  | ||||||
| 		int count = mainTree.getRowCount(); |  | ||||||
| 		for( int n = count - 1; n >= 0; n-- ) |  | ||||||
| 		{ |  | ||||||
| 			mainTree.expandRow( n ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_PROCESSO) |  | ||||||
| 	public void createProcessoNode( TrabalhadoresProcesso processo ) |  | ||||||
| 	{ |  | ||||||
| 		if( processo != null ) |  | ||||||
| 		{ |  | ||||||
| 			ProcessoMutableTreeNode node = new ProcessoMutableTreeNode( processo ); |  | ||||||
| 			addAndRefresh( node, rootNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_FICHA) |  | ||||||
| 	public void createFichaNode() |  | ||||||
| 	{ |  | ||||||
| 		// if( ficha != null )
 |  | ||||||
| 		// {
 |  | ||||||
| 		// FichaAptidaoMutableTreeNode node = new FichaAptidaoMutableTreeNode(
 |  | ||||||
| 		// ficha );
 |  | ||||||
| 		// DefaultMutableTreeNode parentNode = nodeByObject.get(
 |  | ||||||
| 		// ficha.getToTrabalhadoresProcesso() );
 |  | ||||||
| 		// addAndRefresh( node, parentNode );
 |  | ||||||
| 		// }
 |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = APAGAR_PROCESSO) |  | ||||||
| 	public void apagarProcessoNode( TrabalhadoresProcesso processo ) |  | ||||||
| 	{ |  | ||||||
| 		if( processo != null ) |  | ||||||
| 		{ |  | ||||||
| 			for( int i = 0; i < rootNode.getChildCount(); ++i ) |  | ||||||
| 			{ |  | ||||||
| 				DefaultMutableTreeNode node = (DefaultMutableTreeNode) rootNode.getChildAt( i ); |  | ||||||
| 
 |  | ||||||
| 				if( processo.equals( node.getUserObject() ) ) |  | ||||||
| 				{ |  | ||||||
| 					removeNode( node ); |  | ||||||
| 					break; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = APAGAR_CONSULTA) |  | ||||||
| 	public void apagarConsultaNode( TrabalhadoresConsultas consulta ) |  | ||||||
| 	{ |  | ||||||
| 		if( consulta != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode node = nodeByObject.get( consulta ); |  | ||||||
| 			if( node != null ) |  | ||||||
| 			{ |  | ||||||
| 				removeNode( node ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = APAGAR_CONSULTA_MARCACAO) |  | ||||||
| 	public void apagarConsultaMarcacaoNode( TrabalhadoresConsultasDatas consulta ) |  | ||||||
| 	{ |  | ||||||
| 		if( consulta != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode node = nodeByObject.get( consulta ); |  | ||||||
| 			if( node != null ) |  | ||||||
| 			{ |  | ||||||
| 				removeNode( node ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	@LeafUIActionBinding(action = APAGAR_EXAME_MARCACAO) |  | ||||||
| 	public void apagarExameMarcacaoNode( TrabalhadoresEcdsDatas exame ) |  | ||||||
| 	{ |  | ||||||
| 		if( exame != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode node = nodeByObject.get( exame ); |  | ||||||
| 			if( node != null ) |  | ||||||
| 			{ |  | ||||||
| 				removeNode( node ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA) |  | ||||||
| 	public void createConsultaNode( TrabalhadoresConsultas consulta ) |  | ||||||
| 	{ |  | ||||||
| 		if( consulta != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( consulta.getToTrabalhadoresProcesso() ); |  | ||||||
| 			ConsultaMutableTreeNode node = new ConsultaMutableTreeNode( consulta ); |  | ||||||
| 			node.setData( consulta.getData() ); |  | ||||||
| 			addAndRefresh( node, parentNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO) |  | ||||||
| 	public void createConsultaMarcacaoNode( TrabalhadoresConsultasDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		if( marcacao != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( marcacao.getToTrabalhadoresConsultas() ); |  | ||||||
| 			DataMutableTreeNode node = new DataMutableTreeNode( marcacao ); |  | ||||||
| 			addAndRefresh( node, parentNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL) |  | ||||||
| 	public void createConsultaMarcacaoEmailNode( TrabalhadoresConsultasDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( email.getToTrabalhadoresConsultasDatas() ); |  | ||||||
| 			MailMutableTreeNode node = new MailMutableTreeNode( email ); |  | ||||||
| 			addAndRefresh( node, parentNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES) |  | ||||||
| 	public void createConsultaMarcacaoObservacoesNode( TrabalhadoresConsultasDatasObservacoes observacoes ) |  | ||||||
| 	{ |  | ||||||
| 		if( observacoes != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( observacoes.getToTrabalhadoresConsultasDatas() ); |  | ||||||
| 			ObservacoesMutableTreeNode node = new ObservacoesMutableTreeNode( observacoes ); |  | ||||||
| 			addNodeTo( node, parentNode ); |  | ||||||
| 			((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode ); |  | ||||||
| 			mainTree.setSelectionPath( new TreePath( node.getPath() ) ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_EXAME) |  | ||||||
| 	public void createExameNode( TrabalhadoresEcds exame ) |  | ||||||
| 	{ |  | ||||||
| 		if( exame != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( exame.getToTrabalhadoresProcesso() ); |  | ||||||
| 			ECDsMutableTreeNode node = new ECDsMutableTreeNode( exame ); |  | ||||||
| 			node.setData( exame.getData() ); |  | ||||||
| 			addAndRefresh( node, parentNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO) |  | ||||||
| 	public void createExameMarcacaoNode( TrabalhadoresEcdsDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		if( marcacao != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( marcacao.getToTrabalhadoresEcds() ); |  | ||||||
| 			DataMutableTreeNode node = new DataMutableTreeNode( marcacao ); |  | ||||||
| 			addAndRefresh( node, parentNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_EMAIL) |  | ||||||
| 	public void createExameMarcacaoEmailNode( TrabalhadoresEcdsDatasEmails email ) |  | ||||||
| 	{ |  | ||||||
| 		if( email != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( email.getToTrabalhadoresEcdsDatas() ); |  | ||||||
| 			MailMutableTreeNode node = new MailMutableTreeNode( email ); |  | ||||||
| 			addAndRefresh( node, parentNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = CREATE_EXAME_MARCACAO_OBSERVACOES) |  | ||||||
| 	public void createConsultaMarcacaoObservacoesNode( TrabalhadoresEcdsDatasObservacoes observacoes ) |  | ||||||
| 	{ |  | ||||||
| 		if( observacoes != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parentNode = nodeByObject.get( observacoes.getToTrabalhadoresEcdsDatas() ); |  | ||||||
| 			ObservacoesMutableTreeNode node = new ObservacoesMutableTreeNode( observacoes ); |  | ||||||
| 			addNodeTo( node, parentNode ); |  | ||||||
| 			((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode ); |  | ||||||
| 			mainTree.setSelectionPath( new TreePath( node.getPath() ) ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = REFRESH) |  | ||||||
| 	public void refresh() |  | ||||||
| 	{ |  | ||||||
| 		DefaultMutableTreeNode selected = getSelectedNode(); |  | ||||||
| 		if( selected != null ) |  | ||||||
| 		{ |  | ||||||
| 			// ((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged(
 |  | ||||||
| 			// rootNode );
 |  | ||||||
| 			mainTree.setSelectionPath( new TreePath( rootNode.getPath() ) ); |  | ||||||
| 			mainTree.setSelectionPath( new TreePath( selected.getPath() ) ); |  | ||||||
| 		} |  | ||||||
| 		revalidate(); |  | ||||||
| 		repaint(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	protected List<DefaultMutableTreeNode> loadProcessos( Trabalhadores trabalhador ) |  | ||||||
| 	{ |  | ||||||
| 		List<DefaultMutableTreeNode> result = new ArrayList<DefaultMutableTreeNode>(); |  | ||||||
| 		List<TrabalhadoresProcesso> processos = trabalhador.getTrabalhadoresProcessoArray(); |  | ||||||
| 		for( TrabalhadoresProcesso trabalhadoresProcesso : processos ) |  | ||||||
| 		{ |  | ||||||
| 			result.add( loadProcesso( trabalhadoresProcesso ) ); |  | ||||||
| 		} |  | ||||||
| 		return result; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private ProcessoMutableTreeNode loadProcesso( TrabalhadoresProcesso processo ) |  | ||||||
| 	{ |  | ||||||
| 		ProcessoMutableTreeNode node = new ProcessoMutableTreeNode( processo ); |  | ||||||
| 		node.removeAllChildren(); |  | ||||||
| 		for( TrabalhadoresConsultas current : (List<TrabalhadoresConsultas>) processo.getTrabalhadoresConsultasArray() ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( loadConsulta( current ), node ); |  | ||||||
| 		} |  | ||||||
| 		for( TrabalhadoresEcds current : (List<TrabalhadoresEcds>) processo.getTrabalhadoresEcdsArray() ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( loadExame( current ), node ); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		List<TrabalhadoresFichasAptidao> fichas = processo.getTrabalhadoresFichasAptidaoArray(); |  | ||||||
| 		if( fichas != null ) |  | ||||||
| 		{ |  | ||||||
| 			TrabalhadoresFichasAptidao ficha = null; |  | ||||||
| 			for( TrabalhadoresFichasAptidao currentFicha : fichas ) |  | ||||||
| 			{ |  | ||||||
| 				if( ficha == null || ficha.getId() < currentFicha.getId() ) |  | ||||||
| 				{ |  | ||||||
| 					ficha = currentFicha; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			if( ficha != null ) |  | ||||||
| 			{ |  | ||||||
| 				addNodeTo( loadFicha( ficha ), node ); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		return node; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private FichaAptidaoMutableTreeNode loadFicha( TrabalhadoresFichasAptidao ficha ) |  | ||||||
| 	{ |  | ||||||
| 		FichaAptidaoMutableTreeNode result = new FichaAptidaoMutableTreeNode( ficha ); |  | ||||||
| 		return result; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private ECDsMutableTreeNode loadExame( TrabalhadoresEcds exame ) |  | ||||||
| 	{ |  | ||||||
| 		ECDsMutableTreeNode node = new ECDsMutableTreeNode( exame ); |  | ||||||
| 		node.setData( exame.getData() ); |  | ||||||
| 		node.removeAllChildren(); |  | ||||||
| 		List<TrabalhadoresEcdsDatas> marcacoes = exame.getTrabalhadoresEcdsDatasArray(); |  | ||||||
| 		for( TrabalhadoresEcdsDatas marcacao : marcacoes ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( loadExameMarcacao( marcacao ), node ); |  | ||||||
| 		} |  | ||||||
| 		return node; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private DataMutableTreeNode loadExameMarcacao( TrabalhadoresEcdsDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		DataMutableTreeNode node = new DataMutableTreeNode( marcacao ); |  | ||||||
| 		for( TrabalhadoresEcdsDatasEmails email : (List<TrabalhadoresEcdsDatasEmails>) marcacao.getTrabalhadoresEcdsDatasEmailsArray() ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( new MailMutableTreeNode( email ), node ); |  | ||||||
| 		} |  | ||||||
| 		for( TrabalhadoresEcdsDatasObservacoes observacoes : (List<TrabalhadoresEcdsDatasObservacoes>) marcacao.getTrabalhadoresEcdsDatasObservacoesArray() ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( new ObservacoesMutableTreeNode( observacoes ), node ); |  | ||||||
| 		} |  | ||||||
| 		return node; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private ConsultaMutableTreeNode loadConsulta( TrabalhadoresConsultas consulta ) |  | ||||||
| 	{ |  | ||||||
| 		ConsultaMutableTreeNode node = new ConsultaMutableTreeNode( consulta ); |  | ||||||
| 		node.setData( consulta.getData() ); |  | ||||||
| 		node.removeAllChildren(); |  | ||||||
| 		List<TrabalhadoresConsultasDatas> marcacoes = consulta.getTrabalhadoresConsultasDatasArray(); |  | ||||||
| 		for( TrabalhadoresConsultasDatas marcacao : marcacoes ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( loadMarcacao( marcacao ), node ); |  | ||||||
| 		} |  | ||||||
| 		return node; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private DataMutableTreeNode loadMarcacao( TrabalhadoresConsultasDatas marcacao ) |  | ||||||
| 	{ |  | ||||||
| 		DataMutableTreeNode node = new DataMutableTreeNode( marcacao ); |  | ||||||
| 		for( TrabalhadoresConsultasDatasEmails email : (List<TrabalhadoresConsultasDatasEmails>) marcacao.getTrabalhadoresConsultasDatasEmailsArray() ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( new MailMutableTreeNode( email ), node ); |  | ||||||
| 		} |  | ||||||
| 		for( TrabalhadoresConsultasDatasObservacoes observacoes : (List<TrabalhadoresConsultasDatasObservacoes>) marcacao.getTrabalhadoresConsultasDatasObservacoesArray() ) |  | ||||||
| 		{ |  | ||||||
| 			addNodeTo( new ObservacoesMutableTreeNode( observacoes ), node ); |  | ||||||
| 		} |  | ||||||
| 		return node; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void addNodeTo( DefaultMutableTreeNode node, DefaultMutableTreeNode to ) |  | ||||||
| 	{ |  | ||||||
| 		if( node.getUserObject() != null && node.getUserObject() instanceof CayenneDataObject ) |  | ||||||
| 		{ |  | ||||||
| 			nodeByObject.put( (CayenneDataObject) node.getUserObject(), node ); |  | ||||||
| 		} |  | ||||||
| 		to.add( node ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void addAndRefresh( DefaultMutableTreeNode node, DefaultMutableTreeNode parentNode ) |  | ||||||
| 	{ |  | ||||||
| 		addNodeTo( node, parentNode ); |  | ||||||
| 		refresh( node, parentNode ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void removeNode( DefaultMutableTreeNode node ) |  | ||||||
| 	{ |  | ||||||
| 		if( node != null ) |  | ||||||
| 		{ |  | ||||||
| 			DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); |  | ||||||
| 			if( parent == null ) |  | ||||||
| 			{ |  | ||||||
| 				parent = rootNode; |  | ||||||
| 			} |  | ||||||
| 			node.removeFromParent(); |  | ||||||
| 			nodeByObject.remove( node.getUserObject() ); |  | ||||||
| 			refresh( parent, rootNode ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void refresh( DefaultMutableTreeNode newSelection, DefaultMutableTreeNode parentNode ) |  | ||||||
| 	{ |  | ||||||
| 		((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( parentNode ); |  | ||||||
| 		mainTree.setSelectionPath( new TreePath( newSelection.getPath() ) ); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private DefaultMutableTreeNode getSelectedNode() |  | ||||||
| 	{ |  | ||||||
| 		DefaultMutableTreeNode result = null; |  | ||||||
| 		Object[] nodes = mainTree.getSelectionPath() == null ? null : mainTree.getSelectionPath().getPath(); |  | ||||||
| 		if( nodes != null && nodes.length > 0 && nodes[nodes.length - 1] instanceof DefaultMutableTreeNode ) |  | ||||||
| 		{ |  | ||||||
| 			result = (DefaultMutableTreeNode) nodes[nodes.length - 1]; |  | ||||||
| 		} |  | ||||||
| 		return result; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void clear() |  | ||||||
| 	{ |  | ||||||
| 		rootNode.setUserObject( "" ); |  | ||||||
| 		mainTree.clearSelection(); |  | ||||||
| 		mainTree.setRootVisible( true ); |  | ||||||
| 		rootNode.removeAllChildren(); |  | ||||||
| 		((DefaultTreeModel) mainTree.getModel()).nodeStructureChanged( rootNode ); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,133 +0,0 @@ | |||||||
| package siprp.medicina.processo.ui; |  | ||||||
| 
 |  | ||||||
| import static leaf.ui.LeafLogic.ACTION_STARTUP; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EMPRESA; |  | ||||||
| import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_ESTABELECIMENTO; |  | ||||||
| 
 |  | ||||||
| import java.awt.GridBagConstraints; |  | ||||||
| import java.awt.GridBagLayout; |  | ||||||
| import java.awt.Insets; |  | ||||||
| import java.util.Collection; |  | ||||||
| 
 |  | ||||||
| import javax.swing.JPanel; |  | ||||||
| import javax.swing.JScrollPane; |  | ||||||
| import javax.swing.ListSelectionModel; |  | ||||||
| 
 |  | ||||||
| import leaf.ui.LeafTableModel; |  | ||||||
| import leaf.ui.LeafWindow; |  | ||||||
| import leaf.ui.LeafLogic.LeafUIActionBinding; |  | ||||||
| import leaf.ui.LeafWindow.ActionActivation; |  | ||||||
| import siprp.database.cayenne.objects.Empresas; |  | ||||||
| import siprp.database.cayenne.objects.Estabelecimentos; |  | ||||||
| 
 |  | ||||||
| import com.evolute.utils.tables.BaseTable; |  | ||||||
| 
 |  | ||||||
| public class TrabalhadoresChooserPanel extends JPanel |  | ||||||
| { |  | ||||||
| 	private static final long serialVersionUID = 1L; |  | ||||||
| 
 |  | ||||||
| 	private final LeafWindow parentWindow; |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = SELECT_EMPRESA, onChange = "") |  | ||||||
| 	public BaseTable empresasTable; |  | ||||||
| 	public LeafTableModel empresasModel; |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = SELECT_ESTABELECIMENTO, onChange = "") |  | ||||||
| 	public BaseTable estabelecimentosTable; |  | ||||||
| 	public LeafTableModel estabelecimentosModel; |  | ||||||
| 
 |  | ||||||
| 	@ActionActivation(onSelect = LOAD_TRABALHADOR, onChange = "") |  | ||||||
| 	public BaseTable trabalhadoresTable; |  | ||||||
| 	public LeafTableModel trabalhadoresModel; |  | ||||||
| 
 |  | ||||||
| 	public TrabalhadoresChooserPanel(LeafWindow parentWindow) |  | ||||||
| 	{ |  | ||||||
| 		super(); |  | ||||||
| 		this.parentWindow = parentWindow; |  | ||||||
| 
 |  | ||||||
| 		setupComponents(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private void setupComponents() |  | ||||||
| 	{ |  | ||||||
| 		empresasModel = new LeafTableModel( 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 ); |  | ||||||
| 		estabelecimentosModel = new LeafTableModel( 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 ); |  | ||||||
| 		trabalhadoresModel = new LeafTableModel( 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 ); |  | ||||||
| 
 |  | ||||||
| 		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 ); |  | ||||||
| 
 |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	@LeafUIActionBinding(action= ACTION_STARTUP) |  | ||||||
| 	public void fillEmpresas( Collection<Empresas> allEmpresas ) |  | ||||||
| 	{ |  | ||||||
| 		empresasTable.clearSelection(); |  | ||||||
| 		empresasModel.clearAll(); |  | ||||||
| 		if( allEmpresas != null ) |  | ||||||
| 		{ |  | ||||||
| 			empresasModel.setValues( allEmpresas ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_EMPRESA) |  | ||||||
| 	public void fillEstablecimentos( Empresas empresa ) |  | ||||||
| 	{ |  | ||||||
| 		estabelecimentosTable.clearSelection(); |  | ||||||
| 		estabelecimentosModel.clearAll(); |  | ||||||
| 		if( empresa != null ) |  | ||||||
| 		{ |  | ||||||
| 			estabelecimentosModel.setValues( empresa.getEstabelecimentosArray() ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	@LeafUIActionBinding(action = SELECT_ESTABELECIMENTO) |  | ||||||
| 	public void fillTrabalhadores(Estabelecimentos estabelecimento) |  | ||||||
| 	{ |  | ||||||
| 		trabalhadoresTable.clearSelection(); |  | ||||||
| 		trabalhadoresModel.clearAll(); |  | ||||||
| 		if( estabelecimento != null ) |  | ||||||
| 		{ |  | ||||||
| 			trabalhadoresModel.setValues( estabelecimento.getTrabalhadoresArray() ); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
					Loading…
					
					
				
		Reference in new issue