no message

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

@ -17,8 +17,12 @@ import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import siprp.medicina.processo.data.MarcacoesProcessoData;
/**
@ -26,6 +30,7 @@ import siprp.medicina.processo.data.MarcacoesProcessoData;
* @author fpalma
*/
public class EstruturaProcessoPanel extends JPanel
implements TreeSelectionListener
{
protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
@ -38,6 +43,8 @@ public class EstruturaProcessoPanel extends JPanel
protected IDObject trabalhador;
protected final HashMap<Integer,MarcacoesProcessoData> PROCESSOS_POR_ID =
new HashMap<Integer,MarcacoesProcessoData>();
private final Vector<TreeSelectionListener> SELECTION_LISTENERS =
new Vector<TreeSelectionListener>();
/** Creates a new instance of EstruturaProcessoPanel */
public EstruturaProcessoPanel()
@ -55,6 +62,7 @@ public class EstruturaProcessoPanel extends JPanel
mainScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
rootNode = new DefaultMutableTreeNode( new MappableObject( new Integer( 12 ), "Frederico Palma" ) );
mainTree = new JTree( rootNode );
mainTree.addTreeSelectionListener( this );
mainScroll.setViewportView( mainTree );
setLayout( new GridLayout( 1, 1 ) );
add( mainScroll );
@ -69,10 +77,16 @@ public class EstruturaProcessoPanel extends JPanel
rootNode.setUserObject( trabalhador );
DefaultMutableTreeNode nodes[] =
loadProcessos( trabalhador.getID() );
rootNode.add( new DefaultMutableTreeNode( new MappableObject( new Integer( -1 ), "Novo Processo..." ) ) );
for( int n = 0; n < nodes.length; n++ )
{
rootNode.add( nodes[ n ] );
}
int count = mainTree.getRowCount();
for( int n = count - 1; n >= 0; n-- )
{
mainTree.expandRow( n );
}
repaint();
}
@ -108,4 +122,44 @@ public class EstruturaProcessoPanel extends JPanel
return new DefaultMutableTreeNode[ 0 ];
}
}
public void addTreeSelectionListener( TreeSelectionListener listener )
{
SELECTION_LISTENERS.add( listener );
}
public void removeTreeSelectionListener( TreeSelectionListener listener )
{
SELECTION_LISTENERS.remove( listener );
}
public void valueChanged(TreeSelectionEvent e)
{
for( int n = 0; n < SELECTION_LISTENERS.size(); n++ )
{
SELECTION_LISTENERS.get( n ).valueChanged( e );
}
}
public MarcacoesProcessoData getProcessoEscolhido()
{
TreePath path = mainTree.getSelectionPath();
MarcacoesProcessoData 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 MarcacoesProcessoData();
PROCESSOS_POR_ID.put( escolhido.getID(), processo );
}
}
}
return processo;
}
}

@ -34,6 +34,7 @@ public class ProcessoDataProvider
public static final String PROCESSO_ABERTO_DESCRIPTION = "Aberto";
public static final String PROCESSO_FECHADO_DESCRIPTION = "Fechado";
public static final String PROCESSO_CANCELADO_DESCRIPTION = "Cancelado";
public static final String PROCESSO_POR_ABRIR_DESCRIPTION = "Por Abrir";
public static final HashMap<String,String> ESTADO_PROCESSO_BY_CODE =
new HashMap<String,String>();

