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.
		
		
		
		
		
			
		
			
				
					
					
						
							263 lines
						
					
					
						
							8.5 KiB
						
					
					
				
			
		
		
	
	
							263 lines
						
					
					
						
							8.5 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 emailButton = new JButton( "Enviar Email" );
 | |
| 	private final JPanelControllable detalhesPanel = new JPanelControllable();
 | |
| 	private RadioButtonFixedPanel estadoList;
 | |
| 	private final JScrollPane observacoesTextScroll = new JScrollPane();
 | |
| 	private final StateTextArea observacoesText = new StateTextArea();
 | |
| 
 | |
| 	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;
 | |
| 		emailButton.setMinimumSize( new Dimension( 300, 20 ) );
 | |
| 		emailButton.setPreferredSize( new Dimension( 200, 20 ) );
 | |
| 
 | |
| 		detalhesPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Detalhes" ) );
 | |
| 
 | |
| 		IDObject estadoListOptions[] = new IDObject[]{
 | |
| 			new MappableObject( new Integer( 0 ), "Por realizar" ),
 | |
| 			new MappableObject( new Integer( 1 ), "Parcialmente realizados" ),
 | |
| 			new MappableObject( new Integer( 2 ), "Realizados" ),
 | |
| 			new MappableObject( new Integer( 3 ), "Desmarcados pelo trabalhador" ),
 | |
| 			new MappableObject( new Integer( 4 ), "Desmarcados pela SIPRP" ),
 | |
| 			new MappableObject( new Integer( 5 ), "Faltou" ),
 | |
| 		};
 | |
| 		estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
 | |
| 		estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
 | |
| 
 | |
| 		observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
 | |
| 		observacoesText.setLineWrap( true );
 | |
| 		observacoesText.setWrapStyleWord( true );
 | |
| 		observacoesText.setRows( 5 );
 | |
| 
 | |
| 	}
 | |
| 
 | |
| 	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 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( emailButton, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( emailButton );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 1;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 2;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( detalhesPanel, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( detalhesPanel );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 2;
 | |
| 		MarcacaoExamePanelGBC.gridy = 1;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 1;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 0.5;
 | |
| 		MarcacaoExamePanelGBC.weighty = 0.0;
 | |
| 		MarcacaoExamePanelGBC.fill = GridBagConstraints.BOTH;
 | |
| 		MarcacaoExamePanelLayout.setConstraints( estadoList, MarcacaoExamePanelGBC );
 | |
| 		MarcacaoExamePanel.add( estadoList );
 | |
| 
 | |
| 		MarcacaoExamePanelGBC.gridx = 0;
 | |
| 		MarcacaoExamePanelGBC.gridy = 2;
 | |
| 		MarcacaoExamePanelGBC.gridwidth = 3;
 | |
| 		MarcacaoExamePanelGBC.gridheight = 1;
 | |
| 		MarcacaoExamePanelGBC.weightx = 1.0;
 | |
| 		MarcacaoExamePanelGBC.weighty = 1.0;
 | |
| 		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 );
 | |
| 
 | |
| 	}
 | |
| 
 | |
| 	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 RadioButtonFixedPanel getEstadoList()
 | |
| 	{
 | |
| 		return estadoList;
 | |
| 	}
 | |
| 
 | |
| 	public StateTextArea getObservacoesText()
 | |
| 	{
 | |
| 		return observacoesText;
 | |
| 	}
 | |
| 
 | |
| }
 |