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.
177 lines
5.1 KiB
177 lines
5.1 KiB
/*
|
|
* RegistarPresencasWindow.java
|
|
*
|
|
* Created on January 31, 2007, 3:09 PM
|
|
*
|
|
* To change this template, choose Tools | Template Manager
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
package siprp.medicina.presencas;
|
|
|
|
import com.evolute.utils.data.IDObject;
|
|
import com.evolute.utils.data.MappableObject;
|
|
import com.evolute.utils.strings.StringPlainer;
|
|
import com.evolute.utils.tracker.TrackableWindow;
|
|
import com.evolute.utils.ui.DialogException;
|
|
import com.evolute.utils.ui.calendar.JCalendarPanel;
|
|
import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel;
|
|
import java.awt.BorderLayout;
|
|
import java.awt.FlowLayout;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.event.WindowAdapter;
|
|
import java.awt.event.WindowEvent;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Vector;
|
|
import javax.swing.*;
|
|
import siprp.data.Marcacao;
|
|
import siprp.medicina.MedicinaDataProvider;
|
|
|
|
/**
|
|
*
|
|
* @author fpalma
|
|
*/
|
|
public class RegistarPresencasWindow extends JFrame
|
|
implements ActionListener, TrackableWindow
|
|
{
|
|
protected JCalendarPanel dataPanel;
|
|
protected JButton carregarButton;
|
|
protected JScrollPane listScroll;
|
|
protected MultipleActionListPanel listPanel;
|
|
|
|
protected MedicinaDataProvider provider;
|
|
|
|
public static void main( String args[] )
|
|
throws Exception
|
|
{
|
|
RegistarPresencasWindow window = new RegistarPresencasWindow();
|
|
window.setVisible( true );
|
|
window.setExtendedState( window.getExtendedState() | MAXIMIZED_BOTH );
|
|
}
|
|
|
|
/** Creates a new instance of RegistarPresencasWindow */
|
|
public RegistarPresencasWindow()
|
|
throws Exception
|
|
{
|
|
provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
|
|
setupComponents();
|
|
|
|
}
|
|
|
|
private void setupComponents()
|
|
{
|
|
setTitle( "Presen\u00e7as" );
|
|
setSize( 1000, 700 );
|
|
JLabel dataLabel = new JLabel( "Data" );
|
|
dataPanel = new JCalendarPanel( this );
|
|
carregarButton = new JButton( "Carregar" );
|
|
carregarButton.addActionListener( this );
|
|
|
|
PresencasActionFactory realizouFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU );
|
|
PresencasActionFactory realizouParcialmenteFactory = new PresencasActionFactory( PresencasActionFactory.REALIZOU_PARCIALMENTE );
|
|
PresencasActionFactory trabalhadorDesmarcouFactory = new PresencasActionFactory( PresencasActionFactory.TRABALHADOR_DESMARCOU );
|
|
PresencasActionFactory shstDesmarcouFactory = new PresencasActionFactory( PresencasActionFactory.SHST_DESMARCOU );
|
|
PresencasActionFactory faltouFactory = new PresencasActionFactory( PresencasActionFactory.FALTOU );
|
|
|
|
getContentPane().setLayout( new BorderLayout( 5, 5 ) );
|
|
JPanel upperPanel = new JPanel();
|
|
getContentPane().add( upperPanel, BorderLayout.NORTH );
|
|
|
|
listPanel =
|
|
new MultipleActionListPanel(
|
|
new PresencasActionFactory[]{ shstDesmarcouFactory, faltouFactory },
|
|
new PresencasActionFactory[]{ realizouFactory, realizouParcialmenteFactory,
|
|
trabalhadorDesmarcouFactory, shstDesmarcouFactory,
|
|
faltouFactory } );
|
|
listScroll = new JScrollPane( listPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
|
getContentPane().add( listScroll, BorderLayout.CENTER );
|
|
|
|
upperPanel.setLayout( new FlowLayout( FlowLayout.CENTER ) );
|
|
upperPanel.add( dataLabel );
|
|
upperPanel.add( dataPanel );
|
|
upperPanel.add( carregarButton );
|
|
|
|
setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE );
|
|
addWindowListener( new WindowAdapter(){
|
|
public void windowClosing( WindowEvent e )
|
|
{
|
|
close();
|
|
}
|
|
|
|
public void windowOpened( WindowEvent e )
|
|
{
|
|
// setExtendedState( getExtendedState() | MAXIMIZED_BOTH );
|
|
}
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
public void actionPerformed( ActionEvent e )
|
|
{
|
|
Object source = e.getSource();
|
|
if( source.equals( carregarButton ) )
|
|
{
|
|
carregar();
|
|
}
|
|
}
|
|
|
|
public void refresh()
|
|
{
|
|
}
|
|
|
|
public void open()
|
|
{
|
|
setVisible( true );
|
|
}
|
|
|
|
public void close()
|
|
{
|
|
SwingUtilities.invokeLater( new Runnable() {
|
|
public void run()
|
|
{
|
|
setVisible( false );
|
|
dispose();
|
|
}
|
|
} );
|
|
}
|
|
|
|
public boolean closeIfPossible()
|
|
{
|
|
close();
|
|
return true;
|
|
}
|
|
|
|
protected void carregar()
|
|
{
|
|
try
|
|
{
|
|
Date data = dataPanel.getDate();
|
|
Object marcacoesArray[][] = provider.getListaMarcacoesByData( data );
|
|
List<Presenca> marcacoes = new Vector<Presenca>();
|
|
for( int n = 0; n < marcacoesArray.length; n++ )
|
|
{
|
|
Integer id = ( Integer ) marcacoesArray[ n ][ 0 ];
|
|
String nome = ( String ) marcacoesArray[ n ][ 1 ];
|
|
String nomePlain = ( String ) marcacoesArray[ n ][ 2 ];
|
|
String empresa = ( String ) marcacoesArray[ n ][ 3 ];
|
|
int tipo = ( ( Integer )marcacoesArray[ n ][ 4 ] ).intValue();
|
|
marcacoes.add( new Presenca( id, nome, nomePlain, empresa, tipo ) );
|
|
}
|
|
Collections.sort( marcacoes );
|
|
listPanel.showList( marcacoes.toArray( new Presenca[ marcacoes.size() ] ) );
|
|
listScroll.setViewportView( listPanel );
|
|
// setExtendedState( getExtendedState() | MAXIMIZED_BOTH );
|
|
}
|
|
catch( Exception ex )
|
|
{
|
|
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
|
|
}
|
|
}
|
|
}
|