@ -14,15 +14,23 @@ import info.clearthought.layout.TableLayoutConstraints;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import siprp.medicina.processo.data.MarcacoesProcessoData;
/**
*
* @author fpalma
*/
public class ProcessoPanel extends JPanel
implements ActionListener
implements ActionListener, TreeSelectionListener
{
private static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );
private JTextField estadoText;
private JTextField inicioText;
private JTextField fimText;
@ -31,12 +39,16 @@ public class ProcessoPanel extends JPanel
private JButton emitirFAButton;
private JButton fecharButton;
private final EstruturaProcessoPanel estruturaPanel;
/** Creates a new instance of ProcessoPanel */
public ProcessoPanel()
public ProcessoPanel( EstruturaProcessoPanel estruturaPanel )
{
this.estruturaPanel = estruturaPanel;
setupComponents();
estruturaPanel.addTreeSelectionListener( this );
}
private void setupComponents()
{
@ -62,11 +74,11 @@ public class ProcessoPanel extends JPanel
fecharButton.addActionListener( this );
double cols[] =
new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL,
TableLayout.PREFERRED, };
double rows[] =
new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.PREFERRED, TableLayout.FILL };
new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL,
TableLayout.PREFERRED, };
double rows[] =
new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.PREFERRED, TableLayout.FILL };
TableLayout tableLayout = new TableLayout( cols, rows );
setLayout( tableLayout );
@ -82,7 +94,7 @@ public class ProcessoPanel extends JPanel
add( emitirFAButton, new TableLayoutConstraints( 3, 2 ) );
add( fecharButton, new TableLayoutConstraints( 3, 3 ) );
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
@ -119,4 +131,65 @@ public class ProcessoPanel extends JPanel
protected void fecharProcesso()
{
}
public void valueChanged(TreeSelectionEvent e)
{
clear();
mudarProcesso();
}
public void clear()
{
estadoText.setText( "" );
inicioText.setText( "" );
fimText.setText( "" );
}
protected void disableButtons()
{
novoECDButton.setEnabled( false );
novaConsultaButton.setEnabled( false );
emitirFAButton.setEnabled( false );
fecharButton.setEnabled( false );
}
protected void enableButtons()
{
novoECDButton.setEnabled( true );
novaConsultaButton.setEnabled( true );
emitirFAButton.setEnabled( true );
fecharButton.setEnabled( true );
}
protected void mudarProcesso()
{
MarcacoesProcessoData processo = estruturaPanel.getProcessoEscolhido();
if( processo == null )
{
disableButtons();
}
else
{
enableButtons();
Date dataInicio = ( Date ) processo.get( MarcacoesProcessoData.DATA_INICIO );
if( dataInicio != null )
{
inicioText.setText( D_F.format( dataInicio ) );
}
Date dataFim = ( Date ) processo.get( MarcacoesProcessoData.DATA_FIM );
if( dataFim != null )
{
fimText.setText( D_F.format( dataFim ) );
}
String estado = ( String ) processo.get( MarcacoesProcessoData.ESTADO );
if( estado == null )
{
estadoText.setText( ProcessoDataProvider.PROCESSO_POR_ABRIR_DESCRIPTION );
}
else
{
estadoText.setText( ProcessoDataProvider.ESTADO_PROCESSO_BY_CODE.get( estado ) );
}
}
}
}

@ -10,7 +10,11 @@
package siprp.medicina.processo;
import com.evolute.utils.tracker.TrackableWindow;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
@ -20,15 +24,41 @@ import javax.swing.SwingUtilities;
public class ProcessoWindow extends JFrame
implements TrackableWindow
{
public static final String TITLE = "Processos de trabalhadores";
private EstruturaProcessoPanel estruturaPanel;
private ProcessoPanel processoPanel;
private JPanel detalhesPanel;
/** Creates a new instance of ProcessoWindow */
public ProcessoWindow()
throws Exception
{
setupComponents();
}
private void setupComponents()
throws Exception
{
setSize( 1024, 768 );
setTitle( TITLE );
estruturaPanel = new EstruturaProcessoPanel();
processoPanel = new ProcessoPanel( estruturaPanel );
processoPanel.setBorder( BorderFactory.createEtchedBorder() );
detalhesPanel = new JPanel();
detalhesPanel.setBorder( BorderFactory.createEtchedBorder() );
double cols[] =
new double[]{ TableLayout.FILL, TableLayout.PREFERRED };
double rows[] =
new double[]{ TableLayout.PREFERRED, TableLayout.FILL };
TableLayout tableLayout = new TableLayout( cols, rows );
setLayout( tableLayout );
add( estruturaPanel, new TableLayoutConstraints( 0, 0, 0, 1 ) );
add( processoPanel, new TableLayoutConstraints( 1, 0 ) );
add( detalhesPanel, new TableLayoutConstraints( 1, 1 ) );
}
public void refresh()

Loading…
Cancel
Save