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.
545 lines
19 KiB
545 lines
19 KiB
/*
|
|
* TrabalhadorPanel.java
|
|
*
|
|
* Created on 14 de Maio de 2004, 12:29
|
|
*/
|
|
|
|
package siprp.clientes;
|
|
|
|
import info.clearthought.layout.TableLayout;
|
|
import info.clearthought.layout.TableLayoutConstraints;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Dimension;
|
|
import java.awt.GridLayout;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
import java.util.Arrays;
|
|
import java.util.Hashtable;
|
|
import java.util.Vector;
|
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JScrollPane;
|
|
import javax.swing.JTable;
|
|
import javax.swing.JTextField;
|
|
import javax.swing.ListSelectionModel;
|
|
import javax.swing.event.ListSelectionEvent;
|
|
import javax.swing.event.ListSelectionListener;
|
|
|
|
import siprp.FichaDataProvider;
|
|
import siprp.SIPRPTracker;
|
|
import siprp.data.EmpresaData;
|
|
import siprp.data.EstabelecimentoData;
|
|
import siprp.data.TrabalhadorData;
|
|
|
|
import com.evolute.utils.data.IDObject;
|
|
import com.evolute.utils.data.MappableObject;
|
|
import com.evolute.utils.dataui.ComponentController;
|
|
import com.evolute.utils.dataui.ComponentsHashtable;
|
|
import com.evolute.utils.dataui.ControllableComponent;
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
import com.evolute.utils.tables.BaseTable;
|
|
import com.evolute.utils.tables.VectorTableModel;
|
|
import com.evolute.utils.ui.DialogException;
|
|
import com.evolute.utils.ui.calendar.JCalendarPanel;
|
|
import com.evolute.utils.ui.panel.RadioButtonFixedPanel;
|
|
import com.evolute.utils.ui.panel.RadioButtonPanel;
|
|
import com.evolute.utils.ui.text.CopyPasteHandler;
|
|
|
|
/**
|
|
*
|
|
* @author fpalma
|
|
*/
|
|
public class TrabalhadorPanel extends JPanel
|
|
implements ControllableComponent, ListSelectionListener, ActionListener
|
|
{
|
|
private FichaDataProvider provider;
|
|
private TrabalhadorData trabalhador;
|
|
private ComponentsHashtable components;
|
|
|
|
private EstabelecimentoData estabelecimento;
|
|
private JTable estabelecimentosTable;
|
|
|
|
private JPanel toolbarPanel;
|
|
|
|
private JPanel dadosTrabalhadorPanel;
|
|
|
|
private JTextField nomeText;
|
|
private RadioButtonFixedPanel sexoPanel;
|
|
private JTextField biText;
|
|
private JCalendarPanel dataNascimentoPanel;
|
|
private JTextField nacionalidadeText;
|
|
private JTextField numeroMecanograficoText;
|
|
private JCalendarPanel dataAdmissaoPanel;
|
|
private JTextField categoriaText;
|
|
private JTextField localText;
|
|
private JTextField funcaoText;
|
|
private JCalendarPanel dataAdmissaoFuncaoPanel;
|
|
private JCalendarPanel dataDemissaoPanel;
|
|
private JTextField observacoesText;
|
|
//private JComboBox perfilCombo;
|
|
private RadioButtonFixedPanel perfilPanel;
|
|
|
|
private SIPRPTracker tracker;
|
|
|
|
private BaseTable trabalhadoresTable;
|
|
private VectorTableModel trabalhadoresModel;
|
|
|
|
private JButton marcacoesButton;
|
|
// private MarcacaoPanel examesPanel;
|
|
// private MarcacaoPanel consultaPanel;
|
|
|
|
private Vector listeners;
|
|
|
|
private boolean lastEnable = false;
|
|
|
|
/** Creates a new instance of TrabalhadorPanel */
|
|
public TrabalhadorPanel( JPanel toolbarPanel, JTable estabelecimentosTable )
|
|
throws Exception
|
|
{
|
|
this.toolbarPanel = toolbarPanel;
|
|
this.estabelecimentosTable = estabelecimentosTable;
|
|
provider = ( FichaDataProvider )FichaDataProvider.getProvider();
|
|
listeners = new Vector();
|
|
setupComponents();
|
|
setupComponentsHashtable();
|
|
}
|
|
|
|
private void setupComponents()
|
|
{
|
|
dadosTrabalhadorPanel = new JPanel();
|
|
// JPanel marcacoesPanel = new JPanel();
|
|
|
|
JLabel nomeLabel = new JLabel( "Nome" );
|
|
nomeText = new JTextField();
|
|
JLabel sexoLabel = new JLabel( "Sexo" );
|
|
sexoPanel =
|
|
new RadioButtonFixedPanel(
|
|
new IDObject[]{ new MappableObject( new Integer( 1 ), "M" ),
|
|
new MappableObject( new Integer( 2 ), "F" ) },
|
|
1, 2, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
|
|
JLabel biLabel = new JLabel("B.I.");
|
|
biText = new JTextField();
|
|
JLabel dataNascimentoLabel = new JLabel( "Data de Nascimento" );
|
|
dataNascimentoPanel = new JCalendarPanel( null );
|
|
JLabel nacionalidadeLabel = new JLabel( "Nacionalidade" );
|
|
nacionalidadeText = new JTextField();
|
|
JLabel numeroMecanograficoLabel = new JLabel( "N\u00famero Mecanogr\u00e1fico/Outro" );
|
|
numeroMecanograficoText = new JTextField();
|
|
JLabel dataAdmissaoLabel = new JLabel( "Data de Admiss\u00e3o" );
|
|
dataAdmissaoPanel = new JCalendarPanel( null );
|
|
JLabel categoriaLabel = new JLabel( "Categoria Profissional" );
|
|
categoriaText = new JTextField();
|
|
JLabel localLabel = new JLabel( "Local de Trabalho" );
|
|
localText = new JTextField();
|
|
JLabel funcaoLabel = new JLabel( "Fun\u00e7\u00e3o Proposta" );
|
|
funcaoText = new JTextField();
|
|
JLabel dataAdmissaoFuncaoLabel = new JLabel( "Data de Admiss\u00e3o na Fun\u00e7\u00e3o" );
|
|
dataAdmissaoFuncaoPanel = new JCalendarPanel( null );
|
|
JLabel perfilLabel = new JLabel( "Perfil" );
|
|
// perfilCombo = new JComboBox();
|
|
// perfilCombo.addItem( new MappableObject( new Integer( 1 ), "A" ) );
|
|
// perfilCombo.addItem( new MappableObject( new Integer( 2 ), "B" ) );
|
|
perfilPanel = new RadioButtonFixedPanel(
|
|
new IDObject[]{ new MappableObject( new Integer( 1 ), "A" ),
|
|
new MappableObject( new Integer( 2 ), "B" ) },
|
|
1, 2, RadioButtonPanel.ORIENTATION_HORIZONTAL, false );
|
|
JLabel dataDemissaoLabel = new JLabel( "Data de Demiss\u00e3o" );
|
|
dataDemissaoPanel = new JCalendarPanel( null );
|
|
JLabel observacoesLabel = new JLabel( "Observa\u00e7\u00f5es" );
|
|
observacoesText = new JTextField();
|
|
marcacoesButton = new JButton( "Marca\u00e7\u00f5es" );
|
|
marcacoesButton.addActionListener( this );
|
|
|
|
JScrollPane trabalhadoresScroll = new JScrollPane();
|
|
trabalhadoresScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
|
trabalhadoresScroll.setPreferredSize( new Dimension( 250, 300 ) );
|
|
trabalhadoresModel = new VectorTableModel( new String[]{ "Trabalhadores" } );
|
|
trabalhadoresTable = new BaseTable( trabalhadoresModel );
|
|
trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
|
trabalhadoresTable.setNonResizableNorReordable();
|
|
trabalhadoresScroll.setViewportView( trabalhadoresTable );
|
|
|
|
JPanel pad;
|
|
|
|
double [] cols = new double[]{TableLayout.MINIMUM,TableLayout.FILL,TableLayout.MINIMUM,TableLayout.FILL};
|
|
double [] rows = new double[]{TableLayout.MINIMUM,
|
|
TableLayout.MINIMUM,
|
|
TableLayout.MINIMUM,
|
|
TableLayout.MINIMUM,
|
|
TableLayout.MINIMUM,
|
|
TableLayout.MINIMUM,
|
|
TableLayout.MINIMUM,
|
|
TableLayout.MINIMUM,
|
|
TableLayout.FILL,
|
|
TableLayout.MINIMUM,};
|
|
|
|
TableLayout layout = new TableLayout(cols,rows);
|
|
layout.setHGap( 5 );
|
|
layout.setVGap( 5 );
|
|
dadosTrabalhadorPanel.setLayout( layout );
|
|
dadosTrabalhadorPanel.add( nomeLabel, new TableLayoutConstraints( 0,0 ) );
|
|
dadosTrabalhadorPanel.add( nomeText, new TableLayoutConstraints( 1,0,3,0 ) );
|
|
dadosTrabalhadorPanel.add( sexoLabel, new TableLayoutConstraints( 0,1 ) );
|
|
JPanel sexoOuterPanel = new JPanel();
|
|
sexoOuterPanel.setLayout( new GridLayout( 1, 2 ) );
|
|
sexoOuterPanel.add( sexoPanel );
|
|
sexoOuterPanel.add( new JPanel() );
|
|
dadosTrabalhadorPanel.add( sexoOuterPanel, new TableLayoutConstraints( 1,1 ) );
|
|
dadosTrabalhadorPanel.add( biLabel, new TableLayoutConstraints( 2,1 ) );
|
|
dadosTrabalhadorPanel.add( biText, new TableLayoutConstraints( 3,1 ) );
|
|
dadosTrabalhadorPanel.add( nacionalidadeLabel, new TableLayoutConstraints( 0,2 ) );
|
|
dadosTrabalhadorPanel.add( nacionalidadeText, new TableLayoutConstraints( 1,2 ) );
|
|
dadosTrabalhadorPanel.add( dataNascimentoLabel, new TableLayoutConstraints( 2,2 ) );
|
|
dadosTrabalhadorPanel.add( dataNascimentoPanel, new TableLayoutConstraints( 3,2 ) );
|
|
|
|
dadosTrabalhadorPanel.add( numeroMecanograficoLabel, new TableLayoutConstraints( 0,3 ) );
|
|
dadosTrabalhadorPanel.add( numeroMecanograficoText, new TableLayoutConstraints( 1,3 ) );
|
|
dadosTrabalhadorPanel.add( dataAdmissaoLabel, new TableLayoutConstraints( 2,3 ) );
|
|
dadosTrabalhadorPanel.add( dataAdmissaoPanel, new TableLayoutConstraints( 3,3 ));
|
|
dadosTrabalhadorPanel.add( categoriaLabel, new TableLayoutConstraints( 0,4 ) );
|
|
dadosTrabalhadorPanel.add( categoriaText, new TableLayoutConstraints( 1,4 ) );
|
|
dadosTrabalhadorPanel.add( localLabel, new TableLayoutConstraints( 2,4 ) );
|
|
dadosTrabalhadorPanel.add( localText, new TableLayoutConstraints( 3,4 ));
|
|
dadosTrabalhadorPanel.add( funcaoLabel, new TableLayoutConstraints( 0,5 ) );
|
|
dadosTrabalhadorPanel.add( funcaoText, new TableLayoutConstraints( 1,5 ) );
|
|
dadosTrabalhadorPanel.add( dataAdmissaoFuncaoLabel, new TableLayoutConstraints( 2,5 ) );
|
|
dadosTrabalhadorPanel.add( dataAdmissaoFuncaoPanel, new TableLayoutConstraints( 3,5 ) );
|
|
dadosTrabalhadorPanel.add( perfilLabel, new TableLayoutConstraints( 0,6 ) );
|
|
dadosTrabalhadorPanel.add( perfilPanel, new TableLayoutConstraints( 1,6 ) );
|
|
dadosTrabalhadorPanel.add( dataDemissaoLabel, new TableLayoutConstraints( 2,6 ) );
|
|
dadosTrabalhadorPanel.add( dataDemissaoPanel, new TableLayoutConstraints( 3,6 ) );
|
|
dadosTrabalhadorPanel.add( observacoesLabel, new TableLayoutConstraints( 0,7 ) );
|
|
dadosTrabalhadorPanel.add( observacoesText, new TableLayoutConstraints( 0,8, 3, 8 ) );
|
|
dadosTrabalhadorPanel.add( marcacoesButton, new TableLayoutConstraints( 0,9,3,9 ) );
|
|
|
|
// examesPanel = new MarcacaoPanel( false, "Realizados", "", Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES );
|
|
// examesPanel.setCalendarDialogOrientation( JCalendarDialog.ABOVE, JCalendarDialog.RIGHT );
|
|
// examesPanel.setBorder( BorderFactory.createTitledBorder(
|
|
// BorderFactory.createEtchedBorder(),
|
|
// "Exames" ) );
|
|
// consultaPanel = new MarcacaoPanel( true, "Realizada", "Ficha de Aptid\u00e3o", Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA );
|
|
// consultaPanel.setCalendarDialogOrientation( JCalendarDialog.ABOVE, JCalendarDialog.LEFT );
|
|
// consultaPanel.setBorder( BorderFactory.createTitledBorder(
|
|
// BorderFactory.createEtchedBorder(),
|
|
// "Consulta" ) );
|
|
// //marcacoesPanel.setLayout( new BoxLayout( marcacoesPanel, BoxLayout.X_AXIS ) );
|
|
// marcacoesPanel.setLayout( new GridLayout( 1, 2 ) );
|
|
// marcacoesPanel.add( examesPanel );
|
|
// marcacoesPanel.add( consultaPanel );
|
|
|
|
JPanel leftPanel = new JPanel();
|
|
leftPanel.setLayout( new BorderLayout() );
|
|
leftPanel.add( toolbarPanel, BorderLayout.NORTH );
|
|
leftPanel.add( trabalhadoresScroll, BorderLayout.CENTER );
|
|
|
|
setLayout( new BorderLayout() );
|
|
add( leftPanel, BorderLayout.WEST );
|
|
add( dadosTrabalhadorPanel, BorderLayout.CENTER );
|
|
// add( marcacoesPanel, BorderLayout.SOUTH );
|
|
|
|
trabalhadoresTable.getSelectionModel().addListSelectionListener( this );
|
|
|
|
new CopyPasteHandler( nomeText );
|
|
new CopyPasteHandler( nacionalidadeText );
|
|
new CopyPasteHandler( numeroMecanograficoText );
|
|
new CopyPasteHandler( categoriaText );
|
|
new CopyPasteHandler( localText );
|
|
new CopyPasteHandler( funcaoText );
|
|
new CopyPasteHandler( observacoesText );
|
|
}
|
|
|
|
private void setupComponentsHashtable()
|
|
{
|
|
components = new ComponentsHashtable();
|
|
components.putComponent( TrabalhadorData.NOME, nomeText );
|
|
components.putComponent( TrabalhadorData.SEXO, new ControllableComponent()
|
|
{
|
|
public void fill( Object value )
|
|
{
|
|
if( value != null && value.equals( "f" ) )
|
|
{
|
|
sexoPanel.fill( new Integer(2) );
|
|
}
|
|
else
|
|
{
|
|
sexoPanel.fill( new Integer(1) );
|
|
}
|
|
}
|
|
|
|
public Object save()
|
|
{
|
|
Integer id = (Integer)sexoPanel.save();
|
|
if( id != null && id.intValue() == 1 )
|
|
{
|
|
return "m";
|
|
}
|
|
return "f";
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
sexoPanel.clear();
|
|
}
|
|
|
|
public void setEnabled( boolean enable )
|
|
{
|
|
sexoPanel.setEnabled( enable );
|
|
}
|
|
} );
|
|
components.putComponent( TrabalhadorData.BI , biText );
|
|
components.putComponent( TrabalhadorData.DATA_NASCIMENTO, dataNascimentoPanel );
|
|
components.putComponent( TrabalhadorData.NACIONALIDADE, nacionalidadeText );
|
|
components.putComponent( TrabalhadorData.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
|
|
components.putComponent( TrabalhadorData.DATA_ADMISSAO, dataAdmissaoPanel );
|
|
components.putComponent( TrabalhadorData.CATEGORIA, categoriaText );
|
|
components.putComponent( TrabalhadorData.LOCAL_TRABALHO, localText );
|
|
components.putComponent( TrabalhadorData.FUNCAO_PROPOSTA, funcaoText );
|
|
components.putComponent( TrabalhadorData.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
|
|
components.putComponent( TrabalhadorData.DATA_DEMISSAO, dataDemissaoPanel );
|
|
components.putDummy( TrabalhadorData.OBSERVACOES );
|
|
components.putComponent( TrabalhadorData.OBSERVACOES_GESTAO, observacoesText );
|
|
components.putComponent( TrabalhadorData.PERFIL, perfilPanel );
|
|
// components.putDummy( TrabalhadorData.INACTIVO );
|
|
components.putDummy( TrabalhadorData.ESTABELECIMENTO );
|
|
components.putDummy( TrabalhadorData.NOME_PLAIN );
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
String names[] = (String[])components.keySet().toArray( new String[0] );
|
|
ComponentController.clear( names, components );
|
|
trabalhador = null;
|
|
}
|
|
|
|
public void fill(Object value)
|
|
{
|
|
clear();
|
|
trabalhador = ( TrabalhadorData ) value;
|
|
// examesPanel.setEnabled( trabalhador != null );
|
|
// examesPanel.fill( trabalhador );
|
|
// consultaPanel.setEnabled( trabalhador != null );
|
|
// consultaPanel.fill( trabalhador );
|
|
if( trabalhador == null )
|
|
{
|
|
trabalhadoresTable.clearSelection();
|
|
return;
|
|
}
|
|
String names[] = trabalhador.getFieldNames();
|
|
ComponentController.fill( names, trabalhador.getHashData(), components );
|
|
}
|
|
|
|
public Object save()
|
|
{
|
|
|
|
if( trabalhador == null )
|
|
{
|
|
trabalhador = new TrabalhadorData();
|
|
}
|
|
|
|
String names[] = trabalhador.getFieldNames();
|
|
Hashtable hash = new Hashtable();
|
|
ComponentController.save( names, hash, components );
|
|
trabalhador.setHashData( hash );
|
|
trabalhador.set( TrabalhadorData.ESTABELECIMENTO, estabelecimento );
|
|
return trabalhador;
|
|
}
|
|
|
|
public void setEnabled( boolean enable )
|
|
{
|
|
super.setEnabled( enable );
|
|
String names[] = (String[])components.keySet().toArray( new String[0] );
|
|
ComponentController.setEnabled( names, enable, components );
|
|
trabalhadoresTable.setEnabled( !enable );
|
|
if( lastEnable != enable )
|
|
{
|
|
if( enable )
|
|
{
|
|
EstabelecimentoPanel.disables++;
|
|
}
|
|
else
|
|
{
|
|
EstabelecimentoPanel.disables--;
|
|
}
|
|
lastEnable = enable;
|
|
}
|
|
estabelecimentosTable.setEnabled( EstabelecimentoPanel.disables == 0 );
|
|
// if( trabalhador == null )
|
|
// {
|
|
// examesPanel.setEnabled( false );
|
|
// consultaPanel.setEnabled( false );
|
|
// }
|
|
}
|
|
|
|
public void reloaList()
|
|
throws Exception
|
|
{
|
|
if( estabelecimento == null )
|
|
{
|
|
trabalhadoresModel.clearAll();
|
|
}
|
|
else
|
|
{
|
|
Integer id = ( Integer )estabelecimento.get( EstabelecimentoData.ID );
|
|
IDObject []trabalhadores = provider.getAllTrabalhadoresForEstabelecimento( id );
|
|
trabalhadoresModel.setValues( new Vector( Arrays.asList( trabalhadores ) ) );
|
|
}
|
|
}
|
|
|
|
public void valueChanged( ListSelectionEvent e )
|
|
{
|
|
Object source = e.getSource();
|
|
if( source instanceof EmpresaPanel )
|
|
{
|
|
Integer id = ( ( EmpresaPanel ) source ).getSelectedEstabelecimento();
|
|
if( id != null )
|
|
{
|
|
try
|
|
{
|
|
IDObject []trabalhadores = provider.getAllTrabalhadoresForEstabelecimento( id );
|
|
trabalhadoresModel.setValues( new Vector( Arrays.asList( trabalhadores ) ) );
|
|
}
|
|
catch( Exception ex )
|
|
{
|
|
DialogException.showExceptionMessage( ex, "Erro a carregar os trabalhadores", true );
|
|
clear();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
trabalhadoresModel.clearAll();
|
|
clear();
|
|
}
|
|
}
|
|
else if( source.equals( trabalhadoresTable.getSelectionModel() ) )
|
|
{
|
|
// int selected = trabalhadoresTable.getSelectedRow();
|
|
// if( selected == -1 )
|
|
// {
|
|
// clear();
|
|
//
|
|
// }
|
|
// else
|
|
// {
|
|
// Integer id = ( ( IDObject ) trabalhadoresModel.getRowAt( selected ) ).getID();;
|
|
// try
|
|
// {
|
|
// TrabalhadorData trabalhador = (TrabalhadorData) TrabalhadorData.load( TrabalhadorData.class, id );
|
|
// fill( trabalhador );
|
|
// }
|
|
// catch( Exception ex )
|
|
// {
|
|
// DialogException.showExceptionMessage( ex, "Erro a carregar o trabalhador", true );
|
|
// clear();
|
|
// }
|
|
for( int n = 0; n < listeners.size(); n++ )
|
|
{
|
|
ListSelectionEvent newEvent =
|
|
new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() );
|
|
( (ListSelectionListener) listeners.elementAt( n ) ).valueChanged( newEvent );
|
|
}
|
|
// }
|
|
}
|
|
}
|
|
|
|
public void postSave()
|
|
{
|
|
int selected = trabalhadoresTable.getSelectedRow();
|
|
//System.out.println( "postSave TRABALHADOR PANEL " + selected + " : " + ( trabalhador == null ) );
|
|
if( trabalhador != null )
|
|
{
|
|
IDObject obj = new MappableObject( (Integer) trabalhador.get( TrabalhadorData.ID ), trabalhador.get( TrabalhadorData.NOME ) );
|
|
if( selected == -1 )
|
|
{
|
|
trabalhadoresModel.insertRowAt( obj, trabalhadoresTable.getRowCount() );
|
|
trabalhadoresTable.setRowSelectionInterval( trabalhadoresTable.getRowCount() - 1, trabalhadoresTable.getRowCount() - 1 );
|
|
}
|
|
else
|
|
{
|
|
trabalhadoresModel.removeRowAt( selected );
|
|
trabalhadoresModel.insertRowAt( obj, selected );
|
|
trabalhadoresTable.setRowSelectionInterval( selected, selected );
|
|
}
|
|
}
|
|
}
|
|
|
|
public void reload()
|
|
{
|
|
fill( trabalhador );
|
|
}
|
|
|
|
public void addListSelectionListener( ListSelectionListener listener )
|
|
{
|
|
listeners.add( listener );
|
|
}
|
|
|
|
public void removeListSelectionListener( ListSelectionListener listener )
|
|
{
|
|
listeners.remove( listener );
|
|
}
|
|
|
|
public Integer getSelectedTrabalhador()
|
|
{
|
|
int selected = trabalhadoresTable.getSelectedRow();
|
|
if( selected == -1 )
|
|
{
|
|
return null;
|
|
}
|
|
return ( (IDObject) trabalhadoresModel.getRowAt( selected ) ).getID();
|
|
}
|
|
|
|
public void setEstabelecimento( EstabelecimentoData estabelecimento )
|
|
{
|
|
this.estabelecimento = estabelecimento;
|
|
}
|
|
|
|
public void setSelectedTrabalhador( TrabalhadorData trab )
|
|
{
|
|
IDObject lista[] = (IDObject [])trabalhadoresModel.getValues().toArray( new IDObject[ 0 ] );
|
|
Integer id = (Integer)trab.get( TrabalhadorData.ID );
|
|
for( int n = 0; n < lista.length; n++ )
|
|
{
|
|
if( lista[ n ].getID().equals( id ) )
|
|
{
|
|
trabalhadoresTable.setRowSelectionInterval( n, n );
|
|
return;
|
|
}
|
|
}
|
|
trabalhadoresTable.clearSelection();
|
|
}
|
|
|
|
public void actionPerformed( ActionEvent e )
|
|
{
|
|
Object source = e.getSource();
|
|
if( source.equals( marcacoesButton ) )
|
|
{
|
|
if( trabalhador == null )
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
EstabelecimentoData estabelecimento = ( EstabelecimentoData ) trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
|
|
EmpresaData empresa = ( EmpresaData ) estabelecimento.get( EstabelecimentoData.EMPRESA );
|
|
tracker.getMedicinaWindow().setVisible( true );
|
|
tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresaData.ID ),
|
|
( Integer ) estabelecimento.get( EstabelecimentoData.ID ),
|
|
( Integer ) trabalhador.get( TrabalhadorData.ID ) );
|
|
}
|
|
catch (Exception ex) {
|
|
ErrorLogger.logException(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setTracker( SIPRPTracker tracker )
|
|
{
|
|
this.tracker = tracker;
|
|
}
|
|
}
|