|
|
|
|
@ -10,7 +10,6 @@
|
|
|
|
|
package siprp.medicina.processo.estrutura;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.data.IDObject;
|
|
|
|
|
import com.evolute.utils.data.MappableObject;
|
|
|
|
|
import com.evolute.utils.ui.DialogException;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
@ -24,6 +23,7 @@ import javax.swing.event.TreeSelectionListener;
|
|
|
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
|
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
|
|
|
import javax.swing.tree.TreePath;
|
|
|
|
|
import siprp.medicina.MedicinaDataProvider;
|
|
|
|
|
import siprp.medicina.processo.*;
|
|
|
|
|
import siprp.medicina.processo.data.TrabalhadoresProcessoData;
|
|
|
|
|
|
|
|
|
|
@ -63,7 +63,7 @@ public class EstruturaProcessoPanel extends JPanel
|
|
|
|
|
mainScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
|
|
|
|
|
mainScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
|
|
|
|
|
// rootNode = new DefaultMutableTreeNode( new MappableObject( new Integer( 12 ), "Frederico Palma" ) );
|
|
|
|
|
rootNode = new TrabalhadorMutableTreeNode( new Integer( 12 ), "Frederico Palma" );
|
|
|
|
|
rootNode = new TrabalhadorMutableTreeNode( new Integer( -1 ), "" );
|
|
|
|
|
mainTree = new JTree( rootNode );
|
|
|
|
|
mainTree.addTreeSelectionListener( this );
|
|
|
|
|
mainTree.setCellRenderer( new EstruturaProcessoRenderer() );
|
|
|
|
|
@ -87,7 +87,7 @@ public class EstruturaProcessoPanel extends JPanel
|
|
|
|
|
rootNode.setDescricao( trabalhador.toString() );
|
|
|
|
|
DefaultMutableTreeNode nodes[] =
|
|
|
|
|
loadProcessos( trabalhador.getID() );
|
|
|
|
|
rootNode.add( new ProcessoMutableTreeNode( new Integer( -1 ), "Novo Processo..." ) );
|
|
|
|
|
rootNode.add( criarProcessoVazio() );
|
|
|
|
|
for( int n = 0; n < nodes.length; n++ )
|
|
|
|
|
{
|
|
|
|
|
rootNode.add( nodes[ n ] );
|
|
|
|
|
@ -107,19 +107,7 @@ public class EstruturaProcessoPanel extends JPanel
|
|
|
|
|
DefaultMutableTreeNode nodes[] = new DefaultMutableTreeNode[ ids.length ];
|
|
|
|
|
for( int n = 0; n < ids.length; n++ )
|
|
|
|
|
{
|
|
|
|
|
TrabalhadoresProcessoData processo = provider.getProcessoByID( ids[ n ] );
|
|
|
|
|
Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO );
|
|
|
|
|
Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM );
|
|
|
|
|
String codigoEstado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO );
|
|
|
|
|
String estado = provider.getDescricaoEstadoProcessoByCodigo( codigoEstado );
|
|
|
|
|
String desc = D_F.format( dataInicio );
|
|
|
|
|
if( dataFim != null )
|
|
|
|
|
{
|
|
|
|
|
desc += " - " + D_F.format( dataFim );
|
|
|
|
|
}
|
|
|
|
|
desc += ": " + estado;
|
|
|
|
|
nodes[ n ] = new ProcessoMutableTreeNode( ids[ n ], desc );
|
|
|
|
|
PROCESSOS_POR_ID.put( ids[ n ], processo );
|
|
|
|
|
nodes[ n ] = loadProcesso( ids[ n ], null );
|
|
|
|
|
}
|
|
|
|
|
//System.out.println( "nl: " + nodes.length );
|
|
|
|
|
return nodes;
|
|
|
|
|
@ -131,6 +119,30 @@ public class EstruturaProcessoPanel extends JPanel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected ProcessoMutableTreeNode loadProcesso( Integer id, ProcessoMutableTreeNode node )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
TrabalhadoresProcessoData processo = provider.getProcessoByID( id );
|
|
|
|
|
Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO );
|
|
|
|
|
Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM );
|
|
|
|
|
String codigoEstado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO );
|
|
|
|
|
String estado = provider.getDescricaoEstadoProcessoByCodigo( codigoEstado );
|
|
|
|
|
String desc = D_F.format( dataInicio );
|
|
|
|
|
Integer motivo = ( Integer ) processo.get( TrabalhadoresProcessoData.MOTIVO );
|
|
|
|
|
desc += ": " + MedicinaDataProvider.MOTIVOS_BY_ID.get( motivo ) + " : " + estado;
|
|
|
|
|
PROCESSOS_POR_ID.put( id, processo );
|
|
|
|
|
if( node == null )
|
|
|
|
|
{
|
|
|
|
|
return new ProcessoMutableTreeNode( id, desc );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
node.setID( id );
|
|
|
|
|
node.setDescricao( desc );
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void valueChanged( TreeSelectionEvent e )
|
|
|
|
|
{
|
|
|
|
|
Object components[] = e.getPath().getPath();
|
|
|
|
|
@ -204,27 +216,27 @@ public class EstruturaProcessoPanel extends JPanel
|
|
|
|
|
PROCESSO_LISTENERS.get( n ).processoStateChanged( event );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TrabalhadoresProcessoData getProcessoEscolhido()
|
|
|
|
|
{
|
|
|
|
|
TreePath path = mainTree.getSelectionPath();
|
|
|
|
|
TrabalhadoresProcessoData processo = null;
|
|
|
|
|
if( path != null )
|
|
|
|
|
{
|
|
|
|
|
IDObject escolhido = ( IDObject )( ( DefaultMutableTreeNode ) path.getLastPathComponent() ).getUserObject();
|
|
|
|
|
if( escolhido != null )
|
|
|
|
|
{
|
|
|
|
|
processo = PROCESSOS_POR_ID.get( escolhido.getID() );
|
|
|
|
|
if( processo == null )
|
|
|
|
|
{
|
|
|
|
|
processo = new TrabalhadoresProcessoData();
|
|
|
|
|
PROCESSOS_POR_ID.put( escolhido.getID(), processo );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return processo;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// public TrabalhadoresProcessoData getProcessoEscolhido()
|
|
|
|
|
// {
|
|
|
|
|
// TreePath path = mainTree.getSelectionPath();
|
|
|
|
|
// TrabalhadoresProcessoData processo = null;
|
|
|
|
|
// if( path != null )
|
|
|
|
|
// {
|
|
|
|
|
// EstruturaProcessoMutableTreeNode escolhido = ( EstruturaProcessoMutableTreeNode ) path.getLastPathComponent();
|
|
|
|
|
// if( escolhido != null )
|
|
|
|
|
// {
|
|
|
|
|
// processo = PROCESSOS_POR_ID.get( escolhido.getID() );
|
|
|
|
|
// if( processo == null )
|
|
|
|
|
// {
|
|
|
|
|
// processo = new TrabalhadoresProcessoData();
|
|
|
|
|
// PROCESSOS_POR_ID.put( escolhido.getID(), processo );
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return processo;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public void addProcessoListener( ProcessoListener listener )
|
|
|
|
|
{
|
|
|
|
|
@ -241,6 +253,27 @@ public class EstruturaProcessoPanel extends JPanel
|
|
|
|
|
return trabalhador;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void actualizarProcessoEscolhido( Integer id )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
TreePath path = mainTree.getSelectionPath();
|
|
|
|
|
ProcessoMutableTreeNode processoNode = ( ProcessoMutableTreeNode ) path.getPathComponent( 1 );
|
|
|
|
|
boolean vazio = processoNode.getID().intValue() == -1;
|
|
|
|
|
loadProcesso( id, processoNode );
|
|
|
|
|
( ( DefaultTreeModel ) mainTree.getModel() ).nodeChanged( processoNode ) ;
|
|
|
|
|
if( vazio )
|
|
|
|
|
{
|
|
|
|
|
ProcessoMutableTreeNode novo = criarProcessoVazio();
|
|
|
|
|
rootNode.insert( novo, 0 );
|
|
|
|
|
( ( DefaultTreeModel ) mainTree.getModel() ).nodesWereInserted( rootNode, new int[]{ 0 } ) ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ProcessoMutableTreeNode criarProcessoVazio()
|
|
|
|
|
{
|
|
|
|
|
return new ProcessoMutableTreeNode( new Integer( -1 ), "Novo Processo..." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void reload()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|