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.
		
		
		
		
		
			
		
			
				
					
					
						
							334 lines
						
					
					
						
							11 KiB
						
					
					
				
			
		
		
	
	
							334 lines
						
					
					
						
							11 KiB
						
					
					
				| package siprp.medicina;
 | |
| 
 | |
| import com.evolute.utils.*;
 | |
| import com.evolute.utils.arrays.*;
 | |
| import com.evolute.utils.data.*;
 | |
| import com.evolute.utils.dataui.*;
 | |
| import com.evolute.utils.db.*;
 | |
| import com.evolute.utils.documents.*;
 | |
| import com.evolute.utils.sql.*;
 | |
| import com.evolute.utils.ui.*;
 | |
| import com.evolute.utils.ui.calendar.*;
 | |
| import com.evolute.utils.ui.panel.*;
 | |
| import com.evolute.utils.ui.text.*;
 | |
| import java.awt.*;
 | |
| import java.util.*;
 | |
| import javax.swing.*;
 | |
| import siprp.data.*;
 | |
| 
 | |
| public class MarcacaoExamePanel
 | |
| 	extends JPanel
 | |
| 	implements ControllableComponent, DataClassAware
 | |
| {
 | |
| 	private siprp.data.MarcacaoTrabalhadorData marcacaoTrabalhadorData;
 | |
| 	private final ComponentsHashtable components = new ComponentsHashtable();
 | |
| 
 | |
| 	protected final SQLExecuter EXECUTER;
 | |
| 
 | |
| 	private final JLabel dataLabel = new JLabel( "Data dos Exames", JLabel.RIGHT );
 | |
| 	private final JCalendarPanel dataPanel = new JCalendarPanel( null );
 | |
| 	private final JButton novaDataButton = new JButton( "Nova data" );
 | |
| 	private final JLabel estadoLabel = new JLabel( "Estado", JLabel.RIGHT );
 | |
| 	private final JComboBox estadoList = new JComboBox();
 | |
| 	private final JPanelControllable detalhesPanel = new JPanelControllable();
 | |
| 	private final JButton emailButton = new JButton( "Enviar Email" );
 | |
| 	private final JPanelControllable historicoPanel = new JPanelControllable();
 | |
| 	private final JScrollPane observacoesTextScroll = new JScrollPane();
 | |
| 	private final StateTextArea observacoesText = new StateTextArea();
 | |
| 	private final JButton historicoButton = new JButton( "Ver Hist\u00f3rico desta Marca\u00e7\u00e3o" );
 | |
| 
 | |
| 	public MarcacaoExamePanel()
 | |
| 		throws Exception
 | |
| 	{
 | |
| 		DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
 | |
| 		if( dbm != null )
 | |
| 		{
 | |
| 			EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
 | |
| 		}
 | |
| 		else
 | |
| 		{
 | |
| 			EXECUTER = null;
 | |
| 		}
 | |
| 		setupComponents();
 | |
| 		setupComponentsHashtable();
 | |
| 		place();
 | |
| 	}
 | |
| 
 | |
| 	public void setupComponents()
 | |
| 		throws Exception
 | |
| 	{
 | |
| 		JComponent MarcacaoExamePanel = this;
 | |
| 		novaDataButton.setMinimumSize( new Dimension( 300, 20 ) );
 | |
| 		novaDataButton.setPreferredSize( new Dimension( 200, 20 ) );
 | |
| 
 | |
| 		estadoList.addItem( new MappableObject( new Integer( 0 ), "Por realizar" ) );
 | |
| 		estadoList.addItem( new MappableObject( new Integer( 1 ), "Parcialmente realizados" ) );
 | |
| 		estadoList.addItem( new MappableObject( new Integer( 2 ), "Realizados" ) );
 | |
| 		estadoList.addItem( new MappableObject( new Integer( 3 ), "Desmarcados pelo trabalhador" ) );
 | |
| 		estadoList.addItem( new MappableObject( new Integer( 4 ), "Desmarcados pela SIPRP" ) );
 | |
| 		estadoList.addItem( new MappableObject( new Integer( 5 ), "Faltou" ) );
 | |
| 		estadoList.setSelectedIndex( 0 );
 | |
| 
 | |
| 		detalhesPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Detalhes" ) );
 | |
| 
 | |
| 		emailButton.setMinimumSize( new Dimension( 300, 20 ) );
 | |
| 		emailButton.setPreferredSize( new Dimension( 300, 20 ) );
 | |
| 
 | |
| 		observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
 | |
| 		observacoesText.setLineWrap( true );
 | |
| 		observacoesText.setWrapStyleWord( true );
 | |
| 		observacoesText.setRows( 3 );
 | |
| 
 | |
| 		historicoButton.setMinimumSize( new Dimension( 300, 20 ) );
 | |
| 		historicoButton.setPreferredSize( new Dimension( 400, 20 ) );
 | |
| 
 | |
| 	}
 | |
| 
 | |
| 	public void place()
 | |
| 	{
 | |
| 		JPanel MarcacaoExamePanel = this;
 | |
| 		GridBagConstraints detalhesPanelGBC = new GridBagConstraints();
 | |
| 		detalhesPanelGBC.insets = new Insets( 1, 1, 1, 1 );
 | |
| 		GridBagLayout detalhesPanelLayout = new GridBagLayout();
 | |
| 		detalhesPanel.setLayout( detalhesPanelLayout );
 | |
| 		GridBagConstraints historicoPanelGBC = new GridBagConstraints();
 | |
| 		historicoPanelGBC.insets = new Insets( 1, 1, 1, 1 );
 | |
| 		GridBagLayout historicoPanelLayout = new GridBagLayout();
 | |
| 		historicoPanel.setLayout( historicoPanelLayout );
 | |
| 		GridBagConstraints MarcacaoExamePanelGBC = new GridBagConstraints();
 | |
| 		MarcacaoExamePanelGBC.insets = new Insets( 1, 1, 1, 1 );
 | |
| 		GridBagLayout MarcacaoExamePanelLayout = new GridBagLayout();
 | |
| 		MarcacaoExamePanel.setLayout( MarcacaoExamePanelLayout );
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 0;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 1;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.0;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( dataLabel, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( dataLabel );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 1;
 | |
| 		MarcacaoExamePanelGBC.gridy = 0;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 1;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( dataPanel, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( dataPanel );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 2;
 | |
| 		MarcacaoExamePanelGBC.gridy = 0;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 1;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.NONE;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( novaDataButton, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( novaDataButton );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 1;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 1;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.0;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( estadoLabel, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( estadoLabel );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 1;
 | |
| 		MarcacaoExamePanelGBC.gridy = 1;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 1;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.HORIZONTAL;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( estadoList, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( estadoList );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 2;
 | |
| 		MarcacaoExamePanelGBC.gridy = 1;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 1;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 3;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.8;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( detalhesPanel, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( detalhesPanel );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 2;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 2;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.NONE;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( emailButton, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( emailButton );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 3;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 2;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.8;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( historicoPanel, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( historicoPanel );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 4;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 3;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 1.0;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.2;
 | |
| 		observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
 | |
| 		observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
 | |
| 		observacoesTextScroll.setViewportView( observacoesText );
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( observacoesTextScroll, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( observacoesTextScroll );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 5;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 3;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 1.0;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.NONE;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( historicoButton, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( historicoButton );
 | |
| 
 | |
| 	}
 | |
| 
 | |
| 	private void setupComponentsHashtable()
 | |
| 	{
 | |
| 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA, dataPanel );
 | |
| 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.ESTADO, estadoList );
 | |
| 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.OBSERVACOES, observacoesText );
 | |
| 	}
 | |
| 
 | |
| 	public void fill( Object toFill )
 | |
| 	{
 | |
| 		clear();
 | |
| 		if( toFill == null || !( toFill instanceof PropertyObject ) )
 | |
| 		{
 | |
| 			return;
 | |
| 		}
 | |
| 		Hashtable data = null;
 | |
| 		if( toFill instanceof PropertyObject )
 | |
| 		{
 | |
| 			data = ( (PropertyObject) toFill ).getHashData();
 | |
| 			if( toFill instanceof siprp.data.MarcacaoTrabalhadorData )
 | |
| 			{
 | |
| 				marcacaoTrabalhadorData = (siprp.data.MarcacaoTrabalhadorData) toFill;
 | |
| 			}
 | |
| 		}
 | |
| 		else if( toFill instanceof Hashtable )
 | |
| 		{
 | |
| 			data = (Hashtable) toFill;
 | |
| 		}
 | |
| 		else
 | |
| 		{
 | |
| 			return;
 | |
| 		}
 | |
| 		if( marcacaoTrabalhadorData == null )
 | |
| 		{
 | |
| 			marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData();
 | |
| 			marcacaoTrabalhadorData.setHashData( data );
 | |
| 		}
 | |
| 		PropertyObject po = (PropertyObject) toFill;
 | |
| 		String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
 | |
| 		ComponentController.fill( properties, po.getHashData(), components );
 | |
| 	}
 | |
| 
 | |
| 	public Object save()
 | |
| 	{
 | |
| 		if( marcacaoTrabalhadorData == null )
 | |
| 		{
 | |
| 			marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData();
 | |
| 		}
 | |
| 		Hashtable data = marcacaoTrabalhadorData.getHashData();
 | |
| 		String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
 | |
| 		ComponentController.save( properties, data, components );
 | |
| 		if( !( marcacaoTrabalhadorData instanceof PropertyObject ) )
 | |
| 		{
 | |
| 			return data;
 | |
| 		}
 | |
| 		marcacaoTrabalhadorData.setHashData( data );
 | |
| 		return marcacaoTrabalhadorData;
 | |
| 	}
 | |
| 
 | |
| 	public void clear()
 | |
| 	{
 | |
| 		marcacaoTrabalhadorData = null;
 | |
| 		String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
 | |
| 		ComponentController.clear( properties, components );
 | |
| 	}
 | |
| 
 | |
| 	public void setEnabled( boolean enable )
 | |
| 	{
 | |
| 		String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
 | |
| 		ComponentController.setEnabled( properties, enable, components );
 | |
| 	}
 | |
| 
 | |
| 	public Class getDataClass()
 | |
| 	{
 | |
| 		return siprp.data.MarcacaoTrabalhadorData.class;
 | |
| 	}
 | |
| 
 | |
| 	public JLabel getDataLabel()
 | |
| 	{
 | |
| 		return dataLabel;
 | |
| 	}
 | |
| 
 | |
| 	public JCalendarPanel getDataPanel()
 | |
| 	{
 | |
| 		return dataPanel;
 | |
| 	}
 | |
| 
 | |
| 	public JPanelControllable getDetalhesPanel()
 | |
| 	{
 | |
| 		return detalhesPanel;
 | |
| 	}
 | |
| 
 | |
| 	public JButton getEmailButton()
 | |
| 	{
 | |
| 		return emailButton;
 | |
| 	}
 | |
| 
 | |
| 	public JLabel getEstadoLabel()
 | |
| 	{
 | |
| 		return estadoLabel;
 | |
| 	}
 | |
| 
 | |
| 	public JComboBox getEstadoList()
 | |
| 	{
 | |
| 		return estadoList;
 | |
| 	}
 | |
| 
 | |
| 	public JButton getHistoricoButton()
 | |
| 	{
 | |
| 		return historicoButton;
 | |
| 	}
 | |
| 
 | |
| 	public JPanelControllable getHistoricoPanel()
 | |
| 	{
 | |
| 		return historicoPanel;
 | |
| 	}
 | |
| 
 | |
| 	public JButton getNovaDataButton()
 | |
| 	{
 | |
| 		return novaDataButton;
 | |
| 	}
 | |
| 
 | |
| 	public StateTextArea getObservacoesText()
 | |
| 	{
 | |
| 		return observacoesText;
 | |
| 	}
 | |
| 
 | |
| }
 |