forked from Coded/SIPRP
unused classes
git-svn-id: https://svn.coded.pt/svn/SIPRP@1368 bb69d46d-e84e-40c8-a05a-06db0d633741lxbfYeaa
parent
b97cebaaa4
commit
129e447d79
@ -1,544 +0,0 @@
|
||||
/*
|
||||
* 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.outer.EmpresasData;
|
||||
import siprp.data.outer.EstabelecimentosData;
|
||||
import siprp.data.outer.TrabalhadoresData;
|
||||
|
||||
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 TrabalhadoresData trabalhador;
|
||||
private ComponentsHashtable components;
|
||||
|
||||
private EstabelecimentosData 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( TrabalhadoresData.NOME, nomeText );
|
||||
components.putComponent( TrabalhadoresData.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( TrabalhadoresData.BI , biText );
|
||||
components.putComponent( TrabalhadoresData.DATA_NASCIMENTO, dataNascimentoPanel );
|
||||
components.putComponent( TrabalhadoresData.NACIONALIDADE, nacionalidadeText );
|
||||
components.putComponent( TrabalhadoresData.NUMERO_MECANOGRAFICO, numeroMecanograficoText );
|
||||
components.putComponent( TrabalhadoresData.DATA_ADMISSAO, dataAdmissaoPanel );
|
||||
components.putComponent( TrabalhadoresData.CATEGORIA, categoriaText );
|
||||
components.putComponent( TrabalhadoresData.LOCAL_TRABALHO, localText );
|
||||
components.putComponent( TrabalhadoresData.FUNCAO_PROPOSTA, funcaoText );
|
||||
components.putComponent( TrabalhadoresData.DATA_ADMISSAO_FUNCAO, dataAdmissaoFuncaoPanel );
|
||||
components.putComponent( TrabalhadoresData.DATA_DEMISSAO, dataDemissaoPanel );
|
||||
components.putDummy( TrabalhadoresData.OBSERVACOES );
|
||||
components.putComponent( TrabalhadoresData.OBSERVACOES_GESTAO, observacoesText );
|
||||
components.putComponent( TrabalhadoresData.PERFIL, perfilPanel );
|
||||
// components.putDummy( TrabalhadoresData.INACTIVO );
|
||||
components.putDummy( TrabalhadoresData.ESTABELECIMENTO_ID );
|
||||
components.putDummy( TrabalhadoresData.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 = ( TrabalhadoresData ) 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 TrabalhadoresData();
|
||||
}
|
||||
|
||||
String names[] = trabalhador.getFieldNames();
|
||||
Hashtable hash = new Hashtable();
|
||||
ComponentController.save( names, hash, components );
|
||||
trabalhador.setHashData( hash );
|
||||
trabalhador.set( TrabalhadoresData.TO_ESTABELECIMENTO_ID, 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( EstabelecimentosData.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
|
||||
// {
|
||||
// TrabalhadoresData trabalhador = (TrabalhadoresData) TrabalhadoresData.load( TrabalhadoresData.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( TrabalhadoresData.ID ), trabalhador.get( TrabalhadoresData.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( EstabelecimentosData estabelecimento )
|
||||
{
|
||||
this.estabelecimento = estabelecimento;
|
||||
}
|
||||
|
||||
public void setSelectedTrabalhador( TrabalhadoresData trab )
|
||||
{
|
||||
IDObject lista[] = (IDObject [])trabalhadoresModel.getValues().toArray( new IDObject[ 0 ] );
|
||||
Integer id = (Integer)trab.get( TrabalhadoresData.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
|
||||
{
|
||||
EstabelecimentosData estabelecimento = trabalhador.toEstabelecimento_id();
|
||||
EmpresasData empresa = estabelecimento.toEmpresa_id();
|
||||
tracker.getMedicinaWindow().setVisible( true );
|
||||
tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresasData.ID ),
|
||||
( Integer ) estabelecimento.get( EstabelecimentosData.ID ),
|
||||
( Integer ) trabalhador.get( TrabalhadoresData.ID ) );
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ErrorLogger.logException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTracker( SIPRPTracker tracker )
|
||||
{
|
||||
this.tracker = tracker;
|
||||
}
|
||||
}
|
||||
@ -1,116 +0,0 @@
|
||||
package siprp.ficha;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Window;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import com.evolute.utils.dataui.ControllableComponent;
|
||||
|
||||
class FichaMainPanel extends JPanel implements ControllableComponent< Object >
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Window owner;
|
||||
|
||||
private UpperPanel upperPanel;
|
||||
private EmpresaPanel empresaPanel;
|
||||
private TrabalhadorPanel trabalhadorPanel;
|
||||
private ObservacoesPanel observacoesPanel;
|
||||
private ExamePanel examePanel;
|
||||
|
||||
|
||||
public FichaMainPanel( Window owner )
|
||||
{
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
||||
private void setupComponents() throws Exception
|
||||
{
|
||||
upperPanel = new UpperPanel();
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
setLayout( new BorderLayout( ) );
|
||||
add( upperPanel, BorderLayout.NORTH );
|
||||
add( tabbedPane, BorderLayout.CENTER );
|
||||
|
||||
|
||||
JPanel empresaTrabalhadorPanel = new JPanel();
|
||||
JPanel exameRecomendacoesPanel = new JPanel();
|
||||
|
||||
tabbedPane.add( empresaTrabalhadorPanel, "Empresa/Trabalhador" );
|
||||
tabbedPane.add( exameRecomendacoesPanel, "Exame" );
|
||||
|
||||
GridBagLayout gridbag = new GridBagLayout();
|
||||
empresaTrabalhadorPanel.setLayout( gridbag );
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
constraints.insets = new Insets( 0, 1, 0, 1 );
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
constraints.weightx = 1;
|
||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
constraints.gridheight = 1;
|
||||
constraints.weighty = 0;
|
||||
|
||||
empresaPanel = new EmpresaPanel();
|
||||
empresaPanel.setEnabled( false );
|
||||
gridbag.setConstraints( empresaPanel, constraints );
|
||||
empresaTrabalhadorPanel.add( empresaPanel );
|
||||
|
||||
constraints.weighty = 0;
|
||||
trabalhadorPanel = new TrabalhadorPanel();
|
||||
gridbag.setConstraints( trabalhadorPanel, constraints );
|
||||
empresaTrabalhadorPanel.add( trabalhadorPanel );
|
||||
|
||||
constraints.weighty = 1;
|
||||
observacoesPanel = new ObservacoesPanel();
|
||||
gridbag.setConstraints( observacoesPanel, constraints );
|
||||
empresaTrabalhadorPanel.add( observacoesPanel );
|
||||
|
||||
|
||||
gridbag = new GridBagLayout();
|
||||
exameRecomendacoesPanel.setLayout( gridbag );
|
||||
constraints = new GridBagConstraints();
|
||||
constraints.insets = new Insets( 0, 1, 0, 1 );
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
constraints.weightx = 1;
|
||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
constraints.gridheight = 1;
|
||||
constraints.weighty = 0;
|
||||
|
||||
constraints.weighty = 1;
|
||||
examePanel = new ExamePanel();
|
||||
gridbag.setConstraints( examePanel, constraints );
|
||||
exameRecomendacoesPanel.add( examePanel );
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled( boolean enable )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill( Object value )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object save()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue