no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@302 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 19 years ago
parent ee2855aa36
commit 8fb2476779

@ -32,6 +32,8 @@ public class LembretesDataProvider
private final HashMap<String,TipoLembrete> TIPOS_LEMBRETES_BY_CODIGO = private final HashMap<String,TipoLembrete> TIPOS_LEMBRETES_BY_CODIGO =
new HashMap<String,TipoLembrete>(); new HashMap<String,TipoLembrete>();
private final HashMap<Integer,TipoLembrete> TIPOS_LEMBRETES_BY_ID =
new HashMap<Integer,TipoLembrete>();
private TipoLembrete tiposLembrete[]; private TipoLembrete tiposLembrete[];
private Executer EXECUTER; private Executer EXECUTER;
@ -78,6 +80,7 @@ public class LembretesDataProvider
Integer ordem = ( Integer ) array.get( n, 3 ); Integer ordem = ( Integer ) array.get( n, 3 );
tiposLembrete[ n ] = new TipoLembrete( id, codigo, descricao, ordem ); tiposLembrete[ n ] = new TipoLembrete( id, codigo, descricao, ordem );
TIPOS_LEMBRETES_BY_CODIGO.put( codigo, tiposLembrete[ n ] ); TIPOS_LEMBRETES_BY_CODIGO.put( codigo, tiposLembrete[ n ] );
TIPOS_LEMBRETES_BY_ID.put( id, tiposLembrete[ n ] );
} }
} }
return tiposLembrete; return tiposLembrete;
@ -90,6 +93,13 @@ public class LembretesDataProvider
return TIPOS_LEMBRETES_BY_CODIGO.get( codigo ); return TIPOS_LEMBRETES_BY_CODIGO.get( codigo );
} }
public TipoLembrete getTipoLembreteByID( Integer id )
throws Exception
{
getTiposLembrete();
return TIPOS_LEMBRETES_BY_ID.get( id );
}
public void criarLembrete( Integer tipoID, public void criarLembrete( Integer tipoID,
Date data, Date data,
String descricao, String descricao,

@ -15,33 +15,43 @@ import javax.swing.*;
import com.evolute.utils.tables.*; import com.evolute.utils.tables.*;
import com.evolute.utils.tracker.TrackableWindow; import com.evolute.utils.tracker.TrackableWindow;
import com.evolute.utils.ui.DialogException;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.Vector;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import siprp.lembretes.remarcacoes.LembretesRemarcacaoPanel;
/** /**
* *
* @author Frederico * @author Frederico
*/ */
public class LembretesWindow extends JFrame public class LembretesWindow extends JFrame
implements ActionListener, TrackableWindow, ListSelectionListener implements ActionListener, TrackableWindow, ListSelectionListener,
LembretesConstants
{ {
public static final String TITLE = "Lembretes"; public static final String TITLE = "Lembretes";
protected VectorTableModel tiposModel; protected VectorTableModel tiposModel;
protected BaseTable tiposTable; protected BaseTable tiposTable;
protected JPanel lembretesPanel; protected JPanel lembretesPanel;
protected JButton recarregarButton;
protected LembretesDataProvider provider;
/** Creates a new instance of LembretesWindow */ /** Creates a new instance of LembretesWindow */
public LembretesWindow() public LembretesWindow()
throws Exception
{ {
provider = LembretesDataProvider.getProvider();
setupComponents(); setupComponents();
} }
private void setupComponents() private void setupComponents()
{ {
setTitle( "Lembretes" );
tiposModel = new VectorTableModel( new String[]{ "tipo", "quantidade" } ); tiposModel = new VectorTableModel( new String[]{ "tipo", "quantidade" } );
tiposTable = new BaseTable( tiposModel ); tiposTable = new BaseTable( tiposModel );
tiposTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); tiposTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
@ -53,10 +63,14 @@ public class LembretesWindow extends JFrame
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
scp.setPreferredSize( new Dimension( 300, 20 ) ); scp.setPreferredSize( new Dimension( 300, 20 ) );
lembretesPanel = new JPanel(); lembretesPanel = new JPanel();
lembretesPanel.setLayout( new GridLayout( 1, 1 ) );
recarregarButton = new JButton( "Recarregar" );
recarregarButton.addActionListener( this );
getContentPane().setLayout( new BorderLayout() ); getContentPane().setLayout( new BorderLayout() );
getContentPane().add( scp, BorderLayout.WEST ); getContentPane().add( scp, BorderLayout.WEST );
getContentPane().add( lembretesPanel, BorderLayout.CENTER ); getContentPane().add( lembretesPanel, BorderLayout.CENTER );
getContentPane().add( recarregarButton, BorderLayout.SOUTH );
addWindowListener( new WindowAdapter(){ addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e ) public void windowClosing( WindowEvent e )
@ -67,6 +81,7 @@ public class LembretesWindow extends JFrame
public void windowOpened( WindowEvent e ) public void windowOpened( WindowEvent e )
{ {
setExtendedState( getExtendedState() | MAXIMIZED_BOTH ); setExtendedState( getExtendedState() | MAXIMIZED_BOTH );
reloadTotais();
} }
} ); } );
} }
@ -93,10 +108,60 @@ public class LembretesWindow extends JFrame
protected void reloadTotais() protected void reloadTotais()
{ {
try
{
Vector values = tiposModel.getValues();
values.clear();
TipoLembrete tipos[] = provider.getTiposLembrete();
for( int n = 0; n < tipos.length; n++ )
{
int count = provider.countLembretesByTipo( tipos[ n ].getID() );
values.add( new ColumnizedObjectArray(
new Object[]{ tipos[ n ].getID(), tipos[ n ].getDescricao(),
"" + count }, true ) );
}
tiposModel.setValues( values );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true );
}
} }
protected void reloadLembretes() protected void reloadLembretes()
{ {
lembretesPanel.removeAll();
int selected = tiposTable.getSelectedRow();
if( selected != -1 )
{
ColumnizedObjectArray line = ( ColumnizedObjectArray ) tiposModel.getRowAt( selected );
Integer tipoID = line.getID();
try
{
TipoLembrete tipo = provider.getTipoLembreteByID( tipoID );
if( CODE_EXTERNO.equals( tipo.getCodigo() ) )
{
}
if( CODE_REMARCACOES.equals( tipo.getCodigo() ) )
{
lembretesPanel.add( new LembretesRemarcacaoPanel() );
}
if( CODE_MARCACOES.equals( tipo.getCodigo() ) )
{
}
if( CODE_OUTROS.equals( tipo.getCodigo() ) )
{
}
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a carregar lembretes", true );
}
}
validate();
repaint();
} }
public boolean closeIfPossible() public boolean closeIfPossible()
@ -107,9 +172,18 @@ public class LembretesWindow extends JFrame
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Object source = e.getSource();
if( source.equals( recarregarButton ) )
{
reloadTotais();
}
} }
public void valueChanged(ListSelectionEvent e) public void valueChanged(ListSelectionEvent e)
{ {
if( !e.getValueIsAdjusting() )
{
reloadLembretes();
}
} }
} }

@ -0,0 +1,101 @@
/*
* LembretesRemarcacaoPanel.java
*
* Created on 13 de Fevereiro de 2007, 23:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.data.MappableObject;
import com.evolute.utils.ui.panel.multipleactionlist.MultipleActionListPanel;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.util.List;
import java.util.Vector;
import javax.swing.*;
import siprp.lembretes.Lembrete;
import siprp.lembretes.LembretesConstants;
import siprp.lembretes.LembretesDataProvider;
/**
*
* @author Frederico
*/
public class LembretesRemarcacaoPanel extends JPanel
implements LembretesConstants
{
protected JScrollPane listTrabalhadoresScroll;
protected JScrollPane listEstabelecimentosScroll;
protected MultipleActionListPanel listTrabalhadoresPanel;
protected MultipleActionListPanel listEstabelecimentosPanel;
protected LembretesDataProvider provider;
/** Creates a new instance of LembretesRemarcacaoPanel */
public LembretesRemarcacaoPanel()
throws Exception
{
provider = LembretesDataProvider.getProvider();
setupComponents();
}
private void setupComponents()
throws Exception
{
listTrabalhadoresPanel =
new MultipleActionListPanel(
new RemarcacoesActionFactory[]{ },
new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.TRABALHADOR ) } );
listTrabalhadoresScroll =
new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
listEstabelecimentosPanel =
new MultipleActionListPanel(
new RemarcacoesActionFactory[]{ },
new RemarcacoesActionFactory[]{ new RemarcacoesActionFactory( RemarcacoesActionFactory.ESTABELECIMENTO ) } );
listEstabelecimentosScroll =
new JScrollPane( listTrabalhadoresPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
setLayout( new GridLayout( 1, 2 ) );
JPanel trabalhadoresPanel = new JPanel();
JPanel estabelecimentosPanel = new JPanel();
add( trabalhadoresPanel );
add( estabelecimentosPanel );
trabalhadoresPanel.setLayout( new BorderLayout() );
trabalhadoresPanel.add( new JLabel( "Consultas / ECDs", JLabel.CENTER ), BorderLayout.NORTH );
trabalhadoresPanel.add( listTrabalhadoresScroll, BorderLayout.CENTER );
estabelecimentosPanel.setLayout( new BorderLayout() );
estabelecimentosPanel.add( new JLabel( "Higiene e Seguran\u00e7a", JLabel.CENTER ), BorderLayout.NORTH );
estabelecimentosPanel.add( listEstabelecimentosScroll, BorderLayout.CENTER );
Lembrete lembretes[] =
provider.getLembretesByTipo(
provider.getTipoLembreteByCodigo( CODE_REMARCACOES ).getID() );
System.out.println( "\nLEMBRETES: " + lembretes.length ) ;
List<IDObject> trabalhadores = new Vector<IDObject>();
List<IDObject> estabelecimentos = new Vector<IDObject>();
for( int n = 0; n < lembretes.length; n++ )
{
if( lembretes[ n ].getMarcacaoTrabalhadorID() != null )
{
trabalhadores.add( new MappableObject(
lembretes[ n ].getMarcacaoTrabalhadorID(),
lembretes[ n ].getDescricao() ) );
}
else if( lembretes[ n ].getMarcacaoEstabelecimentoID() != null )
{
}
}
System.out.println( "\nTRABALHADORES: " + trabalhadores.size() ) ;
listTrabalhadoresPanel.showList( trabalhadores.toArray( new IDObject[ trabalhadores.size() ] ) );
listEstabelecimentosPanel.showList( estabelecimentos.toArray( new IDObject[ estabelecimentos.size() ] ) );
listTrabalhadoresScroll.setViewportView( listTrabalhadoresPanel );
}
}

