forked from Coded/SIPRP
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							204 lines
						
					
					
						
							5.3 KiB
						
					
					
				
			
		
		
	
	
							204 lines
						
					
					
						
							5.3 KiB
						
					
					
				/*
 | 
						|
 * ProcessoPanel.java
 | 
						|
 *
 | 
						|
 * Created on March 21, 2007, 9:11 AM
 | 
						|
 *
 | 
						|
 * To change this template, choose Tools | Template Manager
 | 
						|
 * and open the template in the editor.
 | 
						|
 */
 | 
						|
 | 
						|
package siprp.medicina.processo;
 | 
						|
 | 
						|
import info.clearthought.layout.TableLayout;
 | 
						|
import info.clearthought.layout.TableLayoutConstraints;
 | 
						|
import java.awt.*;
 | 
						|
import java.awt.event.ActionEvent;
 | 
						|
import java.awt.event.ActionListener;
 | 
						|
import java.text.DateFormat;
 | 
						|
import java.util.Date;
 | 
						|
import java.util.Locale;
 | 
						|
import java.util.Vector;
 | 
						|
import javax.swing.*;
 | 
						|
import javax.swing.event.TreeSelectionEvent;
 | 
						|
import javax.swing.event.TreeSelectionListener;
 | 
						|
import siprp.medicina.processo.data.MarcacoesProcessoData;
 | 
						|
import siprp.medicina.processo.estrutura.EstruturaProcessoPanel;
 | 
						|
 | 
						|
/**
 | 
						|
 *
 | 
						|
 * @author fpalma
 | 
						|
 */
 | 
						|