@ -0,0 +1,57 @@
/*
* RemarcacoesActionFactory.java
*
* Created on January 31, 2007, 6:37 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.panel.multipleactionlist.ActionFactory;
import javax.swing.Action;
import siprp.lembretes.remarcacoes.actions.TratarMarcacaoEstabelecimentoAction;
import siprp.lembretes.remarcacoes.actions.TratarMarcacaoTrabalhadorAction;
/**
*
* @author fpalma
*/
public class RemarcacoesActionFactory implements ActionFactory<IDObject>
{
public static final int TRABALHADOR = 0;
public static final int ESTABELECIMENTO = 1;
protected final int TIPO;
/**
* Creates a new instance of RemarcacoesActionFactory
*/
public RemarcacoesActionFactory( int tipo )
{
TIPO = tipo;
}
public Action createAction(IDObject[] objects)
{
return null;
}
public Action createAction(IDObject object)
{
switch( TIPO )
{
case TRABALHADOR:
return new TratarMarcacaoTrabalhadorAction( object );
case ESTABELECIMENTO:
return new TratarMarcacaoEstabelecimentoAction( object );
default:
return null;
}
}
}

@ -0,0 +1,42 @@
/*
* tratarMarcacaoTrabalhadorAction.java
*
* Created on January 31, 2007, 6:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes.actions;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.DialogException;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
/**
*
* @author fpalma
*/
public class TratarMarcacaoEstabelecimentoAction extends AbstractAction
{
/**
* Creates a new instance of tratarMarcacaoTrabalhadorAction
*/
public TratarMarcacaoEstabelecimentoAction( IDObject marcacaoID )
{
super( "Tratar" );
}
public void actionPerformed(ActionEvent e)
{
try
{
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a marcar", true );
}
}
}

@ -0,0 +1,42 @@
/*
* TratarMarcacaoTrabalhadorAction.java
*
* Created on January 31, 2007, 6:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.lembretes.remarcacoes.actions;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.ui.DialogException;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
/**
*
* @author fpalma
*/
public class TratarMarcacaoTrabalhadorAction extends AbstractAction
{
/**
* Creates a new instance of TratarMarcacaoTrabalhadorAction
*/
public TratarMarcacaoTrabalhadorAction( IDObject marcacaoID )
{
super( "Tratar" );
}
public void actionPerformed(ActionEvent e)
{
try
{
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a marcar", true );
}
}
}

@ -0,0 +1,31 @@
/*
* MarcacaoConsultaExtendedPanel.java
*
* Created on 13 de Fevereiro de 2007, 20:36
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.medicina;
import java.awt.*;
import javax.swing.*;
/**
*
* @author Frederico
*/
public class MarcacaoConsultaExtendedPanel extends JPanel
{
/** Creates a new instance of MarcacaoConsultaExtendedPanel */
public MarcacaoConsultaExtendedPanel()
{
setupComponents();
}
private void setupComponents()
{
}
}
Loading…
Cancel
Save