public class ProcessoPanel extends JPanel
 | 
						|
		implements ActionListener, TreeSelectionListener
 | 
						|
{
 | 
						|
	private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
 | 
						|
	
 | 
						|
	private JTextField estadoText;
 | 
						|
	private JTextField inicioText;
 | 
						|
	private JTextField fimText;
 | 
						|
	private JButton novoECDButton;
 | 
						|
	private JButton novaConsultaButton;
 | 
						|
	private JButton emitirFAButton;
 | 
						|
	private JButton fecharButton;
 | 
						|
	
 | 
						|
	private final EstruturaProcessoPanel estruturaPanel;
 | 
						|
	
 | 
						|
	private final Vector<ProcessoListener> PROCESSO_LISTENERS = new Vector<ProcessoListener>();
 | 
						|
	
 | 
						|
	/** Creates a new instance of ProcessoPanel */
 | 
						|
	public ProcessoPanel( EstruturaProcessoPanel estruturaPanel )
 | 
						|
	{
 | 
						|
		this.estruturaPanel = estruturaPanel;
 | 
						|
		setupComponents();
 | 
						|
	}
 | 
						|
	
 | 
						|
	
 | 
						|
	private void setupComponents()
 | 
						|
	{
 | 
						|
		JLabel estadoLabel = new JLabel( "Estado" );
 | 
						|
		estadoText = new JTextField();
 | 
						|
		estadoText.setPreferredSize( new Dimension( 120, 20 ) );
 | 
						|
		estadoText.setEditable( false );
 | 
						|
		JLabel inicioLabel = new JLabel( "In\u00edcio" );
 | 
						|
		inicioText = new JTextField();
 | 
						|
		inicioText.setPreferredSize( new Dimension( 120, 20 ) );
 | 
						|
		inicioText.setEditable( false );
 | 
						|
		JLabel fimLabel = new JLabel( "Fim" );
 | 
						|
		fimText = new JTextField();
 | 
						|
		fimText.setPreferredSize( new Dimension( 120, 20 ) );
 | 
						|
		fimText.setEditable( false );
 | 
						|
		novoECDButton = new JButton( "Marcar ECDs" );
 | 
						|
		novoECDButton.addActionListener( this );
 | 
						|
		novaConsultaButton = new JButton( "Marcar Consulta" );
 | 
						|
		novaConsultaButton.addActionListener( this );
 | 
						|
		emitirFAButton = new JButton( "Emitir Ficha de Aptid\u00e3o" );
 | 
						|
		emitirFAButton.addActionListener( this );
 | 
						|
		fecharButton = new JButton( "Fechar Processo" );
 | 
						|
		fecharButton.addActionListener( this );
 | 
						|
		
 | 
						|
		double cols[] =
 | 
						|
				new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL,
 | 
						|
				TableLayout.PREFERRED,  };
 | 
						|
		double rows[] =
 | 
						|
				new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
 | 
						|
				TableLayout.PREFERRED, TableLayout.FILL };
 | 
						|
		
 | 
						|
		TableLayout tableLayout = new TableLayout( cols, rows );
 | 
						|
		setLayout( tableLayout );
 | 
						|
		
 | 
						|
		add( estadoLabel, new TableLayoutConstraints( 0, 0 ) );
 | 
						|
		add( estadoText, new TableLayoutConstraints( 1, 0 ) );
 | 
						|
		add( novoECDButton, new TableLayoutConstraints( 3, 0 ) );
 | 
						|
		add( inicioLabel, new TableLayoutConstraints( 0, 1 ) );
 | 
						|
		add( inicioText, new TableLayoutConstraints( 1, 1 ) );
 | 
						|
		add( novaConsultaButton, new TableLayoutConstraints( 3, 1 ) );
 | 
						|
		add( fimLabel, new TableLayoutConstraints( 0, 2 ) );
 | 
						|
		add( fimText, new TableLayoutConstraints( 1, 2 ) );
 | 
						|
		add( emitirFAButton, new TableLayoutConstraints( 3, 2 ) );
 | 
						|
		add( fecharButton, new TableLayoutConstraints( 3, 3 ) );
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void actionPerformed(ActionEvent e)
 | 
						|
	{
 | 
						|
		Object source = e.getSource();
 | 
						|
		if( source.equals( novoECDButton ) )
 | 
						|
		{
 | 
						|
			novoECD();
 | 
						|
		}
 | 
						|
		else if( source.equals( novaConsultaButton ) )
 | 
						|
		{
 | 
						|
			novaConsulta();
 | 
						|
		}
 | 
						|
		else if( source.equals( emitirFAButton ) )
 | 
						|
		{
 | 
						|
			emitirFA();
 | 
						|
		}
 | 
						|
		else if( source.equals( fecharButton ) )
 | 
						|
		{
 | 
						|
			fecharProcesso();
 | 
						|
		}
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected void novoECD()
 | 
						|
	{
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected void novaConsulta()
 | 
						|
	{
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected void emitirFA()
 | 
						|
	{
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected void fecharProcesso()
 | 
						|
	{
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void valueChanged(TreeSelectionEvent e)
 | 
						|
	{
 | 
						|
		clear();
 | 
						|
		mudarProcesso();
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void clear()
 | 
						|
	{
 | 
						|
		estadoText.setText( "" );
 | 
						|
		inicioText.setText( "" );
 | 
						|
		fimText.setText( "" );
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected void disableButtons()
 | 
						|
	{
 | 
						|
		novoECDButton.setEnabled( false );
 | 
						|
		novaConsultaButton.setEnabled( false );
 | 
						|
		emitirFAButton.setEnabled( false );
 | 
						|
		fecharButton.setEnabled( false );
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected void enableButtons()
 | 
						|
	{
 | 
						|
		novoECDButton.setEnabled( true );
 | 
						|
		novaConsultaButton.setEnabled( true );
 | 
						|
		emitirFAButton.setEnabled( true );
 | 
						|
		fecharButton.setEnabled( true );
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected void mudarProcesso()
 | 
						|
	{
 | 
						|
		MarcacoesProcessoData processo = estruturaPanel.getProcessoEscolhido();
 | 
						|
		if( processo == null )
 | 
						|
		{
 | 
						|
			disableButtons();
 | 
						|
		}
 | 
						|
		else
 | 
						|
		{
 | 
						|
			enableButtons();
 | 
						|
			Date dataInicio = ( Date ) processo.get( MarcacoesProcessoData.DATA_INICIO );
 | 
						|
			if( dataInicio != null )
 | 
						|
			{
 | 
						|
				inicioText.setText( D_F.format( dataInicio ) );
 | 
						|
			}
 | 
						|
			Date dataFim = ( Date ) processo.get( MarcacoesProcessoData.DATA_FIM );
 | 
						|
			if( dataFim != null )
 | 
						|
			{
 | 
						|
				fimText.setText( D_F.format( dataFim ) );
 | 
						|
			}
 | 
						|
			String estado = ( String ) processo.get( MarcacoesProcessoData.ESTADO );
 | 
						|
			if( estado == null )
 | 
						|
			{
 | 
						|
				estadoText.setText( ProcessoDataProvider.PROCESSO_POR_ABRIR_DESCRIPTION );
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				estadoText.setText( ProcessoDataProvider.ESTADO_PROCESSO_BY_CODE.get( estado ) );
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	
 | 
						|
	public void addProcessoListener( ProcessoListener listener )
 | 
						|
	{
 | 
						|
		PROCESSO_LISTENERS.add( listener );
 | 
						|
	}
 | 
						|
}
 |